summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-09-04 13:20:53 +0200
committerAndreas Kling <kling@serenityos.org>2022-09-06 00:27:09 +0200
commit8f2a711132292238ffd1cd4a2d15556914e0d6dd (patch)
tree6ecef648c3996fe5a9897cf5439189b020325fca /Userland/Libraries/LibWeb
parentbe9d3860b9f962191f658dd991c80edd2ab50a91 (diff)
downloadserenity-8f2a711132292238ffd1cd4a2d15556914e0d6dd.zip
LibWeb: Make Selection GC-allocated
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Forward.h1
-rw-r--r--Userland/Libraries/LibWeb/HTML/Window.cpp1
-rw-r--r--Userland/Libraries/LibWeb/Selection/Selection.cpp13
-rw-r--r--Userland/Libraries/LibWeb/Selection/Selection.h19
-rw-r--r--Userland/Libraries/LibWeb/idl_files.cmake2
5 files changed, 23 insertions, 13 deletions
diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h
index e18837077b..992bd9e15f 100644
--- a/Userland/Libraries/LibWeb/Forward.h
+++ b/Userland/Libraries/LibWeb/Forward.h
@@ -455,7 +455,6 @@ class LocationObject;
class OptionConstructor;
class RangePrototype;
class ResizeObserverWrapper;
-class SelectionWrapper;
class URLSearchParamsIteratorWrapper;
class URLSearchParamsWrapper;
class URLWrapper;
diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index db10fb6816..e01ec222a1 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -23,7 +23,6 @@
#include <LibWeb/Bindings/LocationObject.h>
#include <LibWeb/Bindings/NavigatorObject.h>
#include <LibWeb/Bindings/Replaceable.h>
-#include <LibWeb/Bindings/SelectionWrapper.h>
#include <LibWeb/Bindings/WindowObjectHelper.h>
#include <LibWeb/Bindings/WindowPrototype.h>
#include <LibWeb/CSS/MediaQueryList.h>
diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp
index 4860da5e82..d90894e6d4 100644
--- a/Userland/Libraries/LibWeb/Selection/Selection.cpp
+++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp
@@ -4,15 +4,24 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibWeb/HTML/Window.h>
#include <LibWeb/Selection/Selection.h>
namespace Web::Selection {
-NonnullRefPtr<Selection> Selection::create()
+JS::NonnullGCPtr<Selection> Selection::create(HTML::Window& window)
{
- return adopt_ref(*new Selection);
+ return *window.heap().allocate<Selection>(window.realm(), window);
}
+Selection::Selection(HTML::Window& window)
+ : PlatformObject(window.realm())
+{
+ set_prototype(&window.cached_web_prototype("Selection"));
+}
+
+Selection::~Selection() = default;
+
DOM::Node* Selection::anchor_node()
{
TODO();
diff --git a/Userland/Libraries/LibWeb/Selection/Selection.h b/Userland/Libraries/LibWeb/Selection/Selection.h
index 65fff1443b..15108587b1 100644
--- a/Userland/Libraries/LibWeb/Selection/Selection.h
+++ b/Userland/Libraries/LibWeb/Selection/Selection.h
@@ -6,19 +6,17 @@
#pragma once
-#include <AK/NonnullRefPtr.h>
-#include <AK/RefCounted.h>
-#include <LibWeb/Bindings/Wrappable.h>
+#include <LibWeb/Bindings/PlatformObject.h>
namespace Web::Selection {
-class Selection
- : public RefCounted<Selection>
- , public Bindings::Wrappable {
+class Selection final : public Bindings::PlatformObject {
+ WEB_PLATFORM_OBJECT(Selection, Bindings::PlatformObject);
+
public:
- using WrapperType = Bindings::SelectionWrapper;
+ static JS::NonnullGCPtr<Selection> create(HTML::Window&);
- static NonnullRefPtr<Selection> create();
+ virtual ~Selection() override;
DOM::Node* anchor_node();
unsigned anchor_offset();
@@ -43,6 +41,11 @@ public:
bool contains_node(DOM::Node&, bool allow_partial_containment) const;
String to_string() const;
+
+private:
+ explicit Selection(HTML::Window&);
};
}
+
+WRAPPER_HACK(Selection, Web::Selection)
diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake
index a216c9a56d..a9875eddde 100644
--- a/Userland/Libraries/LibWeb/idl_files.cmake
+++ b/Userland/Libraries/LibWeb/idl_files.cmake
@@ -175,7 +175,7 @@ libweb_js_wrapper(SVG/SVGPolylineElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGRectElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGSVGElement NO_INSTANCE)
libweb_js_wrapper(SVG/SVGTextContentElement NO_INSTANCE)
-libweb_js_wrapper(Selection/Selection)
+libweb_js_wrapper(Selection/Selection NO_INSTANCE)
libweb_js_wrapper(UIEvents/FocusEvent NO_INSTANCE)
libweb_js_wrapper(UIEvents/KeyboardEvent NO_INSTANCE)
libweb_js_wrapper(UIEvents/MouseEvent NO_INSTANCE)