1CSS::DOM::Value::PrimitUisveer(3C)ontributed Perl DocumeCnStSa:t:iDoOnM::Value::Primitive(3)
2
3
4
6 CSS::DOM::Value::Primitive - CSSPrimitiveValue class for CSS::DOM
7
9 Version 0.17
10
12 # ...
13
15 This module implements objects that represent CSS primitive property
16 values (as opposed to lists). It implements the DOM CSSPrimitiveValue,
17 Rect, and RGBColor interfaces.
18
20 If you need the constructor, it's below the object methods. Normally
21 you would get an object via CSS::DOM::Style's "getPropertyCSSValue"
22 method.
23
24 CSSValue Interface
25 cssText
26 Returns a string representation of the attribute. Pass an argument
27 to set it.
28
29 cssValueType
30 Returns "CSS::DOM::Value::CSS_PRIMITIVE_VALUE".
31
32 CSSPrimitiveValue Interface
33 primitiveType
34 Returns one of the "CONSTANTS" listed below.
35
36 getFloatValue
37 Returns a number if the value is numeric.
38
39 The rest have still to be implemented.
40
41 Rect Interface
42 The four methods "top", "right", "bottom" and "left" each return
43 another value object representing the individual value.
44
45 RGBColor Interface
46 The four methods "red", "green", "blue" and "alpha" each return another
47 value object representing the individual value.
48
49 Constructor
50 You probably don't need to call this, but here it is anyway:
51
52 $val = new CSS::DOM::Value::Primitive:: %args;
53
54 The hash-style arguments are as follows. Only "type" and "value" are
55 required.
56
57 type
58 One of the constants listed below under "CONSTANTS"
59
60 value
61 The data stored inside the value object. The format expected
62 depends on the type. See below.
63
64 css CSS code used for serialisation. This will make reading "cssText"
65 faster at least until the value is modified.
66
67 owner
68 The style object that owns this value; if this is omitted, then the
69 value is read-only. The value object holds a weak reference to the
70 owner.
71
72 property
73 The name of the CSS property to which this value belongs. "cssText"
74 uses this to determine how to parse text passed to it. This does
75 not apply to the sub-values of colours, counters and rects, but it
76 does apply to individual elements of a list value.
77
78 index
79 The index of this value within a list value (only applies to
80 elements of a list, of course).
81
82 format
83 This is used by sub-values of colours and rects. It determines how
84 assignment to "cssText" is handled. This uses the same syntax as
85 the formats in CSS::DOM::PropertyParser.
86
87 Here are the formats for the "value" argument, which depend on the
88 type:
89
90 CSS_UNKNOWN
91 A string of CSS code.
92
93 CSS_NUMBER, CSS_PERCENTAGE
94 A simple scalar containing a number.
95
96 Standard Dimensions
97 Also a simple scalar containing a number.
98
99 This applies to "CSS_EMS", "CSS_EXS", "CSS_PX", "CSS_CM", "CSS_MM",
100 "CSS_IN", "CSS_PT", "CSS_PC", "CSS_DEG", "CSS_RAD", "CSS_GRAD",
101 "CSS_MS", "CSS_S", "CSS_HZ" and "CSS_KHZ".
102
103 CSS_DIMENSION
104 An array ref: "[$number, $unit_text]"
105
106 CSS_STRING
107 A simple scalar containing a string (not a CSS string literal;
108 i.e., no quotes or escapes).
109
110 CSS_URI
111 The URL (not a CSS literal)
112
113 CSS_IDENT
114 A string (no escapes)
115
116 CSS_ATTR
117 A string containing the name of the attribute.
118
119 CSS_COUNTER
120 An array ref: "[$name, $separator, $style]"
121
122 $separator and $style may each be "undef". If $separator is
123 "undef", the object represents a "counter(...)". Otherwise it
124 represents "counters(...)".
125
126 CSS_RECT
127 An array ref: "[$top, $right, $bottom, $left]"
128
129 The four elements are either CSSValue objects or array refs of
130 arguments to be passed to the constructor. E.g.:
131
132 [
133 [type => CSS_PX, value => 20],
134 [type => CSS_PERCENTAGE, value => 50],
135 [type => CSS_PERCENTAGE, value => 50],
136 [type => CSS_PX, value => 50],
137 ]
138
139 When these array refs are converted to objects, the "format"
140 argument is supplied automatically, so you do not need to include
141 it here.
142
143 CSS_RGBCOLOR
144 A string beginning with '#', with no escapes (such as '#fff' or
145 '#c0ffee'), a colour name (like red) or an array ref with three to
146 four elements:
147
148 [$r, $g, $b]
149 [$r, $g, $b, $alpha]
150
151 The elements are either CSSValue objects or array refs of argument
152 lists, as with "CSS_RECT".
153
155 The following constants can be imported with "use
156 CSS::DOM::Value::Primitive ':all'". They represent the type of
157 primitive value.
158
159 CSS_UNKNOWN
160 CSS_NUMBER
161 CSS_PERCENTAGE
162 CSS_EMS
163 CSS_EXS
164 CSS_PX
165 CSS_CM
166 CSS_MM
167 CSS_IN
168 CSS_PT
169 CSS_PC
170 CSS_DEG
171 CSS_RAD
172 CSS_GRAD
173 CSS_MS
174 CSS_S
175 CSS_HZ
176 CSS_KHZ
177 CSS_DIMENSION
178 CSS_STRING
179 CSS_URI
180 CSS_IDENT
181 CSS_ATTR
182 CSS_COUNTER
183 CSS_RECT
184 CSS_RGBCOLOR
185
187 CSS::DOM
188
189 CSS::DOM::Value
190
191 CSS::DOM::Value::List
192
193 CSS::DOM::Style
194
195
196
197perl v5.32.0 2020-07-28 CSS::DOM::Value::Primitive(3)