mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00:00
LibWeb: Make IntersectionObserver GC-allocated
This commit is contained in:
parent
fe9c5395d4
commit
25daa14a05
4 changed files with 24 additions and 14 deletions
|
@ -449,7 +449,6 @@ class URLSearchParamsIterator;
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
class DOMExceptionWrapper;
|
class DOMExceptionWrapper;
|
||||||
class IntersectionObserverWrapper;
|
|
||||||
class LocationObject;
|
class LocationObject;
|
||||||
class OptionConstructor;
|
class OptionConstructor;
|
||||||
class RangePrototype;
|
class RangePrototype;
|
||||||
|
|
|
@ -5,20 +5,29 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibWeb/DOM/Element.h>
|
#include <LibWeb/DOM/Element.h>
|
||||||
|
#include <LibWeb/HTML/Window.h>
|
||||||
#include <LibWeb/IntersectionObserver/IntersectionObserver.h>
|
#include <LibWeb/IntersectionObserver/IntersectionObserver.h>
|
||||||
|
|
||||||
namespace Web::IntersectionObserver {
|
namespace Web::IntersectionObserver {
|
||||||
|
|
||||||
// https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-intersectionobserver
|
// https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-intersectionobserver
|
||||||
NonnullRefPtr<IntersectionObserver> IntersectionObserver::create_with_global_object(HTML::Window&, Bindings::CallbackType* callback, IntersectionObserverInit const& options)
|
JS::NonnullGCPtr<IntersectionObserver> IntersectionObserver::create_with_global_object(HTML::Window& window, Bindings::CallbackType* callback, IntersectionObserverInit const& options)
|
||||||
{
|
{
|
||||||
// FIXME: Implement
|
// FIXME: Implement
|
||||||
(void)callback;
|
(void)callback;
|
||||||
(void)options;
|
(void)options;
|
||||||
|
|
||||||
return adopt_ref(*new IntersectionObserver);
|
return *window.heap().allocate<IntersectionObserver>(window.realm(), window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntersectionObserver::IntersectionObserver(HTML::Window& window)
|
||||||
|
: PlatformObject(window.realm())
|
||||||
|
{
|
||||||
|
set_prototype(&window.cached_web_prototype("IntersectionObserver"));
|
||||||
|
}
|
||||||
|
|
||||||
|
IntersectionObserver::~IntersectionObserver() = default;
|
||||||
|
|
||||||
// https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-observe
|
// https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-observe
|
||||||
void IntersectionObserver::observe(DOM::Element& target)
|
void IntersectionObserver::observe(DOM::Element& target)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,10 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/NonnullRefPtr.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
#include <AK/RefCounted.h>
|
|
||||||
#include <LibJS/Heap/Handle.h>
|
|
||||||
#include <LibWeb/Bindings/Wrappable.h>
|
|
||||||
|
|
||||||
namespace Web::IntersectionObserver {
|
namespace Web::IntersectionObserver {
|
||||||
|
|
||||||
|
@ -20,17 +17,22 @@ struct IntersectionObserverInit {
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://w3c.github.io/IntersectionObserver/#intersection-observer-interface
|
// https://w3c.github.io/IntersectionObserver/#intersection-observer-interface
|
||||||
class IntersectionObserver
|
class IntersectionObserver : public Bindings::PlatformObject {
|
||||||
: public RefCounted<IntersectionObserver>
|
WEB_PLATFORM_OBJECT(IntersectionObserver, Bindings::PlatformObject);
|
||||||
, public Bindings::Wrappable {
|
|
||||||
public:
|
|
||||||
using WrapperType = Bindings::IntersectionObserverWrapper;
|
|
||||||
|
|
||||||
static NonnullRefPtr<IntersectionObserver> create_with_global_object(HTML::Window&, Bindings::CallbackType* callback, IntersectionObserverInit const& options = {});
|
public:
|
||||||
|
static JS::NonnullGCPtr<IntersectionObserver> create_with_global_object(HTML::Window&, Bindings::CallbackType* callback, IntersectionObserverInit const& options = {});
|
||||||
|
|
||||||
|
virtual ~IntersectionObserver() override;
|
||||||
|
|
||||||
void observe(DOM::Element& target);
|
void observe(DOM::Element& target);
|
||||||
void unobserve(DOM::Element& target);
|
void unobserve(DOM::Element& target);
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit IntersectionObserver(HTML::Window&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WRAPPER_HACK(IntersectionObserver, Web::IntersectionObserver)
|
||||||
|
|
|
@ -155,7 +155,7 @@ libweb_js_wrapper(HTML/WorkerGlobalScope NO_INSTANCE)
|
||||||
libweb_js_wrapper(HTML/WorkerLocation)
|
libweb_js_wrapper(HTML/WorkerLocation)
|
||||||
libweb_js_wrapper(HTML/WorkerNavigator)
|
libweb_js_wrapper(HTML/WorkerNavigator)
|
||||||
libweb_js_wrapper(HighResolutionTime/Performance NO_INSTANCE)
|
libweb_js_wrapper(HighResolutionTime/Performance NO_INSTANCE)
|
||||||
libweb_js_wrapper(IntersectionObserver/IntersectionObserver)
|
libweb_js_wrapper(IntersectionObserver/IntersectionObserver NO_INSTANCE)
|
||||||
libweb_js_wrapper(NavigationTiming/PerformanceTiming NO_INSTANCE)
|
libweb_js_wrapper(NavigationTiming/PerformanceTiming NO_INSTANCE)
|
||||||
libweb_js_wrapper(RequestIdleCallback/IdleDeadline NO_INSTANCE)
|
libweb_js_wrapper(RequestIdleCallback/IdleDeadline NO_INSTANCE)
|
||||||
libweb_js_wrapper(ResizeObserver/ResizeObserver NO_INSTANCE)
|
libweb_js_wrapper(ResizeObserver/ResizeObserver NO_INSTANCE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue