Evaluates calc()
expressions as well as functions like
min()
, clamp()
or cos()
.
To support percentages within calc()
expressions, it must be
subclassed by something that supports a box model implementation, overriding
the percentage(ExtendedCSSPrimitiveValue, short)
method.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ExtendedCSSPrimitiveValue
absoluteValue
(ExtendedCSSPrimitiveValue partialValue) Obtain an absolute (numeric) value, starting from a primitive value.Evaluate the given expression.evaluateFunction
(CSSFunctionValue function) Evaluate the given function.protected float
percentage
(ExtendedCSSPrimitiveValue value, short resultType) Obtain the float value (in the requested absolute unit) corresponding to the given percentage value.
-
Constructor Details
-
Evaluator
public Evaluator()
-
-
Method Details
-
evaluateFunction
Evaluate the given function.This method checks the result unit, assuming that the unit must match that of the returned primitive value (some functions may return values where the units are raised to a power greater than one, or lesser than zero).
- Parameters:
function
- the function to evaluate.- Returns:
- the result of evaluating the function, or the function itself if this class does not know how to evaluate it.
- Throws:
DOMException
- if a problem was found evaluating the function, or the resulting unit is not a valid CSS unit.
-
evaluateExpression
Evaluate the given expression.This method checks the result unit, assuming that the unit must match that of the returned primitive value (some functions may return values where the units are raised to a power greater than one, or lesser than zero).
- Parameters:
calc
- the expression value to evaluate.- Returns:
- the result from evaluating the expression.
- Throws:
DOMException
- if a problem was found evaluating the expression.
-
absoluteValue
Obtain an absolute (numeric) value, starting from a primitive value.If the supplied value is already absolute, or it is not known how to express it in absolute units, return it.
- Parameters:
partialValue
- the value that has to be expressed in absolute units.- Returns:
- the value in absolute units.
-
percentage
Obtain the float value (in the requested absolute unit) corresponding to the given percentage value.- Parameters:
value
- the percentage value.resultType
- the desired absolute result type.- Returns:
- the absolute float value in the requested unit.
- Throws:
DOMException
- if the percentage could not be converted to the requested unit.
-