| 1872 |
} elsif ({ |
} elsif ({ |
| 1873 |
b => 1, big => 1, blockquote => 1, body => 1, br => 1, |
b => 1, big => 1, blockquote => 1, body => 1, br => 1, |
| 1874 |
center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1, |
center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1, |
| 1875 |
em => 1, embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1, |
em => 1, embed => 1, h1 => 1, h2 => 1, h3 => 1, |
| 1876 |
h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1, |
h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1, |
| 1877 |
img => 1, li => 1, listing => 1, menu => 1, meta => 1, |
img => 1, li => 1, listing => 1, menu => 1, meta => 1, |
| 1878 |
nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1, |
nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1, |
| 1879 |
small => 1, span => 1, strong => 1, strike => 1, sub => 1, |
small => 1, span => 1, strong => 1, strike => 1, sub => 1, |
| 1880 |
sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1, |
sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1, |
| 1881 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}} or |
| 1882 |
|
($token->{tag_name} eq 'font' and |
| 1883 |
|
($token->{attributes}->{color} or |
| 1884 |
|
$token->{attributes}->{face} or |
| 1885 |
|
$token->{attributes}->{size}))) { |
| 1886 |
!!!cp ('t87.2'); |
!!!cp ('t87.2'); |
| 1887 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 1888 |
text => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 2265 |
|
|
| 2266 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 2267 |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
| 2268 |
## ISSUE: A spec bug [Bug 6038] |
|
| 2269 |
|
## NOTE: At this point the stack of open elements contain |
| 2270 |
|
## the |head| element (index == -2) and the |script| element |
| 2271 |
|
## (index == -1). In the "after head" insertion mode the |
| 2272 |
|
## |head| element is inserted only for the purpose of |
| 2273 |
|
## providing the context for the |script| element, and |
| 2274 |
|
## therefore we can now and have to remove the element from |
| 2275 |
|
## the stack. |
| 2276 |
splice @{$self->{open_elements}}, -2, 1, () # <head> |
splice @{$self->{open_elements}}, -2, 1, () # <head> |
| 2277 |
if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM; |
if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM; |
| 2278 |
next B; |
next B; |
| 2507 |
## Ignore the token |
## Ignore the token |
| 2508 |
!!!next-token; |
!!!next-token; |
| 2509 |
next B; |
next B; |
| 2510 |
} elsif ($token->{tag_name} eq 'br') { |
} elsif ($token->{tag_name} eq 'br') { |
| 2511 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 2512 |
!!!cp ('t142.2'); |
!!!cp ('t142.2'); |
| 2513 |
## (before head) as if <head>, (in head) as if </head> |
## (before head) as if <head>, (in head) as if </head> |
| 2514 |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
| 2515 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 2516 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 2517 |
|
|
| 2518 |
## Reprocess in the "after head" insertion mode... |
## Reprocess in the "after head" insertion mode... |
| 2519 |
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
| 2520 |
!!!cp ('t143.2'); |
!!!cp ('t143.2'); |
| 2521 |
## As if </head> |
## As if </head> |
| 2522 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 2523 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 2524 |
|
|
| 2525 |
## Reprocess in the "after head" insertion mode... |
## Reprocess in the "after head" insertion mode... |
| 2526 |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 2527 |
!!!cp ('t143.3'); |
!!!cp ('t143.3'); |
| 2528 |
## NOTE: Two parse errors for <head><noscript></br> |
## NOTE: Two parse errors for <head><noscript></br> |
| 2529 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
| 2530 |
text => 'br', token => $token); |
text => 'br', token => $token); |
| 2531 |
## As if </noscript> |
## As if </noscript> |
| 2532 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 2533 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 2534 |
|
|
| 2535 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 2536 |
## As if </head> |
## As if </head> |
| 2537 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 2538 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 2539 |
|
|
| 2540 |
## Reprocess in the "after head" insertion mode... |
## Reprocess in the "after head" insertion mode... |
| 2541 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 2542 |
!!!cp ('t143.4'); |
!!!cp ('t143.4'); |
| 2543 |
# |
# |
| 2544 |
} else { |
} else { |
| 2545 |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
| 2546 |
} |
} |
| 2547 |
|
|
| 2548 |
## ISSUE: does not agree with IE7 - it doesn't ignore </br>. |
# |
| 2549 |
!!!parse-error (type => 'unmatched end tag', |
} else { ## Other end tags |
|
text => 'br', token => $token); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
next B; |
|
|
} else { |
|
| 2550 |
!!!cp ('t145'); |
!!!cp ('t145'); |
| 2551 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
| 2552 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
| 2590 |
!!!insert-element ('body',, $token); |
!!!insert-element ('body',, $token); |
| 2591 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 2592 |
## reprocess |
## reprocess |
| 2593 |
next B; |
next B; |
| 2594 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 2595 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 2596 |
!!!cp ('t149.1'); |
!!!cp ('t149.1'); |
| 3856 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 3857 |
tr => 1, td => 1, th => 1, |
tr => 1, td => 1, th => 1, |
| 3858 |
}->{$token->{tag_name}})) { |
}->{$token->{tag_name}})) { |
| 3859 |
## TODO: The type below is not good - <select> is replaced by </select> |
|
| 3860 |
!!!parse-error (type => 'not closed', text => 'select', |
## 1. Parse error. |
| 3861 |
token => $token); |
if ($token->{tag_name} eq 'select') { |
| 3862 |
## NOTE: As if the token were </select> (<select> case) or |
!!!parse-error (type => 'select in select', ## XXX: documentation |
| 3863 |
## as if there were </select> (otherwise). |
token => $token); |
| 3864 |
## have an element in table scope |
} else { |
| 3865 |
|
!!!parse-error (type => 'not closed', text => 'select', |
| 3866 |
|
token => $token); |
| 3867 |
|
} |
| 3868 |
|
|
| 3869 |
|
## 2./<select>-1. Unless "have an element in table scope" (select): |
| 3870 |
my $i; |
my $i; |
| 3871 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3872 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 3881 |
} # INSCOPE |
} # INSCOPE |
| 3882 |
unless (defined $i) { |
unless (defined $i) { |
| 3883 |
!!!cp ('t280'); |
!!!cp ('t280'); |
| 3884 |
!!!parse-error (type => 'unmatched end tag', |
if ($token->{tag_name} eq 'select') { |
| 3885 |
text => 'select', token => $token); |
## NOTE: This error would be raised when |
| 3886 |
## Ignore the token |
## |select.innerHTML = '<select>'| is executed; in this |
| 3887 |
|
## case two errors, "select in select" and "unmatched |
| 3888 |
|
## end tags" are reported to the user, the latter might |
| 3889 |
|
## be confusing but this is what the spec requires. |
| 3890 |
|
!!!parse-error (type => 'unmatched end tag', |
| 3891 |
|
text => 'select', |
| 3892 |
|
token => $token); |
| 3893 |
|
} |
| 3894 |
|
## Ignore the token. |
| 3895 |
!!!nack ('t280.1'); |
!!!nack ('t280.1'); |
| 3896 |
!!!next-token; |
!!!next-token; |
| 3897 |
next B; |
next B; |
| 3898 |
} |
} |
| 3899 |
|
|
| 3900 |
|
## 3. Otherwise, as if there were <select>: |
| 3901 |
|
|
| 3902 |
!!!cp ('t281'); |
!!!cp ('t281'); |
| 3903 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4433 |
table => 1, |
table => 1, |
| 4434 |
hr => 1, |
hr => 1, |
| 4435 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4436 |
|
|
| 4437 |
|
## 1. When there is an opening |form| element: |
| 4438 |
if ($token->{tag_name} eq 'form' and defined $self->{form_element}) { |
if ($token->{tag_name} eq 'form' and defined $self->{form_element}) { |
| 4439 |
!!!cp ('t350'); |
!!!cp ('t350'); |
| 4440 |
!!!parse-error (type => 'in form:form', token => $token); |
!!!parse-error (type => 'in form:form', token => $token); |
| 4444 |
next B; |
next B; |
| 4445 |
} |
} |
| 4446 |
|
|
| 4447 |
|
## 2. Close the |p| element, if any. |
| 4448 |
if ($token->{tag_name} ne 'table' or # The Hixie Quirk |
if ($token->{tag_name} ne 'table' or # The Hixie Quirk |
| 4449 |
$self->{document}->manakai_compat_mode ne 'quirks') { |
$self->{document}->manakai_compat_mode ne 'quirks') { |
| 4450 |
## has a p element in scope |
## has a p element in scope |
| 4461 |
} |
} |
| 4462 |
} # INSCOPE |
} # INSCOPE |
| 4463 |
} |
} |
| 4464 |
|
|
| 4465 |
|
## 3. Close the opening <hn> element, if any. |
| 4466 |
|
if ({h1 => 1, h2 => 1, h3 => 1, |
| 4467 |
|
h4 => 1, h5 => 1, h6 => 1}->{$token->{tag_name}}) { |
| 4468 |
|
if ($self->{open_elements}->[-1]->[1] == HEADING_EL) { |
| 4469 |
|
!!!parse-error (type => 'not closed', |
| 4470 |
|
text => $self->{open_elements}->[-1]->[0]->manakai_local_name, |
| 4471 |
|
token => $token); |
| 4472 |
|
pop @{$self->{open_elements}}; |
| 4473 |
|
} |
| 4474 |
|
} |
| 4475 |
|
|
| 4476 |
|
## 4. Insertion. |
| 4477 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 4478 |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 4479 |
!!!nack ('t346.1'); |
!!!nack ('t346.1'); |
| 4517 |
} elsif ($token->{tag_name} eq 'li') { |
} elsif ($token->{tag_name} eq 'li') { |
| 4518 |
## NOTE: As normal, but imply </li> when there's another <li> ... |
## NOTE: As normal, but imply </li> when there's another <li> ... |
| 4519 |
|
|
| 4520 |
## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>) |
## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>):: |
| 4521 |
## Interpreted as <li><foo/></li><li/> (non-conforming) |
## Interpreted as <li><foo/></li><li/> (non-conforming): |
| 4522 |
## blockquote (O9.27), center (O), dd (Fx3, O, S3.1.2, IE7), |
## blockquote (O9.27), center (O), dd (Fx3, O, S3.1.2, IE7), |
| 4523 |
## dt (Fx, O, S, IE), dl (O), fieldset (O, S, IE), form (Fx, O, S), |
## dt (Fx, O, S, IE), dl (O), fieldset (O, S, IE), form (Fx, O, S), |
| 4524 |
## hn (O), pre (O), applet (O, S), button (O, S), marquee (Fx, O, S), |
## hn (O), pre (O), applet (O, S), button (O, S), marquee (Fx, O, S), |
| 4525 |
## object (Fx) |
## object (Fx) |
| 4526 |
## Generate non-tree (non-conforming) |
## Generate non-tree (non-conforming): |
| 4527 |
## basefont (IE7 (where basefont is non-void)), center (IE), |
## basefont (IE7 (where basefont is non-void)), center (IE), |
| 4528 |
## form (IE), hn (IE) |
## form (IE), hn (IE) |
| 4529 |
## address, div, p (<li><foo><li> == <li><foo/></li><li/>) |
## address, div, p (<li><foo><li> == <li><foo/></li><li/>):: |
| 4530 |
## Interpreted as <li><foo><li/></foo></li> (non-conforming) |
## Interpreted as <li><foo><li/></foo></li> (non-conforming): |
| 4531 |
## div (Fx, S) |
## div (Fx, S) |
| 4532 |
|
|
| 4533 |
my $non_optional; |
my $non_optional; |
| 4874 |
next B; |
next B; |
| 4875 |
} |
} |
| 4876 |
} elsif ($token->{tag_name} eq 'textarea') { |
} elsif ($token->{tag_name} eq 'textarea') { |
| 4877 |
## Step 1 |
## 1. Insert |
| 4878 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 4879 |
|
|
| 4880 |
## Step 2 |
## Step 2 # XXX |
| 4881 |
## TODO: $self->{form_element} if defined |
## TODO: $self->{form_element} if defined |
| 4882 |
|
|
| 4883 |
## Step 3 |
## 2. Drop U+000A LINE FEED |
| 4884 |
$self->{ignore_newline} = 1; |
$self->{ignore_newline} = 1; |
| 4885 |
|
|
| 4886 |
## Step 4 |
## 3. RCDATA |
|
## ISSUE: This step is wrong. (r2302 enbugged) |
|
|
|
|
|
## Step 5 |
|
| 4887 |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
| 4888 |
delete $self->{escape}; # MUST |
delete $self->{escape}; # MUST |
| 4889 |
|
|
| 4890 |
## Step 6-7 |
## 4., 6. Insertion mode |
| 4891 |
$self->{insertion_mode} |= IN_CDATA_RCDATA_IM; |
$self->{insertion_mode} |= IN_CDATA_RCDATA_IM; |
| 4892 |
|
|
| 4893 |
|
## XXX: 5. frameset-ok flag |
| 4894 |
|
|
| 4895 |
!!!nack ('t392.1'); |
!!!nack ('t392.1'); |
| 4896 |
!!!next-token; |
!!!next-token; |
| 4897 |
next B; |
next B; |
| 5063 |
} |
} |
| 5064 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 5065 |
if ($token->{tag_name} eq 'body') { |
if ($token->{tag_name} eq 'body') { |
| 5066 |
## has a |body| element in scope |
|
| 5067 |
|
## 1. If not "have an element in scope": |
| 5068 |
|
## "has a |body| element in scope" |
| 5069 |
my $i; |
my $i; |
| 5070 |
INSCOPE: { |
INSCOPE: { |
| 5071 |
for (reverse @{$self->{open_elements}}) { |
for (reverse @{$self->{open_elements}}) { |
| 5088 |
next B; |
next B; |
| 5089 |
} # INSCOPE |
} # INSCOPE |
| 5090 |
|
|
| 5091 |
|
## 2. If unclosed elements: |
| 5092 |
for (@{$self->{open_elements}}) { |
for (@{$self->{open_elements}}) { |
| 5093 |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL || |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL || |
| 5094 |
$_->[1] == OPTGROUP_EL || |
$_->[1] == OPTGROUP_EL || |
| 5104 |
} |
} |
| 5105 |
} |
} |
| 5106 |
|
|
| 5107 |
|
## 3. Switch the insertion mode. |
| 5108 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 5109 |
!!!next-token; |
!!!next-token; |
| 5110 |
next B; |
next B; |