csspool 0.2.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +16 -0
- data/{CHANGELOG.txt → CHANGELOG.rdoc} +10 -0
- data/Manifest.txt +60 -72
- data/README.rdoc +78 -0
- data/Rakefile +9 -52
- data/lib/csspool/collection.rb +50 -0
- data/lib/csspool/css/charset.rb +7 -0
- data/lib/csspool/css/declaration.rb +8 -0
- data/lib/csspool/css/document.rb +34 -0
- data/lib/csspool/css/document_handler.rb +51 -0
- data/lib/csspool/css/import_rule.rb +15 -0
- data/lib/csspool/css/media.rb +7 -0
- data/lib/csspool/css/rule_set.rb +12 -0
- data/lib/csspool/css.rb +7 -0
- data/lib/csspool/lib_croco/cr_additional_sel.rb +46 -0
- data/lib/csspool/lib_croco/cr_attr_sel.rb +16 -0
- data/lib/csspool/lib_croco/cr_doc_handler.rb +24 -0
- data/lib/csspool/lib_croco/cr_num.rb +13 -0
- data/lib/csspool/lib_croco/cr_parser.rb +11 -0
- data/lib/csspool/lib_croco/cr_parsing_location.rb +17 -0
- data/lib/csspool/lib_croco/cr_pseudo.rb +14 -0
- data/lib/csspool/lib_croco/cr_rgb.rb +18 -0
- data/lib/csspool/lib_croco/cr_selector.rb +34 -0
- data/lib/csspool/lib_croco/cr_simple_sel.rb +54 -0
- data/lib/csspool/lib_croco/cr_term.rb +97 -0
- data/lib/csspool/lib_croco/glist.rb +21 -0
- data/lib/csspool/lib_croco.rb +78 -0
- data/lib/csspool/node.rb +5 -0
- data/lib/csspool/sac/document.rb +35 -0
- data/lib/csspool/sac/parser.rb +122 -0
- data/lib/csspool/sac.rb +2 -0
- data/lib/csspool/selector.rb +32 -0
- data/lib/csspool/selectors/additional.rb +6 -0
- data/lib/csspool/selectors/attribute.rb +21 -0
- data/lib/csspool/selectors/class.rb +11 -0
- data/lib/csspool/selectors/id.rb +11 -0
- data/lib/csspool/selectors/pseudo_class.rb +13 -0
- data/lib/csspool/selectors/simple.rb +22 -0
- data/lib/csspool/selectors/type.rb +6 -0
- data/lib/csspool/selectors/universal.rb +6 -0
- data/lib/csspool/selectors.rb +8 -0
- data/lib/csspool/terms/function.rb +17 -0
- data/lib/csspool/terms/hash.rb +6 -0
- data/lib/csspool/terms/ident.rb +15 -0
- data/lib/csspool/terms/number.rb +14 -0
- data/lib/csspool/terms/rgb.rb +23 -0
- data/lib/csspool/terms/string.rb +6 -0
- data/lib/csspool/terms/uri.rb +6 -0
- data/lib/csspool/terms.rb +7 -0
- data/lib/csspool/visitable.rb +18 -0
- data/lib/csspool/visitors/comparable.rb +78 -0
- data/lib/csspool/visitors/to_css.rb +201 -0
- data/lib/csspool/visitors/visitor.rb +17 -0
- data/lib/csspool/visitors.rb +3 -0
- data/lib/csspool.rb +18 -1
- data/test/css/test_document.rb +13 -0
- data/test/css/test_import_rule.rb +42 -0
- data/test/helper.rb +62 -6
- data/test/sac/test_parser.rb +115 -0
- data/test/sac/test_properties.rb +43 -0
- data/test/sac/test_terms.rb +134 -0
- data/test/test_collection.rb +81 -0
- data/test/test_parser.rb +75 -241
- data/test/test_selector.rb +45 -34
- data/test/visitors/test_comparable.rb +72 -0
- data/test/visitors/test_to_css.rb +141 -0
- metadata +98 -85
- data/README.txt +0 -79
- data/lib/css/sac/conditions/attribute_condition.rb +0 -56
- data/lib/css/sac/conditions/begin_hyphen_condition.rb +0 -22
- data/lib/css/sac/conditions/class_condition.rb +0 -22
- data/lib/css/sac/conditions/combinator_condition.rb +0 -40
- data/lib/css/sac/conditions/condition.rb +0 -35
- data/lib/css/sac/conditions/id_condition.rb +0 -27
- data/lib/css/sac/conditions/one_of_condition.rb +0 -22
- data/lib/css/sac/conditions/pseudo_class_condition.rb +0 -24
- data/lib/css/sac/conditions.rb +0 -5
- data/lib/css/sac/document_handler.rb +0 -67
- data/lib/css/sac/error_handler.rb +0 -14
- data/lib/css/sac/generated_parser.rb +0 -999
- data/lib/css/sac/generated_property_parser.rb +0 -9214
- data/lib/css/sac/lexeme.rb +0 -29
- data/lib/css/sac/lexical_unit.rb +0 -203
- data/lib/css/sac/parse_exception.rb +0 -6
- data/lib/css/sac/parser.rb +0 -115
- data/lib/css/sac/property_parser.rb +0 -47
- data/lib/css/sac/selectors/child_selector.rb +0 -40
- data/lib/css/sac/selectors/conditional_selector.rb +0 -49
- data/lib/css/sac/selectors/descendant_selector.rb +0 -40
- data/lib/css/sac/selectors/element_selector.rb +0 -39
- data/lib/css/sac/selectors/selector.rb +0 -31
- data/lib/css/sac/selectors/sibling_selector.rb +0 -39
- data/lib/css/sac/selectors/simple_selector.rb +0 -25
- data/lib/css/sac/selectors.rb +0 -5
- data/lib/css/sac/token.rb +0 -27
- data/lib/css/sac/tokenizer.rb +0 -187
- data/lib/css/sac/visitable.rb +0 -106
- data/lib/css/sac.rb +0 -14
- data/lib/css/stylesheet/rule.rb +0 -20
- data/lib/css/stylesheet/stylesheet.rb +0 -96
- data/lib/css/stylesheet.rb +0 -3
- data/lib/parser.y +0 -308
- data/lib/property_parser.y +0 -2346
- data/lib/property_parser.y.erb +0 -1321
- data/test/condition_test_case.rb +0 -6
- data/test/selector_test_case.rb +0 -20
- data/test/test_all.rb +0 -4
- data/test/test_attribute_condition.rb +0 -39
- data/test/test_begin_hyphen_condition.rb +0 -15
- data/test/test_child_selector.rb +0 -60
- data/test/test_class_condition.rb +0 -15
- data/test/test_combinator_condition.rb +0 -38
- data/test/test_condition.rb +0 -31
- data/test/test_conditional_selector.rb +0 -44
- data/test/test_descendant_selector.rb +0 -64
- data/test/test_element_selector.rb +0 -31
- data/test/test_error_recovery.rb +0 -28
- data/test/test_id_condition.rb +0 -16
- data/test/test_lexeme.rb +0 -39
- data/test/test_lexical_color.rb +0 -49
- data/test/test_lexical_function.rb +0 -31
- data/test/test_lexical_ident.rb +0 -30
- data/test/test_lexical_number.rb +0 -68
- data/test/test_lexical_string.rb +0 -23
- data/test/test_lexical_unit.rb +0 -106
- data/test/test_lexical_uri.rb +0 -28
- data/test/test_one_of_condition.rb +0 -15
- data/test/test_parse_error.rb +0 -199
- data/test/test_property_parser.rb +0 -593
- data/test/test_selector_as_string.rb +0 -94
- data/test/test_selector_parser.rb +0 -178
- data/test/test_sibling_selector.rb +0 -42
- data/test/test_simple_selector.rb +0 -9
- data/test/test_specificity.rb +0 -76
- data/test/test_stylesheet.rb +0 -95
- data/test/test_token.rb +0 -24
- data/test/test_tokenizer.rb +0 -127
- data/test/test_xpath.rb +0 -105
@@ -1,593 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/helper"
|
2
|
-
|
3
|
-
class PropertyParserTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@tokenizer = CSS::SAC::Tokenizer.new()
|
6
|
-
@property_parser = CSS::SAC::PropertyParser.new()
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_error
|
10
|
-
tokens = @tokenizer.tokenize("h1 { azimuth: blahblah; }").find_all { |x|
|
11
|
-
![:LBRACE, :S].include?(x.name) &&
|
12
|
-
!['h1', '}', ':', ';'].include?(x.value)
|
13
|
-
}
|
14
|
-
assert_nil(@property_parser.parse_tokens(tokens))
|
15
|
-
end
|
16
|
-
|
17
|
-
@@valid_value_tests = {
|
18
|
-
:azimuth => {
|
19
|
-
:values => [ '10deg', 'left-side', 'far-left', 'left', 'center-left',
|
20
|
-
'right', 'far-right', 'right-side', 'behind', 'left behind',
|
21
|
-
'leftwards', 'rightwards', 'inherit'
|
22
|
-
],
|
23
|
-
:unit_types => [ :SAC_DEGREE, nil, nil, nil, nil, nil, nil, nil, nil,
|
24
|
-
[:SAC_IDENT, :SAC_IDENT], nil, nil, nil ],
|
25
|
-
},
|
26
|
-
|
27
|
-
'background-attachment' => {
|
28
|
-
:values => [ 'scroll', 'fixed', 'inherit' ],
|
29
|
-
:unit_types => [nil, nil, nil],
|
30
|
-
},
|
31
|
-
|
32
|
-
'background-color' => {
|
33
|
-
:values => ['red', '#FFFFFF', 'transparent', 'inherit'],
|
34
|
-
:unit_types => [nil, :SAC_RGBCOLOR, nil, nil ],
|
35
|
-
},
|
36
|
-
|
37
|
-
'background-image' => {
|
38
|
-
:values => [ 'url("http://example.com/test.png")', 'none', 'inherit'],
|
39
|
-
:unit_types => [ :SAC_URI, nil, nil ],
|
40
|
-
},
|
41
|
-
|
42
|
-
'background-position' => {
|
43
|
-
:values => [ '10%', '10px', 'left', 'center', 'right',
|
44
|
-
'10% 10%', '10% top', 'left center',
|
45
|
-
'center left', 'inherit'],
|
46
|
-
:unit_types => [ :SAC_PERCENTAGE, :SAC_PIXEL, nil, nil, nil,
|
47
|
-
[:SAC_PERCENTAGE, :SAC_PERCENTAGE], [:SAC_PERCENTAGE, nil], [nil,nil],
|
48
|
-
[nil, nil], nil ],
|
49
|
-
},
|
50
|
-
|
51
|
-
'background-repeat' => {
|
52
|
-
:values => ['repeat', 'repeat-x', 'repeat-y', 'no-repeat',
|
53
|
-
'inherit'],
|
54
|
-
:unit_types => [nil, nil, nil, nil, nil],
|
55
|
-
},
|
56
|
-
|
57
|
-
'background' => {
|
58
|
-
:values => ['red', 'url("http://example.com/test.png")', 'repeat',
|
59
|
-
'scroll', 'left', 'red repeat', 'repeat red'],
|
60
|
-
:unit_types => [nil, :SAC_URI, nil,
|
61
|
-
nil, nil, [nil, nil], [nil, nil]],
|
62
|
-
},
|
63
|
-
|
64
|
-
'border-collapse' => {
|
65
|
-
:values => ['collapse', 'separate', 'inherit'],
|
66
|
-
:unit_types => [nil, nil, nil],
|
67
|
-
},
|
68
|
-
|
69
|
-
'border-color' => {
|
70
|
-
:values => ['black', '#aaa', 'black red blue green', 'black red',
|
71
|
-
'black red #aaa', 'inherit'],
|
72
|
-
:unit_types => [nil, :SAC_RGBCOLOR, [nil, nil, nil, nil], [nil, nil],
|
73
|
-
[nil, nil, :SAC_RGBCOLOR], nil],
|
74
|
-
},
|
75
|
-
|
76
|
-
'border-spacing' => {
|
77
|
-
:values => ['0.5em', '10px 0.5em', 'inherit'],
|
78
|
-
:unit_types => [:SAC_EM, [:SAC_PIXEL, :SAC_EM], nil],
|
79
|
-
},
|
80
|
-
|
81
|
-
'border-style' => {
|
82
|
-
:values => ['none', 'hidden dotted', 'dashed solid groove',
|
83
|
-
'outset inset ridge double'],
|
84
|
-
:unit_types => [nil, [nil, nil], [nil, nil, nil], [nil,nil,nil,nil]],
|
85
|
-
},
|
86
|
-
|
87
|
-
[ 'border-top',
|
88
|
-
'border-right',
|
89
|
-
'border-bottom',
|
90
|
-
'border-left' ] => {
|
91
|
-
:values => ['thin', 'red', 'hidden', '10px dashed',
|
92
|
-
'medium red dashed', 'inherit'],
|
93
|
-
:unit_types => [nil, nil, nil, [:SAC_PIXEL, nil], [nil, nil, nil], nil],
|
94
|
-
},
|
95
|
-
|
96
|
-
[ 'border-top-color',
|
97
|
-
'border-right-color',
|
98
|
-
'border-bottom-color',
|
99
|
-
'border-left-color' ] => {
|
100
|
-
:values => ['#fff', 'green', 'transparent', 'inherit'],
|
101
|
-
:unit_types => [:SAC_RGBCOLOR, nil, nil, nil],
|
102
|
-
},
|
103
|
-
|
104
|
-
[ 'border-top-style',
|
105
|
-
'border-right-style',
|
106
|
-
'border-bottom-style',
|
107
|
-
'border-left-style' ] => {
|
108
|
-
:values => ['none', 'dotted', 'dashed', 'inherit'],
|
109
|
-
:unit_types => [nil, nil, nil, nil],
|
110
|
-
},
|
111
|
-
|
112
|
-
[ 'border-top-width',
|
113
|
-
'border-right-width',
|
114
|
-
'border-bottom-width',
|
115
|
-
'border-left-width' ] => {
|
116
|
-
:values => ['thin', 'medium', 'thick', '10px', 'inherit'],
|
117
|
-
:unit_types => [nil, nil, nil, :SAC_PIXEL, nil],
|
118
|
-
},
|
119
|
-
|
120
|
-
'border-width' => {
|
121
|
-
:values => ['thin', 'medium thin', 'thin medium 10px',
|
122
|
-
'thin thick 10px medium', 'inherit' ],
|
123
|
-
:unit_types => [nil, [nil, nil], [nil, nil, :SAC_PIXEL],
|
124
|
-
[nil, nil, :SAC_PIXEL, nil], nil],
|
125
|
-
},
|
126
|
-
|
127
|
-
'border' => {
|
128
|
-
:values => [ 'thin', 'thin dotted', 'thin red dotted', 'inherit'],
|
129
|
-
:unit_types => [nil, [nil, nil], [nil, nil, nil], nil]
|
130
|
-
},
|
131
|
-
|
132
|
-
'bottom' => {
|
133
|
-
:values => ['10em', '100%', 'auto', 'inherit'],
|
134
|
-
:unit_types => [:SAC_EM, :SAC_PERCENTAGE, nil, nil],
|
135
|
-
},
|
136
|
-
|
137
|
-
'caption-side' => {
|
138
|
-
:values => ['top', 'bottom', 'inherit'],
|
139
|
-
:unit_types => [nil, nil, nil],
|
140
|
-
},
|
141
|
-
|
142
|
-
'clear' => {
|
143
|
-
:values => ['none', 'left', 'right', 'both', 'inherit'],
|
144
|
-
:unit_types => [nil, nil, nil, nil, nil],
|
145
|
-
},
|
146
|
-
|
147
|
-
'clip' => {
|
148
|
-
:values => ['auto', 'rect(5px, 40px, 45px, 5px)', 'inherit'],
|
149
|
-
:unit_types => [nil, :SAC_RECT_FUNCTION, nil],
|
150
|
-
},
|
151
|
-
|
152
|
-
'color' => {
|
153
|
-
:values => ['aqua', 'black', 'blue', 'fuchsia', 'gray', 'green', 'lime',
|
154
|
-
'maroon', 'navy', 'olive', 'orange', 'purple', 'red', 'silver',
|
155
|
-
'teal', 'white', 'yellow', '#f00', '#aabbcc'],
|
156
|
-
:unit_types => [nil, nil, nil, nil, nil, nil, nil,
|
157
|
-
nil, nil, nil, nil, nil, nil, nil,
|
158
|
-
nil, nil, nil, :SAC_RGBCOLOR, :SAC_RGBCOLOR],
|
159
|
-
},
|
160
|
-
|
161
|
-
'content' => {
|
162
|
-
:values => ['normal', 'none', '"test"', 'open-quote "foo"',
|
163
|
-
'url("http://example.com/test.png")', 'inherit', 'attr(foo)'],
|
164
|
-
:unit_types => [nil, nil, :SAC_STRING_VALUE, [nil, :SAC_STRING_VALUE],
|
165
|
-
:SAC_URI, nil, :SAC_FUNCTION],
|
166
|
-
},
|
167
|
-
|
168
|
-
[ 'counter-increment',
|
169
|
-
'counter-reset' ] => {
|
170
|
-
:values => ['foo 10', 'foo', 'none', 'foo 10 bar 20','inherit'],
|
171
|
-
:unit_types => [[nil, :SAC_INTEGER], nil, nil,
|
172
|
-
[nil, :SAC_INTEGER, nil, :SAC_INTEGER], nil],
|
173
|
-
},
|
174
|
-
|
175
|
-
[ 'cue-after',
|
176
|
-
'cue-before' ] => {
|
177
|
-
:values => ['none', 'url("http://tenderlovemaking.com")',
|
178
|
-
'inherit'],
|
179
|
-
:unit_types => [nil, :SAC_URI, nil],
|
180
|
-
},
|
181
|
-
|
182
|
-
'cue' => {
|
183
|
-
:values => ['none url("http://tenderlovemaking.com")', 'none', 'inherit'],
|
184
|
-
:unit_types => [[nil, :SAC_URI], nil, nil],
|
185
|
-
},
|
186
|
-
|
187
|
-
'cursor' => {
|
188
|
-
:values => [ 'url("http://tenderlovemaking.com"), url("http://tenderlovemaking.com") auto', 'inherit' ] +
|
189
|
-
[
|
190
|
-
'auto', 'crosshair', 'default', 'pointer', 'move',
|
191
|
-
'e-resize', 'ne-resize', 'nw-resize', 'n-resize',
|
192
|
-
'se-resize', 'sw-resize', 's-resize', 'w-resize', 'text',
|
193
|
-
'wait', 'help', 'progress' ].map { |x|
|
194
|
-
"url(\"http://tenderlovemaking.com/\") #{x}"
|
195
|
-
},
|
196
|
-
:unit_types => [[:SAC_URI, :SAC_URI, nil], nil] + [[:SAC_URI, nil]] * 17,
|
197
|
-
},
|
198
|
-
|
199
|
-
'direction' => {
|
200
|
-
:values => [ 'ltr', 'rtl', 'inherit' ],
|
201
|
-
:unit_types => [nil, nil, nil],
|
202
|
-
},
|
203
|
-
|
204
|
-
'display' => {
|
205
|
-
:values => [ 'inline', 'block', 'list-item', 'run-in', 'inline-block',
|
206
|
-
'table', 'inline-table', 'table-row-group',
|
207
|
-
'table-header-group', 'table-footer-group', 'table-row',
|
208
|
-
'table-column-group', 'table-column', 'table-cell',
|
209
|
-
'table-caption', 'none', 'inherit' ],
|
210
|
-
:unit_types => [nil] * 17,
|
211
|
-
},
|
212
|
-
|
213
|
-
'elevation' => {
|
214
|
-
:values => ['98deg', 'below', 'level', 'above', 'higher', 'lower',
|
215
|
-
'inherit'],
|
216
|
-
:unit_types => [:SAC_DEGREE] + [nil] * 6,
|
217
|
-
},
|
218
|
-
|
219
|
-
'empty-cells' => {
|
220
|
-
:values => ['show', 'hide', 'inherit'],
|
221
|
-
:unit_types => [nil, nil, nil],
|
222
|
-
},
|
223
|
-
|
224
|
-
'float' => {
|
225
|
-
:values => ['left', 'right', 'none', 'inherit'],
|
226
|
-
:unit_types => [nil, nil, nil, nil],
|
227
|
-
},
|
228
|
-
|
229
|
-
'font-family' => {
|
230
|
-
:values => ['Gill', 'Gill, serif', '"Aaron P", sans-serif',
|
231
|
-
'serif, sans-serif', 'serif', 'sans-serif', 'cursive',
|
232
|
-
'fantasy', 'monospace', 'inherit' ],
|
233
|
-
:unit_types => [nil, [nil, nil], [:SAC_STRING_VALUE, nil], [nil, nil],
|
234
|
-
nil, nil],
|
235
|
-
},
|
236
|
-
|
237
|
-
'font-size' => {
|
238
|
-
:values => ['xx-small', 'x-small', 'small', 'medium', 'large',
|
239
|
-
'x-large', 'xx-large', 'larger', 'smaller', '10in',
|
240
|
-
'50%', 'inherit'],
|
241
|
-
:unit_types => [nil] * 9 + [:SAC_INCH, :SAC_PERCENTAGE, nil]
|
242
|
-
},
|
243
|
-
|
244
|
-
'font-style' => {
|
245
|
-
:values => ['normal', 'italic', 'oblique', 'inherit'],
|
246
|
-
:unit_types => [nil] * 4,
|
247
|
-
},
|
248
|
-
|
249
|
-
'font-variant'=> {
|
250
|
-
:values => ['normal', 'small-caps', 'inherit'],
|
251
|
-
:unit_types => [nil] * 3,
|
252
|
-
},
|
253
|
-
|
254
|
-
'font-weight' => {
|
255
|
-
:values => ['normal', 'bold', 'bolder', 'lighter', '100', '200',
|
256
|
-
'300', '400', '500', '600', '700', '800', '900',
|
257
|
-
'inherit'],
|
258
|
-
:unit_types => ([nil] * 4) + ([:SAC_INTEGER] * 9) + [nil],
|
259
|
-
},
|
260
|
-
|
261
|
-
'font' => {
|
262
|
-
:values => ['x-large/110% "New Century Schoolbook", serif',
|
263
|
-
'12px/14px sans-serif', 'message-box', 'small-caption',
|
264
|
-
'80% sans-serif', 'caption', 'icon', 'menu',
|
265
|
-
'bold italic large Palatino, serif', 'status-bar',
|
266
|
-
'normal small-caps 120%/120% fantasy',
|
267
|
-
],
|
268
|
-
:unit_types => [[nil, :SAC_PERCENTAGE, :SAC_STRING_VALUE, nil],
|
269
|
-
[:SAC_PIXEL, :SAC_PIXEL, nil], nil, nil,
|
270
|
-
[:SAC_PERCENTAGE, nil], nil, nil, nil,
|
271
|
-
[nil] * 5, nil, [nil, nil, :SAC_PERCENTAGE, :SAC_PERCENTAGE, nil]],
|
272
|
-
},
|
273
|
-
|
274
|
-
['height','left','right','top'] => {
|
275
|
-
:values => ['100px', '100%', 'auto', 'inherit'],
|
276
|
-
:unit_types => [:SAC_PIXEL, :SAC_PERCENTAGE, nil, nil ],
|
277
|
-
},
|
278
|
-
|
279
|
-
'letter-spacing' => {
|
280
|
-
:values => ['normal', '100em', 'inherit'],
|
281
|
-
:unit_types => [nil, :SAC_EM, nil ],
|
282
|
-
},
|
283
|
-
|
284
|
-
'line-height' => {
|
285
|
-
:values => ['normal', '55', '100px', '49%', 'inherit'],
|
286
|
-
:unit_types => [nil, :SAC_INTEGER, :SAC_PIXEL, :SAC_PERCENTAGE, nil],
|
287
|
-
},
|
288
|
-
|
289
|
-
'list-style-image' => {
|
290
|
-
:values => ['url("http://tenderlovemaking.com")', 'none',
|
291
|
-
'inherit'],
|
292
|
-
:unit_types => [ :SAC_URI, nil, nil ]
|
293
|
-
},
|
294
|
-
|
295
|
-
'list-style-position' => {
|
296
|
-
:values => ['inside', 'outside', 'inherit'],
|
297
|
-
:unit_types => [nil, nil, nil],
|
298
|
-
},
|
299
|
-
|
300
|
-
'list-style-type' => {
|
301
|
-
:values => ['disc', 'circle', 'square', 'decimal',
|
302
|
-
'decimal-leading-zero', 'lower-roman', 'upper-roman',
|
303
|
-
'lower-greek', 'lower-latin', 'upper-latin',
|
304
|
-
'armenian', 'georgian', 'lower-alpha', 'upper-alpha',
|
305
|
-
'none', 'inherit'],
|
306
|
-
:unit_types => [nil] * 16,
|
307
|
-
},
|
308
|
-
|
309
|
-
'list-style' => {
|
310
|
-
:values => ['disc', 'inside', 'url("http://tenderlovemaking.com")',
|
311
|
-
'disc url("http://tenderlovemaking.com") inside',
|
312
|
-
'inherit'],
|
313
|
-
:unit_types => [nil, nil, :SAC_URI, [nil, :SAC_URI, nil], nil],
|
314
|
-
},
|
315
|
-
|
316
|
-
[ 'margin-right',
|
317
|
-
'margin-left',
|
318
|
-
'margin-top',
|
319
|
-
'margin-bottom' ] => {
|
320
|
-
:values => ['100px', '50%', 'auto' ],
|
321
|
-
:unit_types => [:SAC_PIXEL, :SAC_PERCENTAGE, nil],
|
322
|
-
},
|
323
|
-
|
324
|
-
'margin' => {
|
325
|
-
:values => ['auto', '100px', '50%', 'auto 100px', '100px 54% auto',
|
326
|
-
'auto 100px 90px 85px'],
|
327
|
-
:unit_types => [nil, :SAC_PIXEL, :SAC_PERCENTAGE, [nil, :SAC_PIXEL],
|
328
|
-
[:SAC_PIXEL, :SAC_PERCENTAGE, nil],
|
329
|
-
[nil, :SAC_PIXEL, :SAC_PIXEL, :SAC_PIXEL]],
|
330
|
-
},
|
331
|
-
|
332
|
-
[ 'max-height',
|
333
|
-
'max-width' ] => {
|
334
|
-
:values => ['10px', '60%', 'none', 'inherit'],
|
335
|
-
:unit_types => [:SAC_PIXEL, :SAC_PERCENTAGE, nil, nil],
|
336
|
-
},
|
337
|
-
|
338
|
-
[ 'min-height',
|
339
|
-
'min-width' ] => {
|
340
|
-
:values => ['10px', '60%', 'inherit'],
|
341
|
-
:unit_types => [:SAC_PIXEL, :SAC_PERCENTAGE, nil],
|
342
|
-
},
|
343
|
-
|
344
|
-
'orphans' => {
|
345
|
-
:values => ['1000', 'inherit'],
|
346
|
-
:unit_types => [:SAC_INTEGER, nil],
|
347
|
-
},
|
348
|
-
|
349
|
-
'outline-color' => {
|
350
|
-
:values => ['red', '#ddd', '#ab12ff', 'invert', 'inherit'],
|
351
|
-
:unit_types => [nil, :SAC_RGBCOLOR, :SAC_RGBCOLOR, nil, nil]
|
352
|
-
},
|
353
|
-
|
354
|
-
'outline-style' => {
|
355
|
-
:values => ['none', 'hidden', 'dotted', 'dashed', 'solid', 'double',
|
356
|
-
'groove', 'ridge', 'inset', 'outset', 'inherit'],
|
357
|
-
:unit_types => [nil] * 11,
|
358
|
-
},
|
359
|
-
|
360
|
-
'outline-width' => {
|
361
|
-
:values => ['thin', 'thick', 'medium', '100in'],
|
362
|
-
:unit_types => [nil, nil, nil, :SAC_INCH],
|
363
|
-
},
|
364
|
-
|
365
|
-
'outline' => {
|
366
|
-
:values => ['red', 'hidden', '100in', 'hidden 100in red', 'hidden red',
|
367
|
-
'100in red', 'inherit'],
|
368
|
-
:unit_types => [nil, nil, :SAC_INCH, [nil, :SAC_INCH, nil], [nil, nil],
|
369
|
-
[:SAC_INCH, nil], nil],
|
370
|
-
},
|
371
|
-
|
372
|
-
'overflow' => {
|
373
|
-
:values => ['visible', 'hidden', 'scroll', 'auto', 'inherit'],
|
374
|
-
:unit_types => [nil] * 5,
|
375
|
-
},
|
376
|
-
|
377
|
-
[ 'padding-top',
|
378
|
-
'padding-right',
|
379
|
-
'padding-bottom',
|
380
|
-
'padding-left' ] => {
|
381
|
-
:values => [ '100in', '100%', 'inherit' ],
|
382
|
-
:unit_types => [ :SAC_INCH, :SAC_PERCENTAGE, nil],
|
383
|
-
},
|
384
|
-
|
385
|
-
'padding' => {
|
386
|
-
:values => ['100in', '100in 100%', '2em 4in 5ex', '1ex 100% 5% 2%',
|
387
|
-
'inherit' ],
|
388
|
-
:unit_types => [:SAC_INCH, [:SAC_INCH, :SAC_PERCENTAGE],
|
389
|
-
[:SAC_EM, :SAC_INCH, :SAC_EX],
|
390
|
-
[:SAC_EX, :SAC_PERCENTAGE, :SAC_PERCENTAGE, :SAC_PERCENTAGE], nil ],
|
391
|
-
},
|
392
|
-
|
393
|
-
[ 'page-break-after',
|
394
|
-
'page-break-before' ] => {
|
395
|
-
:values => ['auto', 'always', 'avoid', 'left', 'right',
|
396
|
-
'inherit'],
|
397
|
-
:unit_types => [nil] * 6,
|
398
|
-
},
|
399
|
-
|
400
|
-
'page-break-inside' => {
|
401
|
-
:values => ['avoid', 'auto', 'inherit'],
|
402
|
-
:unit_types => [nil] * 3,
|
403
|
-
},
|
404
|
-
|
405
|
-
[ 'pause-after',
|
406
|
-
'pause-before' ] => {
|
407
|
-
:values => ['123ms', '321s', '10%', 'inherit'],
|
408
|
-
:unit_types => [:SAC_MILLISECOND, :SAC_SECOND, :SAC_PERCENTAGE, nil],
|
409
|
-
},
|
410
|
-
|
411
|
-
'pause' => {
|
412
|
-
:values => ['10ms 19%', '10s 10ms', '10ms', 'inherit' ],
|
413
|
-
:unit_types => [[:SAC_MILLISECOND, :SAC_PERCENTAGE],
|
414
|
-
[:SAC_SECOND, :SAC_MILLISECOND], :SAC_MILLISECOND, nil],
|
415
|
-
},
|
416
|
-
|
417
|
-
'pitch-range' => {
|
418
|
-
:values => ['1000', 'inherit'],
|
419
|
-
:unit_types => [:SAC_INTEGER, nil],
|
420
|
-
},
|
421
|
-
|
422
|
-
'pitch' => {
|
423
|
-
:values => ['10Hz', '100kHz', 'x-low', 'low', 'medium', 'high', 'x-high',
|
424
|
-
'inherit'],
|
425
|
-
:unit_types => [:SAC_HERTZ, :SAC_KILOHERTZ] + [nil] * 6,
|
426
|
-
},
|
427
|
-
|
428
|
-
'play-during' => {
|
429
|
-
:values => ['url("http://tenderlovemaking.com/")',
|
430
|
-
'url("http://tenderlovemaking.com/") mix',
|
431
|
-
'url("http://tenderlovemaking.com/") repeat mix',
|
432
|
-
'auto', 'none', 'inherit'],
|
433
|
-
:unit_types => [:SAC_URI, [:SAC_URI, nil], [:SAC_URI, nil, nil],
|
434
|
-
nil, nil, nil],
|
435
|
-
},
|
436
|
-
|
437
|
-
'position' => {
|
438
|
-
:values => ['static', 'relative', 'absolute', 'fixed', 'inherit'],
|
439
|
-
:unit_types => [nil] * 5,
|
440
|
-
},
|
441
|
-
|
442
|
-
'quotes' => {
|
443
|
-
:values => ['"one" "two"', 'none', 'inherit'],
|
444
|
-
:unit_types => [[:SAC_STRING_VALUE, :SAC_STRING_VALUE], nil, nil],
|
445
|
-
},
|
446
|
-
|
447
|
-
'richness' => {
|
448
|
-
:values => ['1000', 'inherit'],
|
449
|
-
:unit_types => [:SAC_INTEGER, nil],
|
450
|
-
},
|
451
|
-
|
452
|
-
'speak-header' => {
|
453
|
-
:values => ['once', 'always', 'inherit'],
|
454
|
-
:unit_types => [nil] * 3,
|
455
|
-
},
|
456
|
-
|
457
|
-
'speak-numeral' => {
|
458
|
-
:values => ['digits', 'continuous', 'inherit'],
|
459
|
-
:unit_types => [nil] * 3,
|
460
|
-
},
|
461
|
-
|
462
|
-
'speak-punctuation' => {
|
463
|
-
:values => ['code', 'none', 'inherit'],
|
464
|
-
:unit_types => [nil] * 3,
|
465
|
-
},
|
466
|
-
|
467
|
-
'speak' => {
|
468
|
-
:values => ['normal', 'none', 'spell-out', 'inherit'],
|
469
|
-
:unit_types => [nil] * 4,
|
470
|
-
},
|
471
|
-
|
472
|
-
'speech-rate' => {
|
473
|
-
:values => ['1000', 'x-slow', 'slow', 'medium', 'fast', 'x-fast',
|
474
|
-
'faster', 'slower', 'inherit'],
|
475
|
-
:unit_types => [:SAC_INTEGER] + [nil] * 8,
|
476
|
-
},
|
477
|
-
|
478
|
-
'stress' => {
|
479
|
-
:values => ['69', 'inherit'],
|
480
|
-
:unit_types => [:SAC_INTEGER, nil],
|
481
|
-
},
|
482
|
-
|
483
|
-
'table-layout' => {
|
484
|
-
:values => ['auto', 'fixed', 'inherit'],
|
485
|
-
:unit_types => [nil] * 3,
|
486
|
-
},
|
487
|
-
|
488
|
-
'text-align' => {
|
489
|
-
:values => ['left', 'right', 'center', 'justify', 'inherit'],
|
490
|
-
:unit_types => [nil] * 5,
|
491
|
-
},
|
492
|
-
|
493
|
-
'text-decoration' => {
|
494
|
-
:values => ['none', 'underline', 'overline underline',
|
495
|
-
'blink line-through underline',
|
496
|
-
'underline blink overline line-through', 'inherit'],
|
497
|
-
:unit_types => [nil, nil, [nil, nil], [nil, nil, nil],
|
498
|
-
[nil, nil, nil, nil], nil],
|
499
|
-
},
|
500
|
-
|
501
|
-
'text-indent' => {
|
502
|
-
:values => ['69in', '69%', 'inherit'],
|
503
|
-
:unit_types => [:SAC_INCH, :SAC_PERCENTAGE, nil],
|
504
|
-
},
|
505
|
-
|
506
|
-
'text-transform' => {
|
507
|
-
:values => ['capitalize', 'uppercase', 'lowercase', 'none', 'inherit'],
|
508
|
-
:unit_types => [nil] * 5,
|
509
|
-
},
|
510
|
-
|
511
|
-
'unicode-bidi' => {
|
512
|
-
:values => ['normal', 'embed', 'bidi-override', 'inherit'],
|
513
|
-
:unit_types => [nil] * 4,
|
514
|
-
},
|
515
|
-
|
516
|
-
'vertical-align' => {
|
517
|
-
:values => ['baseline', 'sub', 'super', 'top', 'text-top',
|
518
|
-
'middle', 'bottom', 'text-bottom', '70%', '100in',
|
519
|
-
'inherit'],
|
520
|
-
:unit_types => ([nil] * 8) + [:SAC_PERCENTAGE, :SAC_INCH, nil],
|
521
|
-
},
|
522
|
-
|
523
|
-
'visibility' => {
|
524
|
-
:values => ['visible', 'hidden', 'collapse', 'inherit'],
|
525
|
-
:unit_types => [nil] * 4,
|
526
|
-
},
|
527
|
-
|
528
|
-
'voice-family' => {
|
529
|
-
:values => ['romeo, male', 'juliet, female', 'male', 'male, female',
|
530
|
-
'inherit'],
|
531
|
-
:unit_types => [[nil, nil], [nil, nil], nil, [nil, nil], nil],
|
532
|
-
},
|
533
|
-
|
534
|
-
'volume' => {
|
535
|
-
:values => ['10', '10%', 'silent', 'x-soft', 'soft', 'medium', 'loud',
|
536
|
-
'x-loud', 'inherit'],
|
537
|
-
:unit_types => [:SAC_INTEGER, :SAC_PERCENTAGE] + ([nil] * 7),
|
538
|
-
},
|
539
|
-
|
540
|
-
'white-space' => {
|
541
|
-
:values => ['normal', 'pre', 'nowrap', 'pre-wrap', 'pre-line', 'inherit'],
|
542
|
-
:unit_types => [nil] * 6,
|
543
|
-
},
|
544
|
-
|
545
|
-
'windows' => {
|
546
|
-
:values => ['169', 'inherit'],
|
547
|
-
:unit_types => [:SAC_INTEGER, nil],
|
548
|
-
},
|
549
|
-
|
550
|
-
'width' => {
|
551
|
-
:values => ['100em', '50%', 'auto', 'inherit'],
|
552
|
-
:unit_types => [:SAC_EM, :SAC_PERCENTAGE, nil, nil],
|
553
|
-
},
|
554
|
-
|
555
|
-
'word-spacing' => {
|
556
|
-
:values => ['normal', '10in', 'inherit'],
|
557
|
-
:unit_types => [nil, :SAC_INCH, nil],
|
558
|
-
},
|
559
|
-
|
560
|
-
'z-index' => {
|
561
|
-
:values => ['auto', '10', 'inherit'],
|
562
|
-
:unit_types => [nil, :SAC_INTEGER, nil],
|
563
|
-
},
|
564
|
-
}
|
565
|
-
|
566
|
-
@@valid_value_tests.each do |k,v|
|
567
|
-
[k].flatten.each do |key|
|
568
|
-
define_method :"test_valid_#{key.to_s.gsub(/-/, '_')}" do
|
569
|
-
v[:values].each_with_index do |value, i|
|
570
|
-
tok = @tokenizer.tokenize("#{key}: #{value}")
|
571
|
-
result = @property_parser.parse_tokens(tok)
|
572
|
-
if result.nil?
|
573
|
-
p tok
|
574
|
-
end
|
575
|
-
assert_not_nil(result)
|
576
|
-
|
577
|
-
unit_types = [v[:unit_types][i] || :SAC_IDENT].flatten.map { |x|
|
578
|
-
x || :SAC_IDENT
|
579
|
-
}
|
580
|
-
result_types = [result].flatten.map { |x| x.lexical_unit_type }
|
581
|
-
result_strings = [result].flatten.map { |x| x.to_s }
|
582
|
-
|
583
|
-
assert_equal(unit_types, result_types, tok.inspect)
|
584
|
-
assert(result_strings.length > 0)
|
585
|
-
result_strings.each do |rs|
|
586
|
-
assert(rs)
|
587
|
-
assert_match(rs, value)
|
588
|
-
end
|
589
|
-
end
|
590
|
-
end
|
591
|
-
end
|
592
|
-
end
|
593
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/helper"
|
2
|
-
|
3
|
-
class SelectorAsStringTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@sac = CSS::SAC::Parser.new()
|
6
|
-
class << @sac.document_handler
|
7
|
-
attr_accessor :selectors
|
8
|
-
def start_selector(selectors)
|
9
|
-
@selectors = selectors
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_equal2
|
15
|
-
@sac.parse('h1 > h2 { }')
|
16
|
-
selectors = @sac.document_handler.selectors
|
17
|
-
@sac.document_handler.selectors = []
|
18
|
-
|
19
|
-
@sac.parse('h1 > h2 { }')
|
20
|
-
selectors2 = @sac.document_handler.selectors
|
21
|
-
|
22
|
-
assert_equal selectors, selectors2
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_any_node_selector
|
26
|
-
@sac.parse('* { }')
|
27
|
-
selectors = @sac.document_handler.selectors
|
28
|
-
assert_equal(1, selectors.length)
|
29
|
-
assert_equal('*', selectors.first.to_css)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_element_node_selector
|
33
|
-
@sac.parse('h1 { }')
|
34
|
-
selectors = @sac.document_handler.selectors
|
35
|
-
assert_equal(1, selectors.length)
|
36
|
-
assert_equal('h1', selectors.first.to_css)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_element_node_conditional_selector
|
40
|
-
@sac.parse('h1.awesome { }')
|
41
|
-
selectors = @sac.document_handler.selectors
|
42
|
-
assert_equal(1, selectors.length)
|
43
|
-
assert_equal('h1.awesome', selectors.first.to_css)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_element_node_conditional
|
47
|
-
@sac.parse('.awesome { }')
|
48
|
-
selectors = @sac.document_handler.selectors
|
49
|
-
assert_equal(1, selectors.length)
|
50
|
-
assert_equal('.awesome', selectors.first.to_css)
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_element_node_conditional_selector_id
|
54
|
-
@sac.parse('h1#awesome { }')
|
55
|
-
selectors = @sac.document_handler.selectors
|
56
|
-
assert_equal(1, selectors.length)
|
57
|
-
assert_equal('h1#awesome', selectors.first.to_css)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_selector_attribute
|
61
|
-
@sac.parse('h1[class=foo] { }')
|
62
|
-
selectors = @sac.document_handler.selectors
|
63
|
-
assert_equal(1, selectors.length)
|
64
|
-
assert_equal('h1[class=foo]', selectors.first.to_css)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_combinator_selector
|
68
|
-
@sac.parse('h1[class=foo].aaron { }')
|
69
|
-
selectors = @sac.document_handler.selectors
|
70
|
-
assert_equal(1, selectors.length)
|
71
|
-
assert_equal('h1[class=foo].aaron', selectors.first.to_css)
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_descendant_selectors
|
75
|
-
@sac.parse('div h1 { }')
|
76
|
-
selectors = @sac.document_handler.selectors
|
77
|
-
assert_equal(1, selectors.length)
|
78
|
-
assert_equal('div h1', selectors.first.to_css)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_direct_descendant_selectors
|
82
|
-
@sac.parse('div > h1 { }')
|
83
|
-
selectors = @sac.document_handler.selectors
|
84
|
-
assert_equal(1, selectors.length)
|
85
|
-
assert_equal('div > h1', selectors.first.to_css)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_direct_sibling_selectors
|
89
|
-
@sac.parse('div + h1 { }')
|
90
|
-
selectors = @sac.document_handler.selectors
|
91
|
-
assert_equal(1, selectors.length)
|
92
|
-
assert_equal('div + h1', selectors.first.to_css)
|
93
|
-
end
|
94
|
-
end
|