1
0
mirror of https://github.com/golang/go synced 2024-11-20 02:14:46 -07:00

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
This commit is contained in:
Andrew Balholm 2012-05-23 11:11:34 +10:00 committed by Nigel Tao
parent 13a59b8c6d
commit 33a89b5fda
4 changed files with 21 additions and 7 deletions

View File

@ -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.
}

View File

@ -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>"

View File

@ -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>"

View File

@ -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>"