summaryrefslogtreecommitdiff
path: root/Source/WebCore/bindings/js/JSDOMWindowShell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/bindings/js/JSDOMWindowShell.cpp')
-rw-r--r--Source/WebCore/bindings/js/JSDOMWindowShell.cpp41
1 files changed, 28 insertions, 13 deletions
diff --git a/Source/WebCore/bindings/js/JSDOMWindowShell.cpp b/Source/WebCore/bindings/js/JSDOMWindowShell.cpp
index b5fc83e99..a42a030e9 100644
--- a/Source/WebCore/bindings/js/JSDOMWindowShell.cpp
+++ b/Source/WebCore/bindings/js/JSDOMWindowShell.cpp
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -29,10 +29,12 @@
#include "config.h"
#include "JSDOMWindowShell.h"
+#include "CommonVM.h"
#include "Frame.h"
#include "GCController.h"
#include "JSDOMWindow.h"
-#include "DOMWindow.h"
+#include "JSDOMWindowProperties.h"
+#include "JSEventTarget.h"
#include "ScriptController.h"
#include <heap/StrongInlines.h>
#include <runtime/JSObject.h>
@@ -41,7 +43,7 @@ using namespace JSC;
namespace WebCore {
-const ClassInfo JSDOMWindowShell::s_info = { "JSDOMWindowShell", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSDOMWindowShell) };
+const ClassInfo JSDOMWindowShell::s_info = { "JSDOMWindowShell", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDOMWindowShell) };
JSDOMWindowShell::JSDOMWindowShell(VM& vm, Structure* structure, DOMWrapperWorld& world)
: Base(vm, structure)
@@ -49,11 +51,11 @@ JSDOMWindowShell::JSDOMWindowShell(VM& vm, Structure* structure, DOMWrapperWorld
{
}
-void JSDOMWindowShell::finishCreation(VM& vm, PassRefPtr<DOMWindow> window)
+void JSDOMWindowShell::finishCreation(VM& vm, RefPtr<DOMWindow>&& window)
{
Base::finishCreation(vm);
- ASSERT(inherits(info()));
- setWindow(window);
+ ASSERT(inherits(vm, info()));
+ setWindow(WTFMove(window));
}
void JSDOMWindowShell::destroy(JSCell* cell)
@@ -66,25 +68,30 @@ void JSDOMWindowShell::setWindow(VM& vm, JSDOMWindow* window)
ASSERT_ARG(window, window);
setTarget(vm, window);
structure()->setGlobalObject(vm, window);
- gcController().garbageCollectSoon();
+ GCController::singleton().garbageCollectSoon();
}
-void JSDOMWindowShell::setWindow(PassRefPtr<DOMWindow> domWindow)
+void JSDOMWindowShell::setWindow(RefPtr<DOMWindow>&& domWindow)
{
// Replacing JSDOMWindow via telling JSDOMWindowShell to use the same DOMWindow it already uses makes no sense,
// so we'd better never try to.
- ASSERT(!window() || domWindow.get() != &window()->impl());
+ ASSERT(!window() || domWindow.get() != &window()->wrapped());
// Explicitly protect the global object's prototype so it isn't collected
// when we allocate the global object. (Once the global object is fully
// constructed, it can mark its own prototype.)
- VM& vm = *JSDOMWindow::commonVM();
+ VM& vm = commonVM();
Structure* prototypeStructure = JSDOMWindowPrototype::createStructure(vm, 0, jsNull());
Strong<JSDOMWindowPrototype> prototype(vm, JSDOMWindowPrototype::create(vm, 0, prototypeStructure));
Structure* structure = JSDOMWindow::createStructure(vm, 0, prototype.get());
- JSDOMWindow* jsDOMWindow = JSDOMWindow::create(vm, structure, domWindow, this);
+ JSDOMWindow* jsDOMWindow = JSDOMWindow::create(vm, structure, *domWindow, this);
prototype->structure()->setGlobalObject(vm, jsDOMWindow);
+
+ Structure* windowPropertiesStructure = JSDOMWindowProperties::createStructure(vm, jsDOMWindow, JSEventTarget::prototype(vm, jsDOMWindow));
+ JSDOMWindowProperties* windowProperties = JSDOMWindowProperties::create(windowPropertiesStructure, *jsDOMWindow);
+
+ prototype->structure()->setPrototypeWithoutTransition(vm, windowProperties);
setWindow(vm, jsDOMWindow);
ASSERT(jsDOMWindow->globalObject() == jsDOMWindow);
ASSERT(prototype->globalObject() == jsDOMWindow);
@@ -94,9 +101,17 @@ void JSDOMWindowShell::setWindow(PassRefPtr<DOMWindow> domWindow)
// JSDOMWindow methods
// ----
-DOMWindow& JSDOMWindowShell::impl() const
+DOMWindow& JSDOMWindowShell::wrapped() const
+{
+ return window()->wrapped();
+}
+
+DOMWindow* JSDOMWindowShell::toWrapped(VM& vm, JSObject* value)
{
- return window()->impl();
+ auto* wrapper = jsDynamicDowncast<JSDOMWindowShell*>(vm, value);
+ if (!wrapper)
+ return nullptr;
+ return &wrapper->window()->wrapped();
}
// ----