DOMRect.cpp 837 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/Geometry/DOMRect.h>
  8. namespace Web::Geometry {
  9. JS::NonnullGCPtr<DOMRect> DOMRect::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
  10. {
  11. return *realm.heap().allocate<DOMRect>(realm, realm, x, y, width, height);
  12. }
  13. JS::NonnullGCPtr<DOMRect> DOMRect::create(JS::Realm& realm, Gfx::FloatRect const& rect)
  14. {
  15. return construct_impl(realm, rect.x(), rect.y(), rect.width(), rect.height());
  16. }
  17. DOMRect::DOMRect(JS::Realm& realm, double x, double y, double width, double height)
  18. : DOMRectReadOnly(realm, x, y, width, height)
  19. {
  20. set_prototype(&Bindings::cached_web_prototype(realm, "DOMRect"));
  21. }
  22. DOMRect::~DOMRect() = default;
  23. }