1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:07:44 +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:
Aliaksandr Kalenik 2024-02-19 05:06:39 +01:00 committed by Andreas Kling
parent fb4c632309
commit fb8edcea00
15 changed files with 494 additions and 13 deletions

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/Bindings/ResizeObserverPrototype.h>
#include <LibWeb/ResizeObserver/ResizeObserverSize.h>
namespace Web::ResizeObserver {
// https://drafts.csswg.org/resize-observer-1/#resize-observation-interface
class ResizeObservation : public JS::Cell {
JS_CELL(ResizeObservation, JS::Cell);
JS_DECLARE_ALLOCATOR(ResizeObservation);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ResizeObservation>> create(JS::Realm&, DOM::Element&, Bindings::ResizeObserverBoxOptions);
bool is_active();
JS::NonnullGCPtr<DOM::Element> target() const { return m_target; }
Bindings::ResizeObserverBoxOptions observed_box() const { return m_observed_box; }
Vector<JS::NonnullGCPtr<ResizeObserverSize>>& last_reported_sizes() { return m_last_reported_sizes; }
explicit ResizeObservation(JS::Realm& realm, DOM::Element& target, Bindings::ResizeObserverBoxOptions observed_box);
private:
virtual void visit_edges(JS::Cell::Visitor&) override;
JS::NonnullGCPtr<JS::Realm> m_realm;
JS::NonnullGCPtr<DOM::Element> m_target;
Bindings::ResizeObserverBoxOptions m_observed_box;
Vector<JS::NonnullGCPtr<ResizeObserverSize>> m_last_reported_sizes;
};
}