DOMRectReadOnly.cpp 1002 B

12345678910111213141516171819202122232425262728293031323334
  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/DOMRectReadOnly.h>
  8. #include <LibWeb/WebIDL/ExceptionOr.h>
  9. namespace Web::Geometry {
  10. WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRectReadOnly>> DOMRectReadOnly::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
  11. {
  12. return MUST_OR_THROW_OOM(realm.heap().allocate<DOMRectReadOnly>(realm, realm, x, y, width, height));
  13. }
  14. DOMRectReadOnly::DOMRectReadOnly(JS::Realm& realm, double x, double y, double width, double height)
  15. : PlatformObject(realm)
  16. , m_rect(x, y, width, height)
  17. {
  18. }
  19. DOMRectReadOnly::~DOMRectReadOnly() = default;
  20. JS::ThrowCompletionOr<void> DOMRectReadOnly::initialize(JS::Realm& realm)
  21. {
  22. MUST_OR_THROW_OOM(Base::initialize(realm));
  23. set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMRectReadOnlyPrototype>(realm, "DOMRectReadOnly"));
  24. return {};
  25. }
  26. }