| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CSS::Style; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = 1.02; |
|
4
|
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
45
|
use strict; |
|
|
8
|
|
|
|
|
18
|
|
|
|
8
|
|
|
|
|
270
|
|
|
6
|
8
|
|
|
8
|
|
38
|
use warnings; |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
218
|
|
|
7
|
8
|
|
|
8
|
|
3583
|
use overload '""' => 'to_string'; |
|
|
8
|
|
|
|
|
2292
|
|
|
|
8
|
|
|
|
|
71
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# create a new CSS::Style object |
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
67
|
|
|
67
|
1
|
53195
|
my $class = shift; |
|
12
|
67
|
|
|
|
|
232
|
my $self = bless {}, $class; |
|
13
|
|
|
|
|
|
|
|
|
14
|
67
|
|
|
|
|
535
|
$self->{options} = shift; |
|
15
|
67
|
|
|
|
|
178
|
$self->{selectors} = []; |
|
16
|
67
|
|
|
|
|
153
|
$self->{properties} = []; |
|
17
|
67
|
|
100
|
|
|
375
|
$self->{adaptor} = $self->{options}->{adaptor} || 'CSS::Adaptor'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
67
|
|
|
|
|
496
|
return $self; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub add_selector { |
|
23
|
89
|
|
|
89
|
1
|
135
|
my $self = shift; |
|
24
|
89
|
|
|
|
|
117
|
my $selector = shift; |
|
25
|
|
|
|
|
|
|
|
|
26
|
89
|
|
|
|
|
117
|
push @{$self->{selectors}}, $selector; |
|
|
89
|
|
|
|
|
216
|
|
|
27
|
89
|
|
|
|
|
316
|
$selector->set_adaptor($self->{adaptor}); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub add_property { |
|
31
|
71
|
|
|
71
|
1
|
127
|
my $self = shift; |
|
32
|
71
|
|
|
|
|
101
|
my $property = shift; |
|
33
|
|
|
|
|
|
|
|
|
34
|
71
|
|
|
|
|
101
|
push @{$self->{properties}}, $property; |
|
|
71
|
|
|
|
|
191
|
|
|
35
|
71
|
|
|
|
|
299
|
$property->set_adaptor($self->{adaptor}); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub set_adaptor { |
|
39
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
|
40
|
3
|
|
|
|
|
8
|
my $adaptor = shift; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# set adaptor |
|
43
|
3
|
|
|
|
|
8
|
$self->{adaptor} = $adaptor; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# recurse adaptor |
|
46
|
3
|
|
|
|
|
5
|
$_->set_adaptor($adaptor) for(@{$self->{selectors}}); |
|
|
3
|
|
|
|
|
13
|
|
|
47
|
3
|
|
|
|
|
9
|
$_->set_adaptor($adaptor) for(@{$self->{properties}}); |
|
|
3
|
|
|
|
|
18
|
|
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub selectors { |
|
51
|
4
|
|
|
4
|
1
|
7
|
my $self = shift; |
|
52
|
4
|
|
|
4
|
|
198
|
eval "use $self->{adaptor}"; |
|
|
4
|
|
|
|
|
22
|
|
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
41
|
|
|
53
|
4
|
|
|
|
|
137
|
my $adaptor_obj = new $self->{adaptor}; |
|
54
|
4
|
|
|
|
|
27
|
return $adaptor_obj->output_selectors($self->{selectors}); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub properties { |
|
58
|
4
|
|
|
4
|
1
|
8
|
my $self = shift; |
|
59
|
4
|
|
|
4
|
|
194
|
eval "use $self->{adaptor}"; |
|
|
4
|
|
|
|
|
23
|
|
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
41
|
|
|
60
|
4
|
|
|
|
|
137
|
my $adaptor_obj = new $self->{adaptor}; |
|
61
|
4
|
|
|
|
|
21
|
return $adaptor_obj->output_properties($self->{properties}); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub to_string { |
|
65
|
4
|
|
|
4
|
1
|
31
|
my $self = shift; |
|
66
|
4
|
|
|
4
|
|
257
|
eval "use $self->{adaptor}"; |
|
|
4
|
|
|
|
|
1137
|
|
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
71
|
|
|
67
|
4
|
|
|
|
|
143
|
my $adaptor_obj = new $self->{adaptor}; |
|
68
|
4
|
|
|
|
|
22
|
return $adaptor_obj->output_rule($self); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub get_property_by_name { |
|
72
|
1
|
|
|
1
|
1
|
518
|
my ($self, $prop_name) = @_; |
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
2
|
for my $prop (@{$self->{properties}}){ |
|
|
1
|
|
|
|
|
4
|
|
|
75
|
2
|
100
|
|
|
|
7
|
if ($prop->{property} eq $prop_name){ |
|
76
|
1
|
|
|
|
|
4
|
return $prop; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
0
|
|
|
|
|
0
|
return 0; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
CSS::Style - A ruleset in a CSS object tree |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
use CSS; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This module represents a ruleset in a CSS object tree. |
|
97
|
|
|
|
|
|
|
Read the CSS.pm pod for information about the CSS object tree. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 METHODS |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 CONSTRUCTORS |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item C<new()> or C<new( { ..options.. } )> |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This constructor returns a new C<CSS::Style> object, with |
|
108
|
|
|
|
|
|
|
an optional hash of options. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
adaptor adaptor to use for serialization |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=back |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 ACCESSORS |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=over 4 |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item C<add_selector( $selector )> |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This method adds a selector to the selector list for the object. |
|
121
|
|
|
|
|
|
|
C<$selector> is a reference to a CSS::Selector object. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item C<add_property( $property )> |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This method adds a selector to the property list for the object. |
|
126
|
|
|
|
|
|
|
C<$property> is a reference to a CSS::Property object. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item C<set_adaptor( 'CSS::Adaptor::Foo' )> |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This method sets the current adaptor for the object. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item C<selectors()> |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This method is used to serialize the ruleset's selectors, using the current |
|
135
|
|
|
|
|
|
|
adaptor. It returns a string which come from the adaptor's C<output_selectors()> |
|
136
|
|
|
|
|
|
|
method. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item C<properties()> |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This method is used to serialize the ruleset's properties, using the current |
|
141
|
|
|
|
|
|
|
adaptor. It returns a string which come from the adaptor's C<output_properties()> |
|
142
|
|
|
|
|
|
|
method. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item C<to_string()> |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This method is used to serialize the ruleset, using the current adaptor. It returns |
|
147
|
|
|
|
|
|
|
a string which comes from the adaptor's output_rules() method. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item C<get_property_by_name( 'property_name' )> |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns the first CSS::Property object with the specified name. Returns |
|
152
|
|
|
|
|
|
|
zero on failure. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=back |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 AUTHOR |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Copyright (C) 2003-2004, Cal Henderson <cal@iamcal.com> |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L<CSS>, http://www.w3.org/TR/REC-CSS1 |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
|
165
|
|
|
|
|
|
|
|