/[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.3 - (hide annotations) (download)
Mon Jul 21 05:24:32 2008 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.2: +4 -3 lines
++ ChangeLog	21 Jul 2008 05:20:07 -0000
	* cc.cgi: Information sections are now handled by WebHACC::Input
	module.  Input objects for subdocuments now owns their
	own subclass.

2008-07-21  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/Language/ChangeLog	21 Jul 2008 05:24:27 -0000
	* Base.pm: Use new method for node links.

	* CSS.pm: Typo fixes.  Pass |input| object as an argument
	to the CSSOM validation not supported error.

2008-07-21  Wakaba  <wakaba@suika.fam.cx>

++ html/WebHACC/ChangeLog	21 Jul 2008 05:23:21 -0000
	* Input.pm: A new subclass for subdocuments are added.
	Methods for information sections are added (from cc.cgi).

	* Output.pm (code): Support for attributes.
	(script, dt): New methods.
	(node_link): New method (from get_node_link in WebHACC::Result,
	which comes from cc.cgi).

	* Result.pm (add_error): Show some text even if no location
	infomration is available.  Use input object, if available,
	as fallback for location information.
	(get_error_label, get_node_path, get_node_link): Removed.
	The first method is no longer used.  The latters are now
	supported as |node_link| method in WebHACC::Output.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24