Class AbstractCssStyleDeclaration

    • Field Detail

      • URL_PATTERN

        private static final java.util.regex.Pattern URL_PATTERN
      • POSITION_PATTERN

        private static final java.util.regex.Pattern POSITION_PATTERN
      • POSITION_PATTERN2

        private static final java.util.regex.Pattern POSITION_PATTERN2
      • POSITION_PATTERN3

        private static final java.util.regex.Pattern POSITION_PATTERN3
    • Constructor Detail

      • AbstractCssStyleDeclaration

        public AbstractCssStyleDeclaration()
    • Method Detail

      • getStylePriority

        public abstract java.lang.String getStylePriority​(java.lang.String name)
        Returns the priority of the named style attribute, or an empty string if it is not found.
        Parameters:
        name - the name of the style attribute whose value is to be retrieved
        Returns:
        the named style attribute value, or an empty string if it is not found
      • getCssText

        public abstract java.lang.String getCssText()
        Returns the actual text of the style.
        Returns:
        the actual text of the style
      • getStyleAttribute

        public abstract java.lang.String getStyleAttribute​(java.lang.String name)
        Get the value for the style attribute.
        Parameters:
        name - the name
        Returns:
        the value
      • getStyleAttribute

        public abstract java.lang.String getStyleAttribute​(StyleAttributes.Definition definition,
                                                           boolean getDefaultValueIfEmpty)
        Get the value for the style attribute. This impl ignores the default getDefaultValueIfEmpty flag, but there is a overload in ComputedCssStyleDeclaration.
        Parameters:
        definition - the definition
        getDefaultValueIfEmpty - whether to get the default value if empty or not
        Returns:
        the value
      • hasFeature

        public abstract boolean hasFeature​(BrowserVersionFeatures property)
        Indicates if the browser this is associated with has the feature.
        Parameters:
        property - the property name
        Returns:
        false if this browser doesn't have this feature
      • getStyleAttribute

        public java.lang.String getStyleAttribute​(StyleAttributes.Definition definition1,
                                                  StyleAttributes.Definition definition2)

        Returns the value of one of the two named style attributes. If both attributes exist, the value of the attribute that was declared last is returned. If only one of the attributes exists, its value is returned. If neither attribute exists, an empty string is returned.

        The second named attribute may be shorthand for a the actual desired property. The following formats are possible:

        1. top right bottom left: All values are explicit.
        2. top right bottom: Left is implicitly the same as right.
        3. top right: Left is implicitly the same as right, bottom is implicitly the same as top.
        4. top: Left, bottom and right are implicitly the same as top.
        Parameters:
        definition1 - the name of the first style attribute
        definition2 - the name of the second style attribute
        Returns:
        the value of one of the two named style attributes
      • setCssText

        public abstract void setCssText​(java.lang.String value)
        Sets the actual text of the style.
        Parameters:
        value - the new text
      • setStyleAttribute

        public abstract void setStyleAttribute​(java.lang.String name,
                                               java.lang.String newValue,
                                               java.lang.String important)
        Sets the specified style attribute.
        Parameters:
        name - the attribute name (camel-cased)
        newValue - the attribute value
        important - important value
      • removeStyleAttribute

        public abstract java.lang.String removeStyleAttribute​(java.lang.String name)
        Removes the specified style attribute, returning the value of the removed attribute.
        Parameters:
        name - the attribute name (delimiter-separated, not camel-cased)
        Returns:
        the removed value
      • getLength

        public abstract int getLength()
        Returns the length property.
        Returns:
        the length property
      • item

        public abstract java.lang.Object item​(int index)
        Returns the item in the given index.
        Parameters:
        index - the index
        Returns:
        the item in the given index
      • getParentRule

        public abstract org.htmlunit.cssparser.dom.AbstractCSSRuleImpl getParentRule()
        Returns the CSSRule that is the parent of this style block or null if this CSSStyleDeclaration is not attached to a CSSRule.
        Returns:
        the CSSRule that is the parent of this style block or null if this CSSStyleDeclaration is not attached to a CSSRule
      • getStyleElement

        public abstract StyleElement getStyleElement​(java.lang.String name)
        Determines the StyleElement for the given name.
        Parameters:
        name - the name of the requested StyleElement
        Returns:
        the StyleElement or null if not found
      • getStyleElementCaseInSensitive

        public abstract StyleElement getStyleElementCaseInSensitive​(java.lang.String name)
        Determines the StyleElement for the given name. This ignores the case of the name.
        Parameters:
        name - the name of the requested StyleElement
        Returns:
        the StyleElement or null if not found
      • getStyleMap

        public abstract java.util.Map<java.lang.String,​StyleElement> getStyleMap()
        Returns a sorted map containing style elements, keyed on style element name. We use a LinkedHashMap map so that results are deterministic and are thus testable.
        Returns:
        a sorted map containing style elements, keyed on style element name
      • isComputed

        public boolean isComputed()
        Returns:
        true if this is a computed style declaration
      • getBackgroundAttachment

        public java.lang.String getBackgroundAttachment()
        Gets the backgroundAttachment style attribute.
        Returns:
        the style attribute
      • getBackgroundColor

        public java.lang.String getBackgroundColor()
        Gets the backgroundColor style attribute.
        Returns:
        the style attribute
      • getBackgroundImage

        public java.lang.String getBackgroundImage()
        Gets the backgroundImage style attribute.
        Returns:
        the style attribute
      • getBackgroundPosition

        public java.lang.String getBackgroundPosition()
        Gets the backgroundPosition style attribute.
        Returns:
        the style attribute
      • getBackgroundRepeat

        public java.lang.String getBackgroundRepeat()
        Gets the backgroundRepeat style attribute.
        Returns:
        the style attribute
      • getBorderBottomColor

        public java.lang.String getBorderBottomColor()
        Gets the borderBottomColor style attribute.
        Returns:
        the style attribute
      • getBorderBottomStyle

        public java.lang.String getBorderBottomStyle()
        Gets the borderBottomStyle style attribute.
        Returns:
        the style attribute
      • getBorderBottomWidth

        public java.lang.String getBorderBottomWidth()
        Gets the borderBottomWidth style attribute.
        Returns:
        the style attribute
      • getBorderLeftColor

        public java.lang.String getBorderLeftColor()
        Gets the borderLeftColor style attribute.
        Returns:
        the style attribute
      • getBorderLeftStyle

        public java.lang.String getBorderLeftStyle()
        Gets the borderLeftStyle style attribute.
        Returns:
        the style attribute
      • getBorderLeftWidth

        public java.lang.String getBorderLeftWidth()
        Gets the borderLeftWidth style attribute.
        Returns:
        the style attribute
      • getBorderWidth

        private java.lang.String getBorderWidth​(StyleAttributes.Definition borderSideWidth,
                                                StyleAttributes.Definition borderSide)
        Gets the border width for the specified side
        Parameters:
        borderSideWidth - the border side width Definition
        borderSide - the border side Definition
        Returns:
        the width, "" if not defined
      • getBorderRightColor

        public java.lang.String getBorderRightColor()
        Gets the borderRightColor style attribute.
        Returns:
        the style attribute
      • getBorderRightStyle

        public java.lang.String getBorderRightStyle()
        Gets the borderRightStyle style attribute.
        Returns:
        the style attribute
      • getBorderRightWidth

        public java.lang.String getBorderRightWidth()
        Gets the borderRightWidth style attribute.
        Returns:
        the style attribute
      • getBorderTop

        public java.lang.String getBorderTop()
        Gets the borderTop style attribute.
        Returns:
        the style attribute
      • getBorderTopColor

        public java.lang.String getBorderTopColor()
        Gets the borderTopColor style attribute.
        Returns:
        the style attribute
      • getBorderTopStyle

        public java.lang.String getBorderTopStyle()
        Gets the borderTopStyle style attribute.
        Returns:
        the style attribute
      • getBorderTopWidth

        public java.lang.String getBorderTopWidth()
        Gets the borderTopWidth style attribute.
        Returns:
        the style attribute
      • getBottom

        public java.lang.String getBottom()
        Gets the bottom style attribute.
        Returns:
        the style attribute
      • getColor

        public java.lang.String getColor()
        Gets the color style attribute.
        Returns:
        the style attribute
      • getCssFloat

        public java.lang.String getCssFloat()
        Gets the cssFloat style attribute.
        Returns:
        the style attribute
      • getDisplay

        public java.lang.String getDisplay()
        Gets the display style attribute.
        Returns:
        the style attribute
      • getFont

        public java.lang.String getFont()
        Gets the font style attribute.
        Returns:
        the style attribute
      • getFontFamily

        public java.lang.String getFontFamily()
        Gets the fontFamily style attribute.
        Returns:
        the style attribute
      • getFontSize

        public java.lang.String getFontSize()
        Gets the fontSize style attribute.
        Returns:
        the style attribute
      • getHeight

        public java.lang.String getHeight()
        Gets the height style attribute.
        Returns:
        the style attribute
      • getLeft

        public java.lang.String getLeft()
        Returns:
        the style attribute left
      • getLetterSpacing

        public java.lang.String getLetterSpacing()
        Returns:
        the style attribute letterSpacing
      • getLineHeight

        public java.lang.String getLineHeight()
        Returns:
        the style attribute lineHeight
      • getMargin

        public java.lang.String getMargin()
        Returns:
        the style attribute margin
      • getMarginBottom

        public java.lang.String getMarginBottom()
        Gets the marginBottom style attribute.
        Returns:
        the style attribute
      • getMarginLeft

        public java.lang.String getMarginLeft()
        Gets the marginLeft style attribute.
        Returns:
        the style attribute
      • getMarginRight

        public java.lang.String getMarginRight()
        Gets the marginRight style attribute.
        Returns:
        the style attribute
      • getMarginTop

        public java.lang.String getMarginTop()
        Gets the marginTop style attribute.
        Returns:
        the style attribute
      • getMaxHeight

        public java.lang.String getMaxHeight()
        Returns:
        the style attribute maxHeight
      • getMaxWidth

        public java.lang.String getMaxWidth()
        Returns:
        the style attribute maxWidth
      • getMinHeight

        public java.lang.String getMinHeight()
        Returns:
        the style attribute minHeight
      • getMinWidth

        public java.lang.String getMinWidth()
        Returns:
        the style attribute minWidth
      • getOpacity

        public java.lang.String getOpacity()
        Gets the opacity style attribute.
        Returns:
        the style attribute
      • getOrphans

        public java.lang.String getOrphans()
        Returns:
        the style attribute orphans
      • getOutline

        public java.lang.String getOutline()
        Returns:
        the style attribute outline
      • getOutlineWidth

        public java.lang.String getOutlineWidth()
        Returns:
        the style attribute outlineWidth
      • getPadding

        public java.lang.String getPadding()
        Returns:
        the style attribute padding
      • getPaddingBottom

        public java.lang.String getPaddingBottom()
        Returns:
        the style attribute paddingBottom
      • getPaddingLeft

        public java.lang.String getPaddingLeft()
        Returns:
        the style attribute paddingLeft
      • getPaddingRight

        public java.lang.String getPaddingRight()
        Returns:
        the style attribute paddingRight
      • getPaddingTop

        public java.lang.String getPaddingTop()
        Returns:
        the style attribute paddingTop
      • getPosition

        public java.lang.String getPosition()
        Returns:
        the style attribute position
      • getRight

        public java.lang.String getRight()
        Returns:
        the style attribute right
      • getRubyAlign

        public java.lang.String getRubyAlign()
        Returns:
        the style attribute rubyAlign
      • getSize

        public java.lang.String getSize()
        Returns:
        the style attribute size
      • getTextIndent

        public java.lang.String getTextIndent()
        Returns:
        the style attribute textIndent
      • getTop

        public java.lang.String getTop()
        Returns:
        the style attribute top
      • getVerticalAlign

        public java.lang.String getVerticalAlign()
        Returns:
        the style attribute verticalAlign
      • getWidows

        public java.lang.String getWidows()
        Returns:
        the style attribute widows
      • getWidth

        public java.lang.String getWidth()
        Returns:
        the style attribute width
      • getWordSpacing

        public java.lang.String getWordSpacing()
        Returns:
        the style attribute wordSpacing
      • getZIndex

        public java.lang.Object getZIndex()
        Gets the zIndex style attribute.
        Returns:
        the style attribute
      • findAttachment

        private static java.lang.String findAttachment​(java.lang.String text)
        Searches for any attachment notation in the specified text.
        Parameters:
        text - the string to search in
        Returns:
        the string of the attachment if found, null otherwise
      • findColor

        private static java.lang.String findColor​(java.lang.String text)
        Searches for any color notation in the specified text.
        Parameters:
        text - the string to search in
        Returns:
        the string of the color if found, null otherwise
      • findImageUrl

        private static java.lang.String findImageUrl​(java.lang.String text)
        Searches for any URL notation in the specified text.
        Parameters:
        text - the string to search in
        Returns:
        the string of the URL if found, null otherwise
      • findPosition

        private static java.lang.String findPosition​(java.lang.String text)
        Searches for any position notation in the specified text.
        Parameters:
        text - the string to search in
        Returns:
        the string of the position if found, null otherwise
      • findRepeat

        private static java.lang.String findRepeat​(java.lang.String text)
        Searches for any repeat notation in the specified text.
        Parameters:
        text - the string to search in
        Returns:
        the string of the repeat if found, null otherwise
      • findBorderStyle

        private static java.lang.String findBorderStyle​(java.lang.String text)
        Searches for a border style in the specified text.
        Parameters:
        text - the string to search in
        Returns:
        the border style if found, null otherwise
      • isBorderStyle

        private static boolean isBorderStyle​(java.lang.String token)
        Returns if the specified token is a border style.
        Parameters:
        token - the token to check
        Returns:
        whether the token is a border style or not
      • findBorderWidth

        private static java.lang.String findBorderWidth​(java.lang.String text)
        Searches for a border width in the specified text.
        Parameters:
        text - the string to search in
        Returns:
        the border width if found, null otherwise
      • isBorderWidth

        private static boolean isBorderWidth​(java.lang.String token)
        Returns if the specified token is a border width.
        Parameters:
        token - the token to check
        Returns:
        whether the token is a border width or not
      • isLength

        static boolean isLength​(java.lang.String token)
        Returns if the specified token is a length.
        Parameters:
        token - the token to check
        Returns:
        whether the token is a length or not