DOMRectReadOnly.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. JS_DEFINE_ALLOCATOR(DOMRectReadOnly);
  11. WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRectReadOnly>> DOMRectReadOnly::construct_impl(JS::Realm& realm, double x, double y, double width, double height)
  12. {
  13. return realm.heap().allocate<DOMRectReadOnly>(realm, realm, x, y, width, height);
  14. }
  15. // https://drafts.fxtf.org/geometry/#create-a-domrect-from-the-dictionary
  16. JS::NonnullGCPtr<DOMRectReadOnly> DOMRectReadOnly::from_rect(JS::VM& vm, Geometry::DOMRectInit const& other)
  17. {
  18. auto& realm = *vm.current_realm();
  19. return realm.heap().allocate<DOMRectReadOnly>(realm, realm, other.x, other.y, other.width, other.height);
  20. }
  21. DOMRectReadOnly::DOMRectReadOnly(JS::Realm& realm, double x, double y, double width, double height)
  22. : PlatformObject(realm)
  23. , m_rect(x, y, width, height)
  24. {
  25. }
  26. DOMRectReadOnly::~DOMRectReadOnly() = default;
  27. void DOMRectReadOnly::initialize(JS::Realm& realm)
  28. {
  29. Base::initialize(realm);
  30. WEB_SET_PROTOTYPE_FOR_INTERFACE(DOMRectReadOnly);
  31. }
  32. }