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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Sat Aug 16 07:42:20 2008 UTC (16 years, 10 months ago) by wakaba
Branch: MAIN
Changes since 1.8: +1 -1 lines
++ ChangeLog	16 Aug 2008 07:38:01 -0000
	* cc-script.js: Support for #index- fragment identifiers.

	* cc-style.css: Prety styling for reformatted sources.
	Support for new version of manifest dump sections.

	* error-description-source.xml: Support for Whatpm::CacheManifest,
	Whatpm::CSS::SelectorsParser, Whatpm::CSS::MediaQueryParser,
	and Whatpm::CSS::Parser errors.  Support for l10n of cache
	manifest dump sections.

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

++ html/WebHACC/Language/ChangeLog	16 Aug 2008 07:42:17 -0000
	* CSS.pm, CacheManifest.pm, HTML.pm, XML.pm: Use ->url attribute to
	obtain the URL of the document.

	* CacheManifest.pm (generate_structure_dump_section): It is
	now i18n'ed.  In addition, since URLs are tend to be long,
	tables for fallback entries are replaced by |dd| entries and
	paragraphs.  "No entry" message is now handled by catalog,
	rather than CSS.

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

++ html/WebHACC/ChangeLog	16 Aug 2008 07:39:54 -0000
	* Input.pm (Subdocument new): Invoke superclass's new method
	such that |urls| attribute is initialized.

	* Result.pm (add_error): Use ->url attribute to obtain
	the URL of the document.  No longer output |text| argument,
	since all error types except for those used in the WebIDL module
	are now defined in the catalog.

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

1 wakaba 1.1 package WebHACC::Language::HTML;
2     use strict;
3     require WebHACC::Language::DOM;
4     push our @ISA, 'WebHACC::Language::DOM';
5    
6     sub new ($) {
7     return bless {}, shift;
8     } # new
9    
10     sub generate_syntax_error_section ($) {
11     my $self = shift;
12    
13 wakaba 1.4 require Message::DOM::DOMImplementation;
14 wakaba 1.1 require Encode;
15     require Whatpm::HTML;
16    
17 wakaba 1.5 $self->result->layer_uncertain ('charset');
18    
19 wakaba 1.1 my $out = $self->output;
20 wakaba 1.3 $out->start_section (role => 'parse-errors');
21     $out->start_error_list (role => 'parse-errors');
22 wakaba 1.5 $self->result->layer_applicable ('syntax');
23 wakaba 1.1
24     my $input = $self->input;
25     my $result = $self->result;
26    
27     my $onerror = sub {
28 wakaba 1.7 my %opt = @_;
29     $result->add_error (layer => 'syntax', %opt);
30    
31     if ($opt{type} eq 'chardecode:no error') {
32     $self->result->layer_uncertain ('encode');
33     } elsif ($opt{type} eq 'chardecode:fallback') {
34     $self->result->layer_uncertain ('charset');
35     $self->result->layer_uncertain ('syntax');
36     $self->result->layer_uncertain ('structure');
37     $self->result->layer_uncertain ('semantics');
38     }
39 wakaba 1.1 };
40    
41     my $dom = Message::DOM::DOMImplementation->new;
42     my $doc = $dom->create_document;
43     my $el;
44     my $inner_html_element = $input->{inner_html_element};
45     if (defined $inner_html_element and length $inner_html_element) {
46 wakaba 1.7 $input->{charset} ||= 'utf-8';
47 wakaba 1.1 my $t = \($input->{s});
48     unless ($input->{is_char_string}) {
49     $t = \(Encode::decode ($input->{charset}, $$t));
50 wakaba 1.7 $self->result->layer_applicable ('encode');
51 wakaba 1.1 }
52    
53     $el = $doc->create_element_ns
54     ('http://www.w3.org/1999/xhtml', [undef, $inner_html_element]);
55     Whatpm::HTML->set_inner_html ($el, $$t, $onerror);
56    
57     $self->{structure} = $el;
58 wakaba 1.7 $self->{_structure_root} = $doc;
59     ## NOTE: This is necessary, otherwise it would be garbage collected
60     ## before $el is useless, since $el->owner_document is only a weak
61     ## reference.
62 wakaba 1.1 } else {
63     if ($input->{is_char_string}) {
64     Whatpm::HTML->parse_char_string ($input->{s} => $doc, $onerror);
65     } else {
66 wakaba 1.7 $self->result->layer_applicable ('encode');
67 wakaba 1.1 Whatpm::HTML->parse_byte_string
68     ($input->{charset}, $input->{s} => $doc, $onerror);
69     }
70    
71     $self->{structure} = $doc;
72     }
73     $doc->manakai_charset ($input->{official_charset})
74     if defined $input->{official_charset};
75    
76 wakaba 1.9 $doc->document_uri ($input->url);
77 wakaba 1.1 $doc->manakai_entity_base_uri ($input->{base_uri});
78    
79 wakaba 1.8 $doc->input_encoding (undef) if $input->isa ('WebHACC::Input::Text');
80    
81 wakaba 1.3 $out->end_error_list (role => 'parse-errors');
82 wakaba 1.1 $out->end_section;
83     } # generate_syntax_error_section
84    
85     sub source_charset ($) {
86     my $self = shift;
87     return $self->input->{charset} || ($self->{structure}->owner_document || $self->{structure})->input_encoding;
88     ## TODO: Can we always use input_encoding?
89     } # source_charset
90    
91     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24