/[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.5 - (show annotations) (download)
Sun Jul 27 10:33:46 2008 UTC (17 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.4: +1 -1 lines
++ ChangeLog	27 Jul 2008 10:33:38 -0000
2008-07-27  Wakaba  <wakaba@suika.fam.cx>

	* .htaccess: Files gone.

	* cc-interface.en.html, cc-todo.txt: Removed.

	* cc-about.en.html: New document.

	* cc.cgi: Insert document input section before anything.
	No check performed if no URL is specified and the
	input is empty.

	* error-description-source.xml (WebHACC:Heading): Link
	to cc-about in place of cc-interface.

++ html/WebHACC/Language/ChangeLog	27 Jul 2008 10:31:14 -0000
2008-07-27  Wakaba  <wakaba@suika.fam.cx>

	* CSS.pm (generate_structure_dump_section): Role name was wrong.

++ html/WebHACC/ChangeLog	27 Jul 2008 10:30:52 -0000
2008-07-27  Wakaba  <wakaba@suika.fam.cx>

	* Output.pm (new, input): |input| attribute should always have an input
	object, even though it might be an empty one.
	(add_source_to_parse_error_list): s/shift/shift ()/ to remove
	ambigiousness warning.
	(select): New method.
	(generate_input_section): New method.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24