Class CascadedStyle


  • public class CascadedStyle
    extends java.lang.Object
    Holds a set of PropertyDeclarations 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 Rulesets to Document Elements 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.
    Author:
    Torbjörn Gannholm, Patrick Wright
    • Field Detail

      • emptyCascadedStyle

        public static final CascadedStyle emptyCascadedStyle
        Get an empty singleton, used to negate inheritance of properties
    • Method Detail

      • createAnonymousStyle

        public static CascadedStyle createAnonymousStyle​(IdentValue display)
        Creates a CascadedStyle, setting the display property to to the value of the display parameter.
      • createLayoutStyle

        public static CascadedStyle createLayoutStyle​(java.util.List decls)
      • hasProperty

        public boolean hasProperty​(CSSName cssName)
        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

        public PropertyDeclaration propertyByName​(CSSName cssName)
        Returns a PropertyDeclaration 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

        public IdentValue getIdent​(CSSName cssName)
        Gets the ident attribute of the CascadedStyle object
        Parameters:
        cssName - PARAM
        Returns:
        The ident value
      • getCascadedPropertyDeclarations

        public java.util.Iterator getCascadedPropertyDeclarations()
        Returns an Iterator over the set of PropertyDeclarations already matched in this CascadedStyle. For a given property name, there may be no match, in which case there will be no PropertyDeclaration for that property name in the Iterator.
        Returns:
        Iterator over a set of properly cascaded PropertyDeclarations.
      • countAssigned

        public int countAssigned()
      • getFingerprint

        public java.lang.String getFingerprint()