DOMPoint.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. JS::NonnullGCPtr<DOMPoint> DOMPoint::create(JS::Realm& realm)
  16. {
  17. return realm.heap().allocate<DOMPoint>(realm, realm);
  18. }
  19. DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w)
  20. : DOMPointReadOnly(realm, x, y, z, w)
  21. {
  22. }
  23. DOMPoint::DOMPoint(JS::Realm& realm)
  24. : DOMPointReadOnly(realm)
  25. {
  26. }
  27. // https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
  28. JS::NonnullGCPtr<DOMPoint> DOMPoint::from_point(JS::VM& vm, DOMPointInit const& other)
  29. {
  30. // The fromPoint(other) static method on DOMPoint must create a DOMPoint from the dictionary other.
  31. return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w);
  32. }
  33. DOMPoint::~DOMPoint() = default;
  34. void DOMPoint::initialize(JS::Realm& realm)
  35. {
  36. Base::initialize(realm);
  37. WEB_SET_PROTOTYPE_FOR_INTERFACE(DOMPoint);
  38. }
  39. }