line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::DOM::Value; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.17'; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
1471
|
use warnings; no warnings qw 'utf8 parenthesis';; |
|
3
|
|
|
3
|
|
4
|
|
|
3
|
|
|
|
|
118
|
|
|
3
|
|
|
|
|
22
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
110
|
|
6
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
80
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
14
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
173
|
|
9
|
3
|
|
|
3
|
|
407
|
use CSS::DOM::Constants; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
104
|
|
10
|
3
|
|
|
3
|
|
403
|
use CSS'DOM'Exception 'NO_MODIFICATION_ALLOWED_ERR'; |
|
3
|
|
|
|
|
21
|
|
|
3
|
|
|
|
|
168
|
|
11
|
3
|
|
|
3
|
|
15
|
use Exporter 5.57 'import'; |
|
3
|
|
|
|
|
51
|
|
|
3
|
|
|
|
|
149
|
|
12
|
3
|
|
|
3
|
|
16
|
use Scalar'Util < weaken reftype >; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
337
|
|
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
|
|
209
|
use constant 1.03 our $_const = { |
15
|
|
|
|
|
|
|
type => 0, |
16
|
|
|
|
|
|
|
valu => 1, |
17
|
|
|
|
|
|
|
ownr => 2, |
18
|
|
|
|
|
|
|
prop => 3, |
19
|
3
|
|
|
3
|
|
18
|
}; |
|
3
|
|
|
|
|
36
|
|
20
|
3
|
|
|
3
|
|
13
|
{ no strict; delete @{__PACKAGE__.'::'}{_const => keys %{our $_const}} } |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1673
|
|
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
|
2680
|
my $self = bless[], shift; |
27
|
15
|
|
|
|
|
47
|
my %args = @_; |
28
|
15
|
|
|
|
|
32
|
my $type = $self->[type] = $args{type}; |
29
|
|
|
|
|
|
|
$type == CSS_CUSTOM |
30
|
15
|
100
|
33
|
|
|
61
|
? !exists $args{value} && croak |
|
|
|
33
|
|
|
|
|
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
|
|
|
|
|
356
|
@$self[valu,ownr,prop] = @args{< value owner property >}; |
36
|
15
|
|
|
|
|
68
|
weaken $$self[ownr]; |
37
|
|
|
|
|
|
|
|
38
|
15
|
|
|
|
|
53
|
$self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
7
|
1
|
30
|
sub cssValueType { shift->[type] } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub cssText { |
44
|
14
|
|
|
14
|
1
|
1044
|
my $self = shift; |
45
|
14
|
100
|
|
|
|
39
|
my $old = $self->[type] == CSS_CUSTOM |
|
|
100
|
|
|
|
|
|
46
|
|
|
|
|
|
|
? $self->[valu] : 'inherit' |
47
|
|
|
|
|
|
|
if defined wantarray; |
48
|
14
|
100
|
|
|
|
23
|
if(@_) { |
49
|
6
|
100
|
|
|
|
21
|
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
|
|
|
|
12
|
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
|
|
|
|
10
|
if( |
60
|
|
|
|
|
|
|
my @arsg |
61
|
|
|
|
|
|
|
= $owner->property_parser->match($prop, $_[0]) |
62
|
|
|
|
|
|
|
) { |
63
|
4
|
|
|
|
|
10
|
_apply_args_to_self($self,$owner,$prop,@arsg); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
4
|
100
|
|
|
|
13
|
if(my $mh = $owner->modification_handler) { |
67
|
1
|
|
|
|
|
4
|
&$mh(); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
$old |
71
|
12
|
|
|
|
|
35
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _apply_args_to_self { |
74
|
50
|
|
|
50
|
|
125
|
my($self,$owner,$prop,@arsg) = @_; |
75
|
50
|
|
|
|
|
100
|
_load_if_necessary($arsg[1]); |
76
|
50
|
|
|
|
|
187
|
my $new = $arsg[1]->new( |
77
|
|
|
|
|
|
|
owner => $owner, property => $prop, @arsg[2...$#arsg] |
78
|
|
|
|
|
|
|
); |
79
|
50
|
100
|
|
|
|
277
|
reftype $self eq "HASH" |
80
|
|
|
|
|
|
|
? %$self = %$new |
81
|
|
|
|
|
|
|
: (@$self = @$new); |
82
|
50
|
100
|
|
|
|
231
|
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
|
|
299
|
|| 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.17 |
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 or C |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item css |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
A string of CSS code. This is |
149
|
|
|
|
|
|
|
only used when C is C. |
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 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 |
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 |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
L |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
L |