incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r504414 - in /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal: renderkit/core/StyleContextImpl.java skin/SkinStyleProvider.java style/StyleContext.java style/cache/FileSystemStyleCache.java
Date Wed, 07 Feb 2007 02:20:12 GMT
Author: jwaldman
Date: Tue Feb  6 18:20:11 2007
New Revision: 504414

URL: http://svn.apache.org/viewvc?view=rev&rev=504414
Log:
I changed my implementation for 
http://issues.apache.org/jira/browse/ADFFACES-370 (Need to avoid IE's number of CSS selectors
limitation
)
 so that I don't need the getSkin in the StyleContext API. We have a SkinStyleProvider which
extends FileSystemStyleCache.java and that already has the skin information. I added a protected
isCompressGeneratedStyles(Map) method which figures out if we need to compress based on if
the shortened style class map matches the skin's style class map and the disable content compression
flag.
The end result is identical -- I write out compressed or uncompressed, but not both unless
it is a styleclass that doesn't have '|' in it.

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
    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/StyleContext.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/renderkit/core/StyleContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java?view=diff&rev=504414&r1=504413&r2=504414
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
Tue Feb  6 18:20:11 2007
@@ -80,11 +80,6 @@
     return ((CoreRenderingContext) _arc).getTrinidadAgent();
   }
 
-  public Skin getSkin()
-  {
-    return ((CoreRenderingContext) _arc).getSkin();
-  }
-
   public boolean checkStylesModified()
   {
     // =-=AEW Expose a configuration option if this

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=504414&r1=504413&r2=504414
==============================================================================
--- 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
Tue Feb  6 18:20:11 2007
@@ -21,8 +21,12 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.trinidad.context.RenderingContext;
 import org.apache.myfaces.trinidad.skin.Skin;
 
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.StyleSheetRenderer;
 import org.apache.myfaces.trinidadinternal.style.StyleContext;
 import org.apache.myfaces.trinidadinternal.style.StyleProvider;
 import org.apache.myfaces.trinidadinternal.style.cache.FileSystemStyleCache;
@@ -204,6 +208,27 @@
     }
 
     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

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java?view=diff&rev=504414&r1=504413&r2=504414
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
Tue Feb  6 18:20:11 2007
@@ -41,7 +41,6 @@
    * Returns the end user's Agent.
    */
   public TrinidadAgent getAgent();
-  public Skin getSkin();
 
   public String getGeneratedFilesPath();
   public boolean checkStylesModified();

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=504414&r1=504413&r2=504414
==============================================================================
--- 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
Tue Feb  6 18:20:11 2007
@@ -348,6 +348,16 @@
 
     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()
@@ -707,14 +717,7 @@
     // 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.
-    
-    Map skinsStyleClassMap = context.getSkin().getStyleClassMap(
-                                RenderingContext.getCurrentInstance());
-    String disableContentCompression = 
-      FacesContext.getCurrentInstance().getExternalContext().
-      getInitParameter(StyleSheetRenderer.DISABLE_CONTENT_COMPRESSION);
-    boolean compressStyles = (skinsStyleClassMap == shortStyleClassMap) && 
-                             !"true".equals(disableContentCompression);
+    boolean compressStyles = isCompressGeneratedStyles(shortStyleClassMap);
 
     CSSGenerationUtils.writeCSS(context,
                                 styles,



Mime
View raw message