DOMPoint.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233
  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::NonnullGCPtr<DOMPoint> DOMPoint::construct_impl(JS::Realm& realm, double x, double y, double z, double w)
  11. {
  12. return *realm.heap().allocate<DOMPoint>(realm, realm, x, y, z, w);
  13. }
  14. DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w)
  15. : DOMPointReadOnly(realm, x, y, z, w)
  16. {
  17. set_prototype(&Bindings::cached_web_prototype(realm, "DOMPoint"));
  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. }