DOMPoint.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
  3. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <LibWeb/Bindings/DOMPointPrototype.h>
  8. #include <LibWeb/Bindings/Intrinsics.h>
  9. #include <LibWeb/Geometry/DOMPoint.h>
  10. namespace Web::Geometry {
  11. GC_DEFINE_ALLOCATOR(DOMPoint);
  12. GC::Ref<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
  13. {
  14. return realm.create<DOMPoint>(realm, x, y, z, w);
  15. }
  16. GC::Ref<DOMPoint> DOMPoint::create(JS::Realm& realm)
  17. {
  18. return realm.create<DOMPoint>(realm);
  19. }
  20. DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w)
  21. : DOMPointReadOnly(realm, x, y, z, w)
  22. {
  23. }
  24. DOMPoint::DOMPoint(JS::Realm& realm)
  25. : DOMPointReadOnly(realm)
  26. {
  27. }
  28. // https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
  29. GC::Ref<DOMPoint> DOMPoint::from_point(JS::VM& vm, DOMPointInit const& other)
  30. {
  31. // The fromPoint(other) static method on DOMPoint must create a DOMPoint from the dictionary other.
  32. return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w);
  33. }
  34. DOMPoint::~DOMPoint() = default;
  35. void DOMPoint::initialize(JS::Realm& realm)
  36. {
  37. Base::initialize(realm);
  38. WEB_SET_PROTOTYPE_FOR_INTERFACE(DOMPoint);
  39. }
  40. }