mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:07:35 +00:00
LibWeb: Make Selection GC-allocated
This commit is contained in:
parent
be9d3860b9
commit
8f2a711132
5 changed files with 24 additions and 14 deletions
|
@ -455,7 +455,6 @@ class LocationObject;
|
||||||
class OptionConstructor;
|
class OptionConstructor;
|
||||||
class RangePrototype;
|
class RangePrototype;
|
||||||
class ResizeObserverWrapper;
|
class ResizeObserverWrapper;
|
||||||
class SelectionWrapper;
|
|
||||||
class URLSearchParamsIteratorWrapper;
|
class URLSearchParamsIteratorWrapper;
|
||||||
class URLSearchParamsWrapper;
|
class URLSearchParamsWrapper;
|
||||||
class URLWrapper;
|
class URLWrapper;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <LibWeb/Bindings/LocationObject.h>
|
#include <LibWeb/Bindings/LocationObject.h>
|
||||||
#include <LibWeb/Bindings/NavigatorObject.h>
|
#include <LibWeb/Bindings/NavigatorObject.h>
|
||||||
#include <LibWeb/Bindings/Replaceable.h>
|
#include <LibWeb/Bindings/Replaceable.h>
|
||||||
#include <LibWeb/Bindings/SelectionWrapper.h>
|
|
||||||
#include <LibWeb/Bindings/WindowObjectHelper.h>
|
#include <LibWeb/Bindings/WindowObjectHelper.h>
|
||||||
#include <LibWeb/Bindings/WindowPrototype.h>
|
#include <LibWeb/Bindings/WindowPrototype.h>
|
||||||
#include <LibWeb/CSS/MediaQueryList.h>
|
#include <LibWeb/CSS/MediaQueryList.h>
|
||||||
|
|
|
@ -4,15 +4,24 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/HTML/Window.h>
|
||||||
#include <LibWeb/Selection/Selection.h>
|
#include <LibWeb/Selection/Selection.h>
|
||||||
|
|
||||||
namespace Web::Selection {
|
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()
|
DOM::Node* Selection::anchor_node()
|
||||||
{
|
{
|
||||||
TODO();
|
TODO();
|
||||||
|
|
|
@ -6,19 +6,17 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/NonnullRefPtr.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
#include <AK/RefCounted.h>
|
|
||||||
#include <LibWeb/Bindings/Wrappable.h>
|
|
||||||
|
|
||||||
namespace Web::Selection {
|
namespace Web::Selection {
|
||||||
|
|
||||||
class Selection
|
class Selection final : public Bindings::PlatformObject {
|
||||||
: public RefCounted<Selection>
|
WEB_PLATFORM_OBJECT(Selection, Bindings::PlatformObject);
|
||||||
, public Bindings::Wrappable {
|
|
||||||
public:
|
|
||||||
using WrapperType = Bindings::SelectionWrapper;
|
|
||||||
|
|
||||||
static NonnullRefPtr<Selection> create();
|
public:
|
||||||
|
static JS::NonnullGCPtr<Selection> create(HTML::Window&);
|
||||||
|
|
||||||
|
virtual ~Selection() override;
|
||||||
|
|
||||||
DOM::Node* anchor_node();
|
DOM::Node* anchor_node();
|
||||||
unsigned anchor_offset();
|
unsigned anchor_offset();
|
||||||
|
@ -43,6 +41,11 @@ public:
|
||||||
bool contains_node(DOM::Node&, bool allow_partial_containment) const;
|
bool contains_node(DOM::Node&, bool allow_partial_containment) const;
|
||||||
|
|
||||||
String to_string() const;
|
String to_string() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit Selection(HTML::Window&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WRAPPER_HACK(Selection, Web::Selection)
|
||||||
|
|
|
@ -175,7 +175,7 @@ libweb_js_wrapper(SVG/SVGPolylineElement NO_INSTANCE)
|
||||||
libweb_js_wrapper(SVG/SVGRectElement NO_INSTANCE)
|
libweb_js_wrapper(SVG/SVGRectElement NO_INSTANCE)
|
||||||
libweb_js_wrapper(SVG/SVGSVGElement NO_INSTANCE)
|
libweb_js_wrapper(SVG/SVGSVGElement NO_INSTANCE)
|
||||||
libweb_js_wrapper(SVG/SVGTextContentElement 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/FocusEvent NO_INSTANCE)
|
||||||
libweb_js_wrapper(UIEvents/KeyboardEvent NO_INSTANCE)
|
libweb_js_wrapper(UIEvents/KeyboardEvent NO_INSTANCE)
|
||||||
libweb_js_wrapper(UIEvents/MouseEvent NO_INSTANCE)
|
libweb_js_wrapper(UIEvents/MouseEvent NO_INSTANCE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue