ladybird/Userland/Libraries/LibWeb/Geometry/DOMRect.h
Andreas Kling cc4b3cbacc
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Meta: Update my e-mail address everywhere
2024-10-04 13:19:50 +02:00

45 lines
1.5 KiB
C++

/*
* Copyright (c) 2021, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Geometry/DOMRectReadOnly.h>
namespace Web::Geometry {
// https://drafts.fxtf.org/geometry/#DOMRect
class DOMRect final : public DOMRectReadOnly {
WEB_PLATFORM_OBJECT(DOMRect, DOMRectReadOnly);
JS_DECLARE_ALLOCATOR(DOMRect);
public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0);
[[nodiscard]] static JS::NonnullGCPtr<DOMRect> create(JS::Realm&, Gfx::FloatRect const&);
[[nodiscard]] static JS::NonnullGCPtr<DOMRect> create(JS::Realm&);
[[nodiscard]] static JS::NonnullGCPtr<DOMRect> from_rect(JS::VM&, DOMRectInit const&);
virtual ~DOMRect() override;
double x() const { return m_rect.x(); }
double y() const { return m_rect.y(); }
double width() const { return m_rect.width(); }
double height() const { return m_rect.height(); }
void set_x(double x) { m_rect.set_x(x); }
void set_y(double y) { m_rect.set_y(y); }
void set_width(double width) { m_rect.set_width(width); }
void set_height(double height) { m_rect.set_height(height); }
virtual StringView interface_name() const override { return "DOMRect"sv; }
private:
DOMRect(JS::Realm&, double x, double y, double width, double height);
explicit DOMRect(JS::Realm&);
virtual void initialize(JS::Realm&) override;
};
}