Commit 33a89b5f authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

exp/html: adjust the last few insertion modes to match the spec

Handle text, comment, and doctype tokens in afterBodyIM, afterAfterBodyIM,
and afterAfterFramesetIM.

Pass three more tests.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6231043
parent 13a59b8c
......@@ -1597,6 +1597,12 @@ func afterBodyIM(p *parser) bool {
case ErrorToken:
// Stop parsing.
return true
case TextToken:
s := strings.TrimLeft(p.tok.Data, whitespace)
if len(s) == 0 {
// It was all whitespace.
return inBodyIM(p)
}
case StartTagToken:
if p.tok.Data == "html" {
return inBodyIM(p)
......@@ -1717,7 +1723,11 @@ func afterAfterBodyIM(p *parser) bool {
// Stop parsing.
return true
case TextToken:
// TODO.
s := strings.TrimLeft(p.tok.Data, whitespace)
if len(s) == 0 {
// It was all whitespace.
return inBodyIM(p)
}
case StartTagToken:
if p.tok.Data == "html" {
return inBodyIM(p)
......@@ -1728,6 +1738,8 @@ func afterAfterBodyIM(p *parser) bool {
Data: p.tok.Data,
})
return true
case DoctypeToken:
return inBodyIM(p)
}
p.im = inBodyIM
return false
......@@ -1737,7 +1749,7 @@ func afterAfterBodyIM(p *parser) bool {
func afterAfterFramesetIM(p *parser) bool {
switch p.tok.Type {
case CommentToken:
p.addChild(&Node{
p.doc.Add(&Node{
Type: CommentNode,
Data: p.tok.Data,
})
......@@ -1751,8 +1763,8 @@ func afterAfterFramesetIM(p *parser) bool {
return -1
}, p.tok.Data)
if s != "" {
p.reconstructActiveFormattingElements()
p.addText(s)
p.tok.Data = s
return inBodyIM(p)
}
case StartTagToken:
switch p.tok.Data {
......@@ -1761,6 +1773,8 @@ func afterAfterFramesetIM(p *parser) bool {
case "noframes":
return inHeadIM(p)
}
case DoctypeToken:
return inBodyIM(p)
default:
// Ignore the token.
}
......
......@@ -15,6 +15,6 @@ PASS "<!doctype html><table><tr><select><script></style></script>abc"
PASS "<!doctype html><frameset></frameset><noframes>abc"
PASS "<!doctype html><frameset></frameset><noframes>abc</noframes><!--abc-->"
PASS "<!doctype html><frameset></frameset></html><noframes>abc"
FAIL "<!doctype html><frameset></frameset></html><noframes>abc</noframes><!--abc-->"
PASS "<!doctype html><frameset></frameset></html><noframes>abc</noframes><!--abc-->"
PASS "<!doctype html><table><tr></tbody><tfoot>"
PASS "<!doctype html><table><td><svg></svg>abc<td>"
......@@ -36,7 +36,7 @@ FAIL "<!doctype html><p><math><mtext><p><h1>"
PASS "<!doctype html><frameset></noframes>"
FAIL "<!doctype html><html c=d><body></html><html a=b>"
FAIL "<!doctype html><html c=d><frameset></frameset></html><html a=b>"
FAIL "<!doctype html><html><frameset></frameset></html><!--foo-->"
PASS "<!doctype html><html><frameset></frameset></html><!--foo-->"
PASS "<!doctype html><html><frameset></frameset></html> "
PASS "<!doctype html><html><frameset></frameset></html>abc"
PASS "<!doctype html><html><frameset></frameset></html><p>"
......
......@@ -25,7 +25,7 @@ PASS "<html><body></body></html>x<!-- Hi there --></html><!-- Again -->"
PASS "<html><body></body></html>x<!-- Hi there --></body></html><!-- Again -->"
FAIL "<html><body><ruby><div><rp>xx</rp></div></ruby></body></html>"
FAIL "<html><body><ruby><div><rt>xx</rt></div></ruby></body></html>"
FAIL "<html><frameset><!--1--><noframes>A</noframes><!--2--></frameset><!--3--><noframes>B</noframes><!--4--></html><!--5--><noframes>C</noframes><!--6-->"
PASS "<html><frameset><!--1--><noframes>A</noframes><!--2--></frameset><!--3--><noframes>B</noframes><!--4--></html><!--5--><noframes>C</noframes><!--6-->"
PASS "<select><option>A<select><option>B<select><option>C<select><option>D<select><option>E<select><option>F<select><option>G<select>"
PASS "<dd><dd><dt><dt><dd><li><li>"
PASS "<div><b></div><div><nobr>a<nobr>"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment