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

Unified Diff: third_party/WebKit/Source/core/frame/DOMWindow.cpp

Issue 2617733004: binding: Changes the association among global-proxy/global/window-instance. (Closed)
Patch Set: Fixed Document.defaultView Created 3 years, 11 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/core/frame/DOMWindow.cpp
diff --git a/third_party/WebKit/Source/core/frame/DOMWindow.cpp b/third_party/WebKit/Source/core/frame/DOMWindow.cpp
index 7e94256eeb1bf98fc362e9e48c664d7de2d55314..009c197fba9fa9f9422ffd52d3bf631b2d7d0780 100644
--- a/third_party/WebKit/Source/core/frame/DOMWindow.cpp
+++ b/third_party/WebKit/Source/core/frame/DOMWindow.cpp
@@ -4,6 +4,7 @@
#include "core/frame/DOMWindow.h"
+#include "bindings/core/v8/WindowProxy.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
@@ -39,23 +40,34 @@ DOMWindow::DOMWindow(Frame& frame) : m_frame(frame), m_windowIsClosing(false) {}
DOMWindow::~DOMWindow() {
// The frame must be disconnected before finalization.
DCHECK(!m_frame);
+
+ // Because the wrapper object of a DOMWindow is the global proxy object which
+ // may live much longer than the DOMWindow, we need to dissociate all wrappers
+ // for this instance.
+ DOMWrapperWorld::dissociateWrappersInAllWorlds(this);
}
-v8::Local<v8::Object> DOMWindow::wrap(v8::Isolate*,
+v8::Local<v8::Object> DOMWindow::wrap(v8::Isolate* isolate,
v8::Local<v8::Object> creationContext) {
- LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The "
- "wrappers must be created at WindowProxy::createContext() and "
- "setupWindowPrototypeChain().";
- return v8::Local<v8::Object>();
+ // Notice that we explicitly ignore |creationContext| because the DOMWindow
+ // has its own creation context.
+
+ Frame* frame = this->frame();
+ CHECK(frame);
haraken 2017/02/09 12:46:40 Would you help me understand why frame is guarante
Yuki 2017/02/10 07:47:21 If WindowProxy::initialize() was already called, t
+
+ v8::Local<v8::Object> globalProxy =
+ frame->windowProxy(DOMWrapperWorld::current(isolate))
+ ->globalIfNotDetached();
+ CHECK(!globalProxy.IsEmpty());
+
+ return globalProxy;
}
v8::Local<v8::Object> DOMWindow::associateWithWrapper(
v8::Isolate*,
const WrapperTypeInfo*,
v8::Local<v8::Object> wrapper) {
- LOG(FATAL) << "DOMWindow must never be wrapped with wrap method. The "
- "wrappers must be created at WindowProxy::createContext() and "
- "setupWindowPrototypeChain().";
+ NOTREACHED();
return v8::Local<v8::Object>();
}

Powered by Google App Engine
This is Rietveld 408576698