DOMPoint.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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/DOMPoint.h>
  9. namespace Web::Geometry {
  10. JS_DEFINE_ALLOCATOR(DOMPoint);
  11. JS::NonnullGCPtr<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
  12. {
  13. return realm.heap().allocate<DOMPoint>(realm, realm, x, y, z, w);
  14. }
  15. DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w)
  16. : DOMPointReadOnly(realm, x, y, z, w)
  17. {
  18. }
  19. // https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
  20. JS::NonnullGCPtr<DOMPoint> DOMPoint::from_point(JS::VM& vm, DOMPointInit const& other)
  21. {
  22. // The fromPoint(other) static method on DOMPoint must create a DOMPoint from the dictionary other.
  23. return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w);
  24. }
  25. DOMPoint::~DOMPoint() = default;
  26. void DOMPoint::initialize(JS::Realm& realm)
  27. {
  28. Base::initialize(realm);
  29. WEB_SET_PROTOTYPE_FOR_INTERFACE(DOMPoint);
  30. }
  31. }