Index: third_party/WebKit/Source/core/xml/DocumentXMLTreeViewer.cpp |
diff --git a/third_party/WebKit/Source/core/xml/DocumentXMLTreeViewer.cpp b/third_party/WebKit/Source/core/xml/DocumentXMLTreeViewer.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ace03f446d025d836bf4da82101ff461b363dea2 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/xml/DocumentXMLTreeViewer.cpp |
@@ -0,0 +1,41 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "core/xml/DocumentXMLTreeViewer.h" |
+ |
+#include "bindings/core/v8/DOMWrapperWorld.h" |
+#include "bindings/core/v8/ScriptController.h" |
+#include "bindings/core/v8/ScriptSourceCode.h" |
+#include "core/dom/Document.h" |
+#include "core/dom/Element.h" |
+#include "core/frame/LocalFrame.h" |
+#include "public/platform/Platform.h" |
+ |
+namespace blink { |
+ |
+void DocumentXMLTreeViewer::transformDocumentToTreeView() { |
+ WebData DocumentXMLTreeViewerJs = |
+ blink::Platform::current()->loadResource("DocumentXMLTreeViewer.js"); |
+ WebData DocumentXMLTreeViewerCSS = |
+ blink::Platform::current()->loadResource("DocumentXMLTreeViewer.css"); |
+ |
+ String scriptString(DocumentXMLTreeViewerJs.data(), |
jbroman
2016/12/10 20:35:31
Nit: this assumes with no check that the data will
adithyas
2016/12/12 16:13:50
Done.
|
+ DocumentXMLTreeViewerJs.size()); |
+ String cssString(DocumentXMLTreeViewerCSS.data(), |
+ DocumentXMLTreeViewerCSS.size()); |
+ |
+ HeapVector<ScriptSourceCode> sources; |
+ sources.append(ScriptSourceCode(scriptString)); |
+ v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
+ |
+ m_document->frame()->script().executeScriptInIsolatedWorld( |
+ WorldIdConstants::DocumentXMLTreeViewerWorldId, sources, 0, nullptr); |
haraken
2016/12/12 01:09:56
Does this need to be executed in an isolated world
adithyas
2016/12/12 16:13:50
We used to use the main world to execute the scrip
|
+ m_document->getElementById("xml-viewer-style")->setTextContent(cssString); |
+} |
+ |
+DEFINE_TRACE(DocumentXMLTreeViewer) { |
+ visitor->trace(m_document); |
+} |
+ |
+} // namespace blink |