Revision: 7426
Author: [email protected]
Date: Tue Jan 19 06:47:00 2010
Log: Merge tr...@7317 to make @url and the gwt-image property accept
dot-path values.
http://code.google.com/p/google-web-toolkit/source/detail?r=7426
Added:
/releases/2.0/user/test/com/google/gwt/resources/ext
Modified:
/releases/2.0/branch-info.txt
/releases/2.0/dev/core/src/com/google/gwt/core/ext/typeinfo/JClassType.java
/releases/2.0/user/src/com/google/gwt/resources/css/Spriter.java
/releases/2.0/user/src/com/google/gwt/resources/css/SubstitutionReplacer.java
/releases/2.0/user/src/com/google/gwt/resources/css/ast/CssNodeCloner.java
/releases/2.0/user/src/com/google/gwt/resources/css/ast/CssProperty.java
/releases/2.0/user/src/com/google/gwt/resources/css/ast/CssSprite.java
/releases/2.0/user/src/com/google/gwt/resources/css/ast/CssUrl.java
/releases/2.0/user/src/com/google/gwt/resources/ext/ResourceGeneratorUtil.java
/releases/2.0/user/src/com/google/gwt/resources/rg/CssResourceGenerator.java
/releases/2.0/user/test/com/google/gwt/resources/ResourcesSuite.java
/releases/2.0/user/test/com/google/gwt/resources/client/CSSResourceTest.java
/releases/2.0/user/test/com/google/gwt/resources/client/test.css
Replaced:
/releases/2.0/user/test/com/google/gwt/resources/ext/ResourceGeneratorUtilTest.java
=======================================
--- /releases/2.0/branch-info.txt Tue Jan 19 05:26:56 2010
+++ /releases/2.0/branch-info.txt Tue Jan 19 06:47:00 2010
@@ -1254,3 +1254,7 @@
Fix issue 4304 where !important was ignored when merging CSS rules.
svn merge -c 7316 --ignore-ancestry
https://google-web-toolkit.googlecode.com/svn/trunk
+tr...@7317 was merged into this branch
+ Make @url and the gwt-image property accept dot-path values
+ svn merge -c 7317 --ignore-ancestry
https://google-web-toolkit.googlecode.com/svn/trunk
+
=======================================
---
/releases/2.0/dev/core/src/com/google/gwt/core/ext/typeinfo/JClassType.java
Wed Nov 11 12:06:42 2009
+++
/releases/2.0/dev/core/src/com/google/gwt/core/ext/typeinfo/JClassType.java
Tue Jan 19 06:47:00 2010
@@ -16,10 +16,10 @@
package com.google.gwt.core.ext.typeinfo;
import com.google.gwt.dev.util.collect.HashSet;
-import com.google.gwt.dev.util.collect.Sets;
import java.lang.annotation.Annotation;
import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -34,15 +34,18 @@
/**
* Returns all of the superclasses and superinterfaces for a given type
- * including the type itself.
+ * including the type itself. The returned set maintains an internal
+ * breadth-first ordering of the type, followed by its interfaces (and
their
+ * super-interfaces), then the supertype and its interfaces, and so on.
*/
protected static Set<JClassType> getFlattenedSuperTypeHierarchy(
JClassType type) {
Set<JClassType> flattened = type.flattenedSupertypes;
if (flattened == null) {
- flattened = new HashSet<JClassType>();
+ flattened = new LinkedHashSet<JClassType>();
getFlattenedSuperTypeHierarchyRecursive(type, flattened);
- type.flattenedSupertypes = Sets.normalizeUnmodifiable(flattened);
+ // flattened.size() > 1 for all types other than Object
+ type.flattenedSupertypes = Collections.unmodifiableSet(flattened);
}
return flattened;
}
@@ -315,18 +318,18 @@
return;
}
typesSeen.add(type);
-
- // Superclass
- JClassType superclass = type.getSuperclass();
- if (superclass != null) {
- typesSeen.addAll(getFlattenedSuperTypeHierarchy(superclass));
- }
// Check the interfaces
JClassType[] intfs = type.getImplementedInterfaces();
for (JClassType intf : intfs) {
typesSeen.addAll(getFlattenedSuperTypeHierarchy(intf));
}
+
+ // Superclass
+ JClassType superclass = type.getSuperclass();
+ if (superclass != null) {
+ typesSeen.addAll(getFlattenedSuperTypeHierarchy(superclass));
+ }
}
/**
@@ -452,6 +455,17 @@
public abstract JField getField(String name);
public abstract JField[] getFields();
+
+ /**
+ * Returns all of the superclasses and superinterfaces for a given type
+ * including the type itself. The returned set maintains an internal
+ * breadth-first ordering of the type, followed by its interfaces (and
their
+ * super-interfaces), then the supertype and its interfaces, and so on.
+ */
+ public Set<JClassType> getFlattenedSupertypeHierarchy() {
+ // Retuns an immutable set
+ return getFlattenedSuperTypeHierarchy(this);
+ }
public abstract JClassType[] getImplementedInterfaces();
=======================================
--- /releases/2.0/user/src/com/google/gwt/resources/css/Spriter.java Mon
Nov 2 12:44:54 2009
+++ /releases/2.0/user/src/com/google/gwt/resources/css/Spriter.java Tue
Jan 19 06:47:00 2010
@@ -18,6 +18,7 @@
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.NotFoundException;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.resources.client.ImageResource.ImageOptions;
import com.google.gwt.resources.client.ImageResource.RepeatStyle;
@@ -27,9 +28,11 @@
import com.google.gwt.resources.css.ast.CssProperty;
import com.google.gwt.resources.css.ast.CssRule;
import com.google.gwt.resources.css.ast.CssSprite;
+import com.google.gwt.resources.css.ast.CssProperty.DotPathValue;
import com.google.gwt.resources.css.ast.CssProperty.ExpressionValue;
import com.google.gwt.resources.css.ast.CssProperty.IdentValue;
import com.google.gwt.resources.ext.ResourceContext;
+import com.google.gwt.resources.ext.ResourceGeneratorUtil;
import java.util.List;
@@ -52,43 +55,28 @@
@Override
public void endVisit(CssSprite x, Context ctx) {
JClassType bundleType = context.getClientBundleType();
- String functionName = x.getResourceFunction();
+ DotPathValue functionName = x.getResourceFunction();
if (functionName == null) {
logger.log(TreeLogger.ERROR, "The @sprite rule " + x.getSelectors()
+ " must specify the " + CssSprite.IMAGE_PROPERTY_NAME + "
property");
throw new CssCompilerException("No image property specified");
}
-
- // Find the image accessor method
- JMethod imageMethod = null;
- JMethod[] allMethods = bundleType.getOverridableMethods();
- for (int i = 0; imageMethod == null && i < allMethods.length; i++) {
- JMethod candidate = allMethods[i];
- // If the function name matches and takes no parameters
- if (candidate.getName().equals(functionName)
- && candidate.getParameters().length == 0) {
- // We have a match
- imageMethod = candidate;
- }
- }
-
- // Method unable to be located
- if (imageMethod == null) {
- logger.log(TreeLogger.ERROR, "Unable to find ImageResource method "
- + functionName + " in " + bundleType.getQualifiedSourceName());
- throw new CssCompilerException("Cannot find image function");
- }
JClassType imageResourceType =
context.getGeneratorContext().getTypeOracle().findType(
ImageResource.class.getName());
assert imageResourceType != null;
- if
(!imageResourceType.isAssignableFrom(imageMethod.getReturnType().isClassOrInterface()))
{
- logger.log(TreeLogger.ERROR, "The return type of " + functionName
- + " is not assignable to " +
imageResourceType.getSimpleSourceName());
- throw new CssCompilerException("Incorrect return type for "
- + CssSprite.IMAGE_PROPERTY_NAME + " method");
+ // Find the image accessor method
+ JMethod imageMethod;
+ try {
+ imageMethod = ResourceGeneratorUtil.getMethodByPath(bundleType,
+ functionName.getParts(), imageResourceType);
+ } catch (NotFoundException e) {
+ logger.log(TreeLogger.ERROR, "Unable to find ImageResource method "
+ + functionName + " in " + bundleType.getQualifiedSourceName()
+ " : "
+ + e.getMessage());
+ throw new CssCompilerException("Cannot find image function");
}
ImageOptions options = imageMethod.getAnnotation(ImageOptions.class);
@@ -100,7 +88,7 @@
}
String instance = "(" + context.getImplementationSimpleSourceName()
- + ".this." + functionName + "())";
+ + ".this." + functionName.getExpression() + ")";
CssRule replacement = new CssRule();
replacement.getSelectors().addAll(x.getSelectors());
=======================================
---
/releases/2.0/user/src/com/google/gwt/resources/css/SubstitutionReplacer.java
Mon Nov 2 12:44:54 2009
+++
/releases/2.0/user/src/com/google/gwt/resources/css/SubstitutionReplacer.java
Tue Jan 19 06:47:00 2010
@@ -16,7 +16,8 @@
package com.google.gwt.resources.css;
import com.google.gwt.core.ext.TreeLogger;
-import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JClassType;
+import com.google.gwt.core.ext.typeinfo.NotFoundException;
import com.google.gwt.resources.client.DataResource;
import com.google.gwt.resources.css.ast.Context;
import com.google.gwt.resources.css.ast.CssCompilerException;
@@ -24,11 +25,13 @@
import com.google.gwt.resources.css.ast.CssProperty;
import com.google.gwt.resources.css.ast.CssUrl;
import com.google.gwt.resources.css.ast.CssVisitor;
+import com.google.gwt.resources.css.ast.CssProperty.DotPathValue;
import com.google.gwt.resources.css.ast.CssProperty.ExpressionValue;
import com.google.gwt.resources.css.ast.CssProperty.IdentValue;
import com.google.gwt.resources.css.ast.CssProperty.ListValue;
import com.google.gwt.resources.css.ast.CssProperty.Value;
import com.google.gwt.resources.ext.ResourceContext;
+import com.google.gwt.resources.ext.ResourceGeneratorUtil;
import java.util.ArrayList;
import java.util.List;
@@ -40,12 +43,15 @@
*/
public class SubstitutionReplacer extends CssVisitor {
private final ResourceContext context;
+ private final JClassType dataResourceType;
private final TreeLogger logger;
private final Map<String, CssDef> substitutions;
public SubstitutionReplacer(TreeLogger logger, ResourceContext context,
Map<String, CssDef> substitutions) {
this.context = context;
+ this.dataResourceType =
context.getGeneratorContext().getTypeOracle().findType(
+ DataResource.class.getCanonicalName());
this.logger = logger;
this.substitutions = substitutions;
}
@@ -74,31 +80,20 @@
continue;
} else if (def instanceof CssUrl) {
assert def.getValues().size() == 1;
- assert def.getValues().get(0).isIdentValue() != null;
- String functionName =
def.getValues().get(0).isIdentValue().getIdent();
-
- // Find the method
- JMethod methods[] =
context.getClientBundleType().getOverridableMethods();
- boolean foundMethod = false;
- if (methods != null) {
- for (JMethod method : methods) {
- if (method.getName().equals(functionName)) {
- foundMethod = true;
- break;
- }
- }
- }
-
- if (!foundMethod) {
- logger.log(TreeLogger.ERROR, "Unable to find DataResource
method "
- + functionName + " in "
- + context.getClientBundleType().getQualifiedSourceName());
- throw new CssCompilerException("Cannot find data function");
+ assert def.getValues().get(0).isDotPathValue() != null;
+ DotPathValue functionName =
def.getValues().get(0).isDotPathValue();
+
+ try {
+
ResourceGeneratorUtil.getMethodByPath(context.getClientBundleType(),
+ functionName.getParts(), dataResourceType);
+ } catch (NotFoundException e) {
+ logger.log(TreeLogger.ERROR, e.getMessage());
+ throw new CssCompilerException("Cannot find data method");
}
String instance = "((" + DataResource.class.getName() + ")("
+ context.getImplementationSimpleSourceName() + ".this."
- + functionName + "()))";
+ + functionName.getExpression() + "))";
StringBuilder expression = new StringBuilder();
expression.append("\"url('\" + ");
=======================================
---
/releases/2.0/user/src/com/google/gwt/resources/css/ast/CssNodeCloner.java
Wed May 20 16:14:31 2009
+++
/releases/2.0/user/src/com/google/gwt/resources/css/ast/CssNodeCloner.java
Tue Jan 19 06:47:00 2010
@@ -240,9 +240,9 @@
@Override
public boolean visit(CssUrl x, Context ctx) {
assert x.getValues().size() == 1;
- assert x.getValues().get(0).isIdentValue() != null;
- String ident = x.getValues().get(0).isIdentValue().getIdent();
- CssUrl newUrl = new CssUrl(x.getKey(), ident);
+ assert x.getValues().get(0).isDotPathValue() != null;
+ CssUrl newUrl = new CssUrl(x.getKey(),
+ x.getValues().get(0).isDotPathValue());
addToNodes(newUrl);
return true;
}
=======================================
---
/releases/2.0/user/src/com/google/gwt/resources/css/ast/CssProperty.java
Sat Oct 24 08:11:35 2009
+++
/releases/2.0/user/src/com/google/gwt/resources/css/ast/CssProperty.java
Tue Jan 19 06:47:00 2010
@@ -35,15 +35,34 @@
private final String path;
private final String suffix;
+ public DotPathValue(String path) {
+ assert path != null : "path";
+ this.path = path;
+ this.suffix = null;
+ }
+
public DotPathValue(String path, String suffix) {
+ assert path != null : "path";
+ assert suffix != null : "suffix";
this.path = path;
this.suffix = suffix;
}
@Override
public String getExpression() {
- return path.replace(".", "().") + "() + \"" +
Generator.escape(suffix)
- + "\"";
+ StringBuilder toReturn = new StringBuilder();
+ toReturn.append(path.replace(".", "()."));
+ toReturn.append("()");
+ if (suffix != null) {
+ toReturn.append(" + \"");
+ toReturn.append(Generator.escape(suffix));
+ toReturn.append("\"");
+ }
+ return toReturn.toString();
+ }
+
+ public List<String> getParts() {
+ return Arrays.asList(path.split("\\."));
}
public String getPath() {
=======================================
--- /releases/2.0/user/src/com/google/gwt/resources/css/ast/CssSprite.java
Tue Mar 17 11:59:31 2009
+++ /releases/2.0/user/src/com/google/gwt/resources/css/ast/CssSprite.java
Tue Jan 19 06:47:00 2010
@@ -15,6 +15,7 @@
*/
package com.google.gwt.resources.css.ast;
+import com.google.gwt.resources.css.ast.CssProperty.DotPathValue;
import com.google.gwt.resources.css.ast.CssProperty.ListValue;
import com.google.gwt.resources.css.ast.CssProperty.StringValue;
import com.google.gwt.resources.css.ast.CssProperty.Value;
@@ -156,18 +157,18 @@
}
}
- private String resourceFunction;
+ private DotPathValue resourceFunction;
@Override
public List<CssProperty> getProperties() {
return new SpritePropertyList(super.getProperties());
}
- public String getResourceFunction() {
+ public DotPathValue getResourceFunction() {
return resourceFunction;
}
- public void setResourceFunction(String resourceFunction) {
+ public void setResourceFunction(DotPathValue resourceFunction) {
this.resourceFunction = resourceFunction;
}
@@ -192,13 +193,14 @@
ListValue listValue;
if ((stringValue = value.isStringValue()) != null) {
- resourceFunction = stringValue.getValue();
+ String s = stringValue.getValue();
// Allow the user to use both raw idents and quoted strings
- if (resourceFunction.startsWith("\"")) {
- resourceFunction = resourceFunction.substring(1,
- resourceFunction.length() - 1);
- }
+ if (s.startsWith("\"")) {
+ s = s.substring(1, s.length() - 1);
+ }
+
+ resourceFunction = new DotPathValue(s);
} else if ((listValue = value.isListValue()) != null) {
List<Value> values = listValue.getValues();
=======================================
--- /releases/2.0/user/src/com/google/gwt/resources/css/ast/CssUrl.java Wed
Mar 11 17:58:41 2009
+++ /releases/2.0/user/src/com/google/gwt/resources/css/ast/CssUrl.java Tue
Jan 19 06:47:00 2010
@@ -15,7 +15,7 @@
*/
package com.google.gwt.resources.css.ast;
-import com.google.gwt.resources.css.ast.CssProperty.IdentValue;
+import com.google.gwt.resources.css.ast.CssProperty.DotPathValue;
import com.google.gwt.resources.css.ast.CssProperty.Value;
import java.util.Collections;
@@ -29,9 +29,12 @@
private final List<Value> values;
public CssUrl(String key, String functionPath) {
+ this(key, new DotPathValue(functionPath));
+ }
+
+ public CssUrl(String key, DotPathValue functionValue) {
super(key);
- Value functionValue = new IdentValue(functionPath);
- values = Collections.singletonList(functionValue);
+ values = Collections.<Value> singletonList(functionValue);
}
@Override
=======================================
---
/releases/2.0/user/src/com/google/gwt/resources/ext/ResourceGeneratorUtil.java
Thu Nov 5 11:49:42 2009
+++
/releases/2.0/user/src/com/google/gwt/resources/ext/ResourceGeneratorUtil.java
Tue Jan 19 06:47:00 2010
@@ -23,6 +23,9 @@
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.JPackage;
+import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
+import com.google.gwt.core.ext.typeinfo.JType;
+import com.google.gwt.core.ext.typeinfo.NotFoundException;
import com.google.gwt.dev.resource.Resource;
import com.google.gwt.dev.resource.ResourceOracle;
import com.google.gwt.dev.util.collect.Maps;
@@ -292,6 +295,81 @@
defaultSuffixes);
return toReturn;
}
+
+ /**
+ * Finds a method by following a dotted path interpreted as a series of
no-arg
+ * method invocations from an instance of a given root type.
+ *
+ * @param rootType the type from which the search begins
+ * @param pathElements a sequence of no-arg method names
+ * @param expectedReturnType the expected return type of the method to
locate,
+ * or <code>null</code> if no constraint on the return type is
+ * necessary
+ *
+ * @return the requested JMethod
+ * @throws NotFoundException if the requested method could not be found
+ */
+ public static JMethod getMethodByPath(JClassType rootType,
+ List<String> pathElements, JType expectedReturnType)
+ throws NotFoundException {
+ if (pathElements.isEmpty()) {
+ throw new NotFoundException("No path specified");
+ }
+
+ JMethod currentMethod = null;
+ JType currentType = rootType;
+ for (String pathElement : pathElements) {
+
+ JClassType referenceType = currentType.isClassOrInterface();
+ if (referenceType == null) {
+ throw new NotFoundException("Cannot resolve member " + pathElement
+ + " on type " + currentType.getQualifiedSourceName());
+ }
+
+ currentMethod = null;
+ searchType : for (JClassType searchType :
referenceType.getFlattenedSupertypeHierarchy()) {
+ for (JMethod method : searchType.getOverloads(pathElement)) {
+ if (method.getParameters().length == 0) {
+ currentMethod = method;
+ break searchType;
+ }
+ }
+ }
+
+ if (currentMethod == null) {
+ throw new NotFoundException("Could not find no-arg method named "
+ + pathElement + " in type " +
currentType.getQualifiedSourceName());
+ }
+ currentType = currentMethod.getReturnType();
+ }
+
+ if (expectedReturnType != null) {
+ JPrimitiveType expectedIsPrimitive =
expectedReturnType.isPrimitive();
+ JClassType expectedIsClassType =
expectedReturnType.isClassOrInterface();
+ boolean error = false;
+
+ if (expectedIsPrimitive != null) {
+ if (!expectedIsPrimitive.equals(currentMethod.getReturnType())) {
+ error = true;
+ }
+ } else {
+ JClassType returnIsClassType =
currentMethod.getReturnType().isClassOrInterface();
+ if (returnIsClassType == null) {
+ error = true;
+ } else if
(!expectedIsClassType.isAssignableFrom(returnIsClassType)) {
+ error = true;
+ }
+ }
+
+ if (error) {
+ throw new NotFoundException("Expecting return type "
+ + expectedReturnType.getQualifiedSourceName() + " found "
+ + currentMethod.getReturnType().getQualifiedSourceName());
+ }
+ }
+
+ return currentMethod;
+ }
/**
* We want to warn the user about any annotations from ImageBundle or
the old
=======================================
---
/releases/2.0/user/src/com/google/gwt/resources/rg/CssResourceGenerator.java
Wed Nov 4 06:59:39 2009
+++
/releases/2.0/user/src/com/google/gwt/resources/rg/CssResourceGenerator.java
Tue Jan 19 06:47:00 2010
@@ -24,7 +24,6 @@
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
-import com.google.gwt.core.ext.typeinfo.JType;
import com.google.gwt.core.ext.typeinfo.NotFoundException;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.dev.util.DefaultTextOutput;
@@ -335,35 +334,14 @@
DotPathValue dot = value.isDotPathValue();
if (dot != null) {
- String[] elements = dot.getPath().split("\\.");
- if (elements.length == 0) {
- logger.log(TreeLogger.ERROR, "value() functions must specify a
path");
+ try {
+ // This will either succeed or throw an exception
+ ResourceGeneratorUtil.getMethodByPath(resourceBundleType,
+ dot.getParts(), null);
+ } catch (NotFoundException e) {
+ logger.log(TreeLogger.ERROR, e.getMessage());
throw new UnableToCompleteException();
}
-
- JType currentType = resourceBundleType;
- for (Iterator<String> i = Arrays.asList(elements).iterator();
i.hasNext();) {
- String pathElement = i.next();
-
- JClassType referenceType = currentType.isClassOrInterface();
- if (referenceType == null) {
- logger.log(TreeLogger.ERROR, "Cannot resolve member " +
pathElement
- + " on non-reference type "
- + currentType.getQualifiedSourceName());
- throw new UnableToCompleteException();
- }
-
- try {
- JMethod m = referenceType.getMethod(pathElement, new JType[0]);
- currentType = m.getReturnType();
- } catch (NotFoundException e) {
- logger.log(TreeLogger.ERROR, "Could not find no-arg method
named "
- + pathElement + " in type "
- + currentType.getQualifiedSourceName());
- throw new UnableToCompleteException();
- }
- }
- return;
}
}
@@ -729,10 +707,10 @@
* also perform some limited sanity-checking for the now-deprecated
Strict
* annotation.
*/
- @SuppressWarnings("deprecation") // keep references to deprecated Strict
annotation local
+ @SuppressWarnings("deprecation")
+ // keep references to deprecated Strict annotation local
private boolean isStrict(TreeLogger logger, JMethod method) {
- com.google.gwt.resources.client.CssResource.Strict strictAnnotation =
-
method.getAnnotation(com.google.gwt.resources.client.CssResource.Strict.class);
+ com.google.gwt.resources.client.CssResource.Strict strictAnnotation =
method.getAnnotation(com.google.gwt.resources.client.CssResource.Strict.class);
NotStrict nonStrictAnnotation = method.getAnnotation(NotStrict.class);
boolean strict = true;
=======================================
--- /releases/2.0/user/test/com/google/gwt/resources/ResourcesSuite.java
Tue Sep 29 13:58:11 2009
+++ /releases/2.0/user/test/com/google/gwt/resources/ResourcesSuite.java
Tue Jan 19 06:47:00 2010
@@ -25,6 +25,7 @@
import com.google.gwt.resources.css.CssReorderTest;
import com.google.gwt.resources.css.CssRtlTest;
import com.google.gwt.resources.css.ExtractClassNamesVisitorTest;
+import com.google.gwt.resources.ext.ResourceGeneratorUtilTest;
import junit.framework.Test;
@@ -43,6 +44,7 @@
suite.addTestSuite(ImageResourceTest.class);
suite.addTestSuite(ImageResourceNoInliningTest.class);
suite.addTestSuite(NestedBundleTest.class);
+ suite.addTestSuite(ResourceGeneratorUtilTest.class);
suite.addTestSuite(TextResourceTest.class);
return suite;
=======================================
---
/releases/2.0/user/test/com/google/gwt/resources/client/CSSResourceTest.java
Sat Oct 10 13:50:44 2009
+++
/releases/2.0/user/test/com/google/gwt/resources/client/CSSResourceTest.java
Tue Jan 19 06:47:00 2010
@@ -108,6 +108,8 @@
String multiClassB();
+ String nestedSprite();
+
String replacement();
@ClassName("replacement-not-java-ident")
@@ -160,6 +162,14 @@
String replacement();
}
+
+ interface NestedResources extends ClientBundle {
+ @Source("32x32.png")
+ DataResource dataMethod();
+
+ @Source("16x16.png")
+ ImageResource spriteMethod();
+ }
interface Resources extends ClientBundle {
Resources INSTANCE = GWT.create(Resources.class);
@@ -186,6 +196,9 @@
// Make sure an empty, no-op CssResource works
CssResource empty();
+ // Test nested ClientBundles
+ NestedResources nested();
+
@Source("16x16.png")
ImageResource spriteMethod();
}
@@ -289,7 +302,10 @@
assertTrue(text.contains("top:expression(document.compatMode==\"CSS1Compat\" ?
documentElement.scrollTop:document.body.scrollTop \\ 2);"));
// Check data URL expansion
- assertTrue(text.contains(Resources.INSTANCE.dataMethod().getUrl()));
+ assertTrue(text.contains("backgroundTopLevel:url('"
+ + Resources.INSTANCE.dataMethod().getUrl() + "')"));
+ assertTrue(text.contains("backgroundNested:url('"
+ + Resources.INSTANCE.nested().dataMethod().getUrl() + "')"));
// Check @eval expansion
assertTrue(text.contains(red() + ";"));
=======================================
--- /releases/2.0/user/test/com/google/gwt/resources/client/test.css Sat
Oct 10 13:50:44 2009
+++ /releases/2.0/user/test/com/google/gwt/resources/client/test.css Tue
Jan 19 06:47:00 2010
@@ -17,10 +17,12 @@
@def DIRECTION ltr;
@eval RED com.google.gwt.resources.client.CSSResourceTest.red();
@url BACKGROUND dataMethod;
+...@url NESTEDBACKGROUND nested.dataMethod;
/* Check @def expansion */
@def SPRITEWIDTH value("spriteMethod.getWidth", "px");
@def SPRITESIZE SPRITEWIDTH value("spriteMethod.getHeight", "px");
+...@def NESTEDSPRITEWIDTH value("nested.spriteMethod.getWidth", "px");
/*
* We'll use the token FAIL to indicate text that should never be seen in
the output.
@@ -31,6 +33,10 @@
gwt-image: "spriteMethod";
more: properties;
}
+
+...@sprite .nestedSprite {
+ gwt-image: "nested.spriteMethod";
+}
.affectedBySprite {
offset-left: "guard" SPRITEWIDTH !important;
@@ -49,7 +55,8 @@
div {
border: BIG solid RED;
direction: DIRECTION;
- background: BACKGROUND;
+ backgroundTopLevel: BACKGROUND;
+ backgroundNested: NESTEDBACKGROUND;
}
div[foo="bar"] {
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors