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

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: Addressed review comments. Created 3 years, 10 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 6a8dfce87f09f396c2f9ec1faacd5ba37d160dc2..b61c198c5bc46ee9460bc0542e6042f30be159f7 100644
--- a/third_party/WebKit/Source/core/frame/DOMWindow.cpp
+++ b/third_party/WebKit/Source/core/frame/DOMWindow.cpp
@@ -5,6 +5,7 @@
#include "core/frame/DOMWindow.h"
#include <memory>
+#include "bindings/core/v8/WindowProxy.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
#include "core/dom/SecurityContext.h"
@@ -34,23 +35,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::dissociateDOMWindowWrappersInAllWorlds(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);
+
+ 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>();
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.idl ('k') | third_party/WebKit/Source/core/html/HTMLFrameOwnerElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698