line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
###
|
3
|
|
|
|
|
|
|
# CSS::SAC::Selector::Sibling - SAC SiblingSelector
|
4
|
|
|
|
|
|
|
# Robin Berjon
|
5
|
|
|
|
|
|
|
# 24/02/2001
|
6
|
|
|
|
|
|
|
###
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package CSS::SAC::Selector::Sibling;
|
9
|
2
|
|
|
2
|
|
10
|
use strict;
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
133
|
|
10
|
2
|
|
|
2
|
|
12
|
use vars qw($VERSION);
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
125
|
|
11
|
|
|
|
|
|
|
$VERSION = $CSS::SAC::VERSION || '0.03';
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
10
|
use base qw(CSS::SAC::Selector);
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1357
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
17
|
|
|
|
|
|
|
# build the fields for an array based object
|
18
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
19
|
2
|
|
|
|
|
29
|
use Class::ArrayObjects extend => {
|
20
|
|
|
|
|
|
|
class => 'CSS::SAC::Selector',
|
21
|
|
|
|
|
|
|
with => [qw(
|
22
|
|
|
|
|
|
|
_node_type_
|
23
|
|
|
|
|
|
|
_selector_
|
24
|
|
|
|
|
|
|
_sibling_selector_
|
25
|
|
|
|
|
|
|
)],
|
26
|
2
|
|
|
2
|
|
16
|
};
|
|
2
|
|
|
|
|
3
|
|
27
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
### Constants #########################################################
|
32
|
|
|
|
|
|
|
# #
|
33
|
|
|
|
|
|
|
# #
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub ELEMENT_NODE () { 1 }
|
36
|
|
|
|
|
|
|
sub ATTRIBUTE_NODE () { 2 }
|
37
|
|
|
|
|
|
|
sub TEXT_NODE () { 3 }
|
38
|
|
|
|
|
|
|
sub CDATA_SECTION_NODE () { 4 }
|
39
|
|
|
|
|
|
|
sub ENTITY_REFERENCE_NODE () { 5 }
|
40
|
|
|
|
|
|
|
sub ENTITY_NODE () { 6 }
|
41
|
|
|
|
|
|
|
sub PROCESSING_INSTRUCTION_NODE () { 7 }
|
42
|
|
|
|
|
|
|
sub COMMENT_NODE () { 8 }
|
43
|
|
|
|
|
|
|
sub DOCUMENT_NODE () { 9 }
|
44
|
|
|
|
|
|
|
sub DOCUMENT_TYPE_NODE () { 10 }
|
45
|
|
|
|
|
|
|
sub DOCUMENT_FRAGMENT_NODE () { 11 }
|
46
|
|
|
|
|
|
|
sub NOTATION_NODE () { 12 }
|
47
|
|
|
|
|
|
|
sub ANY_NODE () { 13 }
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
51
|
|
|
|
|
|
|
# import()
|
52
|
|
|
|
|
|
|
# all import can do is export the constants
|
53
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
54
|
|
|
|
|
|
|
sub import {
|
55
|
3
|
|
|
3
|
|
75
|
my $class = shift;
|
56
|
3
|
|
50
|
|
|
16
|
my $tag = shift || '';
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# check that we have the right tag
|
59
|
3
|
50
|
|
|
|
15
|
return unless $tag eq ':constants';
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# define some useful vars
|
62
|
3
|
|
|
|
|
8
|
my $pkg = caller;
|
63
|
3
|
|
|
|
|
17
|
my @constants = qw(
|
64
|
|
|
|
|
|
|
ELEMENT_NODE
|
65
|
|
|
|
|
|
|
ATTRIBUTE_NODE
|
66
|
|
|
|
|
|
|
TEXT_NODE
|
67
|
|
|
|
|
|
|
CDATA_SECTION_NODE
|
68
|
|
|
|
|
|
|
ENTITY_REFERENCE_NODE
|
69
|
|
|
|
|
|
|
ENTITY_NODE
|
70
|
|
|
|
|
|
|
PROCESSING_INSTRUCTION_NODE
|
71
|
|
|
|
|
|
|
COMMENT_NODE
|
72
|
|
|
|
|
|
|
DOCUMENT_NODE
|
73
|
|
|
|
|
|
|
DOCUMENT_TYPE_NODE
|
74
|
|
|
|
|
|
|
DOCUMENT_FRAGMENT_NODE
|
75
|
|
|
|
|
|
|
NOTATION_NODE
|
76
|
|
|
|
|
|
|
ANY_NODE
|
77
|
|
|
|
|
|
|
);
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# now lets create the constants in the caller's package
|
80
|
2
|
|
|
2
|
|
1172
|
no strict 'refs';
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
839
|
|
81
|
3
|
|
|
|
|
15
|
for my $c (@constants) {
|
82
|
39
|
|
|
|
|
76
|
my $qname = "${pkg}::$c";
|
83
|
39
|
|
|
|
|
40
|
*$qname = \&{$c};
|
|
39
|
|
|
|
|
2567
|
|
84
|
|
|
|
|
|
|
}
|
85
|
|
|
|
|
|
|
}
|
86
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# #
|
90
|
|
|
|
|
|
|
# #
|
91
|
|
|
|
|
|
|
### Constants #########################################################
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
### Constructor #######################################################
|
95
|
|
|
|
|
|
|
# #
|
96
|
|
|
|
|
|
|
# #
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
100
|
|
|
|
|
|
|
# CSS::SAC::Selector::Sibling->new($type,$node_type,$sel,$sibling_sel)
|
101
|
|
|
|
|
|
|
# creates a new sac SiblingSelector object
|
102
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
103
|
|
|
|
|
|
|
sub new {
|
104
|
2
|
50
|
|
2
|
1
|
7
|
my $class = ref($_[0])?ref(shift):shift;
|
105
|
2
|
|
|
|
|
14
|
my $type = shift;
|
106
|
2
|
|
|
|
|
3
|
my $node_type = shift;
|
107
|
2
|
|
|
|
|
3
|
my $sel = shift;
|
108
|
2
|
|
|
|
|
3
|
my $sibling_sel = shift;
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# create a selector
|
111
|
2
|
|
|
|
|
13
|
my $ssel = $class->SUPER::new($type);
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# add our fields
|
114
|
2
|
|
50
|
|
|
12
|
$ssel->[_node_type_] = $node_type || ANY_NODE;
|
115
|
2
|
|
|
|
|
6
|
$ssel->[_selector_] = $sel;
|
116
|
2
|
|
|
|
|
3
|
$ssel->[_sibling_selector_] = $sibling_sel;
|
117
|
|
|
|
|
|
|
|
118
|
2
|
|
|
|
|
11
|
return $ssel;
|
119
|
|
|
|
|
|
|
}
|
120
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# #
|
124
|
|
|
|
|
|
|
# #
|
125
|
|
|
|
|
|
|
### Constructor #######################################################
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
### Accessors #########################################################
|
130
|
|
|
|
|
|
|
# #
|
131
|
|
|
|
|
|
|
# #
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
*CSS::SAC::Selector::Sibling::getNodeType = \&NodeType;
|
134
|
|
|
|
|
|
|
*CSS::SAC::Selector::Sibling::getSelector = \&Selector;
|
135
|
|
|
|
|
|
|
*CSS::SAC::Selector::Sibling::getSiblingSelector = \&SiblingSelector;
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
138
|
|
|
|
|
|
|
# my $node_type = $ssel->NodeType()
|
139
|
|
|
|
|
|
|
# $ssel->NodeType($node_type)
|
140
|
|
|
|
|
|
|
# get/set the node type to which we apply
|
141
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
142
|
|
|
|
|
|
|
sub NodeType {
|
143
|
0
|
0
|
|
0
|
1
|
0
|
(@_==2) ? $_[0]->[_node_type_] = $_[1] :
|
144
|
|
|
|
|
|
|
$_[0]->[_node_type_];
|
145
|
|
|
|
|
|
|
}
|
146
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
150
|
|
|
|
|
|
|
# my $sel = $ssel->Selector()
|
151
|
|
|
|
|
|
|
# $ssel->Selector($sel)
|
152
|
|
|
|
|
|
|
# get/set the selector
|
153
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
154
|
|
|
|
|
|
|
sub Selector {
|
155
|
2
|
50
|
|
2
|
1
|
34
|
(@_==2) ? $_[0]->[_selector_] = $_[1] :
|
156
|
|
|
|
|
|
|
$_[0]->[_selector_];
|
157
|
|
|
|
|
|
|
}
|
158
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
162
|
|
|
|
|
|
|
# my $o_ssel = $ssel->SiblingSelector()
|
163
|
|
|
|
|
|
|
# $ssel->SiblingSelector($o_ssel)
|
164
|
|
|
|
|
|
|
# get/set the sibling selector
|
165
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
166
|
|
|
|
|
|
|
sub SiblingSelector {
|
167
|
2
|
50
|
|
2
|
1
|
13
|
(@_==2) ? $_[0]->[_sibling_selector_] = $_[1] :
|
168
|
|
|
|
|
|
|
$_[0]->[_sibling_selector_];
|
169
|
|
|
|
|
|
|
}
|
170
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# #
|
174
|
|
|
|
|
|
|
# #
|
175
|
|
|
|
|
|
|
### Accessors #########################################################
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
1;
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=pod
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 NAME
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
CSS::SAC::Selector::Sibling - SAC SiblingSelector
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
see CSS::SAC::Selector
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This is a subclass of CSS::SAC::Selector, look there for more
|
194
|
|
|
|
|
|
|
documentation. This class adds the methods described below.
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
This subclass also defines the constants for the DOM nodes. It uses
|
197
|
|
|
|
|
|
|
the same constants as the DOM, and adds the ANY_NODE constant which
|
198
|
|
|
|
|
|
|
matches any node.
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 CONSTANTS
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=over
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=item * ELEMENT_NODE
|
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * ATTRIBUTE_NODE
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=item * TEXT_NODE
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item * CDATA_SECTION_NODE
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item * ENTITY_REFERENCE_NODE
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item * ENTITY_NODE
|
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item * PROCESSING_INSTRUCTION_NODE
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item * COMMENT_NODE
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item * DOCUMENT_NODE
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item * DOCUMENT_TYPE_NODE
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=item * DOCUMENT_FRAGMENT_NODE
|
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item * NOTATION_NODE
|
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * ANY_NODE
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=back
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 METHODS
|
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
These also exist in spec style, simply prepend them with 'get'.
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=over
|
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item * CSS::SAC::Selector::Sibling->new($type,$node_type,$sel,$sibling_sel)
|
239
|
|
|
|
|
|
|
=item * $ssel->new($type,$node_type,$sel,$sibling_sel)
|
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Creates a new sibling selector.
|
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item * $ssel->NodeType([$node_type])
|
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
get/set the node type to which we apply
|
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item * $ssel->Selector([$sel])
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
get/set the selector's sub selector
|
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item * $ssel->SiblingSelector([$sib_sel])
|
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
get/set the selector's sibling selector
|
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=back
|
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 AUTHOR
|
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Robin Berjon
|
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
This module is licensed under the same terms as Perl itself.
|
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=cut
|