/[suikacvs]/test/html-webhacc/WebHACC/Language/CSS.pm
Suika

Contents of /test/html-webhacc/WebHACC/Language/CSS.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Sat Aug 16 08:37:12 2008 UTC (17 years, 10 months ago) by wakaba
Branch: MAIN
Changes since 1.8: +21 -15 lines
++ ChangeLog	16 Aug 2008 08:36:07 -0000
	* error-description-source.xml: Error for CSS cursor: hand
	is added.

2008-08-16  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/Language/ChangeLog	16 Aug 2008 08:37:07 -0000
	* CSS.pm (generate_structure_error_section): Make the method
	do nothing.

2008-08-16  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/ChangeLog	16 Aug 2008 08:36:35 -0000
	* Output.pm (nl_text): We can finally get rid of a quirk.

2008-08-16  Wakaba  <wakaba@suika.fam.cx>

1 package WebHACC::Language::CSS;
2 use strict;
3 require WebHACC::Language::Base;
4 push our @ISA, 'WebHACC::Language::Base';
5
6 sub new ($) {
7 my $self = bless {}, shift;
8 return $self;
9 } # new
10
11 sub generate_syntax_error_section ($) {
12 my $self = shift;
13
14 my $out = $self->output;
15
16 $self->result->layer_uncertain ('charset');
17
18 $out->start_section (role => 'parse-errors');
19 $out->start_error_list (role => 'parse-errors');
20 $self->result->layer_applicable ('syntax');
21
22 my $input = $self->input;
23 my $result = $self->result;
24
25 my $p = $self->get_css_parser ();
26 $p->init;
27 $p->{onerror} = sub {
28 my (%opt) = @_;
29 if (not defined $opt{value} and defined $opt{token}) {
30 $opt{value} = Whatpm::CSS::Tokenizer->serialize_token ($opt{token});
31 }
32 $result->add_error (%opt, layer => 'syntax');
33 };
34 $p->{href} = $input->url;
35 $p->{base_uri} = $input->{base_uri};
36
37 # if ($parse_mode eq 'q') {
38 # $p->{unitless_px} = 1;
39 # $p->{hashless_color} = 1;
40 # }
41
42 ## TODO: Make $input->{s} a ref.
43
44 my $s = \$input->{s};
45 my $charset;
46 unless ($input->{is_char_string}) {
47 $self->result->layer_uncertain ('encode');
48 require Encode;
49 if (defined $input->{charset}) {## TODO: IANA->Perl
50 $charset = $input->{charset};
51 $s = \(Encode::decode ($input->{charset}, $$s));
52 } else {
53 ## TODO: charset detection
54 $s = \(Encode::decode ($charset = 'utf-8', $$s));
55 }
56 }
57
58 $self->{structure} = $p->parse_char_string ($$s);
59 $self->{structure}->manakai_input_encoding ($charset) if defined $charset;
60
61 $out->end_error_list (role => 'parse-errors');
62 $out->end_section;
63 } # generate_syntax_error_section
64
65 sub source_charset ($) {
66 return shift->{structure}->manakai_input_encoding;
67 } # source_charset
68
69 sub generate_structure_dump_section ($) {
70 my $self = shift;
71
72 my $out = $self->output;
73
74 $out->start_section (role => 'reformatted');
75
76 $out->start_code_block;
77 $out->text ($self->{structure}->css_text);
78 $out->end_code_block;
79
80 $out->end_section;
81 } # generate_structure_dump_section
82
83 sub generate_structure_error_section ($) {
84 ## NOTE: The content of this method is commented out, since a CSSOM
85 ## tree would contain no error that affect conformance, AFAICT.
86 ## The plan is that we could someday implement "semantic" checking for CSSOM
87 ## trees, like "this color and this background color is too resemble such that
88 ## a user might not be able to read the text". Such errors do not affect
89 ## conformance, in any way.
90 # my $self = shift;
91 #
92 # my $out = $self->output;
93 #
94 # $out->start_section (role => 'structure-errors');
95 # $out->start_error_list (role => 'structure-errors');
96 # $self->result->layer_applicable ('structure');
97 #
98 # $self->result->add_error (level => 'u',
99 # layer => 'structure',
100 # input => $self->input,
101 # type => 'CSSOM validation not supported');
102 #
103 # $out->end_error_list (role => 'structure-errors');
104 # $out->end_section;
105 } # generate_structure_error_section
106
107 sub get_css_parser () {
108 our $CSSParser;
109 return $CSSParser if $CSSParser;
110
111 require Whatpm::CSS::Parser;
112 my $p = Whatpm::CSS::Parser->new;
113
114 $p->{prop}->{$_} = 1 for qw/
115 alignment-baseline
116 background background-attachment background-color background-image
117 background-position background-position-x background-position-y
118 background-repeat border border-bottom border-bottom-color
119 border-bottom-style border-bottom-width border-collapse border-color
120 border-left border-left-color
121 border-left-style border-left-width border-right border-right-color
122 border-right-style border-right-width
123 border-spacing -manakai-border-spacing-x -manakai-border-spacing-y
124 border-style border-top border-top-color border-top-style border-top-width
125 border-width bottom
126 caption-side clear clip color content counter-increment counter-reset
127 cursor direction display dominant-baseline empty-cells float font
128 font-family font-size font-size-adjust font-stretch
129 font-style font-variant font-weight height left
130 letter-spacing line-height
131 list-style list-style-image list-style-position list-style-type
132 margin margin-bottom margin-left margin-right margin-top marker-offset
133 marks max-height max-width min-height min-width opacity -moz-opacity
134 orphans outline outline-color outline-style outline-width overflow
135 overflow-x overflow-y
136 padding padding-bottom padding-left padding-right padding-top
137 page page-break-after page-break-before page-break-inside
138 position quotes right size table-layout
139 text-align text-anchor text-decoration text-indent text-transform
140 top unicode-bidi vertical-align visibility white-space width widows
141 word-spacing writing-mode z-index
142 /;
143 $p->{prop_value}->{display}->{$_} = 1 for qw/
144 block clip inline inline-block inline-table list-item none
145 table table-caption table-cell table-column table-column-group
146 table-header-group table-footer-group table-row table-row-group
147 compact marker
148 /;
149 $p->{prop_value}->{position}->{$_} = 1 for qw/
150 absolute fixed relative static
151 /;
152 $p->{prop_value}->{float}->{$_} = 1 for qw/
153 left right none
154 /;
155 $p->{prop_value}->{clear}->{$_} = 1 for qw/
156 left right none both
157 /;
158 $p->{prop_value}->{direction}->{ltr} = 1;
159 $p->{prop_value}->{direction}->{rtl} = 1;
160 $p->{prop_value}->{marks}->{crop} = 1;
161 $p->{prop_value}->{marks}->{cross} = 1;
162 $p->{prop_value}->{'unicode-bidi'}->{$_} = 1 for qw/
163 normal bidi-override embed
164 /;
165 for my $prop_name (qw/overflow overflow-x overflow-y/) {
166 $p->{prop_value}->{$prop_name}->{$_} = 1 for qw/
167 visible hidden scroll auto -webkit-marquee -moz-hidden-unscrollable
168 /;
169 }
170 $p->{prop_value}->{visibility}->{$_} = 1 for qw/
171 visible hidden collapse
172 /;
173 $p->{prop_value}->{'list-style-type'}->{$_} = 1 for qw/
174 disc circle square decimal decimal-leading-zero
175 lower-roman upper-roman lower-greek lower-latin
176 upper-latin armenian georgian lower-alpha upper-alpha none
177 hebrew cjk-ideographic hiragana katakana hiragana-iroha
178 katakana-iroha
179 /;
180 $p->{prop_value}->{'list-style-position'}->{outside} = 1;
181 $p->{prop_value}->{'list-style-position'}->{inside} = 1;
182 $p->{prop_value}->{'page-break-before'}->{$_} = 1 for qw/
183 auto always avoid left right
184 /;
185 $p->{prop_value}->{'page-break-after'}->{$_} = 1 for qw/
186 auto always avoid left right
187 /;
188 $p->{prop_value}->{'page-break-inside'}->{auto} = 1;
189 $p->{prop_value}->{'page-break-inside'}->{avoid} = 1;
190 $p->{prop_value}->{'background-repeat'}->{$_} = 1 for qw/
191 repeat repeat-x repeat-y no-repeat
192 /;
193 $p->{prop_value}->{'background-attachment'}->{scroll} = 1;
194 $p->{prop_value}->{'background-attachment'}->{fixed} = 1;
195 $p->{prop_value}->{'font-size'}->{$_} = 1 for qw/
196 xx-small x-small small medium large x-large xx-large
197 -manakai-xxx-large -webkit-xxx-large
198 larger smaller
199 /;
200 $p->{prop_value}->{'font-style'}->{normal} = 1;
201 $p->{prop_value}->{'font-style'}->{italic} = 1;
202 $p->{prop_value}->{'font-style'}->{oblique} = 1;
203 $p->{prop_value}->{'font-variant'}->{normal} = 1;
204 $p->{prop_value}->{'font-variant'}->{'small-caps'} = 1;
205 $p->{prop_value}->{'font-stretch'}->{$_} = 1 for
206 qw/normal wider narrower ultra-condensed extra-condensed
207 condensed semi-condensed semi-expanded expanded
208 extra-expanded ultra-expanded/;
209 $p->{prop_value}->{'text-align'}->{$_} = 1 for qw/
210 left right center justify begin end
211 /;
212 $p->{prop_value}->{'text-transform'}->{$_} = 1 for qw/
213 capitalize uppercase lowercase none
214 /;
215 $p->{prop_value}->{'white-space'}->{$_} = 1 for qw/
216 normal pre nowrap pre-line pre-wrap -moz-pre-wrap
217 /;
218 $p->{prop_value}->{'writing-mode'}->{$_} = 1 for qw/
219 lr rl tb lr-tb rl-tb tb-rl
220 /;
221 $p->{prop_value}->{'text-anchor'}->{$_} = 1 for qw/
222 start middle end
223 /;
224 $p->{prop_value}->{'dominant-baseline'}->{$_} = 1 for qw/
225 auto use-script no-change reset-size ideographic alphabetic
226 hanging mathematical central middle text-after-edge text-before-edge
227 /;
228 $p->{prop_value}->{'alignment-baseline'}->{$_} = 1 for qw/
229 auto baseline before-edge text-before-edge middle central
230 after-edge text-after-edge ideographic alphabetic hanging
231 mathematical
232 /;
233 $p->{prop_value}->{'text-decoration'}->{$_} = 1 for qw/
234 none blink underline overline line-through
235 /;
236 $p->{prop_value}->{'caption-side'}->{$_} = 1 for qw/
237 top bottom left right
238 /;
239 $p->{prop_value}->{'table-layout'}->{auto} = 1;
240 $p->{prop_value}->{'table-layout'}->{fixed} = 1;
241 $p->{prop_value}->{'border-collapse'}->{collapse} = 1;
242 $p->{prop_value}->{'border-collapse'}->{separate} = 1;
243 $p->{prop_value}->{'empty-cells'}->{show} = 1;
244 $p->{prop_value}->{'empty-cells'}->{hide} = 1;
245 $p->{prop_value}->{cursor}->{$_} = 1 for qw/
246 auto crosshair default pointer move e-resize ne-resize nw-resize n-resize
247 se-resize sw-resize s-resize w-resize text wait help progress
248 /;
249 for my $prop (qw/border-top-style border-left-style
250 border-bottom-style border-right-style outline-style/) {
251 $p->{prop_value}->{$prop}->{$_} = 1 for qw/
252 none hidden dotted dashed solid double groove ridge inset outset
253 /;
254 }
255 for my $prop (qw/color background-color
256 border-bottom-color border-left-color border-right-color
257 border-top-color border-color/) {
258 $p->{prop_value}->{$prop}->{transparent} = 1;
259 $p->{prop_value}->{$prop}->{flavor} = 1;
260 $p->{prop_value}->{$prop}->{'-manakai-default'} = 1;
261 }
262 $p->{prop_value}->{'outline-color'}->{invert} = 1;
263 $p->{prop_value}->{'outline-color'}->{'-manakai-invert-or-currentcolor'} = 1;
264 $p->{pseudo_class}->{$_} = 1 for qw/
265 active checked disabled empty enabled first-child first-of-type
266 focus hover indeterminate last-child last-of-type link only-child
267 only-of-type root target visited
268 lang nth-child nth-last-child nth-of-type nth-last-of-type not
269 -manakai-contains -manakai-current
270 /;
271 $p->{pseudo_element}->{$_} = 1 for qw/
272 after before first-letter first-line
273 /;
274
275 return $CSSParser = $p;
276 } # get_css_parser
277
278 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24