
This is a monster patch that turns all EventTargets into GC-allocated PlatformObjects. Their C++ wrapper classes are removed, and the LibJS garbage collector is now responsible for their lifetimes. There's a fair amount of hacks and band-aids in this patch, and we'll have a lot of cleanup to do after this.
36 lines
1 KiB
C++
36 lines
1 KiB
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 <LibJS/Heap/Handle.h>
|
|
#include <LibWeb/Bindings/Wrappable.h>
|
|
|
|
namespace Web::IntersectionObserver {
|
|
|
|
struct IntersectionObserverInit {
|
|
Optional<Variant<JS::Handle<DOM::Element>, JS::Handle<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(HTML::Window&, Bindings::CallbackType* callback, IntersectionObserverInit const& options = {});
|
|
|
|
void observe(DOM::Element& target);
|
|
void unobserve(DOM::Element& target);
|
|
void disconnect();
|
|
};
|
|
|
|
}
|