/[suikacvs]/markup/html/whatpm/Whatpm/HTML.pm.src
Suika

Diff of /markup/html/whatpm/Whatpm/HTML.pm.src

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

revision 1.10 by wakaba, Sat Jun 23 03:30:06 2007 UTC revision 1.17 by wakaba, Sat Jun 23 08:15:21 2007 UTC
# Line 18  my $permitted_slash_tag_name = { Line 18  my $permitted_slash_tag_name = {
18    input => 1,    input => 1,
19  };  };
20    
 my $entity_char = {  
   AElig => "\x{00C6}",  
   Aacute => "\x{00C1}",  
   Acirc => "\x{00C2}",  
   Agrave => "\x{00C0}",  
   Alpha => "\x{0391}",  
   Aring => "\x{00C5}",  
   Atilde => "\x{00C3}",  
   Auml => "\x{00C4}",  
   Beta => "\x{0392}",  
   Ccedil => "\x{00C7}",  
   Chi => "\x{03A7}",  
   Dagger => "\x{2021}",  
   Delta => "\x{0394}",  
   ETH => "\x{00D0}",  
   Eacute => "\x{00C9}",  
   Ecirc => "\x{00CA}",  
   Egrave => "\x{00C8}",  
   Epsilon => "\x{0395}",  
   Eta => "\x{0397}",  
   Euml => "\x{00CB}",  
   Gamma => "\x{0393}",  
   Iacute => "\x{00CD}",  
   Icirc => "\x{00CE}",  
   Igrave => "\x{00CC}",  
   Iota => "\x{0399}",  
   Iuml => "\x{00CF}",  
   Kappa => "\x{039A}",  
   Lambda => "\x{039B}",  
   Mu => "\x{039C}",  
   Ntilde => "\x{00D1}",  
   Nu => "\x{039D}",  
   OElig => "\x{0152}",  
   Oacute => "\x{00D3}",  
   Ocirc => "\x{00D4}",  
   Ograve => "\x{00D2}",  
   Omega => "\x{03A9}",  
   Omicron => "\x{039F}",  
   Oslash => "\x{00D8}",  
   Otilde => "\x{00D5}",  
   Ouml => "\x{00D6}",  
   Phi => "\x{03A6}",  
   Pi => "\x{03A0}",  
   Prime => "\x{2033}",  
   Psi => "\x{03A8}",  
   Rho => "\x{03A1}",  
   Scaron => "\x{0160}",  
   Sigma => "\x{03A3}",  
   THORN => "\x{00DE}",  
   Tau => "\x{03A4}",  
   Theta => "\x{0398}",  
   Uacute => "\x{00DA}",  
   Ucirc => "\x{00DB}",  
   Ugrave => "\x{00D9}",  
   Upsilon => "\x{03A5}",  
   Uuml => "\x{00DC}",  
   Xi => "\x{039E}",  
   Yacute => "\x{00DD}",  
   Yuml => "\x{0178}",  
   Zeta => "\x{0396}",  
   aacute => "\x{00E1}",  
   acirc => "\x{00E2}",  
   acute => "\x{00B4}",  
   aelig => "\x{00E6}",  
   agrave => "\x{00E0}",  
   alefsym => "\x{2135}",  
   alpha => "\x{03B1}",  
   amp => "\x{0026}",  
   AMP => "\x{0026}",  
   and => "\x{2227}",  
   ang => "\x{2220}",  
   apos => "\x{0027}",  
   aring => "\x{00E5}",  
   asymp => "\x{2248}",  
   atilde => "\x{00E3}",  
   auml => "\x{00E4}",  
   bdquo => "\x{201E}",  
   beta => "\x{03B2}",  
   brvbar => "\x{00A6}",  
   bull => "\x{2022}",  
   cap => "\x{2229}",  
   ccedil => "\x{00E7}",  
   cedil => "\x{00B8}",  
   cent => "\x{00A2}",  
   chi => "\x{03C7}",  
   circ => "\x{02C6}",  
   clubs => "\x{2663}",  
   cong => "\x{2245}",  
   copy => "\x{00A9}",  
   COPY => "\x{00A9}",  
   crarr => "\x{21B5}",  
   cup => "\x{222A}",  
   curren => "\x{00A4}",  
   dArr => "\x{21D3}",  
   dagger => "\x{2020}",  
   darr => "\x{2193}",  
   deg => "\x{00B0}",  
   delta => "\x{03B4}",  
   diams => "\x{2666}",  
   divide => "\x{00F7}",  
   eacute => "\x{00E9}",  
   ecirc => "\x{00EA}",  
   egrave => "\x{00E8}",  
   empty => "\x{2205}",  
   emsp => "\x{2003}",  
   ensp => "\x{2002}",  
   epsilon => "\x{03B5}",  
   equiv => "\x{2261}",  
   eta => "\x{03B7}",  
   eth => "\x{00F0}",  
   euml => "\x{00EB}",  
   euro => "\x{20AC}",  
   exist => "\x{2203}",  
   fnof => "\x{0192}",  
   forall => "\x{2200}",  
   frac12 => "\x{00BD}",  
   frac14 => "\x{00BC}",  
   frac34 => "\x{00BE}",  
   frasl => "\x{2044}",  
   gamma => "\x{03B3}",  
   ge => "\x{2265}",  
   gt => "\x{003E}",  
   GT => "\x{003E}",  
   hArr => "\x{21D4}",  
   harr => "\x{2194}",  
   hearts => "\x{2665}",  
   hellip => "\x{2026}",  
   iacute => "\x{00ED}",  
   icirc => "\x{00EE}",  
   iexcl => "\x{00A1}",  
   igrave => "\x{00EC}",  
   image => "\x{2111}",  
   infin => "\x{221E}",  
   int => "\x{222B}",  
   iota => "\x{03B9}",  
   iquest => "\x{00BF}",  
   isin => "\x{2208}",  
   iuml => "\x{00EF}",  
   kappa => "\x{03BA}",  
   lArr => "\x{21D0}",  
   lambda => "\x{03BB}",  
   lang => "\x{2329}",  
   laquo => "\x{00AB}",  
   larr => "\x{2190}",  
   lceil => "\x{2308}",  
   ldquo => "\x{201C}",  
   le => "\x{2264}",  
   lfloor => "\x{230A}",  
   lowast => "\x{2217}",  
   loz => "\x{25CA}",  
   lrm => "\x{200E}",  
   lsaquo => "\x{2039}",  
   lsquo => "\x{2018}",  
   lt => "\x{003C}",  
   LT => "\x{003C}",  
   macr => "\x{00AF}",  
   mdash => "\x{2014}",  
   micro => "\x{00B5}",  
   middot => "\x{00B7}",  
   minus => "\x{2212}",  
   mu => "\x{03BC}",  
   nabla => "\x{2207}",  
   nbsp => "\x{00A0}",  
   ndash => "\x{2013}",  
   ne => "\x{2260}",  
   ni => "\x{220B}",  
   not => "\x{00AC}",  
   notin => "\x{2209}",  
   nsub => "\x{2284}",  
   ntilde => "\x{00F1}",  
   nu => "\x{03BD}",  
   oacute => "\x{00F3}",  
   ocirc => "\x{00F4}",  
   oelig => "\x{0153}",  
   ograve => "\x{00F2}",  
   oline => "\x{203E}",  
   omega => "\x{03C9}",  
   omicron => "\x{03BF}",  
   oplus => "\x{2295}",  
   or => "\x{2228}",  
   ordf => "\x{00AA}",  
   ordm => "\x{00BA}",  
   oslash => "\x{00F8}",  
   otilde => "\x{00F5}",  
   otimes => "\x{2297}",  
   ouml => "\x{00F6}",  
   para => "\x{00B6}",  
   part => "\x{2202}",  
   permil => "\x{2030}",  
   perp => "\x{22A5}",  
   phi => "\x{03C6}",  
   pi => "\x{03C0}",  
   piv => "\x{03D6}",  
   plusmn => "\x{00B1}",  
   pound => "\x{00A3}",  
   prime => "\x{2032}",  
   prod => "\x{220F}",  
   prop => "\x{221D}",  
   psi => "\x{03C8}",  
   quot => "\x{0022}",  
   QUOT => "\x{0022}",  
   rArr => "\x{21D2}",  
   radic => "\x{221A}",  
   rang => "\x{232A}",  
   raquo => "\x{00BB}",  
   rarr => "\x{2192}",  
   rceil => "\x{2309}",  
   rdquo => "\x{201D}",  
   real => "\x{211C}",  
   reg => "\x{00AE}",  
   REG => "\x{00AE}",  
   rfloor => "\x{230B}",  
   rho => "\x{03C1}",  
   rlm => "\x{200F}",  
   rsaquo => "\x{203A}",  
   rsquo => "\x{2019}",  
   sbquo => "\x{201A}",  
   scaron => "\x{0161}",  
   sdot => "\x{22C5}",  
   sect => "\x{00A7}",  
   shy => "\x{00AD}",  
   sigma => "\x{03C3}",  
   sigmaf => "\x{03C2}",  
   sim => "\x{223C}",  
   spades => "\x{2660}",  
   sub => "\x{2282}",  
   sube => "\x{2286}",  
   sum => "\x{2211}",  
   sup => "\x{2283}",  
   sup1 => "\x{00B9}",  
   sup2 => "\x{00B2}",  
   sup3 => "\x{00B3}",  
   supe => "\x{2287}",  
   szlig => "\x{00DF}",  
   tau => "\x{03C4}",  
   there4 => "\x{2234}",  
   theta => "\x{03B8}",  
   thetasym => "\x{03D1}",  
   thinsp => "\x{2009}",  
   thorn => "\x{00FE}",  
   tilde => "\x{02DC}",  
   times => "\x{00D7}",  
   trade => "\x{2122}",  
   uArr => "\x{21D1}",  
   uacute => "\x{00FA}",  
   uarr => "\x{2191}",  
   ucirc => "\x{00FB}",  
   ugrave => "\x{00F9}",  
   uml => "\x{00A8}",  
   upsih => "\x{03D2}",  
   upsilon => "\x{03C5}",  
   uuml => "\x{00FC}",  
   weierp => "\x{2118}",  
   xi => "\x{03BE}",  
   yacute => "\x{00FD}",  
   yen => "\x{00A5}",  
   yuml => "\x{00FF}",  
   zeta => "\x{03B6}",  
   zwj => "\x{200D}",  
   zwnj => "\x{200C}",  
 }; # $entity_char  
   
