Package org.htmlunit.css
Class ElementCssStyleDeclaration
- java.lang.Object
-
- org.htmlunit.css.AbstractCssStyleDeclaration
-
- org.htmlunit.css.ElementCssStyleDeclaration
-
- All Implemented Interfaces:
java.io.Serializable
public class ElementCssStyleDeclaration extends AbstractCssStyleDeclaration
A css StyleDeclaration backed by aDomElement.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private DomElementdomElement_The DomElement.
-
Constructor Summary
Constructors Constructor Description ElementCssStyleDeclaration(DomElement domElement)Creates an instance which backed by the given dom element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BrowserVersiongetBrowserVersion()java.lang.StringgetCssText()Returns the actual text of the style.DomElementgetDomElement()intgetLength()Returns thelengthproperty.org.htmlunit.cssparser.dom.AbstractCSSRuleImplgetParentRule()Returns the CSSRule that is the parent of this style block ornullif this CSSStyleDeclaration is not attached to a CSSRule.java.lang.StringgetStyleAttribute(java.lang.String name)Get the value for the style attribute.java.lang.StringgetStyleAttribute(StyleAttributes.Definition definition, boolean getDefaultValueIfEmpty)Get the value for the style attribute.StyleElementgetStyleElement(java.lang.String name)Determines the StyleElement for the given name.StyleElementgetStyleElementCaseInSensitive(java.lang.String name)Determines the StyleElement for the given name.java.util.Map<java.lang.String,StyleElement>getStyleMap()Returns a sorted map containing style elements, keyed on style element name.java.lang.StringgetStylePriority(java.lang.String name)Returns the priority of the named style attribute, or an empty string if it is not found.booleanhasFeature(BrowserVersionFeatures property)Indicates if the browser this is associated with has the feature.java.lang.Stringitem(int index)Returns the item in the given index.java.lang.StringremoveStyleAttribute(java.lang.String name)Removes the specified style attribute, returning the value of the removed attribute.voidsetCssText(java.lang.String value)Sets the actual text of the style.voidsetStyleAttribute(java.lang.String name, java.lang.String newValue, java.lang.String important)Sets the specified style attribute.java.lang.StringtoString()-
Methods inherited from class org.htmlunit.css.AbstractCssStyleDeclaration
getBackgroundAttachment, getBackgroundColor, getBackgroundImage, getBackgroundPosition, getBackgroundRepeat, getBorderBottomColor, getBorderBottomStyle, getBorderBottomWidth, getBorderLeftColor, getBorderLeftStyle, getBorderLeftWidth, getBorderRightColor, getBorderRightStyle, getBorderRightWidth, getBorderTop, getBorderTopColor, getBorderTopStyle, getBorderTopWidth, getBottom, getColor, getCssFloat, getDisplay, getFont, getFontFamily, getFontSize, getHeight, getLeft, getLetterSpacing, getLineHeight, getMargin, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpacity, getOrphans, getOutline, getOutlineWidth, getPadding, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getPosition, getRight, getRubyAlign, getSize, getStyleAttribute, getStyleAttribute, getTextIndent, getTop, getVerticalAlign, getWidows, getWidth, getWordSpacing, getZIndex, isComputed, isLength
-
-
-
-
Field Detail
-
domElement_
private final DomElement domElement_
The DomElement.
-
-
Constructor Detail
-
ElementCssStyleDeclaration
public ElementCssStyleDeclaration(DomElement domElement)
Creates an instance which backed by the given dom element.- Parameters:
domElement- the dom element this is based on
-
-
Method Detail
-
getStylePriority
public 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.- Specified by:
getStylePriorityin classAbstractCssStyleDeclaration- 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 java.lang.String getCssText()
Returns the actual text of the style.- Specified by:
getCssTextin classAbstractCssStyleDeclaration- Returns:
- the actual text of the style
-
getStyleAttribute
public java.lang.String getStyleAttribute(java.lang.String name)
Get the value for the style attribute.- Specified by:
getStyleAttributein classAbstractCssStyleDeclaration- Parameters:
name- the name- Returns:
- the value
-
getStyleAttribute
public 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 inComputedCssStyleDeclaration.- Specified by:
getStyleAttributein classAbstractCssStyleDeclaration- Parameters:
definition- the definitiongetDefaultValueIfEmpty- whether to get the default value if empty or not- Returns:
- the value
-
setCssText
public void setCssText(java.lang.String value)
Sets the actual text of the style.- Specified by:
setCssTextin classAbstractCssStyleDeclaration- Parameters:
value- the new text
-
setStyleAttribute
public void setStyleAttribute(java.lang.String name, java.lang.String newValue, java.lang.String important)Sets the specified style attribute.- Specified by:
setStyleAttributein classAbstractCssStyleDeclaration- Parameters:
name- the attribute name (camel-cased)newValue- the attribute valueimportant- important value
-
removeStyleAttribute
public java.lang.String removeStyleAttribute(java.lang.String name)
Removes the specified style attribute, returning the value of the removed attribute.- Specified by:
removeStyleAttributein classAbstractCssStyleDeclaration- Parameters:
name- the attribute name (delimiter-separated, not camel-cased)- Returns:
- the removed value
-
getLength
public int getLength()
Returns thelengthproperty.- Specified by:
getLengthin classAbstractCssStyleDeclaration- Returns:
- the
lengthproperty
-
item
public java.lang.String item(int index)
Returns the item in the given index.- Specified by:
itemin classAbstractCssStyleDeclaration- Parameters:
index- the index- Returns:
- the item in the given index
-
getParentRule
public org.htmlunit.cssparser.dom.AbstractCSSRuleImpl getParentRule()
Returns the CSSRule that is the parent of this style block ornullif this CSSStyleDeclaration is not attached to a CSSRule.- Specified by:
getParentRulein classAbstractCssStyleDeclaration- Returns:
- the CSSRule that is the parent of this style block or
nullif this CSSStyleDeclaration is not attached to a CSSRule
-
getStyleElement
public StyleElement getStyleElement(java.lang.String name)
Determines the StyleElement for the given name.- Specified by:
getStyleElementin classAbstractCssStyleDeclaration- Parameters:
name- the name of the requested StyleElement- Returns:
- the StyleElement or null if not found
-
getStyleElementCaseInSensitive
public StyleElement getStyleElementCaseInSensitive(java.lang.String name)
Determines the StyleElement for the given name. This ignores the case of the name.- Specified by:
getStyleElementCaseInSensitivein classAbstractCssStyleDeclaration- Parameters:
name- the name of the requested StyleElement- Returns:
- the StyleElement or null if not found
-
getStyleMap
public java.util.Map<java.lang.String,StyleElement> getStyleMap()
Returns a sorted map containing style elements, keyed on style element name. We use aLinkedHashMapmap so that results are deterministic and are thus testable.- Specified by:
getStyleMapin classAbstractCssStyleDeclaration- Returns:
- a sorted map containing style elements, keyed on style element name
-
getDomElement
public DomElement getDomElement()
-
hasFeature
public boolean hasFeature(BrowserVersionFeatures property)
Indicates if the browser this is associated with has the feature.- Specified by:
hasFeaturein classAbstractCssStyleDeclaration- Parameters:
property- the property name- Returns:
falseif this browser doesn't have this feature
-
getBrowserVersion
public BrowserVersion getBrowserVersion()
- Specified by:
getBrowserVersionin classAbstractCssStyleDeclaration- Returns:
- the
BrowserVersion
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-