Interface CSSPrimitiveValue

All Superinterfaces:
Cloneable, CSSValue
All Known Subinterfaces:
CSSAttrValue, CSSColorMixFunction, CSSColorValue, CSSCountersValue, CSSCounterValue, CSSEnvVariableValue, CSSExpressionValue, CSSFunctionValue, CSSGradientValue, CSSLexicalValue, CSSMathFunctionValue, CSSRatioValue, CSSTypedValue, CSSUnicodeRangeValue, CSSUnicodeRangeValue.CSSUnicodeValue, CSSVarValue, HSLColorValue, HWBColorValue, LABColorValue, LCHColorValue
All Known Implementing Classes:
AttrValue, CalcValue, ColorValue, EnvVariableValue, ExpressionValue, FunctionValue, GradientValue, HSLColorValue, HWBColorValue, IdentifierValue, LABColorValue, LCHColorValue, LexicalValue, NumberValue, PercentageValue, PrimitiveValue, ProxyValue, RatioValue, RectValue, RGBColorValue, StringValue, SystemDefaultValue, TypedValue, UnicodeRangeValue, UnicodeValue, UnicodeWildcardValue, UnknownValue, URIValue, URIValueWrapper, VarValue

public interface CSSPrimitiveValue extends CSSValue
A CSS primitive value.

Primitive values include two categories: TYPED and PROXY values.

  • Method Details

    • setExpectInteger

      void setExpectInteger() throws DOMException
      This value is expected to contain an integer.

      If this value is a non-integer number, an exception will be thrown immediately.

      If this value is a calc() that ever produces a non-integer number, the value shall be rounded to the nearest integer.

      If the value is a proxy that ever produces other than an integer number (without calc() involvement), an exception should be thrown later.

      Throws:
      DOMException - TYPE_MISMATCH_ERR if the value is a constant number and not an integer.
    • isNegativeNumber

      default boolean isNegativeNumber()
      Test whether this is a numeric value that is less than zero.
      Returns:
      true if this is a numeric value and its value is negative.
    • getUnitType

      default short getUnitType()
      If this is a NUMERIC value, get its unit type.

      You can also find the unit types of mathematical functions and calc() expressions, although this may be computationally expensive:

      Returns:
      the unit type as in CSSUnit, or CSS_INVALID if the type is not numeric or the unit is not valid.