Cssprimitivevalue class for css::dom
Version 0.15
# ...
This module implements objects that represent \s-1CSS\s0 primitive property values (as opposed to lists). It implements the \s-1DOM\s0 CSSPrimitiveValue, Rect, and RGBColor interfaces.
If you need the constructor, it's below the object methods. Normally you would get an object via CSS::DOM::Style's \*(C`getPropertyCSSValue\*(C' method.
Returns a string representation of the attribute. Pass an argument to set it.
Returns \*(C`CSS::DOM::Value::CSS_PRIMITIVE_VALUE\*(C'.
Returns one of the \*(L"\s-1CONSTANTS\s0\*(R" listed below.
Returns a number if the value is numeric.
The rest have still to be implemented.
The four methods \*(C`top\*(C', \*(C`right\*(C', \*(C`bottom\*(C' and \*(C`left\*(C' each return another value object representing the individual value.
The four methods \*(C`red\*(C', \*(C`green\*(C', \*(C`blue\*(C' and \*(C`alpha\*(C' each return another value object representing the individual value.
You probably don't need to call this, but here it is anyway:
$val = new CSS::DOM::Value::Primitive:: %args;
The hash-style arguments are as follows. Only \*(C`type\*(C' and \*(C`value\*(C' are required.
One of the constants listed below under \*(L"\s-1CONSTANTS\s0\*(R"
The data stored inside the value object. The format expected depends on the type. See below.
\s-1CSS\s0 code used for serialisation. This will make reading \*(C`cssText\*(C' faster at least until the value is modified.
The style object that owns this value; if this is omitted, then the value is read-only. The value object holds a weak reference to the owner.
The name of the \s-1CSS\s0 property to which this value belongs. \*(C`cssText\*(C' uses this to determine how to parse text passed to it. This does not apply to the sub-values of colours, counters and rects, but it does apply to individual elements of a list value.
The index of this value within a list value (only applies to elements of a list, of course).
This is used by sub-values of colours and rects. It determines how assignment to \*(C`cssText\*(C' is handled. This uses the same syntax as the formats in CSS::DOM::PropertyParser.
Here are the formats for the \*(C`value\*(C' argument, which depend on the type:
A string of \s-1CSS\s0 code.
A simple scalar containing a number.
Also a simple scalar containing a number. This applies to \*(C`CSS_EMS\*(C', \*(C`CSS_EXS\*(C', \*(C`CSS_PX\*(C', \*(C`CSS_CM\*(C', \*(C`CSS_MM\*(C', \*(C`CSS_IN\*(C', \*(C`CSS_PT\*(C', \*(C`CSS_PC\*(C', \*(C`CSS_DEG\*(C', \*(C`CSS_RAD\*(C', \*(C`CSS_GRAD\*(C', \*(C`CSS_MS\*(C', \*(C`CSS_S\*(C', \*(C`CSS_HZ\*(C' and \*(C`CSS_KHZ\*(C'.
An array ref: \*(C`[$number, $unit_text]\*(C'
A simple scalar containing a string (not a \s-1CSS\s0 string literal; i.e., no quotes or escapes).
The \s-1URL\s0 (not a \s-1CSS\s0 literal)
A string (no escapes)
A string containing the name of the attribute.
An array ref: \*(C`[$name, $separator, $style]\*(C' $separator and $style may each be \*(C`undef\*(C'. If $separator is \*(C`undef\*(C', the object represents a \*(C`counter(...)\*(C'. Otherwise it represents \*(C`counters(...)\*(C'.
An array ref: \*(C`[$top, $right, $bottom, $left]\*(C' The four elements are either CSSValue objects or array refs of arguments to be passed to the constructor. E.g.: [ [type => CSS_PX, value => 20], [type => CSS_PERCENTAGE, value => 50], [type => CSS_PERCENTAGE, value => 50], [type => CSS_PX, value => 50], ] When these array refs are converted to objects, the \*(C`format\*(C' argument is supplied automatically, so you do not need to include it here.
A string beginning with '#', with no escapes (such as '#fff' or '#c0ffee'), a colour name (like red) or an array ref with three to four elements: [$r, $g, $b] [$r, $g, $b, $alpha] The elements are either CSSValue objects or array refs of argument lists, as with \*(C`CSS_RECT\*(C'.
The following constants can be imported with \*(C`use CSS::DOM::Value::Primitive ':all'\*(C'. They represent the type of primitive value.
\s-1CSS::DOM\s0
CSS::DOM::Value
CSS::DOM::Value::List
CSS::DOM::Style