Package org.htmlunit.css
Class AbstractCssStyleDeclaration
java.lang.Object
org.htmlunit.css.AbstractCssStyleDeclaration
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ComputedCssStyleDeclaration,ElementCssStyleDeclaration,WrappedCssStyleDeclaration
A css StyleDeclaration.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringfindAttachment(String text) Searches for any attachment notation in the specified text.private static StringfindBorderStyle(String text) Searches for a border style in the specified text.private static StringfindBorderWidth(String text) Searches for a border width in the specified text.private static StringSearches for any color notation in the specified text.private static StringfindImageUrl(String text) Searches for any URL notation in the specified text.private static StringfindPosition(String text) Searches for any position notation in the specified text.private static StringfindRepeat(String text) Searches for any repeat notation in the specified text.Gets thebackgroundAttachmentstyle attribute.Gets thebackgroundColorstyle attribute.Gets thebackgroundImagestyle attribute.Gets thebackgroundPositionstyle attribute.Gets thebackgroundRepeatstyle attribute.Gets theborderBottomColorstyle attribute.Gets theborderBottomStylestyle attribute.Gets theborderBottomWidthstyle attribute.Gets theborderLeftColorstyle attribute.Gets theborderLeftStylestyle attribute.Gets theborderLeftWidthstyle attribute.Gets theborderRightColorstyle attribute.Gets theborderRightStylestyle attribute.Gets theborderRightWidthstyle attribute.Gets theborderTopstyle attribute.Gets theborderTopColorstyle attribute.Gets theborderTopStylestyle attribute.Gets theborderTopWidthstyle attribute.private StringgetBorderWidth(StyleAttributes.Definition borderSideWidth, StyleAttributes.Definition borderSide) Gets the border width for the specified sideGets thebottomstyle attribute.abstract BrowserVersiongetColor()Gets thecolorstyle attribute.Gets thecssFloatstyle attribute.abstract StringReturns the actual text of the style.Gets thedisplaystyle attribute.getFont()Gets thefontstyle attribute.Gets thefontFamilystyle attribute.Gets thefontSizestyle attribute.Gets theheightstyle attribute.getLeft()abstract intReturns thelengthproperty.Gets themarginBottomstyle attribute.Gets themarginLeftstyle attribute.Gets themarginRightstyle attribute.Gets themarginTopstyle attribute.Gets theopacitystyle attribute.abstract org.htmlunit.cssparser.dom.AbstractCSSRuleImplReturns the CSSRule that is the parent of this style block ornullif this CSSStyleDeclaration is not attached to a CSSRule.getRight()getSize()abstract StringgetStyleAttribute(String name) Get the value for the style attribute.abstract StringgetStyleAttribute(StyleAttributes.Definition definition, boolean getDefaultValueIfEmpty) Get the value for the style attribute.protected StringgetStyleAttribute(StyleAttributes.Definition name, String value) getStyleAttribute(StyleAttributes.Definition definition1, StyleAttributes.Definition definition2) Returns the value of one of the two named style attributes.abstract StyleElementgetStyleElement(String name) Determines the StyleElement for the given name.abstract StyleElementDetermines the StyleElement for the given name.abstract Map<String, StyleElement> Returns a sorted map containing style elements, keyed on style element name.abstract StringgetStylePriority(String name) Returns the priority of the named style attribute, or an empty string if it is not found.getTop()getWidth()Gets thezIndexstyle attribute.abstract booleanhasFeature(BrowserVersionFeatures property) Indicates if the browser this is associated with has the feature.private static booleanisBorderStyle(String token) Returns if the specified token is a border style.private static booleanisBorderWidth(String token) Returns if the specified token is a border width.boolean(package private) static booleanReturns if the specified token is a length.abstract Objectitem(int index) Returns the item in the given index.abstract StringremoveStyleAttribute(String name) Removes the specified style attribute, returning the value of the removed attribute.abstract voidsetCssText(String value) Sets the actual text of the style.abstract voidsetStyleAttribute(String name, String newValue, String important) Sets the specified style attribute.
-
Field Details
-
URL_PATTERN
-
POSITION_PATTERN
-
POSITION_PATTERN2
-
POSITION_PATTERN3
-
-
Constructor Details
-
AbstractCssStyleDeclaration
public AbstractCssStyleDeclaration()
-
-
Method Details
-
getStylePriority
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
Returns the actual text of the style.- Returns:
- the actual text of the style
-
getStyleAttribute
Get the value for the style attribute.- Parameters:
name- the name- Returns:
- the value
-
getStyleAttribute
public abstract 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.- Parameters:
definition- the definitiongetDefaultValueIfEmpty- whether to get the default value if empty or not- Returns:
- the value
-
hasFeature
Indicates if the browser this is associated with has the feature.- Parameters:
property- the property name- Returns:
falseif this browser doesn't have this feature
-
getBrowserVersion
- Returns:
- the
BrowserVersion
-
getStyleAttribute
public 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:
top right bottom left: All values are explicit.top right bottom: Left is implicitly the same as right.top right: Left is implicitly the same as right, bottom is implicitly the same as top.top: Left, bottom and right are implicitly the same as top.
- Parameters:
definition1- the name of the first style attributedefinition2- the name of the second style attribute- Returns:
- the value of one of the two named style attributes
-
setCssText
Sets the actual text of the style.- Parameters:
value- the new text
-
setStyleAttribute
Sets the specified style attribute.- Parameters:
name- the attribute name (camel-cased)newValue- the attribute valueimportant- important value
-
removeStyleAttribute
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 thelengthproperty.- Returns:
- the
lengthproperty
-
item
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 ornullif this CSSStyleDeclaration is not attached to a CSSRule.- Returns:
- the CSSRule that is the parent of this style block or
nullif this CSSStyleDeclaration is not attached to a CSSRule
-
getStyleElement
Determines the StyleElement for the given name.- Parameters:
name- the name of the requested StyleElement- Returns:
- the StyleElement or null if not found
-
getStyleElementCaseInSensitive
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
Returns a sorted map containing style elements, keyed on style element name. We use aLinkedHashMapmap 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
-
getStyleAttribute
-
getBackgroundAttachment
Gets thebackgroundAttachmentstyle attribute.- Returns:
- the style attribute
-
getBackgroundColor
Gets thebackgroundColorstyle attribute.- Returns:
- the style attribute
-
getBackgroundImage
Gets thebackgroundImagestyle attribute.- Returns:
- the style attribute
-
getBackgroundPosition
Gets thebackgroundPositionstyle attribute.- Returns:
- the style attribute
-
getBackgroundRepeat
Gets thebackgroundRepeatstyle attribute.- Returns:
- the style attribute
-
getBorderBottomColor
Gets theborderBottomColorstyle attribute.- Returns:
- the style attribute
-
getBorderBottomStyle
Gets theborderBottomStylestyle attribute.- Returns:
- the style attribute
-
getBorderBottomWidth
Gets theborderBottomWidthstyle attribute.- Returns:
- the style attribute
-
getBorderLeftColor
Gets theborderLeftColorstyle attribute.- Returns:
- the style attribute
-
getBorderLeftStyle
Gets theborderLeftStylestyle attribute.- Returns:
- the style attribute
-
getBorderLeftWidth
Gets theborderLeftWidthstyle attribute.- Returns:
- the style attribute
-
getBorderWidth
private String getBorderWidth(StyleAttributes.Definition borderSideWidth, StyleAttributes.Definition borderSide) Gets the border width for the specified side- Parameters:
borderSideWidth- the border side width DefinitionborderSide- the border side Definition- Returns:
- the width, "" if not defined
-
getBorderRightColor
Gets theborderRightColorstyle attribute.- Returns:
- the style attribute
-
getBorderRightStyle
Gets theborderRightStylestyle attribute.- Returns:
- the style attribute
-
getBorderRightWidth
Gets theborderRightWidthstyle attribute.- Returns:
- the style attribute
-
getBorderTop
Gets theborderTopstyle attribute.- Returns:
- the style attribute
-
getBorderTopColor
Gets theborderTopColorstyle attribute.- Returns:
- the style attribute
-
getBorderTopStyle
Gets theborderTopStylestyle attribute.- Returns:
- the style attribute
-
getBorderTopWidth
Gets theborderTopWidthstyle attribute.- Returns:
- the style attribute
-
getBottom
Gets thebottomstyle attribute.- Returns:
- the style attribute
-
getColor
Gets thecolorstyle attribute.- Returns:
- the style attribute
-
getCssFloat
Gets thecssFloatstyle attribute.- Returns:
- the style attribute
-
getDisplay
Gets thedisplaystyle attribute.- Returns:
- the style attribute
-
getFont
Gets thefontstyle attribute.- Returns:
- the style attribute
-
getFontFamily
Gets thefontFamilystyle attribute.- Returns:
- the style attribute
-
getFontSize
Gets thefontSizestyle attribute.- Returns:
- the style attribute
-
getHeight
Gets theheightstyle attribute.- Returns:
- the style attribute
-
getLeft
- Returns:
- the style attribute
left
-
getLetterSpacing
- Returns:
- the style attribute
letterSpacing
-
getLineHeight
- Returns:
- the style attribute
lineHeight
-
getMargin
- Returns:
- the style attribute
margin
-
getMarginBottom
Gets themarginBottomstyle attribute.- Returns:
- the style attribute
-
getMarginLeft
Gets themarginLeftstyle attribute.- Returns:
- the style attribute
-
getMarginRight
Gets themarginRightstyle attribute.- Returns:
- the style attribute
-
getMarginTop
Gets themarginTopstyle attribute.- Returns:
- the style attribute
-
getMaxHeight
- Returns:
- the style attribute
maxHeight
-
getMaxWidth
- Returns:
- the style attribute
maxWidth
-
getMinHeight
- Returns:
- the style attribute
minHeight
-
getMinWidth
- Returns:
- the style attribute
minWidth
-
getOpacity
Gets theopacitystyle attribute.- Returns:
- the style attribute
-
getOrphans
- Returns:
- the style attribute
orphans
-
getOutline
- Returns:
- the style attribute
outline
-
getOutlineWidth
- Returns:
- the style attribute
outlineWidth
-
getPadding
- Returns:
- the style attribute
padding
-
getPaddingBottom
- Returns:
- the style attribute
paddingBottom
-
getPaddingLeft
- Returns:
- the style attribute
paddingLeft
-
getPaddingRight
- Returns:
- the style attribute
paddingRight
-
getPaddingTop
- Returns:
- the style attribute
paddingTop
-
getPosition
- Returns:
- the style attribute
position
-
getRight
- Returns:
- the style attribute
right
-
getRubyAlign
- Returns:
- the style attribute
rubyAlign
-
getSize
- Returns:
- the style attribute
size
-
getTextIndent
- Returns:
- the style attribute
textIndent
-
getTop
- Returns:
- the style attribute
top
-
getVerticalAlign
- Returns:
- the style attribute
verticalAlign
-
getWidows
- Returns:
- the style attribute
widows
-
getWidth
- Returns:
- the style attribute
width
-
getWordSpacing
- Returns:
- the style attribute
wordSpacing
-
getZIndex
Gets thezIndexstyle attribute.- Returns:
- the style attribute
-
findAttachment
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
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
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
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
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
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
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
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
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
Returns if the specified token is a length.- Parameters:
token- the token to check- Returns:
- whether the token is a length or not
-