modules/graphics/src/main/java/javafx/scene/CssStyleHelper.java
Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization
*** 35,74 ****
import java.util.Set;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.WritableValue;
import javafx.css.CssMetaData;
import javafx.css.FontCssMetaData;
import javafx.css.ParsedValue;
import javafx.css.PseudoClass;
import javafx.css.StyleConverter;
import javafx.css.StyleOrigin;
import javafx.css.Styleable;
import javafx.css.StyleableProperty;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
! import com.sun.javafx.util.Logging;
! import com.sun.javafx.util.Utils;
import com.sun.javafx.css.CalculatedValue;
- import com.sun.javafx.css.CascadingStyle;
- import com.sun.javafx.css.CssError;
import com.sun.javafx.css.ParsedValueImpl;
import com.sun.javafx.css.PseudoClassState;
- import com.sun.javafx.css.Rule;
- import com.sun.javafx.css.Selector;
- import com.sun.javafx.css.Style;
import com.sun.javafx.css.StyleCache;
import com.sun.javafx.css.StyleCacheEntry;
- import com.sun.javafx.css.StyleConverterImpl;
import com.sun.javafx.css.StyleManager;
import com.sun.javafx.css.StyleMap;
! import com.sun.javafx.css.Stylesheet;
! import com.sun.javafx.css.converters.FontConverter;
! import sun.util.logging.PlatformLogger;
import sun.util.logging.PlatformLogger.Level;
import static com.sun.javafx.css.CalculatedValue.*;
/**
* The StyleHelper is a helper class used for applying CSS information to Nodes.
--- 35,75 ----
import java.util.Set;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.WritableValue;
+ import javafx.css.CascadingStyle;
import javafx.css.CssMetaData;
+ import javafx.css.CssParser;
import javafx.css.FontCssMetaData;
import javafx.css.ParsedValue;
import javafx.css.PseudoClass;
+ import javafx.css.Rule;
+ import javafx.css.Selector;
+ import javafx.css.Style;
import javafx.css.StyleConverter;
import javafx.css.StyleOrigin;
import javafx.css.Styleable;
import javafx.css.StyleableProperty;
+ import javafx.css.Stylesheet;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
!
import com.sun.javafx.css.CalculatedValue;
import com.sun.javafx.css.ParsedValueImpl;
import com.sun.javafx.css.PseudoClassState;
import com.sun.javafx.css.StyleCache;
import com.sun.javafx.css.StyleCacheEntry;
import com.sun.javafx.css.StyleManager;
import com.sun.javafx.css.StyleMap;
! import javafx.css.converter.FontConverter;
! import com.sun.javafx.util.Logging;
! import com.sun.javafx.util.Utils;
!
import sun.util.logging.PlatformLogger.Level;
+ import sun.util.logging.PlatformLogger;
import static com.sun.javafx.css.CalculatedValue.*;
/**
* The StyleHelper is a helper class used for applying CSS information to Nodes.
*** 630,642 ****
final int max = styleables.size();
final boolean isForceSlowpath = cacheContainer.forceSlowpath;
cacheContainer.forceSlowpath = false;
- // RT-20643
- CssError.setCurrentScene(node.getScene());
-
// For each property that is settable, we need to do a lookup and
// transition to that value.
for(int n=0; n<max; n++) {
@SuppressWarnings("unchecked") // this is a widening conversion
--- 631,640 ----
*** 786,798 ****
StyleableProperty styleableProperty = cssMetaData.getStyleableProperty(node);
final String msg = String.format("Failed to set css [%s] on [%s] due to '%s'\n",
cssMetaData.getProperty(), styleableProperty, e.getMessage());
! List<CssError> errors = null;
if ((errors = StyleManager.getErrors()) != null) {
! final CssError error = new CssError.PropertySetError(cssMetaData, node, msg);
errors.add(error);
}
PlatformLogger logger = Logging.getCSSLogger();
if (logger.isLoggable(Level.WARNING)) {
--- 784,796 ----
StyleableProperty styleableProperty = cssMetaData.getStyleableProperty(node);
final String msg = String.format("Failed to set css [%s] on [%s] due to '%s'\n",
cssMetaData.getProperty(), styleableProperty, e.getMessage());
! List<CssParser.ParseError> errors = null;
if ((errors = StyleManager.getErrors()) != null) {
! final CssParser.ParseError error = new CssParser.ParseError.PropertySetError(cssMetaData, node, msg);
errors.add(error);
}
PlatformLogger logger = Logging.getCSSLogger();
if (logger.isLoggable(Level.WARNING)) {
*** 820,833 ****
}
}
}
-
- // RT-20643
- CssError.setCurrentScene(null);
-
}
/**
* Gets the CSS CascadingStyle for the property of this node in these pseudo-class
* states. A null style may be returned if there is no style information
--- 818,827 ----
*** 962,983 ****
styleMap, states, originatingStyleable, cachedFont);
}
try {
final StyleConverter keyType = cssMetaData.getConverter();
! if (keyType instanceof StyleConverterImpl) {
! Object ret = ((StyleConverterImpl)keyType).convert(subs);
return new CalculatedValue(ret, origin, isRelative);
- } else {
- assert false; // TBD: should an explicit exception be thrown here?
- return SKIP;
- }
} catch (ClassCastException cce) {
final String msg = formatExceptionMessage(styleable, cssMetaData, null, cce);
! List<CssError> errors = null;
if ((errors = StyleManager.getErrors()) != null) {
! final CssError error = new CssError.PropertySetError(cssMetaData, styleable, msg);
errors.add(error);
}
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning(msg);
LOGGER.fine("caught: ", cce);
--- 956,972 ----
styleMap, states, originatingStyleable, cachedFont);
}
try {
final StyleConverter keyType = cssMetaData.getConverter();
! Object ret = keyType.convert(subs);
return new CalculatedValue(ret, origin, isRelative);
} catch (ClassCastException cce) {
final String msg = formatExceptionMessage(styleable, cssMetaData, null, cce);
! List<CssParser.ParseError> errors = null;
if ((errors = StyleManager.getErrors()) != null) {
! final CssParser.ParseError error = new CssParser.ParseError.PropertySetError(cssMetaData, styleable, msg);
errors.add(error);
}
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning(msg);
LOGGER.fine("caught: ", cce);
*** 1004,1014 ****
}
}
// If there was a style found, then we want to check whether the
// value was "inherit". If so, then we will simply inherit.
! final ParsedValueImpl cssValue = style.getParsedValueImpl();
if (cssValue != null && "inherit".equals(cssValue.getValue())) {
style = getInheritedStyle(styleable, property);
if (style == null) return SKIP;
}
}
--- 993,1003 ----
}
}
// If there was a style found, then we want to check whether the
// value was "inherit". If so, then we will simply inherit.
! final ParsedValue cssValue = style.getParsedValue();
if (cssValue != null && "inherit".equals(cssValue.getValue())) {
style = getInheritedStyle(styleable, property);
if (style == null) return SKIP;
}
}
*** 1078,1088 ****
Set<PseudoClass> transitionStates = ((Node)parent).pseudoClassStates;
CascadingStyle cascadingStyle = parentStyleHelper.getStyle(parent, property, parentStyleMap, transitionStates);
if (cascadingStyle != null) {
! final ParsedValueImpl cssValue = cascadingStyle.getParsedValueImpl();
if ("inherit".equals(cssValue.getValue())) {
return getInheritedStyle(parent, property);
}
return cascadingStyle;
--- 1067,1077 ----
Set<PseudoClass> transitionStates = ((Node)parent).pseudoClassStates;
CascadingStyle cascadingStyle = parentStyleHelper.getStyle(parent, property, parentStyleMap, transitionStates);
if (cascadingStyle != null) {
! final ParsedValue cssValue = cascadingStyle.getParsedValue();
if ("inherit".equals(cssValue.getValue())) {
return getInheritedStyle(parent, property);
}
return cascadingStyle;
*** 1146,1158 ****
}
}
}
// to resolve a lookup, we just need to find the parsed value.
! private ParsedValueImpl resolveLookups(
final Styleable styleable,
! final ParsedValueImpl parsedValue,
final StyleMap styleMap, Set<PseudoClass> states,
final ObjectProperty<StyleOrigin> whence,
Set<ParsedValue> resolves) {
//
--- 1135,1147 ----
}
}
}
// to resolve a lookup, we just need to find the parsed value.
! private ParsedValue resolveLookups(
final Styleable styleable,
! final ParsedValue parsedValue,
final StyleMap styleMap, Set<PseudoClass> states,
final ObjectProperty<StyleOrigin> whence,
Set<ParsedValue> resolves) {
//
*** 1170,1180 ****
CascadingStyle resolved =
resolveRef(styleable, sval, styleMap, states);
if (resolved != null) {
! if (resolves.contains(resolved.getParsedValueImpl())) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning("Loop detected in " + resolved.getRule().toString() + " while resolving '" + sval + "'");
}
throw new IllegalArgumentException("Loop detected in " + resolved.getRule().toString() + " while resolving '" + sval + "'");
--- 1159,1169 ----
CascadingStyle resolved =
resolveRef(styleable, sval, styleMap, states);
if (resolved != null) {
! if (resolves.contains(resolved.getParsedValue())) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning("Loop detected in " + resolved.getRule().toString() + " while resolving '" + sval + "'");
}
throw new IllegalArgumentException("Loop detected in " + resolved.getRule().toString() + " while resolving '" + sval + "'");
*** 1196,1206 ****
}
// the resolved value may itself need to be resolved.
// For example, if the value "color" resolves to "base",
// then "base" will need to be resolved as well.
! ParsedValueImpl pv = resolveLookups(styleable, resolved.getParsedValueImpl(), styleMap, states, whence, resolves);
if (resolves != null) {
resolves.remove(parsedValue);
}
--- 1185,1195 ----
}
// the resolved value may itself need to be resolved.
// For example, if the value "color" resolves to "base",
// then "base" will need to be resolved as well.
! ParsedValue pv = resolveLookups(styleable, resolved.getParsedValue(), styleMap, states, whence, resolves);
if (resolves != null) {
resolves.remove(parsedValue);
}
*** 1215,1231 ****
return parsedValue;
}
final Object val = parsedValue.getValue();
! if (val instanceof ParsedValueImpl[][]) {
! // If ParsedValueImpl is a layered sequence of values, resolve the lookups for each.
! final ParsedValueImpl[][] layers = (ParsedValueImpl[][])val;
! ParsedValueImpl[][] resolved = new ParsedValueImpl[layers.length][0];
for (int l=0; l<layers.length; l++) {
! resolved[l] = new ParsedValueImpl[layers[l].length];
for (int ll=0; ll<layers[l].length; ll++) {
if (layers[l][ll] == null) continue;
resolved[l][ll] =
resolveLookups(styleable, layers[l][ll], styleMap, states, whence, resolves);
}
--- 1204,1220 ----
return parsedValue;
}
final Object val = parsedValue.getValue();
! if (val instanceof ParsedValue[][]) {
! // If ParsedValue is a layered sequence of values, resolve the lookups for each.
! final ParsedValue[][] layers = (ParsedValue[][])val;
! ParsedValue[][] resolved = new ParsedValue[layers.length][0];
for (int l=0; l<layers.length; l++) {
! resolved[l] = new ParsedValue[layers[l].length];
for (int ll=0; ll<layers[l].length; ll++) {
if (layers[l][ll] == null) continue;
resolved[l][ll] =
resolveLookups(styleable, layers[l][ll], styleMap, states, whence, resolves);
}
*** 1235,1247 ****
return new ParsedValueImpl(resolved, parsedValue.getConverter(), false);
} else if (val instanceof ParsedValueImpl[]) {
! // If ParsedValueImpl is a sequence of values, resolve the lookups for each.
! final ParsedValueImpl[] layer = (ParsedValueImpl[])val;
! ParsedValueImpl[] resolved = new ParsedValueImpl[layer.length];
for (int l=0; l<layer.length; l++) {
if (layer[l] == null) continue;
resolved[l] =
resolveLookups(styleable, layer[l], styleMap, states, whence, resolves);
}
--- 1224,1236 ----
return new ParsedValueImpl(resolved, parsedValue.getConverter(), false);
} else if (val instanceof ParsedValueImpl[]) {
! // If ParsedValue is a sequence of values, resolve the lookups for each.
! final ParsedValue[] layer = (ParsedValue[])val;
! ParsedValue[] resolved = new ParsedValue[layer.length];
for (int l=0; l<layer.length; l++) {
if (layer[l] == null) continue;
resolved[l] =
resolveLookups(styleable, layer[l], styleMap, states, whence, resolves);
}
*** 1254,1295 ****
return parsedValue;
}
! private String getUnresolvedLookup(final ParsedValueImpl resolved) {
Object value = resolved.getValue();
if (resolved.isLookup() && value instanceof String) {
return (String)value;
}
! if (value instanceof ParsedValueImpl[][]) {
! final ParsedValueImpl[][] layers = (ParsedValueImpl[][])value;
for (int l=0; l<layers.length; l++) {
for (int ll=0; ll<layers[l].length; ll++) {
if (layers[l][ll] == null) continue;
String unresolvedLookup = getUnresolvedLookup(layers[l][ll]);
if (unresolvedLookup != null) return unresolvedLookup;
}
}
! } else if (value instanceof ParsedValueImpl[]) {
! // If ParsedValueImpl is a sequence of values, resolve the lookups for each.
! final ParsedValueImpl[] layer = (ParsedValueImpl[])value;
for (int l=0; l<layer.length; l++) {
if (layer[l] == null) continue;
String unresolvedLookup = getUnresolvedLookup(layer[l]);
if (unresolvedLookup != null) return unresolvedLookup;
}
}
return null;
}
! private String formatUnresolvedLookupMessage(Styleable styleable, CssMetaData cssMetaData, Style style, ParsedValueImpl resolved, ClassCastException cce) {
// Find value that could not be looked up. If the resolved value does not contain lookups, then the
// ClassCastException is not because of trying to convert a String (which is the missing lookup)
// to some value, but is because the convert method got some wrong value - like a paint when it should be a color.
// See RT-33319 for an example of this.
--- 1243,1284 ----
return parsedValue;
}
! private String getUnresolvedLookup(final ParsedValue resolved) {
Object value = resolved.getValue();
if (resolved.isLookup() && value instanceof String) {
return (String)value;
}
! if (value instanceof ParsedValue[][]) {
! final ParsedValue[][] layers = (ParsedValue[][])value;
for (int l=0; l<layers.length; l++) {
for (int ll=0; ll<layers[l].length; ll++) {
if (layers[l][ll] == null) continue;
String unresolvedLookup = getUnresolvedLookup(layers[l][ll]);
if (unresolvedLookup != null) return unresolvedLookup;
}
}
! } else if (value instanceof ParsedValue[]) {
! // If ParsedValue is a sequence of values, resolve the lookups for each.
! final ParsedValue[] layer = (ParsedValue[])value;
for (int l=0; l<layer.length; l++) {
if (layer[l] == null) continue;
String unresolvedLookup = getUnresolvedLookup(layer[l]);
if (unresolvedLookup != null) return unresolvedLookup;
}
}
return null;
}
! private String formatUnresolvedLookupMessage(Styleable styleable, CssMetaData cssMetaData, Style style, ParsedValue resolved, ClassCastException cce) {
// Find value that could not be looked up. If the resolved value does not contain lookups, then the
// ClassCastException is not because of trying to convert a String (which is the missing lookup)
// to some value, but is because the convert method got some wrong value - like a paint when it should be a color.
// See RT-33319 for an example of this.
*** 1370,1383 ****
final CssMetaData cssMetaData,
final StyleMap styleMap, final Set<PseudoClass> states,
final Styleable originatingStyleable,
final CalculatedValue fontFromCacheEntry) {
! final ParsedValueImpl cssValue = style.getParsedValueImpl();
if (cssValue != null && !("null".equals(cssValue.getValue()) || "none".equals(cssValue.getValue()))) {
! ParsedValueImpl resolved = null;
try {
ObjectProperty<StyleOrigin> whence = new SimpleObjectProperty<>(style.getOrigin());
resolved = resolveLookups(styleable, cssValue, styleMap, states, whence, new HashSet<>());
--- 1359,1372 ----
final CssMetaData cssMetaData,
final StyleMap styleMap, final Set<PseudoClass> states,
final Styleable originatingStyleable,
final CalculatedValue fontFromCacheEntry) {
! final ParsedValue cssValue = style.getParsedValue();
if (cssValue != null && !("null".equals(cssValue.getValue()) || "none".equals(cssValue.getValue()))) {
! ParsedValue resolved = null;
try {
ObjectProperty<StyleOrigin> whence = new SimpleObjectProperty<>(style.getOrigin());
resolved = resolveLookups(styleable, cssValue, styleMap, states, whence, new HashSet<>());
*** 1451,1468 ****
}
}
final StyleConverter cssMetaDataConverter = cssMetaData.getConverter();
// RT-37727 - handling of properties that are insets is wonky. If the property is -fx-inset, then
! // there isn't an issue because the converter assigns the InsetsConverter to the ParsedValueImpl.
// But -my-insets will parse as an array of numbers and the parser will assign the Size sequence
// converter to it. So, if the CssMetaData says it uses InsetsConverter, use the InsetsConverter
// and not the parser assigned converter.
if (cssMetaDataConverter == StyleConverter.getInsetsConverter()) {
if (resolved.getValue() instanceof ParsedValue) {
! // If you give the parser "-my-insets: 5;" you end up with a ParsedValueImpl<ParsedValue<?,Size>, Number>
! // and not a ParsedValueImpl<ParsedValue[], Number[]> so here we wrap the value into an array
// to make the InsetsConverter happy.
resolved = new ParsedValueImpl(new ParsedValue[] {(ParsedValue)resolved.getValue()}, null, false);
}
val = cssMetaDataConverter.convert(resolved, fontForFontRelativeSizes);
}
--- 1440,1457 ----
}
}
final StyleConverter cssMetaDataConverter = cssMetaData.getConverter();
// RT-37727 - handling of properties that are insets is wonky. If the property is -fx-inset, then
! // there isn't an issue because the converter assigns the InsetsConverter to the ParsedValue.
// But -my-insets will parse as an array of numbers and the parser will assign the Size sequence
// converter to it. So, if the CssMetaData says it uses InsetsConverter, use the InsetsConverter
// and not the parser assigned converter.
if (cssMetaDataConverter == StyleConverter.getInsetsConverter()) {
if (resolved.getValue() instanceof ParsedValue) {
! // If you give the parser "-my-insets: 5;" you end up with a ParsedValue<ParsedValue<?,Size>, Number>
! // and not a ParsedValue<ParsedValue[], Number[]> so here we wrap the value into an array
// to make the InsetsConverter happy.
resolved = new ParsedValueImpl(new ParsedValue[] {(ParsedValue)resolved.getValue()}, null, false);
}
val = cssMetaDataConverter.convert(resolved, fontForFontRelativeSizes);
}
*** 1474,1486 ****
final StyleOrigin origin = whence.get();
return new CalculatedValue(val, origin, isRelative);
} catch (ClassCastException cce) {
final String msg = formatUnresolvedLookupMessage(styleable, cssMetaData, style.getStyle(),resolved, cce);
! List<CssError> errors = null;
if ((errors = StyleManager.getErrors()) != null) {
! final CssError error = new CssError.PropertySetError(cssMetaData, styleable, msg);
errors.add(error);
}
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning(msg);
LOGGER.fine("node = " + styleable.toString());
--- 1463,1475 ----
final StyleOrigin origin = whence.get();
return new CalculatedValue(val, origin, isRelative);
} catch (ClassCastException cce) {
final String msg = formatUnresolvedLookupMessage(styleable, cssMetaData, style.getStyle(),resolved, cce);
! List<CssParser.ParseError> errors = null;
if ((errors = StyleManager.getErrors()) != null) {
! final CssParser.ParseError error = new CssParser.ParseError.PropertySetError(cssMetaData, styleable, msg);
errors.add(error);
}
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning(msg);
LOGGER.fine("node = " + styleable.toString());
*** 1488,1500 ****
LOGGER.fine("styles = " + getMatchingStyles(styleable, cssMetaData));
}
return SKIP;
} catch (IllegalArgumentException iae) {
final String msg = formatExceptionMessage(styleable, cssMetaData, style.getStyle(), iae);
! List<CssError> errors = null;
if ((errors = StyleManager.getErrors()) != null) {
! final CssError error = new CssError.PropertySetError(cssMetaData, styleable, msg);
errors.add(error);
}
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning(msg);
LOGGER.fine("caught: ", iae);
--- 1477,1489 ----
LOGGER.fine("styles = " + getMatchingStyles(styleable, cssMetaData));
}
return SKIP;
} catch (IllegalArgumentException iae) {
final String msg = formatExceptionMessage(styleable, cssMetaData, style.getStyle(), iae);
! List<CssParser.ParseError> errors = null;
if ((errors = StyleManager.getErrors()) != null) {
! final CssParser.ParseError error = new CssParser.ParseError.PropertySetError(cssMetaData, styleable, msg);
errors.add(error);
}
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning(msg);
LOGGER.fine("caught: ", iae);
*** 1502,1514 ****
LOGGER.fine("node = " + styleable.toString());
}
return SKIP;
} catch (NullPointerException npe) {
final String msg = formatExceptionMessage(styleable, cssMetaData, style.getStyle(), npe);
! List<CssError> errors = null;
if ((errors = StyleManager.getErrors()) != null) {
! final CssError error = new CssError.PropertySetError(cssMetaData, styleable, msg);
errors.add(error);
}
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning(msg);
LOGGER.fine("caught: ", npe);
--- 1491,1503 ----
LOGGER.fine("node = " + styleable.toString());
}
return SKIP;
} catch (NullPointerException npe) {
final String msg = formatExceptionMessage(styleable, cssMetaData, style.getStyle(), npe);
! List<CssParser.ParseError> errors = null;
if ((errors = StyleManager.getErrors()) != null) {
! final CssParser.ParseError error = new CssParser.ParseError.PropertySetError(cssMetaData, styleable, msg);
errors.add(error);
}
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning(msg);
LOGGER.fine("caught: ", npe);
*** 1730,1740 ****
Set<PseudoClass> transitionStates = ((Node)parent).pseudoClassStates;
CascadingStyle cascadingStyle = parentStyleHelper.getStyle(parent, property, parentStyleMap, transitionStates);
if (cascadingStyle != null) {
! final ParsedValueImpl cssValue = cascadingStyle.getParsedValueImpl();
if ("inherit".equals(cssValue.getValue()) == false) {
fontShorthand = cascadingStyle;
break;
}
--- 1719,1729 ----
Set<PseudoClass> transitionStates = ((Node)parent).pseudoClassStates;
CascadingStyle cascadingStyle = parentStyleHelper.getStyle(parent, property, parentStyleMap, transitionStates);
if (cascadingStyle != null) {
! final ParsedValue cssValue = cascadingStyle.getParsedValue();
if ("inherit".equals(cssValue.getValue()) == false) {
fontShorthand = cascadingStyle;
break;
}
*** 1988,1998 ****
if (fontShorthand.compareTo(cascadingStyle) < 0) {
return null;
}
}
! final ParsedValueImpl cssValue = cascadingStyle.getParsedValueImpl();
if ("inherit".equals(cssValue.getValue()) == false) {
return cascadingStyle;
}
}
--- 1977,1987 ----
if (fontShorthand.compareTo(cascadingStyle) < 0) {
return null;
}
}
! final ParsedValue cssValue = cascadingStyle.getParsedValue();
if ("inherit".equals(cssValue.getValue()) == false) {
return cascadingStyle;
}
}
*** 2087,2097 ****
if (matchState) {
CascadingStyle cascadingStyle = getStyle(node, styleableProperty.getProperty(), smap, _node.pseudoClassStates);
if (cascadingStyle != null) {
styleList.add(cascadingStyle);
! final ParsedValueImpl parsedValue = cascadingStyle.getParsedValueImpl();
getMatchingLookupStyles(node, parsedValue, styleList, matchState);
}
} else {
Map<String, List<CascadingStyle>> cascadingStyleMap = smap.getCascadingStyles();
--- 2076,2086 ----
if (matchState) {
CascadingStyle cascadingStyle = getStyle(node, styleableProperty.getProperty(), smap, _node.pseudoClassStates);
if (cascadingStyle != null) {
styleList.add(cascadingStyle);
! final ParsedValue parsedValue = cascadingStyle.getParsedValue();
getMatchingLookupStyles(node, parsedValue, styleList, matchState);
}
} else {
Map<String, List<CascadingStyle>> cascadingStyleMap = smap.getCascadingStyles();
*** 2100,2110 ****
if (styles != null) {
styleList.addAll(styles);
for (int n=0, nMax=styles.size(); n<nMax; n++) {
final CascadingStyle style = styles.get(n);
! final ParsedValueImpl parsedValue = style.getParsedValueImpl();
getMatchingLookupStyles(node, parsedValue, styleList, matchState);
}
}
}
--- 2089,2099 ----
if (styles != null) {
styleList.addAll(styles);
for (int n=0, nMax=styles.size(); n<nMax; n++) {
final CascadingStyle style = styles.get(n);
! final ParsedValue parsedValue = style.getParsedValue();
getMatchingLookupStyles(node, parsedValue, styleList, matchState);
}
}
}
*** 2124,2134 ****
}
}
// Pretty much a duplicate of resolveLookups, but without the state
! private void getMatchingLookupStyles(final Styleable node, final ParsedValueImpl parsedValue, final List<CascadingStyle> styleList, boolean matchState) {
if (parsedValue.isLookup()) {
Object value = parsedValue.getValue();
--- 2113,2123 ----
}
}
// Pretty much a duplicate of resolveLookups, but without the state
! private void getMatchingLookupStyles(final Styleable node, final ParsedValue parsedValue, final List<CascadingStyle> styleList, boolean matchState) {
if (parsedValue.isLookup()) {
Object value = parsedValue.getValue();
*** 2168,2178 ****
final int end = styleList.size();
for (int index=start; index<end; index++) {
final CascadingStyle style = styleList.get(index);
! getMatchingLookupStyles(parent, style.getParsedValueImpl(), styleList, matchState);
}
}
} while ((parent = parent.getStyleableParent()) != null);
--- 2157,2167 ----
final int end = styleList.size();
for (int index=start; index<end; index++) {
final CascadingStyle style = styleList.get(index);
! getMatchingLookupStyles(parent, style.getParsedValue(), styleList, matchState);
}
}
} while ((parent = parent.getStyleableParent()) != null);
*** 2183,2205 ****
if (!parsedValue.isContainsLookups()) {
return;
}
final Object val = parsedValue.getValue();
! if (val instanceof ParsedValueImpl[][]) {
! // If ParsedValueImpl is a layered sequence of values, resolve the lookups for each.
! final ParsedValueImpl[][] layers = (ParsedValueImpl[][])val;
for (int l=0; l<layers.length; l++) {
for (int ll=0; ll<layers[l].length; ll++) {
if (layers[l][ll] == null) continue;
getMatchingLookupStyles(node, layers[l][ll], styleList, matchState);
}
}
! } else if (val instanceof ParsedValueImpl[]) {
! // If ParsedValueImpl is a sequence of values, resolve the lookups for each.
! final ParsedValueImpl[] layer = (ParsedValueImpl[])val;
for (int l=0; l<layer.length; l++) {
if (layer[l] == null) continue;
getMatchingLookupStyles(node, layer[l], styleList, matchState);
}
}
--- 2172,2194 ----
if (!parsedValue.isContainsLookups()) {
return;
}
final Object val = parsedValue.getValue();
! if (val instanceof ParsedValue[][]) {
! // If ParsedValue is a layered sequence of values, resolve the lookups for each.
! final ParsedValue[][] layers = (ParsedValue[][])val;
for (int l=0; l<layers.length; l++) {
for (int ll=0; ll<layers[l].length; ll++) {
if (layers[l][ll] == null) continue;
getMatchingLookupStyles(node, layers[l][ll], styleList, matchState);
}
}
! } else if (val instanceof ParsedValue[]) {
! // If ParsedValue is a sequence of values, resolve the lookups for each.
! final ParsedValue[] layer = (ParsedValue[])val;
for (int l=0; l<layer.length; l++) {
if (layer[l] == null) continue;
getMatchingLookupStyles(node, layer[l], styleList, matchState);
}
}