Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ToV8ForCore.cpp

Issue 2848503002: Revert of binding: Changes the association among global-proxy/global/window-instance (2nd attempt).… (Closed)
Patch Set: Updated the test expectation. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/ToV8ForCore.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ToV8ForCore.cpp b/third_party/WebKit/Source/bindings/core/v8/ToV8ForCore.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..442f1d962d8151488b9a6032f4a3176ea668000c
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/ToV8ForCore.cpp
@@ -0,0 +1,48 @@
+// Copyright 2017 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 "bindings/core/v8/ToV8ForCore.h"
+
+#include "bindings/core/v8/WindowProxy.h"
+#include "core/events/EventTarget.h"
+#include "core/frame/DOMWindow.h"
+#include "core/frame/Frame.h"
+
+namespace blink {
+
+v8::Local<v8::Value> ToV8(DOMWindow* window,
+ v8::Local<v8::Object> creation_context,
+ v8::Isolate* isolate) {
+ // Notice that we explicitly ignore creationContext because the DOMWindow
+ // has its own creationContext.
+
+ if (UNLIKELY(!window))
+ return v8::Null(isolate);
+
+ // TODO(yukishiino): Get understanding of why it's possible to initialize
+ // the context after the frame is detached. And then, remove the following
+ // lines. See also https://crbug.com/712638 .
+ Frame* frame = window->GetFrame();
+ if (!frame)
+ return v8::Local<v8::Object>();
+
+ // TODO(yukishiino): Make this function always return the non-empty handle
+ // even if the frame is detached because the global proxy must always exist
+ // per spec.
+ return frame->GetWindowProxy(DOMWrapperWorld::Current(isolate))
+ ->GlobalProxyIfNotDetached();
+}
+
+v8::Local<v8::Value> ToV8(EventTarget* impl,
+ v8::Local<v8::Object> creation_context,
+ v8::Isolate* isolate) {
+ if (UNLIKELY(!impl))
+ return v8::Null(isolate);
+
+ if (impl->InterfaceName() == EventTargetNames::DOMWindow)
+ return ToV8(static_cast<DOMWindow*>(impl), creation_context, isolate);
+ return ToV8(static_cast<ScriptWrappable*>(impl), creation_context, isolate);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698