1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:27:43 +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,42 @@
/*
* 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>
namespace Web::ResizeObserver {
// https://drafts.csswg.org/resize-observer-1/#resizeobserversize
class ResizeObserverSize : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(ResizeObserverSize, Bindings::PlatformObject);
JS_DECLARE_ALLOCATOR(ResizeObserverSize);
public:
static JS::NonnullGCPtr<ResizeObserverSize> calculate_box_size(JS::Realm& realm, DOM::Element& target, Bindings::ResizeObserverBoxOptions observed_box);
double inline_size() const { return m_inline_size; }
void set_inline_size(double inline_size) { m_inline_size = inline_size; }
double block_size() const { return m_block_size; }
void set_block_size(double block_size) { m_block_size = block_size; }
bool equals(ResizeObserverSize const& other) const;
private:
explicit ResizeObserverSize(JS::Realm& realm)
: PlatformObject(realm)
{
}
virtual void initialize(JS::Realm&) override;
double m_inline_size { 0 };
double m_block_size { 0 };
};
}