]> Cypherpunks repositories - gostls13.git/commitdiff
exp/html: detect "integration points" in SVG and MathML content
authorAndrew Balholm <andybalholm@gmail.com>
Thu, 24 May 2012 03:46:41 +0000 (13:46 +1000)
committerNigel Tao <nigeltao@golang.org>
Thu, 24 May 2012 03:46:41 +0000 (13:46 +1000)
Detect HTML integration points and MathML text integration points.
At these points, process tokens as HTML, not as foreign content.

Pass 33 more tests.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6249044

12 files changed:
src/pkg/exp/html/foreign.go
src/pkg/exp/html/parse.go
src/pkg/exp/html/testlogs/pending-spec-changes.dat.log
src/pkg/exp/html/testlogs/plain-text-unsafe.dat.log
src/pkg/exp/html/testlogs/tables01.dat.log
src/pkg/exp/html/testlogs/tests10.dat.log
src/pkg/exp/html/testlogs/tests12.dat.log
src/pkg/exp/html/testlogs/tests19.dat.log
src/pkg/exp/html/testlogs/tests20.dat.log
src/pkg/exp/html/testlogs/tests26.dat.log
src/pkg/exp/html/testlogs/tests9.dat.log
src/pkg/exp/html/testlogs/webkit01.dat.log

index 99b7a6535daecbcf1834107e3cac365a8856c642..89eef3dcb568e5fc845d971b27eb73f3c7cb230d 100644 (file)
@@ -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,
index d4fcdca4e42c66227baf56cbb784ef98de423c59..1544bee26d512eeebdf96532497b7600ca5e33fd 100644 (file)
@@ -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
 }
 
index cc0ffb015dcf85908bfe172b04f7db3fa9e2e080..71d017039915cf37ad8cdb8297c6463f9c7a3789 100644 (file)
@@ -1,3 +1,3 @@
 PASS "<input type=\"hidden\"><frameset>"
 PASS "<!DOCTYPE html><table><caption><svg>foo</table>bar"
-FAIL "<table><tr><td><svg><desc><td></desc><circle>"
+PASS "<table><tr><td><svg><desc><td></desc><circle>"
index de9f385a20639d4c28acf1ecb2b6ba53208169df..41b003e6899fd8493fe2fd33277b739c5761c532 100644 (file)
@@ -11,7 +11,7 @@ FAIL "<plaintext>\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"
index 265b754ce0ef1ab4b86dbef4d913dcce412443ad..3d8534dee21b1c145b03f7976862e69bd6b7cb2d 100644 (file)
@@ -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>"
index 2b16562357801108c20ebd64269a5b317fccb3dc..edf75d689abc6dc09041e7f9e51573e5a0323cec 100644 (file)
@@ -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>"
index 289112143e7af67c7fc805a136d36860654edeab..6fd0d1ea26f956734e2e82b61e74ea8b9897fefe 100644 (file)
@@ -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"
index f1202346be57b1e25bd7fc6daff7b69395f13591..888ceaa1653326d1a34c7a60a733130a94e2dc76 100644 (file)
@@ -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\">"
index 4f4cb0360ed4bccc7187b04f643bbe1042510cb4..c2a144219335573dc983afa36e9b1ffe5b57f380 100644 (file)
@@ -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>"
index 864f1ea1312f59f4d7e4291871c9b169172160f1..17c6ae82cb5df83c43f34542f80238841c007cf0 100644 (file)
@@ -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"
index 532ee37869158693172b2bdc8d7d14b0f91dec1d..ab4b8c305ed54cd8cb585e6b09517f6b220d8d4a 100644 (file)
@@ -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>"
index cf520cfae65619e3c33a626ee1c4d82b0137bdcf..78c5f68e502f05adc8419ccd2cbc26e0fa9c0206 100644 (file)
@@ -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>"