Package org.htmlunit.css
Class CssPixelValueConverter
- java.lang.Object
-
- org.htmlunit.css.CssPixelValueConverter
-
public final class CssPixelValueConverter extends java.lang.Object
Utilities for css value handling.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CssPixelValueConverter.CssValue
Encapsulates the retrieval of a style attribute, given a DOM element from which to retrieve it.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.Pattern
TO_FLOAT_PATTERN
-
Constructor Summary
Constructors Modifier Constructor Description private
CssPixelValueConverter()
Disallow instantiation of this class.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
pixelString(DomElement element, CssPixelValueConverter.CssValue value)
Returns the specified length CSS attribute value value as a pixel length value.static int
pixelValue(java.lang.String value)
Converts the specified length string value into an integer number of pixels.private static int
pixelValue(DomElement element, java.lang.String styleValue, CssPixelValueConverter.CssValue value, boolean percentMode)
static int
pixelValue(DomElement element, CssPixelValueConverter.CssValue value)
Converts the specified length CSS attribute value into an integer number of pixels.
-
-
-
Method Detail
-
pixelValue
public static int pixelValue(DomElement element, CssPixelValueConverter.CssValue value)
Converts the specified length CSS attribute value into an integer number of pixels. If the specified CSS attribute value is a percentage, this method uses the specified value object to recursively retrieve the base (parent) CSS attribute value.- Parameters:
element
- the element for which the CSS attribute value is to be retrievedvalue
- the CSS attribute value which is to be retrieved- Returns:
- the integer number of pixels corresponding to the specified length CSS attribute value
- See Also:
pixelValue(String)
-
pixelString
public static java.lang.String pixelString(DomElement element, CssPixelValueConverter.CssValue value)
Returns the specified length CSS attribute value value as a pixel length value. If the specified CSS attribute value is a percentage, this method uses the specified value object to recursively retrieve the base (parent) CSS attribute value.- Parameters:
element
- the element for which the CSS attribute value is to be retrievedvalue
- the CSS attribute value which is to be retrieved- Returns:
- the specified length CSS attribute value as a pixel length value
- See Also:
pixelValue(DomElement, CssValue)
-
pixelValue
public static int pixelValue(java.lang.String value)
Converts the specified length string value into an integer number of pixels. This method does NOT handle percentages correctly; usepixelString(DomElement, CssValue)
if you need percentage support).- Parameters:
value
- the length string value to convert to an integer number of pixels- Returns:
- the integer number of pixels corresponding to the specified length string value
- See Also:
- CSS Units,
pixelString(DomElement, CssValue)
-
pixelValue
private static int pixelValue(DomElement element, java.lang.String styleValue, CssPixelValueConverter.CssValue value, boolean percentMode)
-
-