VERSION

Version 0.15

SYNOPSIS

  # ...

DESCRIPTION

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.

METHODS

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.

CSSValue Interface

cssText

Returns a string representation of the attribute. Pass an argument to set it.

cssValueType

Returns \*(C`CSS::DOM::Value::CSS_PRIMITIVE_VALUE\*(C'.

CSSPrimitiveValue Interface

primitiveType

Returns one of the \*(L"\s-1CONSTANTS\s0\*(R" listed below.

getFloatValue

Returns a number if the value is numeric.

The rest have still to be implemented.

Rect Interface

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.

RGBColor Interface

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.

Constructor

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.

type

One of the constants listed below under \*(L"\s-1CONSTANTS\s0\*(R"

value

The data stored inside the value object. The format expected depends on the type. See below.

css

\s-1CSS\s0 code used for serialisation. This will make reading \*(C`cssText\*(C' faster at least until the value is modified.

owner

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.

property

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.

index

The index of this value within a list value (only applies to elements of a list, of course).

format

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:

\s-1CSS_UNKNOWN\s0

A string of \s-1CSS\s0 code.

\s-1CSS_NUMBER\s0, \s-1CSS_PERCENTAGE\s0

A simple scalar containing a number.

Standard Dimensions

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'.

\s-1CSS_DIMENSION\s0

An array ref: \*(C`[$number, $unit_text]\*(C'

\s-1CSS_STRING\s0

A simple scalar containing a string (not a \s-1CSS\s0 string literal; i.e., no quotes or escapes).

\s-1CSS_URI\s0

The \s-1URL\s0 (not a \s-1CSS\s0 literal)

\s-1CSS_IDENT\s0

A string (no escapes)

\s-1CSS_ATTR\s0

A string containing the name of the attribute.

\s-1CSS_COUNTER\s0

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'.

\s-1CSS_RECT\s0

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.

\s-1CSS_RGBCOLOR\s0

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'.

CONSTANTS

The following constants can be imported with \*(C`use CSS::DOM::Value::Primitive ':all'\*(C'. They represent the type of primitive value.

\s-1CSS_UNKNOWN\s0
\s-1CSS_NUMBER\s0
\s-1CSS_PERCENTAGE\s0
\s-1CSS_EMS\s0
\s-1CSS_EXS\s0
\s-1CSS_PX\s0
\s-1CSS_CM\s0
\s-1CSS_MM\s0
\s-1CSS_IN\s0
\s-1CSS_PT\s0
\s-1CSS_PC\s0
\s-1CSS_DEG\s0
\s-1CSS_RAD\s0
\s-1CSS_GRAD\s0
\s-1CSS_MS\s0
\s-1CSS_S\s0
\s-1CSS_HZ\s0
\s-1CSS_KHZ\s0
\s-1CSS_DIMENSION\s0
\s-1CSS_STRING\s0
\s-1CSS_URI\s0
\s-1CSS_IDENT\s0
\s-1CSS_ATTR\s0
\s-1CSS_COUNTER\s0
\s-1CSS_RECT\s0
\s-1CSS_RGBCOLOR\s0

RELATED TO CSS::DOM::Value::Primitive…

\s-1CSS::DOM\s0

CSS::DOM::Value

CSS::DOM::Value::List

CSS::DOM::Style