diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/xml/XMLTreeViewer.cpp | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/xml/XMLTreeViewer.cpp')
-rw-r--r-- | Source/WebCore/xml/XMLTreeViewer.cpp | 71 |
1 files changed, 19 insertions, 52 deletions
diff --git a/Source/WebCore/xml/XMLTreeViewer.cpp b/Source/WebCore/xml/XMLTreeViewer.cpp index f1e2c0f..a2110db 100644 --- a/Source/WebCore/xml/XMLTreeViewer.cpp +++ b/Source/WebCore/xml/XMLTreeViewer.cpp @@ -27,37 +27,20 @@ */ #include "config.h" - -#if ENABLE(XSLT) #include "XMLTreeViewer.h" +#if ENABLE(XSLT) -#include "Base64.h" -#include "Element.h" #include "Document.h" +#include "Element.h" #include "Frame.h" -#include "HTMLNames.h" #include "Page.h" -#include "ProcessingInstruction.h" +#include "ScriptController.h" +#include "ScriptSourceCode.h" #include "Settings.h" -#include "TransformSource.h" -#include "XLinkNames.h" -#include "XMLViewerXSL.h" -#include "XPathResult.h" -#include "XSLStyleSheet.h" -#include "XSLTProcessor.h" - -#include <libxslt/xslt.h> - -#if ENABLE(MATHML) -#include "MathMLNames.h" -#endif -#if ENABLE(SVG) -#include "SVGNames.h" -#endif -#if ENABLE(WML) -#include "WMLNames.h" -#endif +#include "Text.h" +#include "XMLViewerCSS.h" +#include "XMLViewerJS.h" using namespace std; @@ -82,39 +65,23 @@ bool XMLTreeViewer::hasNoStyleInformation() const if (m_document->frame()->tree()->parent(true)) return false; // This document is not in a top frame - if (m_document->frame()->loader()->opener()) - return false; // This document is not opened manually by user return true; } void XMLTreeViewer::transformDocumentToTreeView() { - String sheetString(reinterpret_cast<const char*>(XMLViewer_xsl), sizeof(XMLViewer_xsl)); - RefPtr<XSLStyleSheet> styleSheet = XSLStyleSheet::createForXMLTreeViewer(m_document, sheetString); - - RefPtr<XSLTProcessor> processor = XSLTProcessor::create(); - processor->setXSLStyleSheet(styleSheet); - - processor->setParameter("", "xml_has_no_style_message", "This XML file does not appear to have any style information associated with it. The document tree is shown below."); - - String resultMIMEType; - String newSource; - String resultEncoding; - - Frame* frame = m_document->frame(); - // 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); - + String scriptString(reinterpret_cast<const char*>(XMLViewer_js), sizeof(XMLViewer_js)); + m_document->frame()->script()->evaluate(ScriptSourceCode(scriptString)); + String noStyleMessage("This XML file does not appear to have any style information associated with it. The document tree is shown below."); + m_document->frame()->script()->evaluate(ScriptSourceCode("prepareWebKitXMLViewer('" + noStyleMessage + "');")); + + String cssString(reinterpret_cast<const char*>(XMLViewer_css), sizeof(XMLViewer_css)); + RefPtr<Text> text = m_document->createTextNode(cssString); + ExceptionCode exceptionCode; + m_document->getElementById("xml-viewer-style")->appendChild(text, exceptionCode); + + m_document->setUsesViewSourceStyles(true); + m_document->styleSelectorChanged(RecalcStyleImmediately); } } // namespace WebCore |