diff options
author | DerpyCrabs <derpycrabs@gmail.com> | 2022-02-12 16:38:54 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-12 22:43:10 +0100 |
commit | 2f828231c40a4a78c0563824e204f5b112094c7d (patch) | |
tree | 70c005ba1a63375bcef83648c4fea7109c0d8335 /Userland/Libraries/LibWeb/Geometry/DOMRectList.h | |
parent | 0532d7d2556ad5007c06a26c66e2e5d94a8fe13a (diff) | |
download | serenity-2f828231c40a4a78c0563824e204f5b112094c7d.zip |
LibWeb: Implement Geometry::DOMRectList
Implement DOMRectList that is used as a return type of
getClientRects functions on Element and Range.
Diffstat (limited to 'Userland/Libraries/LibWeb/Geometry/DOMRectList.h')
-rw-r--r-- | Userland/Libraries/LibWeb/Geometry/DOMRectList.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectList.h b/Userland/Libraries/LibWeb/Geometry/DOMRectList.h new file mode 100644 index 0000000000..18cca279f0 --- /dev/null +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectList.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022, DerpyCrabs <derpycrabs@gmail.com> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/Noncopyable.h> +#include <AK/NonnullRefPtrVector.h> +#include <AK/RefCounted.h> +#include <AK/Vector.h> +#include <LibWeb/Bindings/Wrappable.h> +#include <LibWeb/Forward.h> +#include <LibWeb/Geometry/DOMRect.h> + +namespace Web::Geometry { + +// https://drafts.fxtf.org/geometry-1/#DOMRectList +class DOMRectList final + : public RefCounted<DOMRectList> + , public Bindings::Wrappable { + AK_MAKE_NONCOPYABLE(DOMRectList); + AK_MAKE_NONMOVABLE(DOMRectList); + +public: + using WrapperType = Bindings::DOMRectListWrapper; + + static NonnullRefPtr<DOMRectList> create(NonnullRefPtrVector<DOMRect>&& rects) + { + return adopt_ref(*new DOMRectList(move(rects))); + } + + ~DOMRectList() = default; + + u32 length() const; + DOMRect const* item(u32 index) const; + + bool is_supported_property_index(u32) const; + +private: + DOMRectList(NonnullRefPtrVector<DOMRect>&& rects); + + NonnullRefPtrVector<DOMRect> m_rects; +}; + +} |