changeset 2890:5634b086feaa

Merge
author "Jasper Potts"
date Tue, 12 Mar 2013 14:49:44 -0700
parents a0a297647a7c 1ee809c26ddd
children 50811c4425d8
files
diffstat 4 files changed, 60 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/com/sun/javafx/css/Declaration.java	Tue Mar 12 14:49:19 2013 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/Declaration.java	Tue Mar 12 14:49:44 2013 -0700
@@ -25,11 +25,14 @@
 
 package com.sun.javafx.css;
 
+import com.sun.javafx.css.converters.URLConverter;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.net.URL;
 import javafx.css.StyleOrigin;
 import javafx.css.ParsedValue;
+import javafx.css.StyleConverter;
 
 final public class Declaration {
     final String property;
@@ -131,6 +134,41 @@
         if (important) sbuf.append(" !important");
         return sbuf.toString();
     }
+    
+    //
+    // RT-21964
+    //
+    // We know when the .css file is parsed what the stylesheet URL is,
+    // but that might not be the URL of the deployed file. So for URL
+    // types, the parser inserts a null placeholder for the URL and we
+    // fix it up here. This method is called from Rule#setStylesheet
+    // and from Rule#declarations onChanged method.
+    // 
+    void fixUrl(URL stylesheetUrl) {
+        
+        if (stylesheetUrl == null) return;
+        
+        final StyleConverter converter = parsedValue.getConverter();        
+        
+        // code is tightly coupled to the way URLConverter works
+        if (converter == URLConverter.getInstance()) {
+            
+            final ParsedValue[] values = (ParsedValue[])parsedValue.getValue();
+            values[1] = new ParsedValueImpl<URL,URL>(stylesheetUrl, null);
+            
+        } else if (converter == URLConverter.SequenceConverter.getInstance()) {
+
+            final ParsedValue<ParsedValue[], String>[] layers = 
+                (ParsedValue<ParsedValue[], String>[])parsedValue.getValue();
+            
+            for (int layer = 0; layer < layers.length; layer++) {
+                final ParsedValue[] values = (ParsedValue[])layers[layer].getValue();
+                values[1] = new ParsedValueImpl<URL,URL>(stylesheetUrl, null);
+            }
+            
+        }
+                
+    }
 
     void writeBinary(final DataOutputStream os, final StringStore stringStore)
         throws IOException
--- a/javafx-ui-common/src/com/sun/javafx/css/Rule.java	Tue Mar 12 14:49:19 2013 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/Rule.java	Tue Mar 12 14:49:44 2013 -0700
@@ -29,6 +29,7 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
@@ -61,6 +62,14 @@
                     for(int i = 0, max = added.size(); i < max; i++) {
                         Declaration decl = added.get(i);
                         decl.rule = Rule.this;
+                        
+                        if (stylesheet != null && stylesheet.getUrl() != null) {
+
+                            final URL stylesheetUrl = stylesheet.getUrl();
+                            decl.fixUrl(stylesheetUrl);
+
+                        }
+                        
                     }
                 }
                 
@@ -87,6 +96,15 @@
     /* package */
     void setStylesheet(Stylesheet stylesheet) {
         this.stylesheet = stylesheet;
+        
+        if (stylesheet != null && stylesheet.getUrl() != null) {
+            
+            final URL stylesheetUrl = stylesheet.getUrl();
+            for (int d=0, dMax=declarations.size(); d<dMax; d++) {
+                declarations.get(d).fixUrl(stylesheetUrl);
+            }
+            
+        }
     }
 
     public StyleOrigin getOrigin() {
--- a/javafx-ui-common/src/com/sun/javafx/css/converters/URLConverter.java	Tue Mar 12 14:49:19 2013 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/converters/URLConverter.java	Tue Mar 12 14:49:44 2013 -0700
@@ -63,7 +63,7 @@
             } else {
                 uriStr = com.sun.javafx.Utils.stripQuotes(uriStr);
             }
-            URL stylesheetURL = (URL) values[1].getValue();
+            URL stylesheetURL = values[1] != null ? (URL)values[1].getValue() : null;
             URL resolvedURL = null;
             if (stylesheetURL == null) {
                 try {
--- a/javafx-ui-common/src/com/sun/javafx/css/parser/CSSParser.java	Tue Mar 12 14:49:19 2013 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/parser/CSSParser.java	Tue Mar 12 14:49:44 2013 -0700
@@ -2191,7 +2191,7 @@
         final String uri = arg.token.getText();
         ParsedValueImpl[] uriValues = new ParsedValueImpl[] {
             new ParsedValueImpl<String,String>(uri, StringConverter.getInstance()),
-            new ParsedValueImpl<URL,URL>(sourceOfStylesheet, null)
+            null // placeholder for Stylesheet URL
         };
         ParsedValueImpl parsedURI = new ParsedValueImpl<ParsedValue[],String>(uriValues, URLConverter.getInstance());
 
@@ -2266,7 +2266,7 @@
         final String uri = arg.token.getText();
         ParsedValueImpl[] uriValues = new ParsedValueImpl[] {
             new ParsedValueImpl<String,String>(uri, StringConverter.getInstance()),
-            new ParsedValueImpl<URL,URL>(sourceOfStylesheet, null)
+            null // placeholder for Stylesheet URL
         };
         ParsedValueImpl parsedURI = new ParsedValueImpl<ParsedValue[],String>(uriValues, URLConverter.getInstance());
         ParsedValueImpl[] values = new ParsedValueImpl[1];
@@ -3408,7 +3408,7 @@
         final String uri = arg.token.getText();
         ParsedValueImpl[] uriValues = new ParsedValueImpl[] {
             new ParsedValueImpl<String,String>(uri, StringConverter.getInstance()),
-            new ParsedValueImpl<URL,URL>(sourceOfStylesheet, null)
+            null // placeholder for Stylesheet URL
         };
         return new ParsedValueImpl<ParsedValue[],String>(uriValues, URLConverter.getInstance());
     }