changeset 1374:9a2b4524a317

RT-22565: parent stylesheets may be in the default stylesheet container
author David Grieve<david.grieve@oracle.com>
date Tue, 26 Jun 2012 12:20:35 -0400
parents 5b984ca53761
children 385a5b779565
files javafx-ui-common/src/com/sun/javafx/css/StyleManager.java
diffstat 1 files changed, 26 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/com/sun/javafx/css/StyleManager.java	Mon Jun 25 13:05:37 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/StyleManager.java	Tue Jun 26 12:20:35 2012 -0400
@@ -142,15 +142,22 @@
         
         if (scene == null) return;
 
-        if (containerMap == null) {
-            containerMap = new HashMap<WeakReference<Scene>,StylesheetContainer>(); 
-        }
-        StylesheetContainer container = containerMap.get(scene);
-        if (container == null) {
-            container = new StylesheetContainer(null);
-            put(containerMap, scene, container);
-        }
+        final StylesheetContainer container = 
+            (containerMap != null) 
+                ? get(containerMap, scene)
+                : null;
         
+        if (container == null && defaultContainer == null) return;
+        
+        
+        boolean containerNeedsCleared = false;
+        final Map<String,Stylesheet> mapFromContainer = container != null
+                ? container.parentStylesheetMap : null;
+        
+        boolean defaultContainerNeedsCleared = false;
+        final Map<String,Stylesheet> mapFromDefaultContainer = defaultContainer != null
+                ? defaultContainer.parentStylesheetMap : null;
+
         while (c.next()) {
             
             List<String> list = null;
@@ -167,12 +174,19 @@
             // must have been a permutation. continue on to the next change.
             if (list == null) continue;
             
-            for (int n=0, nMax=list.size(); n<nMax; n++) {
-                container.parentStylesheetMap.remove(list.get(n));
+            for (int n=0, nMax=list.size(); n<nMax; n++) {                
+                final String key = list.get(n);
+                if (mapFromContainer != null && mapFromContainer.remove(key) != null) {
+                    containerNeedsCleared = true;
+                }
+                if (mapFromDefaultContainer != null && mapFromDefaultContainer.remove(key) != null) {
+                    defaultContainerNeedsCleared = true;
+                }
             }                
         }
         
-        container.clearCaches();        
+        if (containerNeedsCleared) container.clearCaches();        
+        if (defaultContainerNeedsCleared) defaultContainer.clearCaches();
     }
     /**
      * A map from Scene => StylesheetContainer. This provides us a way to find
@@ -889,7 +903,7 @@
         * added to the authorStylesheetMap because we don't want the scene's
         * list of stylesheets in the container to be updated.
         */
-        private static Map<String,Stylesheet> parentStylesheetMap =
+        private Map<String,Stylesheet> parentStylesheetMap =
                 new HashMap<String,Stylesheet>();
 
         /**