You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2007/05/16 23:59:44 UTC

svn commit: r538754 - in /myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style: cache/FileSystemStyleCache.java util/CSSGenerationUtils.java

Author: jwaldman
Date: Wed May 16 14:59:42 2007
New Revision: 538754

URL: http://svn.apache.org/viewvc?view=rev&rev=538754
Log:
TRINIDAD-20 SKINNING - DO NOT SHORTEN STYLECLASSES THAT START WITH P_AF (THE STATE PREFIX)
https://issues.apache.org/jira/browse/TRINIDAD-20
Changed FileSystemStyleCache.java's code that creates the shortStyleClassMap to not include
any style classes that start with .p_AF
CSSGenerationUtils.java just includes some comments.

Modified:
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/CSSGenerationUtils.java

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java?view=diff&rev=538754&r1=538753&r2=538754
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java Wed May 16 14:59:42 2007
@@ -864,6 +864,7 @@
   }
 
   // Create the map of full style classes to short style classes
+  // Do not shorten styleclasses that start with SkinSelectors.STATE_PREFIX
   private static Map<String, String> _getShortStyleClassMap(
     StyleContext       context,
     StyleSheetDocument document,
@@ -897,8 +898,12 @@
           if (CSSGenerationUtils.isSingleStyleClassSelector(selector))
           {
             String styleClass = selector.substring(1);
-            if (!map.containsKey(styleClass))
-              map.put(styleClass, _getShortStyleClass(map.size()));
+            _putStyleClassInShortMap(styleClass, map);
+            // don't shorten styleclasses that are states since they are likely to be added
+            // and removed on the client.
+            if (styleClass != null && !styleClass.startsWith(SkinSelectors.STATE_PREFIX))
+              if (!map.containsKey(styleClass))
+                map.put(styleClass, _getShortStyleClass(map.size()));
             
             if (style.isEmpty())
               emptySelectors.add(styleClass);
@@ -915,15 +920,14 @@
               while (styleClasses.hasNext())
               {
                 String styleClass = styleClasses.next();
-                
-                if (!map.containsKey(styleClass))
-                  map.put(styleClass, _getShortStyleClass(map.size()));
+                _putStyleClassInShortMap(styleClass, map);
                 
                 // Don't remove any styleclass that is referred to
                 nonEmptySelectors.add(styleClass);
               }
             }
             
+            // now search for the selectors that have namespaces and add those to the map
             int length = namespacePrefixes.length;
             
             for (int i=0; i < length; i++)
@@ -939,9 +943,8 @@
                 while (afSelectors.hasNext())
                 {
                   String styleClass = afSelectors.next();
-                  
-                  if (!map.containsKey(styleClass))
-                    map.put(styleClass, _getShortStyleClass(map.size()));
+                  _putStyleClassInShortMap(styleClass, map);
+
                   if (isFirst && !afSelectors.hasNext() && style.isEmpty())
                   {
                     emptySelectors.add(styleClass);
@@ -971,6 +974,21 @@
     // or else we would need to create a new copy of the Map
     // each time it is requested.
     return Collections.unmodifiableMap(map);
+  }
+  
+  // Method to put styleclasses in the shortened map.
+  // We don't put 'state' styleclasses in the shortened map. Those are styleclasses
+  // that start with SkinSelectors.STATE_PREFIX. The reason is that those
+  // are likely to be added and removed on the client as the state changes, and 
+  // we don't want to require the shortened map on the client.
+  private static void _putStyleClassInShortMap(String styleClass, Map map)
+  {
+    if (styleClass != null &&
+        !styleClass.startsWith(SkinSelectors.STATE_PREFIX) &&
+        !map.containsKey(styleClass))
+    {
+      map.put(styleClass, _getShortStyleClass(map.size())); 
+    } 
   }
 
   // Helper method used by _getShortStyleClassMap().  Returns a new

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/CSSGenerationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/CSSGenerationUtils.java?view=diff&rev=538754&r1=538753&r2=538754
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/CSSGenerationUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/util/CSSGenerationUtils.java Wed May 16 14:59:42 2007
@@ -202,11 +202,12 @@
 
           String validFullNameSelector = null;
 
+          // write out the full selector if we aren't compressing styles or
+          // it doesn't have a '|' in the name which means it may be a user's public styleclass
+          // and we don't want to compress those; we will also write out the compressed
+          // version the public styleclasses in the next step.
           if (!compressStyles || (mappedSelector.indexOf('|') == -1))
           {
-            // write out the full selector if we aren't compressing styles or
-            // it doesn't have a '|' in the name which means it may be a user's public styleclass
-            // and we don't want to compress those.
             validFullNameSelector =
               _getValidFullNameSelector(mappedSelector, namespacePrefixArray);
              
@@ -685,7 +686,7 @@
           // do this in another step.
           if (styleClass.indexOf('|') == -1)
             shortStyleClass = shortStyleClassMap.get(styleClass);
-
+ 
 
           if (shortStyleClass == null)
           {
@@ -908,6 +909,12 @@
     else
       buffer.append(pieces.getMain());
     
+    // Convert the pseudo-classes if they aren't CSS2 pseudo-classes.
+    // We never want to shorten the converted pseudo-classes.
+    // pseudo-classes represent state and the state can be added or removed
+    // on the client with javascript and it is easiest if the states
+    // converted styleclass is not shortened, otherwise we'd have to
+    // send the shortened styleclass map for the states to the client.
     List <String> pseudoClasses = pieces.getPseudoClasses();
     for (String pseudoClass : pseudoClasses )
     {