Package org.xhtmlrenderer.css.newmatch
Class CascadedStyle
java.lang.Object
org.xhtmlrenderer.css.newmatch.CascadedStyle
Holds a set of
PropertyDeclaration
s for
each unique CSS property name. What properties belong in the set is not
determined, except that multiple entries are resolved into a single set using
cascading rules. The set is cascaded during instantiation, so once you have a
CascadedStyle, the PropertyDeclarations you retrieve from it will have been
resolved following the CSS cascading rules. Note that this class knows
nothing about CSS selector-matching rules. Before creating a CascadedStyle,
you will need to determine which PropertyDeclarations belong in the set--for
example, by matching Ruleset
s to Document
Element
s via their selectors. You
can get individual properties by using propertyByName(CSSName)
or an
Iterator
of properties with getCascadedPropertyDeclarations()
. Check for individual property assignments
using hasProperty(CSSName)
. A CascadedStyle is immutable, as
properties can not be added or removed from it once instantiated.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<CSSName,
PropertyDeclaration> static final CascadedStyle
Get an empty singleton, used to negate inheritance of propertiesprivate String
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
Constructs a new CascadedStyle, given anIterator
ofPropertyDeclaration
s already sorted by specificity of the CSS selector they came from.private
CascadedStyle
(Map<CSSName, PropertyDeclaration> cascadedProperties) Default constructor with no initialization.private
CascadedStyle
(Map<CSSName, PropertyDeclaration> startingPoint, Iterator<PropertyDeclaration> iter) -
Method Summary
Modifier and TypeMethodDescriptionint
static CascadedStyle
createAnonymousStyle
(IdentValue display) Creates aCascadedStyle
, setting the display property to the value of thedisplay
parameter.static PropertyDeclaration
createLayoutPropertyDeclaration
(CSSName cssName, IdentValue display) Creates aPropertyDeclaration
suitable for passing tocreateLayoutStyle(List)
orcreateLayoutStyle(CascadedStyle, PropertyDeclaration[])
static CascadedStyle
createLayoutStyle
(List<PropertyDeclaration> declarations) static CascadedStyle
createLayoutStyle
(CascadedStyle startingPoint, PropertyDeclaration[] decls) Creates aCascadedStyle
using style information fromstartingPoint
and then adding the property declarations fromdecls
.static CascadedStyle
createLayoutStyle
(PropertyDeclaration... declarations) Creates aCascadedStyle
using the provided property declarations.Returns anIterator
over the set ofPropertyDeclaration
s already matched in this CascadedStyle.Gets the ident attribute of the CascadedStyle objectboolean
hasProperty
(CSSName cssName) Returns true if property has been defined in this style.propertyByName
(CSSName cssName) Returns aPropertyDeclaration
by CSS property name, e.g.
-
Field Details
-
cascadedProperties
-
fingerprint
-
emptyCascadedStyle
Get an empty singleton, used to negate inheritance of properties
-
-
Constructor Details
-
CascadedStyle
CascadedStyle(Iterable<PropertyDeclaration> iter) Constructs a new CascadedStyle, given anIterator
ofPropertyDeclaration
s already sorted by specificity of the CSS selector they came from. The Iterator can have multiple PropertyDeclarations with the same name; the property cascade will be resolved during instantiation, resulting in a set of PropertyDeclarations. Once instantiated, properties may be retrieved using the normal API for the class.- Parameters:
iter
- An Iterator containing PropertyDeclarations in order of specificity.
-
CascadedStyle
private CascadedStyle(Map<CSSName, PropertyDeclaration> startingPoint, Iterator<PropertyDeclaration> iter) -
CascadedStyle
Default constructor with no initialization. Don't use this to instantiate the class, as the class is immutable and this will leave it without any properties.
-
-
Method Details
-
createAnonymousStyle
Creates aCascadedStyle
, setting the display property to the value of thedisplay
parameter. -
createLayoutStyle
Creates aCascadedStyle
using the provided property declarations. It is used when a box requires a style that does not correspond to anything in the parsed stylesheets.- Parameters:
declarations
- An array of PropertyDeclaration objects created withcreateLayoutPropertyDeclaration(CSSName, IdentValue)
- See Also:
-
createLayoutStyle
-
createLayoutStyle
public static CascadedStyle createLayoutStyle(CascadedStyle startingPoint, PropertyDeclaration[] decls) Creates aCascadedStyle
using style information fromstartingPoint
and then adding the property declarations fromdecls
.- Parameters:
decls
- An array of PropertyDeclaration objects created withcreateLayoutPropertyDeclaration(CSSName, IdentValue)
- See Also:
-
createLayoutPropertyDeclaration
public static PropertyDeclaration createLayoutPropertyDeclaration(CSSName cssName, IdentValue display) Creates aPropertyDeclaration
suitable for passing tocreateLayoutStyle(List)
orcreateLayoutStyle(CascadedStyle, PropertyDeclaration[])
-
hasProperty
Returns true if property has been defined in this style.- Parameters:
cssName
- The CSS property name, e.g. "font-family".- Returns:
- True if the property is defined in this set.
-
propertyByName
Returns aPropertyDeclaration
by CSS property name, e.g. "font-family". Properties are already cascaded during instantiation, so this will return the actual property (and corresponding value) to use for CSS-based layout and rendering.- Parameters:
cssName
- The CSS property name, e.g. "font-family".- Returns:
- The PropertyDeclaration, if declared in this set, or null if not found.
-
getIdent
Gets the ident attribute of the CascadedStyle object -
getCascadedPropertyDeclarations
Returns anIterator
over the set ofPropertyDeclaration
s already matched in this CascadedStyle. For a given property name, there may be no match, in which case there will be noPropertyDeclaration
for that property name in the Iterator.- Returns:
- Iterator over a set of properly cascaded PropertyDeclarations.
-
countAssigned
public int countAssigned() -
getFingerprint
-