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

exp/html: adjust parseForeignContent to match spec

Remove redundant checks for integration points.

Ignore null bytes in text.

Don't break out of foreign content for a <font> tag unless it
has a color, face, or size attribute.

Check for MathML text integration points when breaking out of
foreign content.

Pass two new tests.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6256045
parent 60ffae25
...@@ -82,7 +82,6 @@ var breakout = map[string]bool{ ...@@ -82,7 +82,6 @@ var breakout = map[string]bool{
"dt": true, "dt": true,
"em": true, "em": true,
"embed": true, "embed": true,
"font": true,
"h1": true, "h1": true,
"h2": true, "h2": true,
"h3": true, "h3": true,
......
...@@ -1785,12 +1785,7 @@ func afterAfterFramesetIM(p *parser) bool { ...@@ -1785,12 +1785,7 @@ func afterAfterFramesetIM(p *parser) bool {
func parseForeignContent(p *parser) bool { func parseForeignContent(p *parser) bool {
switch p.tok.Type { switch p.tok.Type {
case TextToken: case TextToken:
// TODO: HTML integration points. p.tok.Data = strings.Replace(p.tok.Data, "\x00", "", -1)
if p.top().Namespace == "" {
inBodyIM(p)
p.resetInsertionMode()
return true
}
if p.framesetOK { if p.framesetOK {
p.framesetOK = strings.TrimLeft(p.tok.Data, whitespace) == "" p.framesetOK = strings.TrimLeft(p.tok.Data, whitespace) == ""
} }
...@@ -1801,15 +1796,21 @@ func parseForeignContent(p *parser) bool { ...@@ -1801,15 +1796,21 @@ func parseForeignContent(p *parser) bool {
Data: p.tok.Data, Data: p.tok.Data,
}) })
case StartTagToken: case StartTagToken:
if htmlIntegrationPoint(p.top()) { b := breakout[p.tok.Data]
inBodyIM(p) if p.tok.Data == "font" {
p.resetInsertionMode() loop:
return true for _, attr := range p.tok.Attr {
switch attr.Key {
case "color", "face", "size":
b = true
break loop
}
}
} }
if breakout[p.tok.Data] { if b {
for i := len(p.oe) - 1; i >= 0; i-- { for i := len(p.oe) - 1; i >= 0; i-- {
// TODO: MathML integration points. n := p.oe[i]
if p.oe[i].Namespace == "" || htmlIntegrationPoint(p.oe[i]) { if n.Namespace == "" || htmlIntegrationPoint(n) || mathMLTextIntegrationPoint(n) {
p.oe = p.oe[:i+1] p.oe = p.oe[:i+1]
break break
} }
...@@ -1833,6 +1834,10 @@ func parseForeignContent(p *parser) bool { ...@@ -1833,6 +1834,10 @@ func parseForeignContent(p *parser) bool {
namespace := p.top().Namespace namespace := p.top().Namespace
p.addElement(p.tok.Data, p.tok.Attr) p.addElement(p.tok.Data, p.tok.Attr)
p.top().Namespace = namespace p.top().Namespace = namespace
if p.hasSelfClosingToken {
p.oe.pop()
p.acknowledgeSelfClosingTag()
}
case EndTagToken: case EndTagToken:
for i := len(p.oe) - 1; i >= 0; i-- { for i := len(p.oe) - 1; i >= 0; i-- {
if p.oe[i].Namespace == "" { if p.oe[i].Namespace == "" {
......
...@@ -16,8 +16,8 @@ FAIL "<svg>\x00filler\x00text" ...@@ -16,8 +16,8 @@ FAIL "<svg>\x00filler\x00text"
FAIL "<svg>\x00<frameset>" FAIL "<svg>\x00<frameset>"
FAIL "<svg>\x00 <frameset>" FAIL "<svg>\x00 <frameset>"
FAIL "<svg>\x00a<frameset>" FAIL "<svg>\x00a<frameset>"
FAIL "<svg>\x00</svg><frameset>" PASS "<svg>\x00</svg><frameset>"
FAIL "<svg>\x00 </svg><frameset>" PASS "<svg>\x00 </svg><frameset>"
FAIL "<svg>\x00a</svg><frameset>" FAIL "<svg>\x00a</svg><frameset>"
PASS "<svg><path></path></svg><frameset>" PASS "<svg><path></path></svg><frameset>"
PASS "<svg><p><frameset>" PASS "<svg><p><frameset>"
......
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