Reviewed by Maciej.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jul 2007 09:21:47 +0000 (09:21 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jul 2007 09:21:47 +0000 (09:21 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=8007
        createElement() and XHTML (A dynamically created table not rendered as such)

        Follow the HTML5 rules of making the name lowercase and then
        creating the element in the xhtml namespace.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24146 268f45cc-cd09-0410-ab3c-d52691b4dbfc

34 files changed:
LayoutTests/ChangeLog
LayoutTests/dom/xhtml/level1/core/hc_documentcreateelementcasesensitive-expected.txt
LayoutTests/dom/xhtml/level2/html/HTMLSelectElement18-expected.txt
LayoutTests/dom/xhtml/level2/html/HTMLSelectElement19-expected.txt
LayoutTests/dom/xhtml/level2/html/HTMLSelectElement20-expected.txt
LayoutTests/dom/xhtml/level2/html/HTMLTableElement31-expected.txt
LayoutTests/dom/xhtml/level3/core/nodeisdefaultnamespace09-expected.txt
LayoutTests/dom/xhtml/level3/core/nodelookupprefix10-expected.txt
LayoutTests/fast/css/create_element_align-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/create_element_align-expected.png [new file with mode: 0644]
LayoutTests/fast/css/create_element_align-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/create_element_align.xhtml [new file with mode: 0644]
LayoutTests/fast/dom/Document/replace-child-expected.txt
LayoutTests/fast/dom/createElement-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/createElement.html [new file with mode: 0644]
LayoutTests/svg/custom/createelement-expected.txt
LayoutTests/svg/custom/createelement.svg
LayoutTests/svg/custom/js-late-clipPath-and-object-creation.svg
LayoutTests/svg/custom/js-late-clipPath-creation.svg
LayoutTests/svg/custom/js-late-gradient-and-object-creation.svg
LayoutTests/svg/custom/js-late-gradient-creation.svg
LayoutTests/svg/custom/js-late-marker-and-object-creation.svg
LayoutTests/svg/custom/js-late-marker-creation.svg
LayoutTests/svg/custom/js-late-mask-and-object-creation.svg
LayoutTests/svg/custom/js-late-mask-creation.svg
LayoutTests/svg/custom/js-late-pattern-and-object-creation.svg
LayoutTests/svg/custom/js-late-pattern-creation.svg
LayoutTests/svg/custom/multiple-title-elements.svg
LayoutTests/svg/custom/path-textPath-simulation.svg
WebCore/ChangeLog
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/html/HTMLDocument.cpp
WebCore/html/HTMLDocument.h

index c6a2e93..6f5e8ad 100644 (file)
@@ -1,3 +1,44 @@
+2007-07-10  Rob Buis  <buis@kde.org>
+
+        Reviewed by Maciej.
+
+        Testcase for:
+        http://bugs.webkit.org/show_bug.cgi?id=8007
+        createElement() and XHTML (A dynamically created table not rendered as such)
+
+        SVG tests are changed to use createElementNS instead of createElement.
+        Other test results match FF2 results, except replace-child.html and 
+        nodeisdefaultnamespace09.xhtml.
+
+        * dom/xhtml/level1/core/hc_documentcreateelementcasesensitive-expected.txt:
+        * dom/xhtml/level2/html/HTMLSelectElement18-expected.txt:
+        * dom/xhtml/level2/html/HTMLSelectElement19-expected.txt:
+        * dom/xhtml/level2/html/HTMLSelectElement20-expected.txt:
+        * dom/xhtml/level2/html/HTMLTableElement31-expected.txt:
+        * dom/xhtml/level3/core/nodeisdefaultnamespace09-expected.txt:
+        * dom/xhtml/level3/core/nodelookupprefix10-expected.txt:
+        * fast/css/create_element_align-expected.checksum: Added.
+        * fast/css/create_element_align-expected.png: Added.
+        * fast/css/create_element_align-expected.txt: Added.
+        * fast/css/create_element_align.xhtml: Added.
+        * fast/dom/Document/replace-child-expected.txt:
+        * fast/dom/createElement-expected.txt: Added.
+        * fast/dom/createElement.html: Added.
+        * svg/custom/createelement-expected.txt:
+        * svg/custom/createelement.svg:
+        * svg/custom/js-late-clipPath-and-object-creation.svg:
+        * svg/custom/js-late-clipPath-creation.svg:
+        * svg/custom/js-late-gradient-and-object-creation.svg:
+        * svg/custom/js-late-gradient-creation.svg:
+        * svg/custom/js-late-marker-and-object-creation.svg:
+        * svg/custom/js-late-marker-creation.svg:
+        * svg/custom/js-late-mask-and-object-creation.svg:
+        * svg/custom/js-late-mask-creation.svg:
+        * svg/custom/js-late-pattern-and-object-creation.svg:
+        * svg/custom/js-late-pattern-creation.svg:
+        * svg/custom/multiple-title-elements.svg:
+        * svg/custom/path-textPath-simulation.svg:
+
 2007-07-09  Alice Liu  <alice.liu@apple.com>
 
         * win/Skipped:
index 5d4f66a..6238e7e 100644 (file)
@@ -1,2 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentcreateelementcasesensitive
-Status Success
+Status failure
+Message        nodeName1: assertEquals failed, actual acronym, expected ACRONYM.
index ac3e265..225a24a 100644 (file)
@@ -1,3 +1,2 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLSelectElement18
-Status failure
-Message        optLength: assertEquals failed, actual 5, expected 6.
+Status Success
index 34ff75a..f3f715d 100644 (file)
@@ -1,3 +1,2 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLSelectElement19
-Status failure
-Message        optLength: assertEquals failed, actual 5, expected 6.
+Status Success
index 9bbbffe..2d70846 100644 (file)
@@ -1,3 +1,2 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLSelectElement20
-Status failure
-Message        throw_NOT_FOUND_ERR: assertTrue failed
+Status Success
index d1aa9dd..ab04559 100644 (file)
@@ -1,3 +1,2 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLTableElement31
-Status error
-Message        TypeError: Undefined value
+Status Success
index 5cdb8e6..e9d3390 100644 (file)
@@ -1,2 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeisdefaultnamespace09
-Status Success
+Status failure
+Message        nodeisdefaultnamespace09_2: assertTrue failed
index 1e8740a..58b4b46 100644 (file)
@@ -1,2 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodelookupprefix10
-Status Success
+Status failure
+Message        nodelookupprefix10: assertEquals failed, actual null, expected dom3.
diff --git a/LayoutTests/fast/css/create_element_align-expected.checksum b/LayoutTests/fast/css/create_element_align-expected.checksum
new file mode 100644 (file)
index 0000000..0647079
--- /dev/null
@@ -0,0 +1 @@
+fdec6ec78c1efb2e98f63fa8103f4e79
\ No newline at end of file
diff --git a/LayoutTests/fast/css/create_element_align-expected.png b/LayoutTests/fast/css/create_element_align-expected.png
new file mode 100644 (file)
index 0000000..f60c344
Binary files /dev/null and b/LayoutTests/fast/css/create_element_align-expected.png differ
diff --git a/LayoutTests/fast/css/create_element_align-expected.txt b/LayoutTests/fast/css/create_element_align-expected.txt
new file mode 100644 (file)
index 0000000..b765f38
--- /dev/null
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x118
+  RenderBlock {html} at (0,0) size 800x118
+    RenderBody {body} at (8,16) size 784x86
+      RenderBlock {p} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 760x18
+          text run at (0,0) width 760: "Below both lines should be centered. The first is static, the second is dynamically generated using javascript. Bug 14506."
+      RenderBlock {p} at (0,34) size 784x18
+        RenderText {#text} at (331,0) size 121x18
+          text run at (331,0) width 121: "Should be centered"
+      RenderBlock {p} at (0,68) size 784x18
+        RenderText {#text} at (331,0) size 121x18
+          text run at (331,0) width 121: "Should be centered"
diff --git a/LayoutTests/fast/css/create_element_align.xhtml b/LayoutTests/fast/css/create_element_align.xhtml
new file mode 100644 (file)
index 0000000..b1f3c36
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+    <head>
+        <title>Align test</title>
+        <style type="text/css" media="all">
+            .center {
+                text-align : center;
+            }
+        </style>
+        <script type="text/javascript">
+            function runTest() {
+                var textElement;
+                var DOMObj = document.getElementById("body");
+
+                if (DOMObj == null) {
+                    alert("Can't get element with id \"body\"");
+                    return;
+                }
+
+                textElement = document.createElement("p");
+                textElement.setAttribute("class", "center");
+                textElement.appendChild(document.createTextNode("Should be centered"));
+
+                DOMObj.appendChild(textElement);
+            }
+        </script>
+    </head>
+    <body id="body" onload="runTest()">
+        <p>Below both lines should be centered. The first is static, the second is dynamically generated using javascript. Bug 14506.</p>
+        <p class="center">Should be centered</p>
+    </body>
+</html>
index 1de270b..b844845 100644 (file)
@@ -1,6 +1,6 @@
 This tests that various combinations of replaceChild on the document works as specified. If this test succeeds, there will be a number of "SUCCESS" lines below followed by "SUCCESS - All tests succeeded".
 replacing element with element
-SUCCESS: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><bar/>
+SUCCESS: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><bar xmlns="http://www.w3.org/1999/xhtml"></bar>
 replacing element with doctype
 SUCCESS: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 SUCCESS - All tests succeeded!
diff --git a/LayoutTests/fast/dom/createElement-expected.txt b/LayoutTests/fast/dom/createElement-expected.txt
new file mode 100644 (file)
index 0000000..61046ca
--- /dev/null
@@ -0,0 +1,2 @@
+namespaceURI: http://www.w3.org/1999/xhtml
+The above text should display the xhtml namespace uri. Bug 8007.
diff --git a/LayoutTests/fast/dom/createElement.html b/LayoutTests/fast/dom/createElement.html
new file mode 100644 (file)
index 0000000..d174360
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!DOCTYPE html 
+     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+    <title></title>
+    <script type="text/javascript">
+        function test()
+        {
+            if (window.layoutTestController)
+              layoutTestController.dumpAsText();
+            var td = document.createElement("td");
+            document.getElementById("target").appendChild(document.createTextNode(td.namespaceURI));
+        }
+    </script>
+</head>
+<body onload="test()">
+    <div id="target">
+        namespaceURI: 
+    </div>
+    <p>The above text should display the xhtml namespace uri. Bug 8007.
+    </p>
+</body>
+</html>
index e15f844..2812ce4 100644 (file)
@@ -1,8 +1,6 @@
+CONSOLE MESSAGE: line 13: TypeError: Null value
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
-    RenderSVGContainer {svg} at (0,0) size 363x124
-      RenderPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
-      RenderSVGText {text} at (10,120) size 800x18
-        RenderSVGInlineText {#text} at (0,-14) size 353x18
-          text run at (0,-14) width 353: "namespace of created rect: http://www.w3.org/2000/svg"
+    RenderSVGContainer {svg} at (0,0) size 100x100
       RenderPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
+      RenderSVGText {text} at (10,120) size 800x0
index 4aace36..9f10e00 100644 (file)
@@ -1,19 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <svg xmlns="http://www.w3.org/2000/svg">
-  <rect id="red" width="100" height="100" fill="red" />
+  <rect id="red" width="100" height="100" fill="green" />
   <text id="text" x="10" y="120"></text>
   <script type="text/javascript">
   <![CDATA[
-    var red = document.getElementById('red');
+    var green = document.getElementById('green');
     // Note the use of createElement instead of createElementNS
-    var green = document.createElement("rect");
-    // DOM 3 core says the namespaceURI must be null:
-    // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/DOM3-Core.html#core-ID-2141741547
-    // but setting it to http://www.w3.org/2000/svg (like html does) is more in line with what web authors will expect.
+    var red = document.createElement("rect");
+    // HTML5 says createElement should lowercase the name and create it in the
+    // xhtml namespace. This means the created element is not an SVG element
+    // and therefore can't be appended to a SVG element.
     green.setAttribute("width", "100");
     green.setAttribute("height", "100");
-    green.setAttribute("fill", "green");
-    red.ownerDocument.rootElement.appendChild(green);
+    green.setAttribute("fill", "red");
+    green.ownerDocument.rootElement.appendChild(red);
     document.getElementById('text').textContent = "namespace of created rect: " + green.namespaceURI;
   ]]>
   </script>
index 806621a..0246b07 100644 (file)
@@ -7,7 +7,7 @@
  
     function createObject()
     {
-        var text = document.createElement("text");
+        var text = document.createElementNS("http://www.w3.org/2000/svg", "text");
         text.setAttribute("font-size", "60");
         text.setAttribute("fill", "navy");
         text.setAttribute("clip-path", "url(#dynClip)");
     {
         createObject();
 
-        var clipPath = document.createElement("clipPath");
+        var clipPath = document.createElementNS("http://www.w3.org/2000/svg", "clipPath");
         clipPath.setAttribute("id", "dynClip");
         clipPath.setAttribute("clipPathUnits", "userSpaceOnUse");
 
-        var path = document.createElement("path");
+        var path = document.createElementNS("http://www.w3.org/2000/svg", "path");
         path.setAttribute("d", "M 0 0 l 200 0 l 0 200 l -200 0 Z");
 
         clipPath.appendChild(path);
index ce26a68..8c0be90 100644 (file)
@@ -9,11 +9,11 @@
 
     function createClipPath()
     {
-        var clipPath = document.createElement("clipPath");
+        var clipPath = document.createElementNS("http://www.w3.org/2000/svg", "clipPath");
         clipPath.setAttribute("id", "dynClip");
         clipPath.setAttribute("clipPathUnits", "userSpaceOnUse");
 
-        var path = document.createElement("path");
+        var path = document.createElementNS("http://www.w3.org/2000/svg", "path");
         path.setAttribute("d", "M 0 0 l 200 0 l 0 200 l -200 0 Z");
 
         clipPath.appendChild(path);
index 4415418..9e8de48 100644 (file)
@@ -9,16 +9,16 @@
        function createGradients()
        {
                // Setup "fillLinearGradient"
-               var gradient1 = document.createElement("linearGradient");
+               var gradient1 = document.createElementNS("http://www.w3.org/2000/svg", "linearGradient");
                gradient1.setAttribute("id", "fillLinearGradient");
                gradient1.setAttribute("x1", "0");
                gradient1.setAttribute("x2", "1");
 
-               var stop11 = document.createElement("stop");
+               var stop11 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
                stop11.setAttribute("stop-color", "blue");
                stop11.setAttribute("offset", "0");
 
-               var stop21 = document.createElement("stop");
+               var stop21 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
                stop21.setAttribute("stop-color", "red");
                stop21.setAttribute("offset", "1");
 
                content.appendChild(gradient1);
 
                // Setup "strokeLinearGradient"
-               var gradient2 = document.createElement("linearGradient");
+               var gradient2 = document.createElementNS("http://www.w3.org/2000/svg", "linearGradient");
                gradient2.setAttribute("id", "strokeLinearGradient");
                gradient2.setAttribute("x1", "0");
                gradient2.setAttribute("x2", "1");
 
-               var stop22 = document.createElement("stop");
+               var stop22 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
                stop22.setAttribute("stop-color", "yellow");
                stop22.setAttribute("offset", "0");
 
-               var stop22 = document.createElement("stop");
+               var stop22 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
                stop22.setAttribute("stop-color", "green");
                stop22.setAttribute("offset", "1");
 
@@ -51,7 +51,7 @@
 
        function setupGradientUsers()
        {
-               var text1 = document.createElement("text");
+               var text1 = document.createElementNS("http://www.w3.org/2000/svg", "text");
                text1.setAttribute("font-size", "68");
                text1.setAttribute("x", "-150");
                text1.setAttribute("y", "70")
@@ -61,7 +61,7 @@
 
                content.appendChild(text1);
 
-               var text2 = document.createElement("text");
+               var text2 = document.createElementNS("http://www.w3.org/2000/svg", "text");
                text2.setAttribute("font-size", "68");
                text2.setAttribute("x", "-150");
                text2.setAttribute("y", "140")
@@ -71,7 +71,7 @@
 
                content.appendChild(text2);
 
-               var text3 = document.createElement("text");
+               var text3 = document.createElementNS("http://www.w3.org/2000/svg", "text");
                text3.setAttribute("font-size", "68");
                text3.setAttribute("x", "-150");
                text3.setAttribute("y", "210")
index 20f7656..703d4ae 100644 (file)
@@ -9,16 +9,16 @@
 
        function createGradient()
        {
-               var gradient = document.createElement("linearGradient");
+               var gradient = document.createElementNS("http://www.w3.org/2000/svg", "linearGradient");
                gradient.setAttribute("id", "dynGrad");
                gradient.setAttribute("x1", "0");
                gradient.setAttribute("x2", "1");
 
-               var stop1 = document.createElement("stop");
+               var stop1 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
                stop1.setAttribute("stop-color", "blue");
                stop1.setAttribute("offset", "0");
 
-               var stop2 = document.createElement("stop");
+               var stop2 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
                stop2.setAttribute("stop-color", "red");
                stop2.setAttribute("offset", "1");
 
index def7a03..c80f180 100644 (file)
@@ -18,7 +18,7 @@
 
     function createObject()
     {
-        var path = document.createElement("path");
+        var path = document.createElementNS("http://www.w3.org/2000/svg", "path");
         path.setAttribute("fill", "none");
         path.setAttribute("stroke", "black");
         path.setAttribute("stroke-width", "8");
@@ -34,7 +34,7 @@
     {
         createObject();
 
-        var marker = document.createElement("marker");
+        var marker = document.createElementNS("http://www.w3.org/2000/svg", "marker");
         marker.setAttribute("id", "markerMiddle");
         marker.setAttribute("viewBox", "0 0 10 10");
         marker.setAttribute("markerWidth", "2");
@@ -43,7 +43,7 @@
         marker.setAttribute("refY", "5");
         marker.setAttribute("markerUnits", "strokeWidth");
 
-        var circle = document.createElement("circle");
+        var circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
         circle.setAttribute("cx", "5");
         circle.setAttribute("cy", "5");
         circle.setAttribute("r", "5");
index 005e1cf..a3730d9 100644 (file)
@@ -18,7 +18,7 @@
 
     function createMarker()
     {
-        var marker = document.createElement("marker");
+        var marker = document.createElementNS("http://www.w3.org/2000/svg", "marker");
         marker.setAttribute("id", "markerMiddle");
         marker.setAttribute("viewBox", "0 0 10 10");
         marker.setAttribute("markerWidth", "2");
@@ -27,7 +27,7 @@
         marker.setAttribute("refY", "5");
         marker.setAttribute("markerUnits", "strokeWidth");
 
-        var circle = document.createElement("circle");
+        var circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
         circle.setAttribute("cx", "5");
         circle.setAttribute("cy", "5");
         circle.setAttribute("r", "5");
index 16eedee..2b0977b 100644 (file)
@@ -9,7 +9,7 @@
 
     function createObject()
     {
-        var rect = document.createElement("rect");
+        var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
         rect.setAttribute("width", "800");
         rect.setAttribute("height", "100");
         rect.setAttribute("y", "100");
@@ -23,7 +23,7 @@
     {
         createObject();
 
-        var mask = document.createElement("mask");
+        var mask = document.createElementNS("http://www.w3.org/2000/svg", "mask");
         mask.setAttribute("id", "dynMask");
         mask.setAttribute("maskUnits", "userSpaceOnUse");
         mask.setAttribute("x", "0");
@@ -31,7 +31,7 @@
         mask.setAttribute("width", "800");
         mask.setAttribute("height", "300");
 
-        var rect = document.createElement("rect");
+        var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
         rect.setAttribute("width", "800");
         rect.setAttribute("height", "300");
         rect.setAttribute("fill", "red");
index 46bf11c..45d043f 100644 (file)
@@ -10,7 +10,7 @@
 
     function createMask()
     {
-        var mask = document.createElement("mask");
+        var mask = document.createElementNS("http://www.w3.org/2000/svg", "mask");
         mask.setAttribute("id", "dynMask");
         mask.setAttribute("maskUnits", "userSpaceOnUse");
         mask.setAttribute("x", "0");
@@ -18,7 +18,7 @@
         mask.setAttribute("width", "800");
         mask.setAttribute("height", "300");
 
-        var rect = document.createElement("rect");
+        var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
         rect.setAttribute("width", "800");
         rect.setAttribute("height", "300");
         rect.setAttribute("fill", "red");
index 6899664..111598d 100644 (file)
@@ -9,7 +9,7 @@
        function createPatterns()
        {
                // Setup "fillPattern"  
-               var pattern1 = document.createElement("pattern");
+               var pattern1 = document.createElementNS("http://www.w3.org/2000/svg", "pattern");
                pattern1.setAttribute("id", "fillPattern");
                pattern1.setAttribute("patternUnits", "userSpaceOnUse");
                pattern1.setAttribute("x", "0");
                pattern1.setAttribute("width", "20");
                pattern1.setAttribute("height", "20");
 
-               var rect11 = document.createElement("rect");
+               var rect11 = document.createElementNS("http://www.w3.org/2000/svg", "rect");
                rect11.setAttribute("x", "5");
                rect11.setAttribute("y", "5");
                rect11.setAttribute("width", "10");
                rect11.setAttribute("height", "10");
                rect11.setAttribute("fill", "red");
 
-               var rect21 = document.createElement("rect");
+               var rect21 = document.createElementNS("http://www.w3.org/2000/svg", "rect");
                rect21.setAttribute("x", "10");
                rect21.setAttribute("y", "10");
                rect21.setAttribute("width", "10");
@@ -37,7 +37,7 @@
                content.appendChild(pattern1);
 
                // Setup "strokePattern"        
-               var pattern2 = document.createElement("pattern");
+               var pattern2 = document.createElementNS("http://www.w3.org/2000/svg", "pattern");
                pattern2.setAttribute("id", "strokePattern");
                pattern2.setAttribute("patternUnits", "userSpaceOnUse");
                pattern2.setAttribute("x", "0");
                pattern2.setAttribute("width", "20");
                pattern2.setAttribute("height", "20");
 
-               var rect12 = document.createElement("rect");
+               var rect12 = document.createElementNS("http://www.w3.org/2000/svg", "rect");
                rect12.setAttribute("x", "5");
                rect12.setAttribute("y", "5");
                rect12.setAttribute("width", "10");
                rect12.setAttribute("height", "10");
                rect12.setAttribute("fill", "yellow");
 
-               var rect22 = document.createElement("rect");
+               var rect22 = document.createElementNS("http://www.w3.org/2000/svg", "rect");
                rect22.setAttribute("x", "10");
                rect22.setAttribute("y", "10");
                rect22.setAttribute("width", "10");
@@ -69,7 +69,7 @@
 
        function setupPatternUsers()
        {
-               var text1 = document.createElement("text");
+               var text1 = document.createElementNS("http://www.w3.org/2000/svg", "text");
                text1.setAttribute("font-size", "68");
                text1.setAttribute("x", "-150");
                text1.setAttribute("y", "70")
@@ -79,7 +79,7 @@
 
                content.appendChild(text1);
 
-               var text2 = document.createElement("text");
+               var text2 = document.createElementNS("http://www.w3.org/2000/svg", "text");
                text2.setAttribute("font-size", "68");
                text2.setAttribute("x", "-150");
                text2.setAttribute("y", "140")
@@ -89,7 +89,7 @@
 
                content.appendChild(text2);
 
-               var text3 = document.createElement("text");
+               var text3 = document.createElementNS("http://www.w3.org/2000/svg", "text");
                text3.setAttribute("font-size", "68");
                text3.setAttribute("x", "-150");
                text3.setAttribute("y", "210")
index ade5aca..ffcc15e 100644 (file)
@@ -9,7 +9,7 @@
 
        function createPattern()
        {
-               var pattern = document.createElement("pattern");
+               var pattern = document.createElementNS("http://www.w3.org/2000/svg", "pattern");
                pattern.setAttribute("id", "dynPattern");
                pattern.setAttribute("patternUnits", "userSpaceOnUse");
                pattern.setAttribute("x", "0");
                pattern.setAttribute("width", "20");
                pattern.setAttribute("height", "20");
 
-               var rect1 = document.createElement("rect");
+               var rect1 = document.createElementNS("http://www.w3.org/2000/svg", "rect");
                rect1.setAttribute("x", "5");
                rect1.setAttribute("y", "5");
                rect1.setAttribute("width", "10");
                rect1.setAttribute("height", "10");
                rect1.setAttribute("fill", "red");
 
-               var rect2 = document.createElement("rect");
+               var rect2 = document.createElementNS("http://www.w3.org/2000/svg", "rect");
                rect2.setAttribute("x", "10");
                rect2.setAttribute("y", "10");
                rect2.setAttribute("width", "10");
index d205294..be10e5a 100644 (file)
@@ -9,7 +9,7 @@ var logOffset = 40;
 var logOffsetIncrement = 40
 function log(message)
 {
-    var t = document.createElement("text");
+    var t = document.createElementNS("http://www.w3.org/2000/svg", "text");
     t.appendChild(document.createTextNode(message));
     t.setAttribute('y', logOffset);
     t.setAttribute('x', 0);
@@ -28,7 +28,7 @@ function expect(expected, actual)
 
 function createTitleElement(title)
 {
-    var t = document.createElement('title');
+    var t = document.createElementNS("http://www.w3.org/2000/svg", 'title');
     t.appendChild(document.createTextNode(title));
     return t;
 }
index 3c274c8..226eda8 100644 (file)
     var midPoint = path.getPointAtLength(0.5 * totalLength);
     var lastPoint = path.getPointAtLength(1.0 * totalLength);
 
-    var text1 = document.createElement("text");
+    var text1 = document.createElementNS("http://www.w3.org/2000/svg", "text");
     text1.appendChild(document.createTextNode("A"));
     text1.setAttribute("x", firstPoint.x);
     text1.setAttribute("y", firstPoint.y);
 
-    var text2 = document.createElement("text");
+    var text2 = document.createElementNS("http://www.w3.org/2000/svg", "text");
     text2.appendChild(document.createTextNode("B"));
     text2.setAttribute("x", midPoint.x);
     text2.setAttribute("y", midPoint.y);
 
-    var text3 = document.createElement("text");
+    var text3 = document.createElementNS("http://www.w3.org/2000/svg", "text");
     text3.appendChild(document.createTextNode("C"));
     text3.setAttribute("x", lastPoint.x);
     text3.setAttribute("y", lastPoint.y);
index 01495d0..2b44062 100644 (file)
@@ -1,3 +1,19 @@
+2007-07-10  Rob Buis  <buis@kde.org>
+
+        Reviewed by Maciej.
+
+        http://bugs.webkit.org/show_bug.cgi?id=8007
+        createElement() and XHTML (A dynamically created table not rendered as such)
+
+        Follow the HTML5 rules of making the name lowercase and then
+        creating the element in the xhtml namespace.
+
+        * dom/Document.cpp:
+        (WebCore::Document::createElement):
+        * dom/Document.h:
+        * html/HTMLDocument.cpp:
+        * html/HTMLDocument.h:
+
 2007-07-09  Qing Zhao  <qing@staikos.net>
 
         Reviewed by George Staikos.
index 27b9ef0..ef23240 100644 (file)
@@ -465,7 +465,12 @@ Element* Document::documentElement() const
 
 PassRefPtr<Element> Document::createElement(const String &name, ExceptionCode& ec)
 {
-    return createElementNS(nullAtom, name, ec);
+    String lowerName(name.lower());
+    if (!isValidName(lowerName)) {
+        ec = INVALID_CHARACTER_ERR;
+        return 0;
+    }
+    return HTMLElementFactory::createHTMLElement(AtomicString(lowerName), this, 0, false);
 }
 
 PassRefPtr<DocumentFragment> Document::createDocumentFragment()
index d6add9e..7e305bd 100644 (file)
@@ -160,7 +160,7 @@ public:
     DOMImplementation* implementation() const;
     virtual void childrenChanged();
     Element* documentElement() const;
-    virtual PassRefPtr<Element> createElement(const String& tagName, ExceptionCode&);
+    PassRefPtr<Element> createElement(const String& tagName, ExceptionCode&);
     PassRefPtr<DocumentFragment> createDocumentFragment ();
     PassRefPtr<Text> createTextNode(const String& data);
     PassRefPtr<Comment> createComment(const String& data);
index 8097e33..9e16044 100644 (file)
@@ -64,7 +64,6 @@
 #include "FrameView.h"
 #include "HTMLBodyElement.h"
 #include "HTMLElement.h"
-#include "HTMLElementFactory.h"
 #include "HTMLNames.h"
 #include "HTMLTokenizer.h"
 #include "InspectorController.h"
@@ -302,16 +301,6 @@ bool HTMLDocument::childAllowed( Node *newChild )
     return newChild->hasTagName(htmlTag);
 }
 
-PassRefPtr<Element> HTMLDocument::createElement(const String &name, ExceptionCode& ec)
-{
-    String lowerName(name.lower());
-    if (!isValidName(lowerName)) {
-        ec = INVALID_CHARACTER_ERR;
-        return 0;
-    }
-    return HTMLElementFactory::createHTMLElement(AtomicString(lowerName), this, 0, false);
-}
-
 static void addItemToMap(HTMLDocument::NameCountMap& map, const String& name)
 {
     if (name.length() == 0)
index 220471e..5758b87 100644 (file)
@@ -71,8 +71,6 @@ public:
 
     virtual bool childAllowed(Node*);
 
-    virtual PassRefPtr<Element> createElement(const String& tagName, ExceptionCode&);
-
     virtual void determineParseMode(const String&);
 
     void addNamedItem(const String& name);