21  my $c1_entity_char = {  my $c1_entity_char = {
22    0x80 => 0x20AC,    0x80 => 0x20AC,
23    0x81 => 0xFFFD,    0x81 => 0xFFFD,
# Line 349  sub parse_string ($$$;$) { Line 87  sub parse_string ($$$;$) {
87    my $column = 0;    my $column = 0;
88    $self->{set_next_input_character} = sub {    $self->{set_next_input_character} = sub {
89      my $self = shift;      my $self = shift;
90    
91        pop @{$self->{prev_input_character}};
92        unshift @{$self->{prev_input_character}}, $self->{next_input_character};
93    
94      $self->{next_input_character} = -1 and return if $i >= length $$s;      $self->{next_input_character} = -1 and return if $i >= length $$s;
95      $self->{next_input_character} = ord substr $$s, $i++, 1;      $self->{next_input_character} = ord substr $$s, $i++, 1;
96      $column++;      $column++;
# Line 357  sub parse_string ($$$;$) { Line 99  sub parse_string ($$$;$) {
99        $line++;        $line++;
100        $column = 0;        $column = 0;
101      } elsif ($self->{next_input_character} == 0x000D) { # CR      } elsif ($self->{next_input_character} == 0x000D) { # CR
102        if ($i >= length $$s) {        $i++ if substr ($$s, $i, 1) eq "\x0A";
         #  
       } else {  
         my $next_char = ord substr $$s, $i++, 1;  
         if ($next_char == 0x000A) { # LF  
           #  
         } else {  
           push @{$self->{char}}, $next_char;  
         }  
       }  
103        $self->{next_input_character} = 0x000A; # LF # MUST        $self->{next_input_character} = 0x000A; # LF # MUST
104        $line++;        $line++;
105        $column = 0;        $column = 0;
# Line 374  sub parse_string ($$$;$) { Line 107  sub parse_string ($$$;$) {
107        $self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST        $self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST
108      } elsif ($self->{next_input_character} == 0x0000) { # NULL      } elsif ($self->{next_input_character} == 0x0000) { # NULL
109        !!!parse-error (type => 'NULL');        !!!parse-error (type => 'NULL');
 ## TODO: test  
110        $self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST        $self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST
111      }      }
112    };    };
113      $self->{prev_input_character} = [-1, -1, -1];
114      $self->{next_input_character} = -1;
115    
116    my $onerror = $_[2] || sub {    my $onerror = $_[2] || sub {
117      my (%opt) = @_;      my (%opt) = @_;
# Line 445  sub _initialize_tokenizer ($) { Line 179  sub _initialize_tokenizer ($) {
179  ## has completed loading.  If one has, then it MUST be executed  ## has completed loading.  If one has, then it MUST be executed
180  ## and removed from the list.  ## and removed from the list.
181    
 ## ISSUE: <http://html5.org/tools/web-apps-tracker?from=874&to=876>  
   
182  sub _get_next_token ($) {  sub _get_next_token ($) {
183    my $self = shift;    my $self = shift;
184    if (@{$self->{token}}) {    if (@{$self->{token}}) {
# Line 464  sub _get_next_token ($) { Line 196  sub _get_next_token ($) {
196          } else {          } else {
197            #            #
198          }          }
199          } elsif ($self->{next_input_character} == 0x002D) { # -
200            if ($self->{content_model_flag} eq 'RCDATA' or
201                $self->{content_model_flag} eq 'CDATA') {
202              unless ($self->{escape}) {
203                if ($self->{prev_input_character}->[0] == 0x002D and # -
204                    $self->{prev_input_character}->[1] == 0x0021 and # !
205                    $self->{prev_input_character}->[2] == 0x003C) { # <
206                  $self->{escape} = 1;
207                }
208              }
209            }
210            
211            #
212        } elsif ($self->{next_input_character} == 0x003C) { # <        } elsif ($self->{next_input_character} == 0x003C) { # <
213          if ($self->{content_model_flag} ne 'PLAINTEXT') {          if ($self->{content_model_flag} eq 'PCDATA' or
214                (($self->{content_model_flag} eq 'CDATA' or
215                  $self->{content_model_flag} eq 'RCDATA') and
216                 not $self->{escape})) {
217            $self->{state} = 'tag open';            $self->{state} = 'tag open';
218            !!!next-input-character;            !!!next-input-character;
219            redo A;            redo A;
220          } else {          } else {
221            #            #
222          }          }
223          } elsif ($self->{next_input_character} == 0x003E) { # >
224            if ($self->{escape} and
225                ($self->{content_model_flag} eq 'RCDATA' or
226                 $self->{content_model_flag} eq 'CDATA')) {
227              if ($self->{prev_input_character}->[0] == 0x002D and # -
228                  $self->{prev_input_character}->[1] == 0x002D) { # -
229                delete $self->{escape};
230              }
231            }
232            
233            #
234        } elsif ($self->{next_input_character} == -1) {        } elsif ($self->{next_input_character} == -1) {
235          !!!emit ({type => 'end-of-file'});          !!!emit ({type => 'end-of-file'});
236          last A; ## TODO: ok?          last A; ## TODO: ok?
# Line 595  sub _get_next_token ($) { Line 354  sub _get_next_token ($) {
354                  $self->{next_input_character} == 0x0020 or # SP                  $self->{next_input_character} == 0x0020 or # SP
355                  $self->{next_input_character} == 0x003E or # >                  $self->{next_input_character} == 0x003E or # >
356                  $self->{next_input_character} == 0x002F or # /                  $self->{next_input_character} == 0x002F or # /
                 $self->{next_input_character} == 0x003C or # <  
357                  $self->{next_input_character} == -1) {                  $self->{next_input_character} == -1) {
358            !!!parse-error (type => 'unmatched end tag');            !!!parse-error (type => 'unmatched end tag');
359            $self->{next_input_character} = shift @next_char; # reconsume            $self->{next_input_character} = shift @next_char; # reconsume
# Line 679  sub _get_next_token ($) { Line 437  sub _get_next_token ($) {
437          ## Stay in this state          ## Stay in this state
438          !!!next-input-character;          !!!next-input-character;
439          redo A;          redo A;
440        } elsif ($self->{next_input_character} == 0x003C or # <        } elsif ($self->{next_input_character} == -1) {
                $self->{next_input_character} == -1) {  
441          !!!parse-error (type => 'unclosed tag');          !!!parse-error (type => 'unclosed tag');
442          if ($self->{current_token}->{type} eq 'start tag') {          if ($self->{current_token}->{type} eq 'start tag') {
443            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};
# Line 766  sub _get_next_token ($) { Line 523  sub _get_next_token ($) {
523          ## Stay in the state          ## Stay in the state
524          # next-input-character is already done          # next-input-character is already done
525          redo A;          redo A;
526        } elsif ($self->{next_input_character} == 0x003C or # <        } elsif ($self->{next_input_character} == -1) {
                $self->{next_input_character} == -1) {  
527          !!!parse-error (type => 'unclosed tag');          !!!parse-error (type => 'unclosed tag');
528          if ($self->{current_token}->{type} eq 'start tag') {          if ($self->{current_token}->{type} eq 'start tag') {
529            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};
# Line 858  sub _get_next_token ($) { Line 614  sub _get_next_token ($) {
614          $self->{state} = 'before attribute name';          $self->{state} = 'before attribute name';
615          # next-input-character is already done          # next-input-character is already done
616          redo A;          redo A;
617        } elsif ($self->{next_input_character} == 0x003C or # <        } elsif ($self->{next_input_character} == -1) {
                $self->{next_input_character} == -1) {  
618          !!!parse-error (type => 'unclosed tag');          !!!parse-error (type => 'unclosed tag');
619          $before_leave->();          $before_leave->();
620          if ($self->{current_token}->{type} eq 'start tag') {          if ($self->{current_token}->{type} eq 'start tag') {
# Line 936  sub _get_next_token ($) { Line 691  sub _get_next_token ($) {
691          $self->{state} = 'before attribute name';          $self->{state} = 'before attribute name';
692          # next-input-character is already done          # next-input-character is already done
693          redo A;          redo A;
694        } elsif ($self->{next_input_character} == 0x003C or # <        } elsif ($self->{next_input_character} == -1) {
                $self->{next_input_character} == -1) {  
695          !!!parse-error (type => 'unclosed tag');          !!!parse-error (type => 'unclosed tag');
696          if ($self->{current_token}->{type} eq 'start tag') {          if ($self->{current_token}->{type} eq 'start tag') {
697            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};
# Line 1002  sub _get_next_token ($) { Line 756  sub _get_next_token ($) {
756          undef $self->{current_token};          undef $self->{current_token};
757    
758          redo A;          redo A;
759        } elsif ($self->{next_input_character} == 0x003C or # <        } elsif ($self->{next_input_character} == -1) {
                $self->{next_input_character} == -1) {  
760          !!!parse-error (type => 'unclosed tag');          !!!parse-error (type => 'unclosed tag');
761          if ($self->{current_token}->{type} eq 'start tag') {          if ($self->{current_token}->{type} eq 'start tag') {
762            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};
# Line 1130  sub _get_next_token ($) { Line 883  sub _get_next_token ($) {
883          undef $self->{current_token};          undef $self->{current_token};
884    
885          redo A;          redo A;
886        } elsif ($self->{next_input_character} == 0x003C or # <        } elsif ($self->{next_input_character} == -1) {
                $self->{next_input_character} == -1) {  
887          !!!parse-error (type => 'unclosed tag');          !!!parse-error (type => 'unclosed tag');
888          if ($self->{current_token}->{type} eq 'start tag') {          if ($self->{current_token}->{type} eq 'start tag') {
889            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};            $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};
# Line 1591  sub _tokenize_attempt_to_consume_an_enti Line 1343  sub _tokenize_attempt_to_consume_an_enti
1343    
1344      my $value = $entity_name;      my $value = $entity_name;
1345      my $match;      my $match;
1346        require Whatpm::_NamedEntityList;
1347        our $EntityChar;
1348    
1349      while (length $entity_name < 10 and      while (length $entity_name < 10 and
1350             ## NOTE: Some number greater than the maximum length of entity name             ## NOTE: Some number greater than the maximum length of entity name
1351             ((0x0041 <= $self->{next_input_character} and             ((0x0041 <= $self->{next_input_character} and # a
1352               $self->{next_input_character} <= 0x005A) or               $self->{next_input_character} <= 0x005A) or # x
1353              (0x0061 <= $self->{next_input_character} and              (0x0061 <= $self->{next_input_character} and # a
1354               $self->{next_input_character} <= 0x007A) or               $self->{next_input_character} <= 0x007A) or # z
1355              (0x0030 <= $self->{next_input_character} and              (0x0030 <= $self->{next_input_character} and # 0
1356               $self->{next_input_character} <= 0x0039))) {               $self->{next_input_character} <= 0x0039) or # 9
1357                $self->{next_input_character} == 0x003B)) { # ;
1358        $entity_name .= chr $self->{next_input_character};        $entity_name .= chr $self->{next_input_character};
1359        if (defined $entity_char->{$entity_name}) {        if (defined $EntityChar->{$entity_name}) {
1360          $value = $entity_char->{$entity_name};          $value = $EntityChar->{$entity_name};
1361          $match = 1;          if ($self->{next_input_character} == 0x003B) { # ;
1362              $match = 1;
1363              !!!next-input-character;
1364              last;
1365            } else {
1366              $match = -1;
1367            }
1368        } else {        } else {
1369          $value .= chr $self->{next_input_character};          $value .= chr $self->{next_input_character};
1370        }        }
1371        !!!next-input-character;        !!!next-input-character;
1372      }      }
1373            
1374      if ($match) {      if ($match > 0) {
1375        if ($self->{next_input_character} == 0x003B) { # ;        return {type => 'character', data => $value};
1376          !!!next-input-character;      } elsif ($match < 0) {
1377        } else {        !!!parse-error (type => 'refc');
         !!!parse-error (type => 'refc');  
       }  
   
1378        return {type => 'character', data => $value};        return {type => 'character', data => $value};
1379      } else {      } else {
1380        !!!parse-error (type => 'bare ero');        !!!parse-error (type => 'bare ero');
# Line 1927  sub _tree_construction_main ($) { Line 1685  sub _tree_construction_main ($) {
1685       ? $self->{head_element} : $self->{open_elements}->[-1]->[0])       ? $self->{head_element} : $self->{open_elements}->[-1]->[0])
1686        ->append_child ($style_el);        ->append_child ($style_el);
1687      $self->{content_model_flag} = 'CDATA';      $self->{content_model_flag} = 'CDATA';
1688        delete $self->{escape}; # MUST
1689                                
1690      my $text = '';      my $text = '';
1691      !!!next-token;      !!!next-token;
# Line 1955  sub _tree_construction_main ($) { Line 1714  sub _tree_construction_main ($) {
1714      ## TODO: mark as "parser-inserted"      ## TODO: mark as "parser-inserted"
1715    
1716      $self->{content_model_flag} = 'CDATA';      $self->{content_model_flag} = 'CDATA';
1717        delete $self->{escape}; # MUST
1718            
1719      my $text = '';      my $text = '';
1720      !!!next-token;      !!!next-token;
# Line 2244  sub _tree_construction_main ($) { Line 2004  sub _tree_construction_main ($) {
2004          (defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0])          (defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0])
2005            ->append_child ($title_el);            ->append_child ($title_el);
2006          $self->{content_model_flag} = 'RCDATA';          $self->{content_model_flag} = 'RCDATA';
2007            delete $self->{escape}; # MUST
2008                    
2009          my $text = '';          my $text = '';
2010          !!!next-token;          !!!next-token;
# Line 2590  sub _tree_construction_main ($) { Line 2351  sub _tree_construction_main ($) {
2351          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
2352                    
2353          $self->{content_model_flag} = 'CDATA';          $self->{content_model_flag} = 'CDATA';
2354            delete $self->{escape}; # MUST
2355                    
2356          !!!next-token;          !!!next-token;
2357          return;          return;
# Line 2706  sub _tree_construction_main ($) { Line 2468  sub _tree_construction_main ($) {
2468          } else {          } else {
2469            $self->{content_model_flag} = 'CDATA';            $self->{content_model_flag} = 'CDATA';
2470          }          }
2471            delete $self->{escape}; # MUST
2472                    
2473          $insert->($el);          $insert->($el);
2474                    
# Line 2807  sub _tree_construction_main ($) { Line 2570  sub _tree_construction_main ($) {
2570                  address => 1, blockquote => 1, center => 1, dir => 1,                  address => 1, blockquote => 1, center => 1, dir => 1,
2571                  div => 1, dl => 1, fieldset => 1, listing => 1,                  div => 1, dl => 1, fieldset => 1, listing => 1,
2572                  menu => 1, ol => 1, pre => 1, ul => 1,                  menu => 1, ol => 1, pre => 1, ul => 1,
                 form => 1,  
2573                  p => 1,                  p => 1,
2574                  dd => 1, dt => 1, li => 1,                  dd => 1, dt => 1, li => 1,
2575                  button => 1, marquee => 1, object => 1,                  button => 1, marquee => 1, object => 1,
# Line 2845  sub _tree_construction_main ($) { Line 2607  sub _tree_construction_main ($) {
2607          }          }
2608                    
2609          splice @{$self->{open_elements}}, $i if defined $i;          splice @{$self->{open_elements}}, $i if defined $i;
         undef $self->{form_element} if $token->{tag_name} eq 'form';  
2610          $clear_up_to_marker->()          $clear_up_to_marker->()
2611            if {            if {
2612              button => 1, marquee => 1, object => 1,              button => 1, marquee => 1, object => 1,
2613            }->{$token->{tag_name}};            }->{$token->{tag_name}};
2614          !!!next-token;          !!!next-token;
2615          return;          return;
2616          } elsif ($token->{tag_name} eq 'form') {
2617            ## has an element in scope
2618            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
2619              my $node = $self->{open_elements}->[$_];
2620              if ($node->[1] eq $token->{tag_name}) {
2621                ## generate implied end tags
2622                if ({
2623                     dd => 1, dt => 1, li => 1, p => 1,
2624                     td => 1, th => 1, tr => 1,
2625                    }->{$self->{open_elements}->[-1]->[1]}) {
2626                  !!!back-token;
2627                  $token = {type => 'end tag',
2628                            tag_name => $self->{open_elements}->[-1]->[1]}; # MUST
2629                  return;
2630                }
2631                last INSCOPE;
2632              } elsif ({
2633                        table => 1, caption => 1, td => 1, th => 1,
2634                        button => 1, marquee => 1, object => 1, html => 1,
2635                       }->{$node->[1]}) {
2636                last INSCOPE;
2637              }
2638            } # INSCOPE
2639            
2640            if ($self->{open_elements}->[-1]->[1] eq $token->{tag_name}) {
2641              pop @{$self->{open_elements}};
2642            } else {
2643              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
2644            }
2645    
2646            undef $self->{form_element};
2647            !!!next-token;
2648            return;
2649        } elsif ({        } elsif ({
2650                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
2651                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
# Line 3097  sub _tree_construction_main ($) { Line 2891  sub _tree_construction_main ($) {
2891                (defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0])                (defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0])
2892                  ->append_child ($title_el);                  ->append_child ($title_el);
2893                $self->{content_model_flag} = 'RCDATA';                $self->{content_model_flag} = 'RCDATA';
2894                  delete $self->{escape}; # MUST
2895    
2896                my $text = '';                my $text = '';
2897                !!!next-token;                !!!next-token;
# Line 4868  sub set_inner_html ($$$) { Line 4663  sub set_inner_html ($$$) {
4663      ## NOTE: Most of this code is copied from |parse_string|      ## NOTE: Most of this code is copied from |parse_string|
4664    
4665      ## Step 1 # MUST      ## Step 1 # MUST
4666      my $doc = $node->owner_document->implementation->create_document;      my $this_doc = $node->owner_document;
4667        my $doc = $this_doc->implementation->create_document;
4668      ## TODO: Mark as HTML document      ## TODO: Mark as HTML document
4669      my $p = $class->new;      my $p = $class->new;
4670      $p->{document} = $doc;      $p->{document} = $doc;
# Line 4879  sub set_inner_html ($$$) { Line 4675  sub set_inner_html ($$$) {
4675      my $column = 0;      my $column = 0;
4676      $p->{set_next_input_character} = sub {      $p->{set_next_input_character} = sub {
4677        my $self = shift;        my $self = shift;
4678    
4679          pop @{$self->{prev_input_character}};
4680          unshift @{$self->{prev_input_character}}, $self->{next_input_character};
4681    
4682        $self->{next_input_character} = -1 and return if $i >= length $$s;        $self->{next_input_character} = -1 and return if $i >= length $$s;
4683        $self->{next_input_character} = ord substr $$s, $i++, 1;        $self->{next_input_character} = ord substr $$s, $i++, 1;
4684        $column++;        $column++;
# Line 4887  sub set_inner_html ($$$) { Line 4687  sub set_inner_html ($$$) {
4687          $line++;          $line++;
4688          $column = 0;          $column = 0;
4689        } elsif ($self->{next_input_character} == 0x000D) { # CR        } elsif ($self->{next_input_character} == 0x000D) { # CR
4690          if ($i >= length $$s) {          $i++ if substr ($$s, $i, 1) eq "\x0A";
           #  
         } else {  
           my $next_char = ord substr $$s, $i++, 1;  
           if ($next_char == 0x000A) { # LF  
             #  
           } else {  
             push @{$self->{char}}, $next_char;  
           }  
         }  
4691          $self->{next_input_character} = 0x000A; # LF # MUST          $self->{next_input_character} = 0x000A; # LF # MUST
4692          $line++;          $line++;
4693          $column = 0;          $column = 0;
4694        } elsif ($self->{next_input_character} > 0x10FFFF) {        } elsif ($self->{next_input_character} > 0x10FFFF) {
4695          $self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST          $self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST
4696        } elsif ($self->{next_input_character} == 0x0000) { # NULL        } elsif ($self->{next_input_character} == 0x0000) { # NULL
4697            !!!parse-error (type => 'NULL');
4698          $self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST          $self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST
4699        }        }
4700      };      };
4701        $p->{prev_input_character} = [-1, -1, -1];
4702        $p->{next_input_character} = -1;
4703            
4704      my $ponerror = $onerror || sub {      my $ponerror = $onerror || sub {
4705        my (%opt) = @_;        my (%opt) = @_;
# Line 4984  sub set_inner_html ($$$) { Line 4778  sub set_inner_html ($$$) {
4778      ## Step 12 # MUST      ## Step 12 # MUST
4779      @cn = @{$root->child_nodes};      @cn = @{$root->child_nodes};
4780      for (@cn) {      for (@cn) {
4781          $this_doc->adopt_node ($_);
4782        $node->append_child ($_);        $node->append_child ($_);
4783      }      }
4784      ## ISSUE: adopt_node? mutation events?      ## ISSUE: mutation events?
4785    
4786      $p->_terminate_tree_constructor;      $p->_terminate_tree_constructor;
4787    } else {    } else {

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.17

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24