2011-03-25 Vsevolod Vlasov <vsevik@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Mar 2011 15:10:32 +0000 (15:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Mar 2011 15:10:32 +0000 (15:10 +0000)
        Reviewed by Pavel Feldman.

        XML Viewer: extensions can't render original XML
        https://bugs.webkit.org/show_bug.cgi?id=56263

        Added source xml to transformed document, renamed onload function.

        * fast/css/dumpAsText/xml-stylesheet-pi-not-in-prolog-expected.txt:
        * fast/encoding/dumpAsText/utf-16-no-bom-expected.txt:
        * http/tests/xmlviewer/dumpAsText/wml-expected.txt:
        * http/tests/xmlviewer/dumpAsText/xlink-expected.txt:
        * http/tests/xmlviewer/dumpAsText/xmlviewer-charset-cp1251-expected.txt:
        * http/tests/xmlviewer/dumpAsText/xmlviewer-charset-utf8-expected.txt:
        * http/tests/xmlviewer/dumpAsText/xmlviewer-expected.txt:
        * http/tests/xmlviewer/dumpAsText/xul-expected.txt:
        * platform/chromium-linux/http/tests/xmlviewer/dumpAsText/wml-expected.txt:
        * platform/chromium/http/tests/xmlviewer/dumpAsText/mathml-expected.txt:
        * svg/hixie/error/dumpAsText/004-expected.txt:
        * svg/hixie/error/dumpAsText/005-expected.txt:
        * xmlviewer/extensions-api-expected.txt: Added.
        * xmlviewer/extensions-api.html_disabled: Added.
        * xmlviewer/resources/sample.xml: Added.
2011-03-25  Vsevolod Vlasov  <vsevik@chromium.org>

        Reviewed by Pavel Feldman.

        XML Viewer: extensions can't render original XML
        https://bugs.webkit.org/show_bug.cgi?id=56263

        Added source xml to transformed document, renamed onload function.

        * xml/XMLTreeViewer.cpp:
        (WebCore::XMLTreeViewer::transformDocumentToTreeView):
        * xml/XMLViewer.xsl:

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/dumpAsText/xml-stylesheet-pi-not-in-prolog-expected.txt
LayoutTests/fast/encoding/dumpAsText/utf-16-no-bom-expected.txt
LayoutTests/http/tests/xmlviewer/dumpAsText/wml-expected.txt
LayoutTests/http/tests/xmlviewer/dumpAsText/xlink-expected.txt
LayoutTests/http/tests/xmlviewer/dumpAsText/xmlviewer-charset-cp1251-expected.txt
LayoutTests/http/tests/xmlviewer/dumpAsText/xmlviewer-charset-utf8-expected.txt
LayoutTests/http/tests/xmlviewer/dumpAsText/xmlviewer-expected.txt
LayoutTests/http/tests/xmlviewer/dumpAsText/xul-expected.txt
LayoutTests/platform/chromium-linux/http/tests/xmlviewer/dumpAsText/wml-expected.txt
LayoutTests/platform/chromium/http/tests/xmlviewer/dumpAsText/mathml-expected.txt
LayoutTests/svg/hixie/error/dumpAsText/004-expected.txt
LayoutTests/svg/hixie/error/dumpAsText/005-expected.txt
LayoutTests/xmlviewer/extensions-api-expected.txt [new file with mode: 0644]
LayoutTests/xmlviewer/extensions-api.html_disabled [new file with mode: 0644]
LayoutTests/xmlviewer/resources/sample.xml [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/xml/XMLTreeViewer.cpp
Source/WebCore/xml/XMLViewer.xsl

index 6d3f13f..228ab77 100644 (file)
@@ -1,3 +1,28 @@
+2011-03-25  Vsevolod Vlasov  <vsevik@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        XML Viewer: extensions can't render original XML
+        https://bugs.webkit.org/show_bug.cgi?id=56263
+
+        Added source xml to transformed document, renamed onload function.
+
+        * fast/css/dumpAsText/xml-stylesheet-pi-not-in-prolog-expected.txt:
+        * fast/encoding/dumpAsText/utf-16-no-bom-expected.txt:
+        * http/tests/xmlviewer/dumpAsText/wml-expected.txt:
+        * http/tests/xmlviewer/dumpAsText/xlink-expected.txt:
+        * http/tests/xmlviewer/dumpAsText/xmlviewer-charset-cp1251-expected.txt:
+        * http/tests/xmlviewer/dumpAsText/xmlviewer-charset-utf8-expected.txt:
+        * http/tests/xmlviewer/dumpAsText/xmlviewer-expected.txt:
+        * http/tests/xmlviewer/dumpAsText/xul-expected.txt:
+        * platform/chromium-linux/http/tests/xmlviewer/dumpAsText/wml-expected.txt:
+        * platform/chromium/http/tests/xmlviewer/dumpAsText/mathml-expected.txt:
+        * svg/hixie/error/dumpAsText/004-expected.txt:
+        * svg/hixie/error/dumpAsText/005-expected.txt:
+        * xmlviewer/extensions-api-expected.txt: Added.
+        * xmlviewer/extensions-api.html_disabled: Added.
+        * xmlviewer/resources/sample.xml: Added.
+
 2011-03-25  Adam Roben  <aroben@apple.com>
 
         Remove no-longer-necessary Windows results
index 192889a..6385620 100644 (file)
@@ -2,4 +2,3 @@ This XML file does not appear to have any style information associated with it.
 <foo>
 This tests that xml-stylesheet processing instructions have no effect when they're not in the prolog (before the root element). If this test is successful, this text should NOT have a black border.
 </foo>
-
index 4aea68a..15ca8a8 100644 (file)
@@ -2,4 +2,3 @@ This XML file does not appear to have any style information associated with it.
 <TEST>
 Should be "CYRILLIC SMALL LETTER IO" (like e with diaeresis): ё
 </TEST>
-
index e850800..f51f55c 100644 (file)
@@ -14,4 +14,3 @@ This tests that xml viewer is not used for documents with WML doctype.
 <p>SUCCESS</p>
 </card>
 </wml>
-
index c04cf9e..17fb50b 100644 (file)
@@ -7,4 +7,3 @@ This tests that xml viewer is not used when there is an attribute XLink namespac
 <FAIL/>
 <xlink l:type="simple" l:href="xlink.xml">SUCCESS</xlink>
 </test>
-
index 8cd20b6..125772b 100644 (file)
@@ -2,4 +2,3 @@ This XML file does not appear to have any style information associated with it.
 <root>
 <cp1251>SUССЕSS - These 'CCE' are cyrillic letters.</cp1251>
 </root>
-
index b897c16..41f0c7f 100644 (file)
@@ -2,4 +2,3 @@ This XML file does not appear to have any style information associated with it.
 <root>
 <utf8>SUССЕSS - These 'CCE' are cyrillic letters.</utf8>
 </root>
-
index 244b069..6d15e1f 100644 (file)
@@ -28,4 +28,3 @@ The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the
 </tag-with-long-cdata>
 <ns:tag-with-some-namespace/>
 </root-tag-with-mixed-content>
-
index 52c9f3f..7a1dbe4 100644 (file)
@@ -6,4 +6,3 @@ This tests that xml viewer is not used when there is an attribute in XUL namespa
 </header>
 <box a:attr="value">SUCCESS</box>
 </FAIL>
-
index 2ec36dc..86967b4 100644 (file)
@@ -7,4 +7,3 @@ This XML file does not appear to have any style information associated with it.
 This document is either not SVG, or is SVG but is in error. Section 5.1.1 of SVG 1.1 says: # In all cases, for compliance with the "Namespaces in XML" # Recommendation [XML-NS], an SVG namespace declaration must be # provided so that all SVG elements are identified as belonging # to the SVG namespace.
 -->
 </svg>
-
index bb94516..2806aa2 100644 (file)
@@ -4,4 +4,3 @@ This XML file does not appear to have any style information associated with it.
 <desc>There should be no red on this page.</desc>
 <rect x="10" y="10" width="280" height="180" fill="red"/>
 </svg>
-
diff --git a/LayoutTests/xmlviewer/extensions-api-expected.txt b/LayoutTests/xmlviewer/extensions-api-expected.txt
new file mode 100644 (file)
index 0000000..ff43ca4
--- /dev/null
@@ -0,0 +1 @@
+SUCCESS
diff --git a/LayoutTests/xmlviewer/extensions-api.html_disabled b/LayoutTests/xmlviewer/extensions-api.html_disabled
new file mode 100644 (file)
index 0000000..230c33a
--- /dev/null
@@ -0,0 +1,28 @@
+<html>
+<head>
+<script>
+    if (window.layoutTestController) {
+       layoutTestController.dumpAsText();
+       layoutTestController.waitUntilDone();
+    }
+
+    function print(str)
+    {
+        document.getElementById('output').textContent = str;
+    }
+
+    function runTest()
+    {
+        var xmlWindow = window.open('resources/sample.xml', "_blank");
+        var sourceXML = xmlWindow.document.getElementById('source-xml');
+        if (xmlWindow.onWebKitXMLViewerLoad && sourceXML && sourceXML.firstChild.localName='root')
+            print('SUCCESS');
+        else
+            print('FAIL');
+    }
+</script>
+</head>
+<body onload="runTest();">
+    <div id='output'></div>
+</body>
+</html>
diff --git a/LayoutTests/xmlviewer/resources/sample.xml b/LayoutTests/xmlviewer/resources/sample.xml
new file mode 100644 (file)
index 0000000..f3f286e
--- /dev/null
@@ -0,0 +1 @@
+<root/>
index 73c9dad..e235020 100644 (file)
@@ -1,3 +1,16 @@
+2011-03-25  Vsevolod Vlasov  <vsevik@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        XML Viewer: extensions can't render original XML
+        https://bugs.webkit.org/show_bug.cgi?id=56263
+
+        Added source xml to transformed document, renamed onload function.
+
+        * xml/XMLTreeViewer.cpp:
+        (WebCore::XMLTreeViewer::transformDocumentToTreeView):
+        * xml/XMLViewer.xsl:
+
 2011-03-25  Benjamin Poulain  <benjamin.poulain@nokia.com>
 
         Reviewed by Andreas Kling.
index 03cbb10..f1e2c0f 100644 (file)
@@ -33,6 +33,7 @@
 
 
 #include "Base64.h"
+#include "Element.h"
 #include "Document.h"
 #include "Frame.h"
 #include "HTMLNames.h"
@@ -104,9 +105,16 @@ void XMLTreeViewer::transformDocumentToTreeView()
     // FIXME: We should introduce error handling
     if (processor->transformToString(m_document, resultMIMEType, newSource, resultEncoding))
         processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, m_document, frame);
+
+    // Adding source xml for dealing with namespaces and CDATA issues and for extensions use.
+    Element* sourceXmlElement = frame->document()->getElementById(AtomicString("source-xml"));
+    if (sourceXmlElement)
+        m_document->cloneChildNodes(sourceXmlElement);
+
     // New document should have been loaded in frame. Tell it to use view source styles.
     frame->document()->setUsesViewSourceStyles(true);
     frame->document()->styleSelectorChanged(RecalcStyleImmediately);
+
 }
 
 } // namespace WebCore
index 1b616f2..4ee3ca8 100644 (file)
                 <xsl:call-template name="style"/>
                 <xsl:call-template name="script"/>
             </head>
-            <body onload="onload()">
+            <body onload="onWebKitXMLViewerLoad()">
                 <div class="header">
-                    <span> <xsl:value-of select="$xml_has_no_style_message"/> </span> 
+                    <span> <xsl:value-of select="$xml_has_no_style_message"/> </span>
                     <br/>
                 </div>
 
                 <div class="pretty-print">
                     <xsl:apply-templates/>
                 </div>
-                <div</div>
+                <div id="source-xml"></div>
             </body>
         </html>
     </xsl:template>
     <xsl:template name="script">
         <script type="text/javascript">
             <xsl:text>
-                function onload()
+                function onWebKitXMLViewerLoad()
                 {
                     drawArrows();
                     initButtons();
                 font-size: 13px;
             }
 
+            #source-xml {
+                display: none;
+            }
+
             .collapsable-content {
                 margin-left: 1em;
             }