summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Bindings
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-20 17:45:27 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-20 17:50:48 +0200
commitcc5cba90db6c7452cce0155a0de51175b9560b40 (patch)
tree6a1e9313e2a5f886d73d294b65cfcd91d0807073 /Libraries/LibWeb/Bindings
parent8194dfb9f4f4163ccee6272ade3cdb3a5b298c4c (diff)
downloadserenity-cc5cba90db6c7452cce0155a0de51175b9560b40.zip
LibWeb: Give the DOM Window object a (weak) pointer to its JS wrapper
Diffstat (limited to 'Libraries/LibWeb/Bindings')
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.cpp1
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.h5
2 files changed, 5 insertions, 1 deletions
diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp
index 746a81c8fc..7c321f8661 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -45,6 +45,7 @@ namespace Bindings {
WindowObject::WindowObject(Window& impl)
: m_impl(impl)
{
+ impl.set_wrapper({}, *this);
}
void WindowObject::initialize()
diff --git a/Libraries/LibWeb/Bindings/WindowObject.h b/Libraries/LibWeb/Bindings/WindowObject.h
index dff689c8e4..3bc6797249 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.h
+++ b/Libraries/LibWeb/Bindings/WindowObject.h
@@ -26,13 +26,16 @@
#pragma once
+#include <AK/Weakable.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibWeb/Forward.h>
namespace Web {
namespace Bindings {
-class WindowObject final : public JS::GlobalObject {
+class WindowObject final
+ : public JS::GlobalObject
+ , public Weakable<WindowObject> {
public:
explicit WindowObject(Window&);
virtual void initialize() override;