mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
521ed0e911
We have two known PlatformObjects that need to implement some of the behavior of LegacyPlatformObjects to date: Window, and HTMLFormElement. To make this not require double (or virtual) inheritance of PlatformObject, move the behavior of LegacyPlatformObject into PlatformObject. The selection of LegacyPlatformObject behavior is done with a new bitfield of feature flags instead of a dozen virtual functions that return bool. This change simplifies every class involved in the diff with the notable exception of Window, which now needs some ugly const casts to implement named property access.
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2022, DerpyCrabs <derpycrabs@gmail.com>
|
|
* Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Vector.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/Geometry/DOMRect.h>
|
|
|
|
namespace Web::Geometry {
|
|
|
|
// https://drafts.fxtf.org/geometry-1/#DOMRectList
|
|
class DOMRectList final : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(DOMRectList, Bindings::PlatformObject);
|
|
JS_DECLARE_ALLOCATOR(DOMRectList);
|
|
|
|
public:
|
|
[[nodiscard]] static JS::NonnullGCPtr<DOMRectList> create(JS::Realm&, Vector<JS::Handle<DOMRect>>);
|
|
|
|
virtual ~DOMRectList() override;
|
|
|
|
u32 length() const;
|
|
DOMRect const* item(u32 index) const;
|
|
|
|
virtual bool is_supported_property_index(u32) const override;
|
|
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
|
|
|
private:
|
|
DOMRectList(JS::Realm&, Vector<JS::NonnullGCPtr<DOMRect>>);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
Vector<JS::NonnullGCPtr<DOMRect>> m_rects;
|
|
};
|
|
|
|
}
|