/[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.6 - (hide annotations) (download)
Thu Aug 14 15:50:42 2008 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.5: +5 -0 lines
++ ChangeLog	14 Aug 2008 15:42:17 -0000
	* cc.cgi: Generate result summary sections for
	each subdocument.

	* error-description-source.xml: New entries to
	support localization of result sections.

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

	* cc-style.css: Support for revised version of result summary
	section styling.

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

++ html/WebHACC/Language/ChangeLog	14 Aug 2008 15:50:38 -0000
	* Base.pm, CSS.pm, CacheManifest.pm, DOM.pm, Default.pm,
	HTML.pm, WebIDL.pm, XML.pm: Set |layer_applicable|
	or |layer_uncertain| flag appropriately.

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

++ html/WebHACC/ChangeLog	14 Aug 2008 15:48:38 -0000
	* Input.pm: Methods |generate_transfer_sections|
	and |generate_http_header_section| are moved to HTTP
	subclass, since they are irrelevant to non-HTTP inputs.
	(_get_document): Forbidden host error was not represented
	by WebHACC::Input::Error subclass.
	(WebHACC::Input::Error generate_transfer_sections): Use
	role name for the section.
	(WebHACC::Input::HTTPError generate_transfer_sections): New method
	added, since the main superclass, i.e. WebHACC::Input::Error,
	no longer dumps HTTP headers due to the change mentioned above.

	* Output.pm (start_section): New roles "transfer-errors" and "result".

	* Result.pm (parent_result): New attribute.
	(layer_applicable, layer_uncertain): New methods to set flags.
	(add_error): Natural language strings are now handled
	by the catalog mechanism.  Use new scoring mechanism.
	(generate_result_section): Use catalog for all natural
	language strings.  Table generation is now much more sophiscated
	that it was.  Support for subdoc result summary.  Support
	for the column of the number of informational message.  Support
	for "N/A" status.

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

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 ('encode');
17     $self->result->layer_uncertain ('charset');
18    
19 wakaba 1.4 $out->start_section (role => 'parse-errors');
20     $out->start_error_list (role => 'parse-errors');
21 wakaba 1.6 $self->result->layer_applicable ('syntax');
22 wakaba 1.1
23     my $input = $self->input;
24     my $result = $self->result;
25    
26     my $p = $self->get_css_parser ();
27     $p->init;
28     $p->{onerror} = sub {
29     my (%opt) = @_;
30 wakaba 1.2 if (not defined $opt{value} and defined $opt{token}) {
31     $opt{value} = Whatpm::CSS::Tokenizer->serialize_token ($opt{token});
32 wakaba 1.1 }
33 wakaba 1.2 $result->add_error (%opt, layer => 'syntax');
34 wakaba 1.1 };
35     $p->{href} = $input->{uri};
36     $p->{base_uri} = $input->{base_uri};
37    
38     # if ($parse_mode eq 'q') {
39     # $p->{unitless_px} = 1;
40     # $p->{hashless_color} = 1;
41     # }
42    
43     ## TODO: Make $input->{s} a ref.
44    
45     my $s = \$input->{s};
46     my $charset;
47     unless ($input->{is_char_string}) {
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 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