Commit b28f0175 authored by Andrew Balholm's avatar Andrew Balholm Committed by Nigel Tao

html: "in select in table" insertion mode.

Pass tests10.dat, test 16:
<!DOCTYPE
html><body><table><tr><td><select><svg><g>foo</g><g>bar</g><p>baz</table><p>quux

| <!DOCTYPE html>
| <html>
|   <head>
|   <body>
|     <table>
|       <tbody>
|         <tr>
|           <td>
|             <select>
|               "foobarbaz"
|     <p>
|       "quux"

Also pass tests through test 21:
<!DOCTYPE html><frameset></frameset><svg><g></g><g></g><p><span>

R=nigeltao
CC=golang-dev
https://golang.org/cl/5505069
parent cadbd3ea
...@@ -683,7 +683,6 @@ func inBodyIM(p *parser) bool { ...@@ -683,7 +683,6 @@ func inBodyIM(p *parser) bool {
p.reconstructActiveFormattingElements() p.reconstructActiveFormattingElements()
p.addElement(p.tok.Data, p.tok.Attr) p.addElement(p.tok.Data, p.tok.Attr)
p.framesetOK = false p.framesetOK = false
// TODO: detect <select> inside a table.
p.im = inSelectIM p.im = inSelectIM
return true return true
case "form": case "form":
...@@ -1049,6 +1048,17 @@ func inTableIM(p *parser) bool { ...@@ -1049,6 +1048,17 @@ func inTableIM(p *parser) bool {
p.addElement("colgroup", p.tok.Attr) p.addElement("colgroup", p.tok.Attr)
p.im = inColumnGroupIM p.im = inColumnGroupIM
return false return false
case "select":
p.reconstructActiveFormattingElements()
switch p.top().Data {
case "table", "tbody", "tfoot", "thead", "tr":
p.fosterParenting = true
}
p.addElement(p.tok.Data, p.tok.Attr)
p.fosterParenting = false
p.framesetOK = false
p.im = inSelectInTableIM
return true
default: default:
// TODO. // TODO.
} }
...@@ -1109,6 +1119,12 @@ func inCaptionIM(p *parser) bool { ...@@ -1109,6 +1119,12 @@ func inCaptionIM(p *parser) bool {
// Ignore the token. // Ignore the token.
return true return true
} }
case "select":
p.reconstructActiveFormattingElements()
p.addElement(p.tok.Data, p.tok.Attr)
p.framesetOK = false
p.im = inSelectInTableIM
return true
} }
case EndTagToken: case EndTagToken:
switch p.tok.Data { switch p.tok.Data {
...@@ -1311,6 +1327,12 @@ func inCellIM(p *parser) bool { ...@@ -1311,6 +1327,12 @@ func inCellIM(p *parser) bool {
case "caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr": case "caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr":
// TODO: check for "td" or "th" in table scope. // TODO: check for "td" or "th" in table scope.
closeTheCellAndReprocess = true closeTheCellAndReprocess = true
case "select":
p.reconstructActiveFormattingElements()
p.addElement(p.tok.Data, p.tok.Attr)
p.framesetOK = false
p.im = inSelectInTableIM
return true
} }
case EndTagToken: case EndTagToken:
switch p.tok.Data { switch p.tok.Data {
...@@ -1405,21 +1427,40 @@ func inSelectIM(p *parser) bool { ...@@ -1405,21 +1427,40 @@ func inSelectIM(p *parser) bool {
}) })
} }
if endSelect { if endSelect {
for i := len(p.oe) - 1; i >= 0; i-- { p.endSelect()
switch p.oe[i].Data { }
case "select": return true
p.oe = p.oe[:i] }
p.resetInsertionMode()
return true // Section 12.2.5.4.17.
case "option", "optgroup": func inSelectInTableIM(p *parser) bool {
continue switch p.tok.Type {
default: case StartTagToken, EndTagToken:
switch p.tok.Data {
case "caption", "table", "tbody", "tfoot", "thead", "tr", "td", "th":
if p.tok.Type == StartTagToken || p.elementInScope(tableScopeStopTags, p.tok.Data) {
p.endSelect()
return false
} else {
// Ignore the token. // Ignore the token.
return true return true
} }
} }
} }
return true return inSelectIM(p)
}
func (p *parser) endSelect() {
for i := len(p.oe) - 1; i >= 0; i-- {
switch p.oe[i].Data {
case "option", "optgroup":
continue
case "select":
p.oe = p.oe[:i]
p.resetInsertionMode()
}
return
}
} }
// Section 12.2.5.4.18. // Section 12.2.5.4.18.
......
...@@ -173,7 +173,7 @@ func TestParser(t *testing.T) { ...@@ -173,7 +173,7 @@ func TestParser(t *testing.T) {
{"tests4.dat", -1}, {"tests4.dat", -1},
{"tests5.dat", -1}, {"tests5.dat", -1},
{"tests6.dat", 47}, {"tests6.dat", 47},
{"tests10.dat", 16}, {"tests10.dat", 22},
} }
for _, tf := range testFiles { for _, tf := range testFiles {
f, err := os.Open("testdata/webkit/" + tf.filename) f, err := os.Open("testdata/webkit/" + tf.filename)
......
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