mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +00:00
LibWeb: Flesh out implementation of ResizeObserver interfaces
Adds the initial implementation for interfaces defined in the ResizeObserver specification. These interfaces will be used to construct and send observation events in the upcoming changes.
This commit is contained in:
parent
fb4c632309
commit
fb8edcea00
15 changed files with 494 additions and 13 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -7,6 +8,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/ResizeObserver/ResizeObservation.h>
|
||||
#include <LibWeb/ResizeObserver/ResizeObserverEntry.h>
|
||||
|
||||
namespace Web::ResizeObserver {
|
||||
|
||||
|
@ -14,7 +17,7 @@ struct ResizeObserverOptions {
|
|||
Bindings::ResizeObserverBoxOptions box;
|
||||
};
|
||||
|
||||
// https://drafts.csswg.org/resize-observer/#resize-observer-interface
|
||||
// https://drafts.csswg.org/resize-observer-1/#resize-observer-interface
|
||||
class ResizeObserver : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(ResizeObserver, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(ResizeObserver);
|
||||
|
@ -28,10 +31,26 @@ public:
|
|||
void unobserve(DOM::Element& target);
|
||||
void disconnect();
|
||||
|
||||
void invoke_callback(Vector<JS::NonnullGCPtr<ResizeObserverEntry>>& entries) const;
|
||||
|
||||
Vector<JS::NonnullGCPtr<ResizeObservation>>& observation_targets() { return m_observation_targets; }
|
||||
Vector<JS::NonnullGCPtr<ResizeObservation>>& active_targets() { return m_active_targets; }
|
||||
Vector<JS::NonnullGCPtr<ResizeObservation>>& skipped_targets() { return m_skipped_targets; }
|
||||
|
||||
private:
|
||||
explicit ResizeObserver(JS::Realm&);
|
||||
explicit ResizeObserver(JS::Realm&, WebIDL::CallbackType* callback);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
virtual void finalize() override;
|
||||
|
||||
JS::GCPtr<WebIDL::CallbackType> m_callback;
|
||||
Vector<JS::NonnullGCPtr<ResizeObservation>> m_observation_targets;
|
||||
Vector<JS::NonnullGCPtr<ResizeObservation>> m_active_targets;
|
||||
Vector<JS::NonnullGCPtr<ResizeObservation>> m_skipped_targets;
|
||||
|
||||
// AD-HOC: This is the document where we've registered the observer.
|
||||
WeakPtr<DOM::Document> m_document;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue