changeset 6568:4925e1655837

RT-34276: css needs to use Styleable.getTypeSelector() instead of getClass().getName() for selector matching
author David Grieve<david.grieve@oracle.com>
date Fri, 28 Mar 2014 17:11:05 -0400
parents d4f62c49a4ad
children eacaf885bab9
files modules/graphics/src/main/java/com/sun/javafx/css/SimpleSelector.java modules/graphics/src/main/java/com/sun/javafx/css/StyleManager.java
diffstat 2 files changed, 3 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/css/SimpleSelector.java	Fri Mar 28 14:16:41 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/css/SimpleSelector.java	Fri Mar 28 17:11:05 2014 -0400
@@ -225,8 +225,8 @@
         // then bail if it doesn't match the node's class name
         // if not wildcard, then match name with node's class name
         if (matchOnName) {
-            final String otherName = styleable.getClass().getName();
-            final boolean classMatch = nameMatchesAtEnd(otherName);
+            final String otherName = styleable.getTypeSelector();
+            final boolean classMatch = this.name.equals(otherName);
             if (!classMatch) return false;
         }
 
@@ -271,14 +271,6 @@
         return applies;
     }
 
-    // todo - is this used?
-    private boolean mightApply(final String className, final String id, StyleClassSet styleClasses) {
-        if (matchOnName && nameMatchesAtEnd(className)) return true;
-        if (matchOnId   && this.id.equals(id)) return true;
-        if (matchOnStyleClass) return matchStyleClasses(styleClasses);
-        return false;
-    }
-    
     @Override
     public boolean stateMatches(final Styleable styleable, Set<PseudoClass> states) {
         // [foo bar] matches [foo bar bang], 
@@ -286,27 +278,6 @@
         return states != null ? states.containsAll(pseudoClassState) : false;
     }
 
-    /*
-     * Optimized className.equals(name) || className.endsWith(".".concat(name)).
-     */
-    private boolean nameMatchesAtEnd(final String className) {
-        // if name is null or empty, why bother?
-        if (!matchOnName) return false;
-
-        final int nameLen = this.name.length();
-
-        // take a guess that '.name' starts at this offset in className
-        final int dotPos = className.length() - nameLen - 1;
-
-        // If dotPos is -1, then className and name are
-        // equal length and may match. Anything less than -1 and
-        // className is shorter than name and no match is possible.
-        if ((dotPos == -1) || (dotPos > -1 && className.charAt(dotPos) == '.')) {
-            return className.regionMatches(dotPos+1, this.name, 0, nameLen);
-        }
-        return false;
-    }
-
     // Are the Selector's style classes a subset of the Node's style classes?
     //
     // http://www.w3.org/TR/css3-selectors/#class-html
--- a/modules/graphics/src/main/java/com/sun/javafx/css/StyleManager.java	Fri Mar 28 14:16:41 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/css/StyleManager.java	Fri Mar 28 17:11:05 2014 -0400
@@ -1438,9 +1438,7 @@
             return StyleMap.EMPTY_MAP;
         }
 
-        final String name = node.getClass().getName();
-        final int dotPos = name.lastIndexOf('.');
-        final String cname = name.substring(dotPos+1);  // want Foo, not bada.bing.Foo
+        final String cname = node.getTypeSelector();
         final String id = node.getId();
         final List<String> styleClasses = node.getStyleClass();