line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
###
|
3
|
|
|
|
|
|
|
# CSS::SAC::ConditionFactory - the default ConditionFactory
|
4
|
|
|
|
|
|
|
# Robin Berjon
|
5
|
|
|
|
|
|
|
# 24/02/2001
|
6
|
|
|
|
|
|
|
###
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package CSS::SAC::ConditionFactory;
|
9
|
2
|
|
|
2
|
|
15
|
use strict;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
75
|
|
10
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION);
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
113
|
|
11
|
|
|
|
|
|
|
$VERSION = $CSS::SAC::VERSION || '0.03';
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
1436
|
use CSS::SAC::Condition qw(:constants);
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
12
|
|
14
|
2
|
|
|
2
|
|
1508
|
use CSS::SAC::Condition::Attribute qw();
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
44
|
|
15
|
2
|
|
|
2
|
|
1204
|
use CSS::SAC::Condition::Combinator qw();
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
43
|
|
16
|
2
|
|
|
2
|
|
1231
|
use CSS::SAC::Condition::Content qw();
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
44
|
|
17
|
2
|
|
|
2
|
|
1260
|
use CSS::SAC::Condition::Lang qw();
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
40
|
|
18
|
2
|
|
|
2
|
|
1209
|
use CSS::SAC::Condition::Negative qw();
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
39
|
|
19
|
2
|
|
|
2
|
|
3485
|
use CSS::SAC::Condition::Positional qw();
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
22
|
|
|
|
|
|
|
# build the fields for an array based object
|
23
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
24
|
2
|
|
|
2
|
|
13
|
use Class::ArrayObjects define => { fields => [] };
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
14
|
|
25
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
### Constructor #######################################################
|
29
|
|
|
|
|
|
|
# #
|
30
|
|
|
|
|
|
|
# #
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
34
|
|
|
|
|
|
|
# CSS::SAC::ConditionFactory->new
|
35
|
|
|
|
|
|
|
# creates a new sac condition factory
|
36
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
37
|
|
|
|
|
|
|
sub new {
|
38
|
2
|
50
|
|
2
|
1
|
10
|
my $class = ref($_[0])?ref(shift):shift;
|
39
|
2
|
|
|
|
|
44
|
return bless [], $class;
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# #
|
45
|
|
|
|
|
|
|
# #
|
46
|
|
|
|
|
|
|
### Constructor #######################################################
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
### Factory Methods ###################################################
|
51
|
|
|
|
|
|
|
# #
|
52
|
|
|
|
|
|
|
# #
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# defined aliases
|
56
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createAndCondition = \&create_and_condition;
|
57
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createAttributeCondition = \&create_attribute_condition;
|
58
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createBeginHyphenAttributeCondition = \&create_begin_hyphen_attribute_condition;
|
59
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createClassCondition = \&create_class_condition;
|
60
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createContentCondition = \&create_content_condition;
|
61
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createIdCondition = \&create_id_condition;
|
62
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createLangCondition = \&create_lang_condition;
|
63
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createNegativeCondition = \&create_negative_condition;
|
64
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createOneOfAttributeCondition = \&create_one_of_attribute_condition;
|
65
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createOnlyChildCondition = \&create_only_child_condition;
|
66
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createOnlyTypeCondition = \&create_only_type_condition;
|
67
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createOrCondition = \&create_or_condition;
|
68
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createPositionalCondition = \&create_positional_condition;
|
69
|
|
|
|
|
|
|
*CSS::SAC::ConditionFactory::createPseudoClassCondition = \&create_pseudo_class_condition;
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
73
|
|
|
|
|
|
|
# my $cond = $cf->create_and_condition($first,$second)
|
74
|
|
|
|
|
|
|
# creates a combinator condition of type and
|
75
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
76
|
|
|
|
|
|
|
sub create_and_condition {
|
77
|
2
|
|
|
2
|
1
|
3
|
my $cf = shift;
|
78
|
2
|
|
|
|
|
4
|
my $first = shift;
|
79
|
2
|
|
|
|
|
3
|
my $second = shift;
|
80
|
|
|
|
|
|
|
|
81
|
2
|
|
|
|
|
23
|
return CSS::SAC::Condition::Combinator->new(
|
82
|
|
|
|
|
|
|
AND_CONDITION,
|
83
|
|
|
|
|
|
|
$first,
|
84
|
|
|
|
|
|
|
$second,
|
85
|
|
|
|
|
|
|
);
|
86
|
|
|
|
|
|
|
}
|
87
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
91
|
|
|
|
|
|
|
# my $cond = $cf->create_attribute_condition($lname,$ns,$specified,$value)
|
92
|
|
|
|
|
|
|
# creates an attr condition
|
93
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
94
|
|
|
|
|
|
|
sub create_attribute_condition {
|
95
|
5
|
|
|
5
|
1
|
8
|
my $cf = shift;
|
96
|
5
|
|
|
|
|
6
|
my $lname = shift;
|
97
|
5
|
|
|
|
|
7
|
my $ns = shift;
|
98
|
5
|
|
|
|
|
5
|
my $specified = shift;
|
99
|
5
|
|
|
|
|
9
|
my $value = shift;
|
100
|
|
|
|
|
|
|
|
101
|
5
|
|
|
|
|
30
|
return CSS::SAC::Condition::Attribute->new(
|
102
|
|
|
|
|
|
|
ATTRIBUTE_CONDITION,
|
103
|
|
|
|
|
|
|
$lname,
|
104
|
|
|
|
|
|
|
$ns,
|
105
|
|
|
|
|
|
|
$specified,
|
106
|
|
|
|
|
|
|
$value,
|
107
|
|
|
|
|
|
|
);
|
108
|
|
|
|
|
|
|
}
|
109
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
113
|
|
|
|
|
|
|
# my $cond = $cf->create_begin_hyphen_attribute_condition($lname,$ns,$specified,$value)
|
114
|
|
|
|
|
|
|
# creates a attr condition of type bh
|
115
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
116
|
|
|
|
|
|
|
sub create_begin_hyphen_attribute_condition {
|
117
|
1
|
|
|
1
|
1
|
3
|
my $cf = shift;
|
118
|
1
|
|
|
|
|
4
|
my $lname = shift;
|
119
|
1
|
|
|
|
|
16
|
my $ns = shift;
|
120
|
1
|
|
|
|
|
2
|
my $specified = shift;
|
121
|
1
|
|
|
|
|
2
|
my $value = shift;
|
122
|
|
|
|
|
|
|
|
123
|
1
|
|
|
|
|
6
|
return CSS::SAC::Condition::Attribute->new(
|
124
|
|
|
|
|
|
|
BEGIN_HYPHEN_ATTRIBUTE_CONDITION,
|
125
|
|
|
|
|
|
|
$lname,
|
126
|
|
|
|
|
|
|
$ns,
|
127
|
|
|
|
|
|
|
$specified,
|
128
|
|
|
|
|
|
|
$value,
|
129
|
|
|
|
|
|
|
);
|
130
|
|
|
|
|
|
|
}
|
131
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
135
|
|
|
|
|
|
|
# my $cond = $cf->create_class_condition($ns,$value)
|
136
|
|
|
|
|
|
|
# creates a attr condition of type class
|
137
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
138
|
|
|
|
|
|
|
sub create_class_condition {
|
139
|
2
|
|
|
2
|
1
|
5
|
my $cf = shift;
|
140
|
2
|
|
|
|
|
3
|
my $ns = shift;
|
141
|
2
|
|
|
|
|
5
|
my $value = shift;
|
142
|
|
|
|
|
|
|
|
143
|
2
|
|
|
|
|
9
|
return CSS::SAC::Condition::Attribute->new(
|
144
|
|
|
|
|
|
|
CLASS_CONDITION,
|
145
|
|
|
|
|
|
|
undef,
|
146
|
|
|
|
|
|
|
$ns,
|
147
|
|
|
|
|
|
|
0,
|
148
|
|
|
|
|
|
|
$value,
|
149
|
|
|
|
|
|
|
);
|
150
|
|
|
|
|
|
|
}
|
151
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
155
|
|
|
|
|
|
|
# my $cond = $cf->create_content_condition($data)
|
156
|
|
|
|
|
|
|
# creates a content condition
|
157
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
158
|
|
|
|
|
|
|
sub create_content_condition {
|
159
|
1
|
|
|
1
|
1
|
2
|
my $cf = shift;
|
160
|
1
|
|
|
|
|
3
|
my $data = shift;
|
161
|
|
|
|
|
|
|
|
162
|
1
|
|
|
|
|
12
|
return CSS::SAC::Condition::Content->new(
|
163
|
|
|
|
|
|
|
CONTENT_CONDITION,
|
164
|
|
|
|
|
|
|
$data,
|
165
|
|
|
|
|
|
|
);
|
166
|
|
|
|
|
|
|
}
|
167
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
171
|
|
|
|
|
|
|
# my $cond = $cf->create_id_condition($value)
|
172
|
|
|
|
|
|
|
# creates a attr condition of type id
|
173
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
174
|
|
|
|
|
|
|
sub create_id_condition {
|
175
|
2
|
|
|
2
|
1
|
4
|
my $cf = shift;
|
176
|
2
|
|
|
|
|
4
|
my $value = shift;
|
177
|
|
|
|
|
|
|
|
178
|
2
|
|
|
|
|
18
|
return CSS::SAC::Condition::Attribute->new(
|
179
|
|
|
|
|
|
|
ID_CONDITION,
|
180
|
|
|
|
|
|
|
undef,
|
181
|
|
|
|
|
|
|
undef,
|
182
|
|
|
|
|
|
|
0,
|
183
|
|
|
|
|
|
|
$value,
|
184
|
|
|
|
|
|
|
);
|
185
|
|
|
|
|
|
|
}
|
186
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
190
|
|
|
|
|
|
|
# my $cond = $cf->create_lang_condition($lang)
|
191
|
|
|
|
|
|
|
# creates a lang condition
|
192
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
193
|
|
|
|
|
|
|
sub create_lang_condition {
|
194
|
1
|
|
|
1
|
1
|
2
|
my $cf = shift;
|
195
|
1
|
|
|
|
|
3
|
my $lang = shift;
|
196
|
|
|
|
|
|
|
|
197
|
1
|
|
|
|
|
10
|
return CSS::SAC::Condition::Lang->new(
|
198
|
|
|
|
|
|
|
LANG_CONDITION,
|
199
|
|
|
|
|
|
|
$lang,
|
200
|
|
|
|
|
|
|
);
|
201
|
|
|
|
|
|
|
}
|
202
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
206
|
|
|
|
|
|
|
# my $cond = $cf->create_negative_condition($cond)
|
207
|
|
|
|
|
|
|
# creates a negative condition
|
208
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
209
|
|
|
|
|
|
|
sub create_negative_condition {
|
210
|
2
|
|
|
2
|
1
|
4
|
my $cf = shift;
|
211
|
2
|
|
|
|
|
3
|
my $cond = shift;
|
212
|
|
|
|
|
|
|
|
213
|
2
|
|
|
|
|
16
|
return CSS::SAC::Condition::Negative->new(
|
214
|
|
|
|
|
|
|
NEGATIVE_CONDITION,
|
215
|
|
|
|
|
|
|
$cond,
|
216
|
|
|
|
|
|
|
);
|
217
|
|
|
|
|
|
|
}
|
218
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
222
|
|
|
|
|
|
|
# my $cond = $cf->create_one_of_attribute_condition($lname,$ns,$specified,$value)
|
223
|
|
|
|
|
|
|
# creates a attr condition of type id
|
224
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
225
|
|
|
|
|
|
|
sub create_one_of_attribute_condition {
|
226
|
1
|
|
|
1
|
1
|
3
|
my $cf = shift;
|
227
|
1
|
|
|
|
|
2
|
my $lname = shift;
|
228
|
1
|
|
|
|
|
2
|
my $ns = shift;
|
229
|
1
|
|
|
|
|
2
|
my $specified = shift;
|
230
|
1
|
|
|
|
|
2
|
my $value = shift;
|
231
|
|
|
|
|
|
|
|
232
|
1
|
|
|
|
|
6
|
return CSS::SAC::Condition::Attribute->new(
|
233
|
|
|
|
|
|
|
ONE_OF_ATTRIBUTE_CONDITION,
|
234
|
|
|
|
|
|
|
$lname,
|
235
|
|
|
|
|
|
|
$ns,
|
236
|
|
|
|
|
|
|
$specified,
|
237
|
|
|
|
|
|
|
$value,
|
238
|
|
|
|
|
|
|
);
|
239
|
|
|
|
|
|
|
}
|
240
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
244
|
|
|
|
|
|
|
# my $cond = $cf->create_only_child_condition()
|
245
|
|
|
|
|
|
|
# creates a only-child condition
|
246
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
247
|
|
|
|
|
|
|
sub create_only_child_condition {
|
248
|
0
|
|
|
0
|
1
|
0
|
my $cf = shift;
|
249
|
0
|
|
|
|
|
0
|
return CSS::SAC::Condition->new(ONLY_CHILD_CONDITION);
|
250
|
|
|
|
|
|
|
}
|
251
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
255
|
|
|
|
|
|
|
# my $cond = $cf->create_only_type_condition()
|
256
|
|
|
|
|
|
|
# creates a only-type condition
|
257
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
258
|
|
|
|
|
|
|
sub create_only_type_condition {
|
259
|
0
|
|
|
0
|
1
|
0
|
my $cf = shift;
|
260
|
0
|
|
|
|
|
0
|
return CSS::SAC::Condition->new(ONLY_TYPE_CONDITION);
|
261
|
|
|
|
|
|
|
}
|
262
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
266
|
|
|
|
|
|
|
# my $cond = $cf->create_or_condition($first,$second)
|
267
|
|
|
|
|
|
|
# creates a combinator condition of type or
|
268
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
269
|
|
|
|
|
|
|
sub create_or_condition {
|
270
|
0
|
|
|
0
|
1
|
0
|
my $cf = shift;
|
271
|
0
|
|
|
|
|
0
|
my $first = shift;
|
272
|
0
|
|
|
|
|
0
|
my $second = shift;
|
273
|
|
|
|
|
|
|
|
274
|
0
|
|
|
|
|
0
|
return CSS::SAC::Condition::Combinator->new(
|
275
|
|
|
|
|
|
|
OR_CONDITION,
|
276
|
|
|
|
|
|
|
$first,
|
277
|
|
|
|
|
|
|
$second,
|
278
|
|
|
|
|
|
|
);
|
279
|
|
|
|
|
|
|
}
|
280
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
284
|
|
|
|
|
|
|
# my $cond = $cf->create_positional_condition($position,$type_node,$same_type)
|
285
|
|
|
|
|
|
|
# creates a positional condition
|
286
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
287
|
|
|
|
|
|
|
sub create_positional_condition {
|
288
|
14
|
|
|
14
|
1
|
22
|
my $cf = shift;
|
289
|
14
|
|
|
|
|
20
|
my $position = shift;
|
290
|
14
|
|
|
|
|
16
|
my $type_node = shift;
|
291
|
14
|
|
|
|
|
15
|
my $same_type = shift;
|
292
|
|
|
|
|
|
|
|
293
|
14
|
|
|
|
|
57
|
return CSS::SAC::Condition::Positional->new(
|
294
|
|
|
|
|
|
|
POSITIONAL_CONDITION,
|
295
|
|
|
|
|
|
|
$position,
|
296
|
|
|
|
|
|
|
$type_node,
|
297
|
|
|
|
|
|
|
$same_type,
|
298
|
|
|
|
|
|
|
);
|
299
|
|
|
|
|
|
|
}
|
300
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
304
|
|
|
|
|
|
|
# my $cond = $cf->create_pseudo_class_condition($ns,$value)
|
305
|
|
|
|
|
|
|
# creates a attr condition of type pseudo class
|
306
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
307
|
|
|
|
|
|
|
sub create_pseudo_class_condition {
|
308
|
2
|
|
|
2
|
1
|
3
|
my $cf = shift;
|
309
|
2
|
|
|
|
|
3
|
my $ns = shift;
|
310
|
2
|
|
|
|
|
4
|
my $value = shift;
|
311
|
|
|
|
|
|
|
|
312
|
2
|
|
|
|
|
30
|
return CSS::SAC::Condition::Attribute->new(
|
313
|
|
|
|
|
|
|
PSEUDO_CLASS_CONDITION,
|
314
|
|
|
|
|
|
|
undef,
|
315
|
|
|
|
|
|
|
$ns,
|
316
|
|
|
|
|
|
|
0,
|
317
|
|
|
|
|
|
|
$value,
|
318
|
|
|
|
|
|
|
);
|
319
|
|
|
|
|
|
|
}
|
320
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
# #
|
324
|
|
|
|
|
|
|
# #
|
325
|
|
|
|
|
|
|
### Factory Methods ###################################################
|
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
### EXPERIMENTAL Factory Methods ######################################
|
330
|
|
|
|
|
|
|
# #
|
331
|
|
|
|
|
|
|
# #
|
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
### IMPORTANT NOTE ####################################################
|
335
|
|
|
|
|
|
|
# #
|
336
|
|
|
|
|
|
|
# These factory methods are considered experiemental. They will #
|
337
|
|
|
|
|
|
|
# remain undocumented until further notice. CSS::SAC uses them when #
|
338
|
|
|
|
|
|
|
# it meets the corresponding tokens, but they should not be relied on #
|
339
|
|
|
|
|
|
|
# for most uses unless you know what you are doing. These methods are #
|
340
|
|
|
|
|
|
|
# just as stable as the others, but given that I have implemented #
|
341
|
|
|
|
|
|
|
# them on my own without consulting with the other SAC implementors #
|
342
|
|
|
|
|
|
|
# (in fact, I tried to consult but they didn't appear to be #
|
343
|
|
|
|
|
|
|
# interested at that moment in time) they are subject to change. #
|
344
|
|
|
|
|
|
|
# #
|
345
|
|
|
|
|
|
|
#######################################################################
|
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
349
|
|
|
|
|
|
|
# my $cond = $cf->create_starts_with_attribute_condition($lname,$ns,$specified,$value)
|
350
|
|
|
|
|
|
|
# creates a attr condition of type sw
|
351
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
352
|
|
|
|
|
|
|
sub create_starts_with_attribute_condition {
|
353
|
1
|
|
|
1
|
0
|
2
|
my $cf = shift;
|
354
|
1
|
|
|
|
|
2
|
my $lname = shift;
|
355
|
1
|
|
|
|
|
2
|
my $ns = shift;
|
356
|
1
|
|
|
|
|
2
|
my $specified = shift;
|
357
|
1
|
|
|
|
|
2
|
my $value = shift;
|
358
|
|
|
|
|
|
|
|
359
|
1
|
|
|
|
|
6
|
return CSS::SAC::Condition::Attribute->new(
|
360
|
|
|
|
|
|
|
STARTS_WITH_ATTRIBUTE_CONDITION,
|
361
|
|
|
|
|
|
|
$lname,
|
362
|
|
|
|
|
|
|
$ns,
|
363
|
|
|
|
|
|
|
$specified,
|
364
|
|
|
|
|
|
|
$value,
|
365
|
|
|
|
|
|
|
);
|
366
|
|
|
|
|
|
|
}
|
367
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
371
|
|
|
|
|
|
|
# my $cond = $cf->create_ends_with_attribute_condition($lname,$ns,$specified,$value)
|
372
|
|
|
|
|
|
|
# creates a attr condition of type ew
|
373
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
374
|
|
|
|
|
|
|
sub create_ends_with_attribute_condition {
|
375
|
1
|
|
|
1
|
0
|
3
|
my $cf = shift;
|
376
|
1
|
|
|
|
|
2
|
my $lname = shift;
|
377
|
1
|
|
|
|
|
2
|
my $ns = shift;
|
378
|
1
|
|
|
|
|
2
|
my $specified = shift;
|
379
|
1
|
|
|
|
|
2
|
my $value = shift;
|
380
|
|
|
|
|
|
|
|
381
|
1
|
|
|
|
|
6
|
return CSS::SAC::Condition::Attribute->new(
|
382
|
|
|
|
|
|
|
ENDS_WITH_ATTRIBUTE_CONDITION,
|
383
|
|
|
|
|
|
|
$lname,
|
384
|
|
|
|
|
|
|
$ns,
|
385
|
|
|
|
|
|
|
$specified,
|
386
|
|
|
|
|
|
|
$value,
|
387
|
|
|
|
|
|
|
);
|
388
|
|
|
|
|
|
|
}
|
389
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
393
|
|
|
|
|
|
|
# my $cond = $cf->create_contains_attribute_condition($lname,$ns,$specified,$value)
|
394
|
|
|
|
|
|
|
# creates a attr condition of type sw
|
395
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
396
|
|
|
|
|
|
|
sub create_contains_attribute_condition {
|
397
|
0
|
|
|
0
|
0
|
0
|
my $cf = shift;
|
398
|
0
|
|
|
|
|
0
|
my $lname = shift;
|
399
|
0
|
|
|
|
|
0
|
my $ns = shift;
|
400
|
0
|
|
|
|
|
0
|
my $specified = shift;
|
401
|
0
|
|
|
|
|
0
|
my $value = shift;
|
402
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
0
|
return CSS::SAC::Condition::Attribute->new(
|
404
|
|
|
|
|
|
|
CONTAINS_ATTRIBUTE_CONDITION,
|
405
|
|
|
|
|
|
|
$lname,
|
406
|
|
|
|
|
|
|
$ns,
|
407
|
|
|
|
|
|
|
$specified,
|
408
|
|
|
|
|
|
|
$value,
|
409
|
|
|
|
|
|
|
);
|
410
|
|
|
|
|
|
|
}
|
411
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
415
|
|
|
|
|
|
|
# my $cond = $cf->create_is_root_condition()
|
416
|
|
|
|
|
|
|
# creates a root condition
|
417
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
418
|
|
|
|
|
|
|
sub create_is_root_condition {
|
419
|
2
|
|
|
2
|
0
|
3
|
my $cf = shift;
|
420
|
2
|
|
|
|
|
11
|
return CSS::SAC::Condition->new(IS_ROOT_CONDITION);
|
421
|
|
|
|
|
|
|
}
|
422
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
426
|
|
|
|
|
|
|
# my $cond = $cf->create_is_empty_condition()
|
427
|
|
|
|
|
|
|
# creates a empty condition
|
428
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
429
|
|
|
|
|
|
|
sub create_is_empty_condition {
|
430
|
1
|
|
|
1
|
0
|
2
|
my $cf = shift;
|
431
|
1
|
|
|
|
|
6
|
return CSS::SAC::Condition->new(IS_EMPTY_CONDITION);
|
432
|
|
|
|
|
|
|
}
|
433
|
|
|
|
|
|
|
#---------------------------------------------------------------------#
|
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
# #
|
439
|
|
|
|
|
|
|
# #
|
440
|
|
|
|
|
|
|
### EXPERIMENTAL Factory Methods ######################################
|
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
1;
|
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
=pod
|
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=head1 NAME
|
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
CSS::SAC::ConditionFactory - the default ConditionFactory
|
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
my $cf = CSS::SAC::ConditionFactory->new;
|
454
|
|
|
|
|
|
|
my $cond1 = $cf->create_foo_condition;
|
455
|
|
|
|
|
|
|
my $cond2 = $cf->create_bar_condition;
|
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
This is the default ConditionFactory for CSS::SAC. It creates
|
460
|
|
|
|
|
|
|
conditions of all types defined in SAC. You may wish to subclass or
|
461
|
|
|
|
|
|
|
replace the default ConditionFactory in order to get your own
|
462
|
|
|
|
|
|
|
condition objects.
|
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
I plan on adding more flexibility to this factory so that one could
|
465
|
|
|
|
|
|
|
tell it the classes to use for various conditions, that would avoid
|
466
|
|
|
|
|
|
|
enforcing subclassing/recoding for people that only want to replace
|
467
|
|
|
|
|
|
|
a family of factory methods.
|
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
I know that some of the method names are quite lengthy, but given the
|
470
|
|
|
|
|
|
|
great number of possible conditions it helps to have descriptive
|
471
|
|
|
|
|
|
|
names.
|
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=head1 METHODS
|
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
These define the interface that must be adhered to by
|
476
|
|
|
|
|
|
|
ConditionFactories. The Java names (given in parens) work too, though
|
477
|
|
|
|
|
|
|
the Perl ones are recommended.
|
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=over 4
|
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=item * CSS::SAC::ConditionFactory->new or $cf->new
|
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
Creates a new condition factory object.
|
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
=item * $cf->create_and_condition($first,$second) (createAndCondition)
|
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
creates a combinator condition of type and
|
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
=item * $cf->create_attribute_condition($lname,$ns,$specified,$value) (createAttributeCondition)
|
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
creates an attr condition
|
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=item * $cf->create_begin_hyphen_attribute_condition($lname,$ns,$specified,$value) (createBeginHyphenAttributeCondition)
|
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
creates a attr condition of type bh
|
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
=item * $cf->create_class_condition($ns,$value) (createClassCondition)
|
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
creates a attr condition of type class
|
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
=item * $cf->create_content_condition($data) (createContentCondition)
|
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
creates a content condition
|
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
=item * $cf->create_id_condition($value) (createIdCondition)
|
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
creates a attr condition of type id
|
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
=item * $cf->create_lang_condition($lang) (createLangCondition)
|
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
creates a lang condition
|
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
=item * $cf->create_negative_condition($cond) (createNegativeCondition)
|
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
creates a negative condition
|
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=item * $cf->create_one_of_attribute_condition($lname,$ns,$specified,$value) (createOneOfAttributeCondition)
|
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
creates a attr condition of type id
|
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
=item * $cf->create_only_child_condition() (createOnlyChildCondition)
|
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
creates a only-child condition
|
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
=item * $cf->create_only_type_condition() (createOnlyTypeCondition)
|
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
creates a only-type condition
|
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
=item * $cf->create_or_condition($first,$second) (createOrCondition)
|
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
creates a combinator condition of type or
|
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=item * $cf->create_positional_condition($position,$type_node,$same_type) (createPositionalCondition)
|
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
creates a positional condition
|
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
=item * $cf->create_pseudo_class_condition($ns,$value) (createPseudoClassCondition)
|
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
creates a attr condition of type pseudo class
|
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
=back
|
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
=head1 EXPERIMENTAL
|
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
There's some experimental stuff in here to provide for some new CSS
|
546
|
|
|
|
|
|
|
constructs. It is and will remain undocumented until there is
|
547
|
|
|
|
|
|
|
consensus on the handling of these new tokens. If you badly need to
|
548
|
|
|
|
|
|
|
use one of the new CSS3 conditions that isn't documented, look at the
|
549
|
|
|
|
|
|
|
source for features tagged EXPERIMENTAL.
|
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=head1 AUTHOR
|
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
Robin Berjon
|
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
This module is licensed under the same terms as Perl itself.
|
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
=cut
|
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
|