protected IdentValue checkIdent(CSSName cssName, CSSPrimitiveValue value) { IdentValue result = IdentValue.valueOf(value.getStringValue()); if (result == null) { throw new CSSParseException("Value " + value.getStringValue() + " is not a recognized identifier", -1); } ((PropertyValue)value).setIdentValue(result); return result; }
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentType(cssName, value); if (! value.getStringValue().equals("auto")) { // Treat as string since it won't be a proper IdentValue value = new PropertyValue( CSSPrimitiveValue.CSS_STRING, value.getStringValue(), value.getCssText()); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
private CSSPrimitiveValue convertToBorderWidth(CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && ! isLength(value)) { return null; } if (isLength(value)) { return value; } else { IdentValue ident = IdentValue.valueOf(value.getStringValue()); if (ident == null) { return null; } if (PrimitivePropertyBuilders.BORDER_WIDTHS.get(ident.FS_ID)) { return Conversions.getBorderWidth(ident.toString()); } else { return null; } } }
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentOrString(cssName, value); if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { // Convert to string return Collections.singletonList( new PropertyDeclaration( cssName, new PropertyValue( CSSPrimitiveValue.CSS_STRING, value.getStringValue(), value.getCssText()), important, origin)); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }
private CSSPrimitiveValue convertToBorderColor(CSSPrimitiveValue value) { int type = value.getPrimitiveType(); if (type != CSSPrimitiveValue.CSS_IDENT && type != CSSPrimitiveValue.CSS_RGBCOLOR) { return null; } if (type == CSSPrimitiveValue.CSS_RGBCOLOR) { return value; } else { FSRGBColor color = Conversions.getColor(value.getStringValue()); if (color != null) { return new PropertyValue(color); } IdentValue ident = IdentValue.valueOf(value.getCssText()); if (ident == null || ident != IdentValue.TRANSPARENT) { return null; } return value; } } }
public List buildDeclarations( CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) { checkValueCount(cssName, 1, values.size()); CSSPrimitiveValue value = (CSSPrimitiveValue)values.get(0); checkInheritAllowed(value, inheritAllowed); if (value.getCssValueType() != CSSPrimitiveValue.CSS_INHERIT) { checkIdentOrColorType(cssName, value); if (value.getPrimitiveType() == CSSPrimitiveValue.CSS_IDENT) { FSRGBColor color = Conversions.getColor(value.getStringValue()); if (color != null) { return Collections.singletonList( new PropertyDeclaration( cssName, new PropertyValue(color), important, origin)); } IdentValue ident = checkIdent(cssName, value); checkValidity(cssName, ALLOWED, ident); } } return Collections.singletonList( new PropertyDeclaration(cssName, value, important, origin)); } }