diff options
Diffstat (limited to 'Source/WebCore/xml/XMLTreeViewer.cpp')
-rw-r--r-- | Source/WebCore/xml/XMLTreeViewer.cpp | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/Source/WebCore/xml/XMLTreeViewer.cpp b/Source/WebCore/xml/XMLTreeViewer.cpp index d52e8112e..5f137ad2f 100644 --- a/Source/WebCore/xml/XMLTreeViewer.cpp +++ b/Source/WebCore/xml/XMLTreeViewer.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 Google Inc. All rights reserved. + * Copyright (C) 2013 Samsung Electronics. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -35,53 +36,34 @@ #include "Element.h" #include "ExceptionCodePlaceholder.h" #include "Frame.h" -#include "Page.h" #include "ScriptController.h" #include "ScriptSourceCode.h" -#include "ScriptValue.h" -#include "Settings.h" +#include "SecurityOrigin.h" +#include "SecurityOriginPolicy.h" #include "Text.h" #include "XMLViewerCSS.h" #include "XMLViewerJS.h" - -using namespace std; +#include <bindings/ScriptValue.h> namespace WebCore { -XMLTreeViewer::XMLTreeViewer(Document* document) +XMLTreeViewer::XMLTreeViewer(Document& document) : m_document(document) { } -bool XMLTreeViewer::hasNoStyleInformation() const -{ - if (m_document->sawElementsInKnownNamespaces() || m_document->transformSourceDocument()) - return false; - - if (!m_document->frame() || !m_document->frame()->page()) - return false; - - if (!m_document->frame()->page()->settings()->developerExtrasEnabled()) - return false; - - if (m_document->frame()->tree()->parent()) - return false; // This document is not in a top frame - - return true; -} - void XMLTreeViewer::transformDocumentToTreeView() { - m_document->setIsViewSource(true); - 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 + "');")); + m_document.setSecurityOriginPolicy(SecurityOriginPolicy::create(SecurityOrigin::createUnique())); + + String scriptString = StringImpl::createWithoutCopying(XMLViewer_js, sizeof(XMLViewer_js)); + m_document.frame()->script().evaluate(ScriptSourceCode(scriptString)); + m_document.frame()->script().evaluate(ScriptSourceCode(AtomicString("prepareWebKitXMLViewer('This XML file does not appear to have any style information associated with it. The document tree is shown below.');"))); - String cssString(reinterpret_cast<const char*>(XMLViewer_css), sizeof(XMLViewer_css)); - RefPtr<Text> text = m_document->createTextNode(cssString); - m_document->getElementById("xml-viewer-style")->appendChild(text, IGNORE_EXCEPTION); - m_document->styleResolverChanged(RecalcStyleImmediately); + String cssString = StringImpl::createWithoutCopying(XMLViewer_css, sizeof(XMLViewer_css)); + Ref<Text> text = m_document.createTextNode(cssString); + m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(WTFMove(text), IGNORE_EXCEPTION); + m_document.styleResolverChanged(RecalcStyleImmediately); } } // namespace WebCore |