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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by wakaba, Sat Aug 16 07:42:20 2008 UTC revision 1.12 by wakaba, Sun Sep 21 05:09:35 2008 UTC
# Line 14  sub generate_syntax_error_section ($) { Line 14  sub generate_syntax_error_section ($) {
14    require Encode;    require Encode;
15    require Whatpm::HTML;    require Whatpm::HTML;
16        
   $self->result->layer_uncertain ('charset');  
   
17    my $out = $self->output;    my $out = $self->output;
18    $out->start_section (role => 'parse-errors');    $out->start_section (role => 'parse-errors');
19    $out->start_error_list (role => 'parse-errors');    $out->start_error_list (role => 'parse-errors');
# Line 30  sub generate_syntax_error_section ($) { Line 28  sub generate_syntax_error_section ($) {
28    
29      if ($opt{type} eq 'chardecode:no error') {      if ($opt{type} eq 'chardecode:no error') {
30        $self->result->layer_uncertain ('encode');        $self->result->layer_uncertain ('encode');
31      } elsif ($opt{type} eq 'chardecode:fallback') {      } elsif ($opt{type} eq 'chardecode:fallback' or
32                 $opt{type} eq 'charset:not supported') {
33        $self->result->layer_uncertain ('charset');        $self->result->layer_uncertain ('charset');
34        $self->result->layer_uncertain ('syntax');        $self->result->layer_uncertain ('syntax');
35        $self->result->layer_uncertain ('structure');        $self->result->layer_uncertain ('structure');
# Line 38  sub generate_syntax_error_section ($) { Line 37  sub generate_syntax_error_section ($) {
37      }      }
38    };    };
39    
40      $self->result->layer_applicable ('charset');
41      my $char_checker = sub ($) {
42        require Whatpm::Charset::UnicodeChecker;
43        return Whatpm::Charset::UnicodeChecker->new_handle ($_[0], 'html5');
44      }; # $char_checker
45    
46    my $dom = Message::DOM::DOMImplementation->new;    my $dom = Message::DOM::DOMImplementation->new;
47    my $doc = $dom->create_document;    my $doc = $dom->create_document;
48    my $el;    my $el;
# Line 52  sub generate_syntax_error_section ($) { Line 57  sub generate_syntax_error_section ($) {
57            
58      $el = $doc->create_element_ns      $el = $doc->create_element_ns
59          ('http://www.w3.org/1999/xhtml', [undef, $inner_html_element]);          ('http://www.w3.org/1999/xhtml', [undef, $inner_html_element]);
60      Whatpm::HTML->set_inner_html ($el, $$t, $onerror);      Whatpm::HTML->set_inner_html ($el, $$t, $onerror, $char_checker);
61    
62      $self->{structure} = $el;      $self->{structure} = $el;
63      $self->{_structure_root} = $doc;      $self->{_structure_root} = $doc;
# Line 61  sub generate_syntax_error_section ($) { Line 66  sub generate_syntax_error_section ($) {
66          ## reference.          ## reference.
67    } else {    } else {
68      if ($input->{is_char_string}) {      if ($input->{is_char_string}) {
69        Whatpm::HTML->parse_char_string ($input->{s} => $doc, $onerror);        Whatpm::HTML->parse_char_string ($input->{s} => $doc,
70                                           $onerror, $char_checker);
71      } else {      } else {
72        $self->result->layer_applicable ('encode');        $self->result->layer_applicable ('encode');
73        Whatpm::HTML->parse_byte_string        Whatpm::HTML->parse_byte_string
74            ($input->{charset}, $input->{s} => $doc, $onerror);            ($input->{charset}, $input->{s} => $doc, $onerror, $char_checker);
75      }      }
76    
77      $self->{structure} = $doc;      $self->{structure} = $doc;
# Line 73  sub generate_syntax_error_section ($) { Line 79  sub generate_syntax_error_section ($) {
79    $doc->manakai_charset ($input->{official_charset})    $doc->manakai_charset ($input->{official_charset})
80        if defined $input->{official_charset};        if defined $input->{official_charset};
81    
82      ## TODO: We need to issue some warning if media type/charset is
83      ## explicitly overridden by the user.
84    
85    $doc->document_uri ($input->url);    $doc->document_uri ($input->url);
86    $doc->manakai_entity_base_uri ($input->{base_uri});    $doc->manakai_entity_base_uri ($input->{base_uri});
87    
# Line 84  sub generate_syntax_error_section ($) { Line 93  sub generate_syntax_error_section ($) {
93    
94  sub source_charset ($) {  sub source_charset ($) {
95    my $self = shift;    my $self = shift;
96    return $self->input->{charset} || ($self->{structure}->owner_document || $self->{structure})->input_encoding;    return (($self->{structure}->owner_document || $self->{structure})->input_encoding || $self->input->{charset});
97    ## TODO: Can we always use input_encoding?    ## TODO: We need some way to get the source charset reliably.  The
98      ## |input_encoding| DOM attribute might be intentionally left blank
99      ## when the input is the direct input form, but even that case the
100      ## charset information should be useful because the input string
101      ## might be a byte sequence.  In addition, the |input_encoding| does
102      ## not reflect the fallback encoding in use.  On the contrary, the
103      ## |{charset}| property of the |input| object is always the value
104      ## from the lower-level protocol and that might be ignored by the
105      ## HTML sniffer.
106  } # source_charset  } # source_charset
107    
108  1;  1;

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.12

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24