diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-08-25 19:20:41 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:30:55 +0000 |
commit | 6882a04fb36642862b11efe514251d32070c3d65 (patch) | |
tree | b7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/xml/XMLTreeViewer.cpp | |
parent | ab6df191029eeeb0b0f16f127d553265659f739e (diff) | |
download | qtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz |
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
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 |