1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00
serenity/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h
Andreas Kling 8cda70c892 LibWeb: Move event listeners, handlers and callbacks to the GC heap
This patch moves the following things to being GC-allocated:
- Bindings::CallbackType
- HTML::EventHandler
- DOM::IDLEventListener
- DOM::DOMEventListener
- DOM::NodeFilter

Note that we only use PlatformObject for things that might be exposed
to web content. Anything that is only used internally inherits directly
from JS::Cell instead, making them a bit more lightweight.
2022-09-06 00:27:09 +02:00

35 lines
1,020 B
C++

/*
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
#include <LibWeb/Bindings/Wrappable.h>
namespace Web::IntersectionObserver {
struct IntersectionObserverInit {
Optional<Variant<NonnullRefPtr<DOM::Element>, NonnullRefPtr<DOM::Document>>> root;
String root_margin { "0px"sv };
Variant<double, Vector<double>> threshold { 0 };
};
// https://w3c.github.io/IntersectionObserver/#intersection-observer-interface
class IntersectionObserver
: public RefCounted<IntersectionObserver>
, public Bindings::Wrappable {
public:
using WrapperType = Bindings::IntersectionObserverWrapper;
static NonnullRefPtr<IntersectionObserver> create_with_global_object(JS::GlobalObject&, Bindings::CallbackType* callback, IntersectionObserverInit const& options = {});
void observe(DOM::Element& target);
void unobserve(DOM::Element& target);
void disconnect();
};
}