From: Andrew Balholm Date: Tue, 22 May 2012 00:31:08 +0000 (+1000) Subject: exp/html: adjust inCellIM to match spec X-Git-Tag: go1.1rc2~3169 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7648f61c7d7d1cd05a507086821133fae61c37af;p=gostls13.git exp/html: adjust inCellIM to match spec Clean up flow of control. Ignore , , , , 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 --- diff --git a/src/pkg/exp/html/parse.go b/src/pkg/exp/html/parse.go index 05c208edcc..4cd7973853 100644 --- a/src/pkg/exp/html/parse.go +++ b/src/pkg/exp/html/parse.go @@ -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 diff --git a/src/pkg/exp/html/testlogs/webkit02.dat.log b/src/pkg/exp/html/testlogs/webkit02.dat.log index ad29cd850b..1a32ff2106 100644 --- a/src/pkg/exp/html/testlogs/webkit02.dat.log +++ b/src/pkg/exp/html/testlogs/webkit02.dat.log @@ -3,7 +3,7 @@ PASS "

B

PASS "
" FAIL "\"
A
" PASS "A" -FAIL "
A" -FAIL "
A" -FAIL "
A" +PASS "
A" +PASS "
A" +PASS "
A" PASS "test"