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 String
findAttachment
(String text) Searches for any attachment notation in the specified text.private static String
findBorderStyle
(String text) Searches for a border style in the specified text.private static String
findBorderWidth
(String text) Searches for a border width in the specified text.private static String
Searches for any color notation in the specified text.private static String
findImageUrl
(String text) Searches for any URL notation in the specified text.private static String
findPosition
(String text) Searches for any position notation in the specified text.private static String
findRepeat
(String text) Searches for any repeat notation in the specified text.Gets thebackgroundAttachment
style attribute.Gets thebackgroundColor
style attribute.Gets thebackgroundImage
style attribute.Gets thebackgroundPosition
style attribute.Gets thebackgroundRepeat
style attribute.Gets theborderBottomColor
style attribute.Gets theborderBottomStyle
style attribute.Gets theborderBottomWidth
style attribute.Gets theborderLeftColor
style attribute.Gets theborderLeftStyle
style attribute.Gets theborderLeftWidth
style attribute.Gets theborderRightColor
style attribute.Gets theborderRightStyle
style attribute.Gets theborderRightWidth
style attribute.Gets theborderTop
style attribute.Gets theborderTopColor
style attribute.Gets theborderTopStyle
style attribute.Gets theborderTopWidth
style attribute.private String
getBorderWidth
(StyleAttributes.Definition borderSideWidth, StyleAttributes.Definition borderSide) Gets the border width for the specified sideGets thebottom
style attribute.abstract BrowserVersion
getColor()
Gets thecolor
style attribute.Gets thecssFloat
style attribute.abstract String
Returns the actual text of the style.Gets thedisplay
style attribute.getFont()
Gets thefont
style attribute.Gets thefontFamily
style attribute.Gets thefontSize
style attribute.Gets theheight
style attribute.getLeft()
abstract int
Returns thelength
property.Gets themarginBottom
style attribute.Gets themarginLeft
style attribute.Gets themarginRight
style attribute.Gets themarginTop
style attribute.Gets theopacity
style attribute.abstract org.htmlunit.cssparser.dom.AbstractCSSRuleImpl
Returns the CSSRule that is the parent of this style block ornull
if this CSSStyleDeclaration is not attached to a CSSRule.getRight()
getSize()
abstract String
getStyleAttribute
(String name) Get the value for the style attribute.abstract String
getStyleAttribute
(StyleAttributes.Definition definition, boolean getDefaultValueIfEmpty) Get the value for the style attribute.protected String
getStyleAttribute
(StyleAttributes.Definition name, String value) getStyleAttribute
(StyleAttributes.Definition definition1, StyleAttributes.Definition definition2) Returns the value of one of the two named style attributes.abstract StyleElement
getStyleElement
(String name) Determines the StyleElement for the given name.abstract StyleElement
Determines the StyleElement for the given name.abstract Map
<String, StyleElement> Returns a sorted map containing style elements, keyed on style element name.abstract String
getStylePriority
(String name) Returns the priority of the named style attribute, or an empty string if it is not found.getTop()
getWidth()
Gets thezIndex
style attribute.abstract boolean
hasFeature
(BrowserVersionFeatures property) Indicates if the browser this is associated with has the feature.private static boolean
isBorderStyle
(String token) Returns if the specified token is a border style.private static boolean
isBorderWidth
(String token) Returns if the specified token is a border width.boolean
(package private) static boolean
Returns if the specified token is a length.abstract Object
item
(int index) Returns the item in the given index.abstract String
removeStyleAttribute
(String name) Removes the specified style attribute, returning the value of the removed attribute.abstract void
setCssText
(String value) Sets the actual text of the style.abstract void
setStyleAttribute
(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:
false
if 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 thelength
property.- Returns:
- the
length
property
-
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 ornull
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
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 aLinkedHashMap
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
-
getStyleAttribute
-
getBackgroundAttachment
Gets thebackgroundAttachment
style attribute.- Returns:
- the style attribute
-
getBackgroundColor
Gets thebackgroundColor
style attribute.- Returns:
- the style attribute
-
getBackgroundImage
Gets thebackgroundImage
style attribute.- Returns:
- the style attribute
-
getBackgroundPosition
Gets thebackgroundPosition
style attribute.- Returns:
- the style attribute
-
getBackgroundRepeat
Gets thebackgroundRepeat
style attribute.- Returns:
- the style attribute
-
getBorderBottomColor
Gets theborderBottomColor
style attribute.- Returns:
- the style attribute
-
getBorderBottomStyle
Gets theborderBottomStyle
style attribute.- Returns:
- the style attribute
-
getBorderBottomWidth
Gets theborderBottomWidth
style attribute.- Returns:
- the style attribute
-
getBorderLeftColor
Gets theborderLeftColor
style attribute.- Returns:
- the style attribute
-
getBorderLeftStyle
Gets theborderLeftStyle
style attribute.- Returns:
- the style attribute
-
getBorderLeftWidth
Gets theborderLeftWidth
style 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 theborderRightColor
style attribute.- Returns:
- the style attribute
-
getBorderRightStyle
Gets theborderRightStyle
style attribute.- Returns:
- the style attribute
-
getBorderRightWidth
Gets theborderRightWidth
style attribute.- Returns:
- the style attribute
-
getBorderTop
Gets theborderTop
style attribute.- Returns:
- the style attribute
-
getBorderTopColor
Gets theborderTopColor
style attribute.- Returns:
- the style attribute
-
getBorderTopStyle
Gets theborderTopStyle
style attribute.- Returns:
- the style attribute
-
getBorderTopWidth
Gets theborderTopWidth
style attribute.- Returns:
- the style attribute
-
getBottom
Gets thebottom
style attribute.- Returns:
- the style attribute
-
getColor
Gets thecolor
style attribute.- Returns:
- the style attribute
-
getCssFloat
Gets thecssFloat
style attribute.- Returns:
- the style attribute
-
getDisplay
Gets thedisplay
style attribute.- Returns:
- the style attribute
-
getFont
Gets thefont
style attribute.- Returns:
- the style attribute
-
getFontFamily
Gets thefontFamily
style attribute.- Returns:
- the style attribute
-
getFontSize
Gets thefontSize
style attribute.- Returns:
- the style attribute
-
getHeight
Gets theheight
style 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 themarginBottom
style attribute.- Returns:
- the style attribute
-
getMarginLeft
Gets themarginLeft
style attribute.- Returns:
- the style attribute
-
getMarginRight
Gets themarginRight
style attribute.- Returns:
- the style attribute
-
getMarginTop
Gets themarginTop
style 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 theopacity
style 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 thezIndex
style 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
-