DOMPointReadOnly.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. namespace Web::Geometry {
  10. JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
  11. {
  12. return *realm.heap().allocate<DOMPointReadOnly>(realm, realm, x, y, z, w);
  13. }
  14. DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm, double x, double y, double z, double w)
  15. : PlatformObject(realm)
  16. , m_x(x)
  17. , m_y(y)
  18. , m_z(z)
  19. , m_w(w)
  20. {
  21. set_prototype(&Bindings::cached_web_prototype(realm, "DOMPointReadOnly"));
  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. }