diff --git a/src/pkg/exp/html/foreign.go b/src/pkg/exp/html/foreign.go index 99b7a6535d..89eef3dcb5 100644 --- a/src/pkg/exp/html/foreign.go +++ b/src/pkg/exp/html/foreign.go @@ -37,8 +37,16 @@ func htmlIntegrationPoint(n *Node) bool { } switch n.Namespace { case "math": - // TODO: annotation-xml elements whose start tags have "text/html" or - // "application/xhtml+xml" encodings. + if n.Data == "annotation-xml" { + for _, a := range n.Attr { + if a.Key == "encoding" { + val := strings.ToLower(a.Val) + if val == "text/html" || val == "application/xhtml+xml" { + return true + } + } + } + } case "svg": switch n.Data { case "desc", "foreignObject", "title": @@ -48,6 +56,17 @@ func htmlIntegrationPoint(n *Node) bool { return false } +func mathMLTextIntegrationPoint(n *Node) bool { + if n.Namespace != "math" { + return false + } + switch n.Data { + case "mi", "mo", "mn", "ms", "mtext": + return true + } + return false +} + // Section 12.2.5.5. var breakout = map[string]bool{ "b": true, diff --git a/src/pkg/exp/html/parse.go b/src/pkg/exp/html/parse.go index d4fcdca4e4..1544bee26d 100644 --- a/src/pkg/exp/html/parse.go +++ b/src/pkg/exp/html/parse.go @@ -1859,8 +1859,23 @@ func (p *parser) inForeignContent() bool { if n.Namespace == "" { return false } - // TODO: MathML, HTML integration points. - // TODO: MathML's annotation-xml combining with SVG's svg. + if mathMLTextIntegrationPoint(n) { + if p.tok.Type == StartTagToken && p.tok.Data != "mglyph" && p.tok.Data != "malignmark" { + return false + } + if p.tok.Type == TextToken { + return false + } + } + if n.Namespace == "math" && n.Data == "annotation-xml" && p.tok.Type == StartTagToken && p.tok.Data == "svg" { + return false + } + if htmlIntegrationPoint(n) && (p.tok.Type == StartTagToken || p.tok.Type == TextToken) { + return false + } + if p.tok.Type == ErrorToken { + return false + } return true } diff --git a/src/pkg/exp/html/testlogs/pending-spec-changes.dat.log b/src/pkg/exp/html/testlogs/pending-spec-changes.dat.log index cc0ffb015d..71d0170399 100644 --- a/src/pkg/exp/html/testlogs/pending-spec-changes.dat.log +++ b/src/pkg/exp/html/testlogs/pending-spec-changes.dat.log @@ -1,3 +1,3 @@ PASS "" PASS "
foo
bar" -FAIL "
" +PASS "
" diff --git a/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log b/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log index de9f385a20..41b003e689 100644 --- a/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log +++ b/src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log @@ -11,7 +11,7 @@ FAIL "\x00filler\x00text\x00" FAIL "<svg><![CDATA[\x00filler\x00text\x00]]>" FAIL "<body><!\x00>" FAIL "<body><!\x00filler\x00text>" -FAIL "<body><svg><foreignObject>\x00filler\x00text" +PASS "<body><svg><foreignObject>\x00filler\x00text" FAIL "<svg>\x00filler\x00text" FAIL "<svg>\x00<frameset>" FAIL "<svg>\x00 <frameset>" @@ -24,10 +24,10 @@ PASS "<svg><p><frameset>" FAIL "<!DOCTYPE html><pre>\r\n\r\nA</pre>" FAIL "<!DOCTYPE html><pre>\r\rA</pre>" PASS "<!DOCTYPE html><pre>\rA</pre>" -FAIL "<!DOCTYPE html><table><tr><td><math><mtext>\x00a" -FAIL "<!DOCTYPE html><table><tr><td><svg><foreignObject>\x00a" -FAIL "<!DOCTYPE html><math><mi>a\x00b" -FAIL "<!DOCTYPE html><math><mo>a\x00b" -FAIL "<!DOCTYPE html><math><mn>a\x00b" -FAIL "<!DOCTYPE html><math><ms>a\x00b" -FAIL "<!DOCTYPE html><math><mtext>a\x00b" +PASS "<!DOCTYPE html><table><tr><td><math><mtext>\x00a" +PASS "<!DOCTYPE html><table><tr><td><svg><foreignObject>\x00a" +PASS "<!DOCTYPE html><math><mi>a\x00b" +PASS "<!DOCTYPE html><math><mo>a\x00b" +PASS "<!DOCTYPE html><math><mn>a\x00b" +PASS "<!DOCTYPE html><math><ms>a\x00b" +PASS "<!DOCTYPE html><math><mtext>a\x00b" diff --git a/src/pkg/exp/html/testlogs/tables01.dat.log b/src/pkg/exp/html/testlogs/tables01.dat.log index 265b754ce0..3d8534dee2 100644 --- a/src/pkg/exp/html/testlogs/tables01.dat.log +++ b/src/pkg/exp/html/testlogs/tables01.dat.log @@ -14,4 +14,4 @@ PASS "<table><tr><caption>" PASS "<table><tr></body></caption></col></colgroup></html></td></th><td>foo" PASS "<table><td><tr>" PASS "<table><td><button><td>" -FAIL "<table><tr><td><svg><desc><td>" +PASS "<table><tr><td><svg><desc><td>" diff --git a/src/pkg/exp/html/testlogs/tests10.dat.log b/src/pkg/exp/html/testlogs/tests10.dat.log index 2b16562357..edf75d689a 100644 --- a/src/pkg/exp/html/testlogs/tests10.dat.log +++ b/src/pkg/exp/html/testlogs/tests10.dat.log @@ -35,8 +35,8 @@ PASS "<!DOCTYPE html><svg><desc><svg><ul>a" PASS "<!DOCTYPE html><p><svg><desc><p>" FAIL "<!DOCTYPE html><p><svg><title><p>" PASS "<div><svg><path><foreignObject><p></foreignObject><p>" -FAIL "<math><mi><div><object><div><span></span></div></object></div></mi><mi>" -FAIL "<math><mi><svg><foreignObject><div><div></div></div></foreignObject></svg></mi><mi>" +PASS "<math><mi><div><object><div><span></span></div></object></div></mi><mi>" +PASS "<math><mi><svg><foreignObject><div><div></div></div></foreignObject></svg></mi><mi>" PASS "<svg><script></script><path>" PASS "<table><svg></svg><tr>" PASS "<math><mi><mglyph>" @@ -49,6 +49,6 @@ PASS "<math><ms><mglyph>" PASS "<math><ms><malignmark>" PASS "<math><mtext><mglyph>" PASS "<math><mtext><malignmark>" -FAIL "<math><annotation-xml><svg></svg></annotation-xml><mi>" -FAIL "<math><annotation-xml><svg><foreignObject><div><math><mi></mi></math><span></span></div></foreignObject><path></path></svg></annotation-xml><mi>" -FAIL "<math><annotation-xml><svg><foreignObject><math><mi><svg></svg></mi><mo></mo></math><span></span></foreignObject><path></path></svg></annotation-xml><mi>" +PASS "<math><annotation-xml><svg></svg></annotation-xml><mi>" +PASS "<math><annotation-xml><svg><foreignObject><div><math><mi></mi></math><span></span></div></foreignObject><path></path></svg></annotation-xml><mi>" +PASS "<math><annotation-xml><svg><foreignObject><math><mi><svg></svg></mi><mo></mo></math><span></span></foreignObject><path></path></svg></annotation-xml><mi>" diff --git a/src/pkg/exp/html/testlogs/tests12.dat.log b/src/pkg/exp/html/testlogs/tests12.dat.log index 289112143e..6fd0d1ea26 100644 --- a/src/pkg/exp/html/testlogs/tests12.dat.log +++ b/src/pkg/exp/html/testlogs/tests12.dat.log @@ -1,2 +1,2 @@ -FAIL "<!DOCTYPE html><body><p>foo<math><mtext><i>baz</i></mtext><annotation-xml><svg><desc><b>eggs</b></desc><g><foreignObject><P>spam<TABLE><tr><td><img></td></table></foreignObject></g><g>quux</g></svg></annotation-xml></math>bar" -FAIL "<!DOCTYPE html><body>foo<math><mtext><i>baz</i></mtext><annotation-xml><svg><desc><b>eggs</b></desc><g><foreignObject><P>spam<TABLE><tr><td><img></td></table></foreignObject></g><g>quux</g></svg></annotation-xml></math>bar" +PASS "<!DOCTYPE html><body><p>foo<math><mtext><i>baz</i></mtext><annotation-xml><svg><desc><b>eggs</b></desc><g><foreignObject><P>spam<TABLE><tr><td><img></td></table></foreignObject></g><g>quux</g></svg></annotation-xml></math>bar" +PASS "<!DOCTYPE html><body>foo<math><mtext><i>baz</i></mtext><annotation-xml><svg><desc><b>eggs</b></desc><g><foreignObject><P>spam<TABLE><tr><td><img></td></table></foreignObject></g><g>quux</g></svg></annotation-xml></math>bar" diff --git a/src/pkg/exp/html/testlogs/tests19.dat.log b/src/pkg/exp/html/testlogs/tests19.dat.log index f1202346be..888ceaa165 100644 --- a/src/pkg/exp/html/testlogs/tests19.dat.log +++ b/src/pkg/exp/html/testlogs/tests19.dat.log @@ -28,11 +28,11 @@ PASS "<!doctype html><table> b <!--foo-->" PASS "<!doctype html><select><option><option>" PASS "<!doctype html><select><option></optgroup>" PASS "<!doctype html><select><option></optgroup>" -FAIL "<!doctype html><p><math><mi><p><h1>" -FAIL "<!doctype html><p><math><mo><p><h1>" -FAIL "<!doctype html><p><math><mn><p><h1>" -FAIL "<!doctype html><p><math><ms><p><h1>" -FAIL "<!doctype html><p><math><mtext><p><h1>" +PASS "<!doctype html><p><math><mi><p><h1>" +PASS "<!doctype html><p><math><mo><p><h1>" +PASS "<!doctype html><p><math><mn><p><h1>" +PASS "<!doctype html><p><math><ms><p><h1>" +PASS "<!doctype html><p><math><mtext><p><h1>" PASS "<!doctype html><frameset></noframes>" FAIL "<!doctype html><html c=d><body></html><html a=b>" FAIL "<!doctype html><html c=d><frameset></frameset></html><html a=b>" @@ -80,7 +80,7 @@ PASS "<html> a <frameset></frameset>" PASS "<!doctype html><div><frameset>" PASS "<!doctype html><div><body><frameset>" PASS "<!doctype html><p><math></p>a" -FAIL "<!doctype html><p><math><mn><span></p>a" +PASS "<!doctype html><p><math><mn><span></p>a" PASS "<!doctype html><math></html>" PASS "<!doctype html><meta charset=\"ascii\">" FAIL "<!doctype html><meta http-equiv=\"content-type\" content=\"text/html;charset=ascii\">" diff --git a/src/pkg/exp/html/testlogs/tests20.dat.log b/src/pkg/exp/html/testlogs/tests20.dat.log index 4f4cb0360e..c2a1442193 100644 --- a/src/pkg/exp/html/testlogs/tests20.dat.log +++ b/src/pkg/exp/html/testlogs/tests20.dat.log @@ -32,8 +32,8 @@ PASS "<option><span><option>" PASS "<option><option>" PASS "<math><annotation-xml><div>" PASS "<math><annotation-xml encoding=\"application/svg+xml\"><div>" -FAIL "<math><annotation-xml encoding=\"application/xhtml+xml\"><div>" -FAIL "<math><annotation-xml encoding=\"aPPlication/xhtmL+xMl\"><div>" -FAIL "<math><annotation-xml encoding=\"text/html\"><div>" -FAIL "<math><annotation-xml encoding=\"Text/htmL\"><div>" +PASS "<math><annotation-xml encoding=\"application/xhtml+xml\"><div>" +PASS "<math><annotation-xml encoding=\"aPPlication/xhtmL+xMl\"><div>" +PASS "<math><annotation-xml encoding=\"text/html\"><div>" +PASS "<math><annotation-xml encoding=\"Text/htmL\"><div>" PASS "<math><annotation-xml encoding=\" text/html \"><div>" diff --git a/src/pkg/exp/html/testlogs/tests26.dat.log b/src/pkg/exp/html/testlogs/tests26.dat.log index 864f1ea131..17c6ae82cb 100644 --- a/src/pkg/exp/html/testlogs/tests26.dat.log +++ b/src/pkg/exp/html/testlogs/tests26.dat.log @@ -8,8 +8,8 @@ PASS "<!DOCTYPE html><body><b><nobr>1<nobr><ins></b><i><nobr>" PASS "<!DOCTYPE html><body><b><nobr>1<ins><nobr></b><i>2" PASS "<!DOCTYPE html><body><b>1<nobr></b><i><nobr>2</i>" FAIL "<p><code x</code></p>" -FAIL "<!DOCTYPE html><svg><foreignObject><p><i></p>a" -FAIL "<!DOCTYPE html><table><tr><td><svg><foreignObject><p><i></p>a" -FAIL "<!DOCTYPE html><math><mtext><p><i></p>a" -FAIL "<!DOCTYPE html><table><tr><td><math><mtext><p><i></p>a" +PASS "<!DOCTYPE html><svg><foreignObject><p><i></p>a" +PASS "<!DOCTYPE html><table><tr><td><svg><foreignObject><p><i></p>a" +PASS "<!DOCTYPE html><math><mtext><p><i></p>a" +PASS "<!DOCTYPE html><table><tr><td><math><mtext><p><i></p>a" PASS "<!DOCTYPE html><body><div><!/div>a" diff --git a/src/pkg/exp/html/testlogs/tests9.dat.log b/src/pkg/exp/html/testlogs/tests9.dat.log index 532ee37869..ab4b8c305e 100644 --- a/src/pkg/exp/html/testlogs/tests9.dat.log +++ b/src/pkg/exp/html/testlogs/tests9.dat.log @@ -1,7 +1,7 @@ PASS "<!DOCTYPE html><math></math>" PASS "<!DOCTYPE html><body><math></math>" PASS "<!DOCTYPE html><math><mi>" -FAIL "<!DOCTYPE html><math><annotation-xml><svg><u>" +PASS "<!DOCTYPE html><math><annotation-xml><svg><u>" PASS "<!DOCTYPE html><body><select><math></math></select>" PASS "<!DOCTYPE html><body><select><option><math></math></option></select>" PASS "<!DOCTYPE html><body><table><math></math></table>" diff --git a/src/pkg/exp/html/testlogs/webkit01.dat.log b/src/pkg/exp/html/testlogs/webkit01.dat.log index cf520cfae6..78c5f68e50 100644 --- a/src/pkg/exp/html/testlogs/webkit01.dat.log +++ b/src/pkg/exp/html/testlogs/webkit01.dat.log @@ -42,7 +42,7 @@ FAIL "<svg><title><svg><div>" PASS "<img <=\"\" FAIL>" FAIL "<ul><li><div id='foo'/>A</li><li>B<div>C</div></li></ul>" PASS "<svg><em><desc></em>" -FAIL "<table><tr><td><svg><desc><td></desc><circle>" +PASS "<table><tr><td><svg><desc><td></desc><circle>" PASS "<svg><tfoot></mi><td>" PASS "<math><mrow><mrow><mn>1</mn></mrow><mi>a</mi></mrow></math>" PASS "<!doctype html><input type=\"hidden\"><frameset>"