incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r505034 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal: skin/SkinStyleProvider.java style/cache/FileSystemStyleCache.java
Date Thu, 08 Feb 2007 20:57:23 GMT
Author: jwaldman
Date: Thu Feb  8 12:57:22 2007
New Revision: 505034

URL: http://svn.apache.org/viewvc?view=rev&rev=505034
Log:
I changed my implementation for 
http://issues.apache.org/jira/browse/ADFFACES-370 (Need to avoid IE's number of CSS selectors
limitation
) AGAIN
In Skin's getStyleClassMap(RenderingContext) we get the StyleContext from the RenderingContext.
This is fine, but the problem I found is that from FileSystemStyleCache the StyleContext is
not yet set up on the RenderingContext, so calling getStyleContext caused it to run through
all the code that processes all the skin files again (they are cached, so it doesn't get stuck
in a loop). Still, this is obviously not good.

If we could pass StyleContext to getStyleClassMap, then that would be good, but StyleContext
is not in the public api. That's why we pass in RenderingContext.

The change I made was to go back to looking to see if the skin's renderKitId is portlet. We
don't compress if portlet.

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleProvider.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleProvider.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleProvider.java?view=diff&rev=505034&r1=505033&r2=505034
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleProvider.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinStyleProvider.java
Thu Feb  8 12:57:22 2007
@@ -210,27 +210,6 @@
     return name;
   }
   
-
-  /**
-   * Returns a boolean to say whether or not we should compress the styles that are
-   * written to the generated css file. We look at the skin to decide.
-   * @param shortStyleClassMap
-   * @return true if we want to compress styles; i.e., if the shortStyleClassMap we are using
-   * to output to the generated CSS matches the styleClassMap of the skin and the disable
content
-   * compression flag is not turned on.
-   */
-  protected boolean isCompressGeneratedStyles(Map<String, String> shortStyleClassMap)
-  {
-    Map skinsStyleClassMap = _skin.getStyleClassMap(
-                                RenderingContext.getCurrentInstance());
-    String disableContentCompression = 
-      FacesContext.getCurrentInstance().getExternalContext().
-      getInitParameter(StyleSheetRenderer.DISABLE_CONTENT_COMPRESSION);
-    boolean compressStyles = (skinsStyleClassMap == shortStyleClassMap) && 
-                             !"true".equals(disableContentCompression);
-    return compressStyles;
-  }
-
   // Returns a Map which hashes ProviderKeys to shared instances
   // of SkinStyleProviders.
   private static Map<ProviderKey, StyleProvider> _getProviders()

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java?view=diff&rev=505034&r1=505033&r2=505034
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
Thu Feb  8 12:57:22 2007
@@ -50,6 +50,8 @@
 import org.apache.myfaces.trinidadinternal.share.io.NameResolver;
 import org.apache.myfaces.trinidad.context.LocaleContext;
 import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidad.skin.Skin;
+import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderKit;
 import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.StyleSheetRenderer;
 import org.apache.myfaces.trinidadinternal.share.xml.JaxpXMLProvider;
 import org.apache.myfaces.trinidadinternal.share.xml.XMLProvider;
@@ -349,16 +351,6 @@
     return buffer.toString();
   }
   
-  /**
-   * Returns a boolean to say whether or not we should compress the styles that are
-   * written to the generated css file. The default implementation returns false.
-   * 
-   */  
-  protected boolean isCompressGeneratedStyles(Map<String, String> shortStyleClassMap)
-  {
-    return false;
-  }
-
   // Returns the current StyleSheetDocument - used by StyleMapImpl only
   StyleSheetDocument __getStyleSheetDocument()
   {
@@ -448,6 +440,7 @@
       return entry;
 
     // If we didn't find an entry in the cache, create a new entry
+    // This generates the CSS file.
     return _createEntry(context,
                         document,
                         cache,
@@ -716,8 +709,18 @@
     // Write out the style sheet
     // First figure out whether or not we need to compress the style classes.
     // We don't compress the style classes if the content compression flag is disabled or
-    // if the skin's styleClassMap does not match our shortStyleClassMap.
-    boolean compressStyles = isCompressGeneratedStyles(shortStyleClassMap);
+    // if the skin is a portlet skin.
+     String disableContentCompression =
+       FacesContext.getCurrentInstance().getExternalContext().
+       getInitParameter(StyleSheetRenderer.DISABLE_CONTENT_COMPRESSION);
+     // we do not compress if it is a portlet skin
+     Skin skin = RenderingContext.getCurrentInstance().getSkin();
+     boolean isPortletSkin =
+     CoreRenderKit.OUTPUT_MODE_PORTLET.equals(skin.getRenderKitId());
+
+     boolean compressStyles = (!"true".equals(disableContentCompression)) &&
+                                              !isPortletSkin;
+
 
     CSSGenerationUtils.writeCSS(context,
                                 styles,



Mime
View raw message