/[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.7 - (hide annotations) (download)
Fri Aug 15 05:53:23 2008 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.6: +1 -1 lines
++ ChangeLog	15 Aug 2008 05:43:43 -0000
2008-08-15  Wakaba  <wakaba@suika.fam.cx>

	* cc-style.css: Add icons to links and headings of error sections.
	Use standard "uncertain" color for level-u errors.  "No error found"
	messages are now handled by catalog, not by CSS presentation.
	The result paragraph saying that the conformance is unknown
	should be bordered as uncertain error messages are.

	* error-description-source.xml: New message entries
	for not-translated-yet messages.  Distinguish result table's
	layer names from other similar texts.

++ html/WebHACC/Language/ChangeLog	15 Aug 2008 05:53:19 -0000
2008-08-15  Wakaba  <wakaba@suika.fam.cx>

	* CSS.pm, CacheManifest.pm, HTML.pm, WebIDL.pm, XML.pm: Don't
	set "uncertain" flag to character encoding (encode) layer if the
	input is a character string.

++ html/WebHACC/ChangeLog	15 Aug 2008 05:51:54 -0000
2008-08-15  Wakaba  <wakaba@suika.fam.cx>

	* Input.pm (generate_transfer_sections): Use standard
	error list methods for transfer errors.  Typos fixed.

	* Output.pm (has_error): New attribute.
	(start_error_list, end_error_list): Support for role "transfer-errors".
	(end_error_list): Generate "no error found" paragraph if it should be.
	(generate_input_section): Decode parameters as UTF-8.

	* Result.pm (add_error): Set |has_error| flag.  Use catalog
	for "Unknown location" message.
	(generate_result_section): Use different text for
	result table rows than normal messages, to avoid collision
	with other messages (such as "Charset").

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24