]> Cypherpunks repositories - gostls13.git/commitdiff
exp/html: adjust inCellIM to match spec
authorAndrew Balholm <andybalholm@gmail.com>
Tue, 22 May 2012 00:31:08 +0000 (10:31 +1000)
committerNigel Tao <nigeltao@golang.org>
Tue, 22 May 2012 00:31:08 +0000 (10:31 +1000)
Clean up flow of control.

Ignore </table>, </tbody>, </tfoot>, </thead>, </tr> if there is not
an appropriate element in table scope.

Pass 3 more tests.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6206093

src/pkg/exp/html/parse.go
src/pkg/exp/html/testlogs/webkit02.dat.log

index 05c208edcc839de3eb81edf9d657503c8940e55b..4cd7973853ec192109f6db999e99ec8184a5f752 100644 (file)
@@ -1451,15 +1451,18 @@ func inRowIM(p *parser) bool {
 
 // Section 12.2.5.4.15.
 func inCellIM(p *parser) bool {
-       var (
-               closeTheCellAndReprocess bool
-       )
        switch p.tok.Type {
        case StartTagToken:
                switch p.tok.Data {
                case "caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr":
-                       // TODO: check for "td" or "th" in table scope.
-                       closeTheCellAndReprocess = true
+                       if p.popUntil(tableScope, "td", "th") {
+                               // Close the cell and reprocess.
+                               p.clearActiveFormattingElements()
+                               p.im = inRowIM
+                               return false
+                       }
+                       // Ignore the token.
+                       return true
                case "select":
                        p.reconstructActiveFormattingElements()
                        p.addElement(p.tok.Data, p.tok.Attr)
@@ -1478,20 +1481,15 @@ func inCellIM(p *parser) bool {
                        p.im = inRowIM
                        return true
                case "body", "caption", "col", "colgroup", "html":
-                       // TODO.
+                       // Ignore the token.
+                       return true
                case "table", "tbody", "tfoot", "thead", "tr":
-                       // TODO: check for matching element in table scope.
-                       closeTheCellAndReprocess = true
-               }
-       case CommentToken:
-               p.addChild(&Node{
-                       Type: CommentNode,
-                       Data: p.tok.Data,
-               })
-               return true
-       }
-       if closeTheCellAndReprocess {
-               if p.popUntil(tableScope, "td") || p.popUntil(tableScope, "th") {
+                       if !p.elementInScope(tableScope, p.tok.Data) {
+                               // Ignore the token.
+                               return true
+                       }
+                       // Close the cell and reprocess.
+                       p.popUntil(tableScope, "td", "th")
                        p.clearActiveFormattingElements()
                        p.im = inRowIM
                        return false
index ad29cd850b0b978d1869c7ca992699d1856f80a5..1a32ff21064c71ce34e624e149a79a2f8fedf69a 100644 (file)
@@ -3,7 +3,7 @@ PASS "<p id=\"status\"><noscript><strong>A</strong></noscript><span>B</span></p>
 PASS "<div><sarcasm><div></div></sarcasm></div>"
 FAIL "<html><body><img src=\"\" border=\"0\" alt=\"><div>A</div></body></html>"
 PASS "<table><td></tbody>A"
-FAIL "<table><td></thead>A"
-FAIL "<table><td></tfoot>A"
-FAIL "<table><thead><td></tbody>A"
+PASS "<table><td></thead>A"
+PASS "<table><td></tfoot>A"
+PASS "<table><thead><td></tbody>A"
 PASS "<legend>test</legend>"