DOMPointReadOnly.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <LibWeb/Bindings/Intrinsics.h>
  8. #include <LibWeb/Geometry/DOMPointReadOnly.h>
  9. #include <LibWeb/WebIDL/ExceptionOr.h>
  10. namespace Web::Geometry {
  11. JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
  12. {
  13. return realm.heap().allocate<DOMPointReadOnly>(realm, realm, x, y, z, w);
  14. }
  15. DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm, double x, double y, double z, double w)
  16. : PlatformObject(realm)
  17. , m_x(x)
  18. , m_y(y)
  19. , m_z(z)
  20. , m_w(w)
  21. {
  22. }
  23. // https://drafts.fxtf.org/geometry/#dom-dompointreadonly-frompoint
  24. JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::from_point(JS::VM& vm, DOMPointInit const& other)
  25. {
  26. // The fromPoint(other) static method on DOMPointReadOnly must create a DOMPointReadOnly from the dictionary other.
  27. return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w);
  28. }
  29. DOMPointReadOnly::~DOMPointReadOnly() = default;
  30. void DOMPointReadOnly::initialize(JS::Realm& realm)
  31. {
  32. Base::initialize(realm);
  33. set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMPointReadOnlyPrototype>(realm, "DOMPointReadOnly"));
  34. }
  35. }