DOMRect.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Geometry/DOMRectReadOnly.h>
  8. namespace Web::Geometry {
  9. // https://drafts.fxtf.org/geometry/#DOMRect
  10. class DOMRect final : public DOMRectReadOnly {
  11. WEB_PLATFORM_OBJECT(DOMRect, DOMRectReadOnly);
  12. public:
  13. static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> construct_impl(JS::Realm&, double x = 0, double y = 0, double width = 0, double height = 0);
  14. static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRect>> create(JS::Realm&, Gfx::FloatRect const&);
  15. virtual ~DOMRect() override;
  16. double x() const { return m_rect.x(); }
  17. double y() const { return m_rect.y(); }
  18. double width() const { return m_rect.width(); }
  19. double height() const { return m_rect.height(); }
  20. void set_x(double x) { m_rect.set_x(x); }
  21. void set_y(double y) { m_rect.set_y(y); }
  22. void set_width(double width) { m_rect.set_width(width); }
  23. void set_height(double height) { m_rect.set_height(height); }
  24. private:
  25. DOMRect(JS::Realm&, double x, double y, double width, double height);
  26. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  27. };
  28. }