java.lang.Object
org.htmlunit.css.CssPixelValueConverter
Utilities for css value handling.
- Author:
- Ronald Brill
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringpixelString(DomElement element, Function<ComputedCssStyleDeclaration, String> styleGetter, IntSupplier defaultValue, IntSupplier windowDefaultValue) Returns the specified length CSS attribute value as a pixel length value.static intpixelValue(String value) Converts the specified length string value into an integer number of pixels.static intpixelValue(DomElement element, Function<ComputedCssStyleDeclaration, String> styleGetter, IntSupplier defaultValue, IntSupplier windowDefaultValue) Converts the specified length CSS attribute value into an integer number of pixels.
-
Method Details
-
pixelValue
public static int pixelValue(DomElement element, Function<ComputedCssStyleDeclaration, String> styleGetter, IntSupplier defaultValue, IntSupplier windowDefaultValue) 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 getters to recursively retrieve the base (parent) CSS attribute value.- Parameters:
element- the element for which the CSS attribute value is to be retrievedstyleGetter- getter function to retrieve the CSS attribute value from ComputedCssStyleDeclarationdefaultValue- supplier for the default valuewindowDefaultValue- supplier for the default value for the window- Returns:
- the integer number of pixels corresponding to the specified length CSS attribute value
- See Also:
-
pixelString
public static String pixelString(DomElement element, Function<ComputedCssStyleDeclaration, String> styleGetter, IntSupplier defaultValue, IntSupplier windowDefaultValue) Returns the specified length CSS attribute value as a pixel length value. If the specified CSS attribute value is a percentage, this method uses the specified value getters to recursively retrieve the base (parent) CSS attribute value.- Parameters:
element- the element for which the CSS attribute value is to be retrievedstyleGetter- getter function to retrieve the CSS attribute value from ComputedCssStyleDeclarationdefaultValue- supplier for the default valuewindowDefaultValue- supplier for the default value for the window- Returns:
- the specified length CSS attribute value as a pixel length value
- See Also:
-
pixelValue
Converts the specified length string value into an integer number of pixels. This method does NOT handle percentages correctly; usepixelString(DomElement, Function, IntSupplier, IntSupplier)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:
-