1
0
mirror of https://github.com/golang/go synced 2024-11-12 04:50:21 -07:00

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
This commit is contained in:
Andrew Balholm 2012-05-25 10:03:59 +10:00 committed by Nigel Tao
parent 60ffae25bc
commit c23041efd9
3 changed files with 20 additions and 16 deletions

View File

@ -82,7 +82,6 @@ var breakout = map[string]bool{
"dt": true,
"em": true,
"embed": true,
"font": true,
"h1": true,
"h2": true,
"h3": true,

View File

@ -1785,12 +1785,7 @@ func afterAfterFramesetIM(p *parser) bool {
func parseForeignContent(p *parser) bool {
switch p.tok.Type {
case TextToken:
// TODO: HTML integration points.
if p.top().Namespace == "" {
inBodyIM(p)
p.resetInsertionMode()
return true
}
p.tok.Data = strings.Replace(p.tok.Data, "\x00", "", -1)
if p.framesetOK {
p.framesetOK = strings.TrimLeft(p.tok.Data, whitespace) == ""
}
@ -1801,15 +1796,21 @@ func parseForeignContent(p *parser) bool {
Data: p.tok.Data,
})
case StartTagToken:
if htmlIntegrationPoint(p.top()) {
inBodyIM(p)
p.resetInsertionMode()
return true
b := breakout[p.tok.Data]
if p.tok.Data == "font" {
loop:
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-- {
// TODO: MathML integration points.
if p.oe[i].Namespace == "" || htmlIntegrationPoint(p.oe[i]) {
n := p.oe[i]
if n.Namespace == "" || htmlIntegrationPoint(n) || mathMLTextIntegrationPoint(n) {
p.oe = p.oe[:i+1]
break
}
@ -1833,6 +1834,10 @@ func parseForeignContent(p *parser) bool {
namespace := p.top().Namespace
p.addElement(p.tok.Data, p.tok.Attr)
p.top().Namespace = namespace
if p.hasSelfClosingToken {
p.oe.pop()
p.acknowledgeSelfClosingTag()
}
case EndTagToken:
for i := len(p.oe) - 1; i >= 0; i-- {
if p.oe[i].Namespace == "" {

View File

@ -16,8 +16,8 @@ FAIL "<svg>\x00filler\x00text"
FAIL "<svg>\x00<frameset>"
FAIL "<svg>\x00 <frameset>"
FAIL "<svg>\x00a<frameset>"
FAIL "<svg>\x00</svg><frameset>"
FAIL "<svg>\x00 </svg><frameset>"
PASS "<svg>\x00</svg><frameset>"
PASS "<svg>\x00 </svg><frameset>"
FAIL "<svg>\x00a</svg><frameset>"
PASS "<svg><path></path></svg><frameset>"
PASS "<svg><p><frameset>"