/src/serenity/Userland/Libraries/LibWeb/Geometry/DOMRect.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2021, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibWeb/Geometry/DOMRectReadOnly.h> |
10 | | |
11 | | namespace Web::Geometry { |
12 | | |
13 | | // https://drafts.fxtf.org/geometry/#DOMRect |
14 | | class DOMRect final : public DOMRectReadOnly { |
15 | | WEB_PLATFORM_OBJECT(DOMRect, DOMRectReadOnly); |
16 | | JS_DECLARE_ALLOCATOR(DOMRect); |
17 | | |
18 | | public: |
19 | | static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0); |
20 | | [[nodiscard]] static JS::NonnullGCPtr<DOMRect> create(JS::Realm&, Gfx::FloatRect const&); |
21 | | [[nodiscard]] static JS::NonnullGCPtr<DOMRect> create(JS::Realm&); |
22 | | [[nodiscard]] static JS::NonnullGCPtr<DOMRect> from_rect(JS::VM&, DOMRectInit const&); |
23 | | |
24 | | virtual ~DOMRect() override; |
25 | | |
26 | 0 | double x() const { return m_rect.x(); } |
27 | 0 | double y() const { return m_rect.y(); } |
28 | 0 | double width() const { return m_rect.width(); } |
29 | 0 | double height() const { return m_rect.height(); } |
30 | | |
31 | 0 | void set_x(double x) { m_rect.set_x(x); } |
32 | 0 | void set_y(double y) { m_rect.set_y(y); } |
33 | 0 | void set_width(double width) { m_rect.set_width(width); } |
34 | 0 | void set_height(double height) { m_rect.set_height(height); } |
35 | | |
36 | 0 | virtual StringView interface_name() const override { return "DOMRect"sv; } |
37 | | |
38 | | private: |
39 | | DOMRect(JS::Realm&, double x, double y, double width, double height); |
40 | | explicit DOMRect(JS::Realm&); |
41 | | |
42 | | virtual void initialize(JS::Realm&) override; |
43 | | }; |
44 | | |
45 | | } |