line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::DOM::Value; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.15'; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
1854
|
use warnings; no warnings qw 'utf8 parenthesis';; |
|
3
|
|
|
3
|
|
7
|
|
|
3
|
|
|
|
|
150
|
|
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
147
|
|
6
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
117
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
19
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
278
|
|
9
|
3
|
|
|
3
|
|
813
|
use CSS::DOM::Constants; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
273
|
|
10
|
3
|
|
|
3
|
|
991
|
use CSS'DOM'Exception 'NO_MODIFICATION_ALLOWED_ERR'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
207
|
|
11
|
3
|
|
|
3
|
|
15
|
use Exporter 5.57 'import'; |
|
3
|
|
|
|
|
73
|
|
|
3
|
|
|
|
|
134
|
|
12
|
3
|
|
|
3
|
|
19
|
use Scalar'Util < weaken reftype >; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
383
|
|
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
|
|
260
|
use constant 1.03 our $_const = { |
15
|
|
|
|
|
|
|
type => 0, |
16
|
|
|
|
|
|
|
valu => 1, |
17
|
|
|
|
|
|
|
ownr => 2, |
18
|
|
|
|
|
|
|
prop => 3, |
19
|
3
|
|
|
3
|
|
21
|
}; |
|
3
|
|
|
|
|
55
|
|
20
|
3
|
|
|
3
|
|
18
|
{ no strict; delete @{__PACKAGE__.'::'}{_const => keys %{our $_const}} } |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2447
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
*EXPORT_OK = $CSS::DOM::Constants::EXPORT_TAGS{value}; |
23
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \our @EXPORT_OK ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
15
|
|
|
15
|
0
|
3245
|
my $self = bless[], shift; |
27
|
15
|
|
|
|
|
76
|
my %args = @_; |
28
|
15
|
|
|
|
|
56
|
my $type = $self->[type] = $args{type}; |
29
|
15
|
100
|
33
|
|
|
80
|
$type == CSS_CUSTOM |
|
|
|
33
|
|
|
|
|
30
|
|
|
|
|
|
|
? !exists $args{value} && croak |
31
|
|
|
|
|
|
|
'new CSS::DOM::Value(type => CSS_CUSTOM) requires a value' |
32
|
|
|
|
|
|
|
: $type == CSS_INHERIT |
33
|
|
|
|
|
|
|
|| croak "Type must be CSS_CUSTOM or CSS_INHERIT"; |
34
|
|
|
|
|
|
|
|
35
|
15
|
|
|
|
|
556
|
@$self[valu,ownr,prop] = @args{< value owner property >}; |
36
|
15
|
|
|
|
|
123
|
weaken $$self[ownr]; |
37
|
|
|
|
|
|
|
|
38
|
15
|
|
|
|
|
81
|
$self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
7
|
1
|
47
|
sub cssValueType { shift->[type] } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub cssText { |
44
|
14
|
|
|
14
|
1
|
1159
|
my $self = shift; |
45
|
14
|
100
|
|
|
|
57
|
my $old = $self->[type] == CSS_CUSTOM |
|
|
100
|
|
|
|
|
|
46
|
|
|
|
|
|
|
? $self->[valu] : 'inherit' |
47
|
|
|
|
|
|
|
if defined wantarray; |
48
|
14
|
100
|
|
|
|
39
|
if(@_) { |
49
|
6
|
100
|
|
|
|
32
|
die new CSS'DOM'Exception |
50
|
|
|
|
|
|
|
NO_MODIFICATION_ALLOWED_ERR, |
51
|
|
|
|
|
|
|
"Unowned value objects cannot be modified" |
52
|
|
|
|
|
|
|
unless my $owner = $self->[ownr]; |
53
|
5
|
100
|
|
|
|
24
|
die new CSS'DOM'Exception |
54
|
|
|
|
|
|
|
NO_MODIFICATION_ALLOWED_ERR, |
55
|
|
|
|
|
|
|
"CSS::DOM::Value objects that do not know to which " |
56
|
|
|
|
|
|
|
."property they belong cannot be modified" |
57
|
|
|
|
|
|
|
unless my $prop = $self->[prop]; |
58
|
|
|
|
|
|
|
|
59
|
4
|
50
|
|
|
|
15
|
if( |
60
|
|
|
|
|
|
|
my @arsg |
61
|
|
|
|
|
|
|
= $owner->property_parser->match($prop, $_[0]) |
62
|
|
|
|
|
|
|
) { |
63
|
4
|
|
|
|
|
17
|
_apply_args_to_self($self,$owner,$prop,@arsg); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
4
|
100
|
|
|
|
101
|
if(my $mh = $owner->modification_handler) { |
67
|
1
|
|
|
|
|
5
|
&$mh(); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
$old |
71
|
12
|
|
|
|
|
133
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _apply_args_to_self { |
74
|
50
|
|
|
50
|
|
183
|
my($self,$owner,$prop,@arsg) = @_; |
75
|
50
|
|
|
|
|
131
|
_load_if_necessary($arsg[1]); |
76
|
50
|
|
|
|
|
264
|
my $new = $arsg[1]->new( |
77
|
|
|
|
|
|
|
owner => $owner, property => $prop, @arsg[2...$#arsg] |
78
|
|
|
|
|
|
|
); |
79
|
50
|
100
|
|
|
|
407
|
reftype $self eq "HASH" |
80
|
|
|
|
|
|
|
? %$self = %$new |
81
|
|
|
|
|
|
|
: (@$self = @$new); |
82
|
50
|
100
|
|
|
|
352
|
bless $self, ref $new unless ref $new eq ref $self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _load_if_necessary { |
86
|
|
|
|
|
|
|
$_[0]->can('new') |
87
|
59
|
50
|
|
59
|
|
620
|
|| do { |
88
|
0
|
|
|
|
|
|
(my $pack = $_[0]) =~ s e::e/egg; |
89
|
0
|
|
|
|
|
|
require "$pack.pm"; |
90
|
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
!()__END__()! |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 NAME |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
CSS::DOM::Value - CSSValue class for CSS::DOM |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 VERSION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Version 0.15 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SYNOPSIS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# ... |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 DESCRIPTION |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This module implements objects that represent CSS property values. It |
110
|
|
|
|
|
|
|
implements the DOM CSSValue interface. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This class is used only for custom values (neither primitive values nor |
113
|
|
|
|
|
|
|
lists) and the special 'inherit' value. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 METHODS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 Object Methods |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over 4 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item cssText |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns a string representation of the attribute. Pass an argument to set |
124
|
|
|
|
|
|
|
it. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item cssValueType |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns one of the constants below. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 Constructor |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
You probably don't need to call this, but here it is anyway: |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
$val = new CSS::DOM::Value %arguments; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The hash-style C<%arguments> are as follows: |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item type |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
C<CSS_INHERIT> or C<CSS_CUSTOM> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item css |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
A string of CSS code. This is |
149
|
|
|
|
|
|
|
only used when C<TYPE> is C<CSS_CUSTOM>. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item owner |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
The style object that owns this value; if this is omitted, then the value |
154
|
|
|
|
|
|
|
is read-only. The value object holds a weak reference to the owner. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item property |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The name of the CSS property to which this value belongs. C<cssText> uses |
159
|
|
|
|
|
|
|
this to determine how to parse text passed to it. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=back |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 CONSTANTS |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
The following constants can be imported with C<use CSS::DOM::Value ':all'>. |
166
|
|
|
|
|
|
|
They represent the type of CSS value. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=over |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item CSS_INHERIT (0) |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item CSS_PRIMITIVE_VALUE (1) |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item CSS_VALUE_LIST (2) |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item CSS_CUSTOM (3) |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 SEE ALSO |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L<CSS::DOM> |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L<CSS::DOM::Value::Primitive> |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
L<CSS::DOM::Value::List> |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
L<CSS::DOM::Style> |