]> Cypherpunks repositories - gostls13.git/commitdiff
exp/html: adjust the last few insertion modes to match the spec
authorAndrew Balholm <andybalholm@gmail.com>
Wed, 23 May 2012 01:11:34 +0000 (11:11 +1000)
committerNigel Tao <nigeltao@golang.org>
Wed, 23 May 2012 01:11:34 +0000 (11:11 +1000)
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

src/pkg/exp/html/parse.go
src/pkg/exp/html/testlogs/tests18.dat.log
src/pkg/exp/html/testlogs/tests19.dat.log
src/pkg/exp/html/testlogs/webkit01.dat.log

index 6688b324fc80df79e67958f56dbca4b1cab49c1b..d4fcdca4e42c66227baf56cbb784ef98de423c59 100644 (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.
        }
index 6f4708062ed58035f32261056a1532d7e1a8cbdc..d52663e922cad142fecbef6cbf1a1bf2d6f7daa6 100644 (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>"
index 2b9dd1f44eb304107fa42653191bf62d9cfe6875..9ada3791f15f6ad20cb74d0f7afa42f2089dd8a6 100644 (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>"
index 3cb8b447c4ceff66e78a45293f971e501d4864c4..3488b7eec853e60d368335b295182607a29ed73b 100644 (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>"