Reviewed by Darin.
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jul 2006 04:31:29 +0000 (04:31 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jul 2006 04:31:29 +0000 (04:31 +0000)
        Fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9901
        XSLTProcessor cannot parse text nodes for INPUT ELEMENTS in an XSLT stylesheet

        Test: fast/js/xhtml-serialize.html

        * editing/markup.cpp:
        (WebCore::endMarkup): If the element has child nodes, write a closing tag even if it
        is not permitted in HTML, to make it valid XML.

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

LayoutTests/ChangeLog
LayoutTests/fast/js/resources/xhtml-serialize.js [new file with mode: 0644]
LayoutTests/fast/js/xhtml-serialize-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/xhtml-serialize.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/markup.cpp

index 4bb4bbe..903917c 100644 (file)
@@ -1,3 +1,14 @@
+2006-07-26  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=9901
+        XSLTProcessor cannot parse text nodes for INPUT ELEMENTS in an XSLT stylesheet
+
+        * fast/js/resources/xhtml-serialize.js: Added.
+        * fast/js/xhtml-serialize-expected.txt: Added.
+        * fast/js/xhtml-serialize.html: Added.
+
 2006-07-26  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by darin
diff --git a/LayoutTests/fast/js/resources/xhtml-serialize.js b/LayoutTests/fast/js/resources/xhtml-serialize.js
new file mode 100644 (file)
index 0000000..aeb55ca
--- /dev/null
@@ -0,0 +1,11 @@
+description(
+"This test checks whether serialized invalid XHTML is valid XML (for bug 9901)."
+);
+
+var doc = (new DOMParser()).parseFromString('<input xmlns="http://www.w3.org/1999/xhtml">123</input>', 'text/xml');
+var str = (new XMLSerializer()).serializeToString(doc);
+
+shouldBe('doc.firstChild.firstChild.nodeValue', '"123"');
+shouldBe('str', "'<input xmlns=\"http://www.w3.org/1999/xhtml\">123</input>'");
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/js/xhtml-serialize-expected.txt b/LayoutTests/fast/js/xhtml-serialize-expected.txt
new file mode 100644 (file)
index 0000000..60dbd78
--- /dev/null
@@ -0,0 +1,11 @@
+This test checks whether serialized invalid XHTML is valid XML (for bug 9901).
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS doc.firstChild.firstChild.nodeValue is "123"
+PASS str is '<input xmlns="http://www.w3.org/1999/xhtml">123</input>'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/js/xhtml-serialize.html b/LayoutTests/fast/js/xhtml-serialize.html
new file mode 100644 (file)
index 0000000..8d64d20
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/js-test-style.css">
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/xhtml-serialize.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
index f2f7da6..70dc3fa 100644 (file)
@@ -1,3 +1,16 @@
+2006-07-26  Alexey Proskuryakov  <ap@nypop.com>
+
+        Reviewed by Darin.
+
+        Fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9901
+        XSLTProcessor cannot parse text nodes for INPUT ELEMENTS in an XSLT stylesheet
+
+        Test: fast/js/xhtml-serialize.html
+
+        * editing/markup.cpp:
+        (WebCore::endMarkup): If the element has child nodes, write a closing tag even if it 
+        is not permitted in HTML, to make it valid XML.
+
 2006-07-26  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by John Sullivan (and Kevin and Timo).
index 1defa2b..2b364c4 100644 (file)
@@ -237,7 +237,7 @@ static inline bool shouldSelfClose(const Node *node)
 
 static DeprecatedString endMarkup(const Node *node)
 {
-    if (node->isElementNode() && !shouldSelfClose(node) && !doesHTMLForbidEndTag(node))
+    if (node->isElementNode() && !shouldSelfClose(node) && (node->hasChildNodes() || !doesHTMLForbidEndTag(node)))
         return "</" + static_cast<const Element*>(node)->nodeNamePreservingCase().deprecatedString() + ">";
     return "";
 }