DOMPoint.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. }
  18. // https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
  19. JS::NonnullGCPtr<DOMPoint> DOMPoint::from_point(JS::VM& vm, DOMPointInit const& other)
  20. {
  21. // The fromPoint(other) static method on DOMPoint must create a DOMPoint from the dictionary other.
  22. return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w);
  23. }
  24. DOMPoint::~DOMPoint() = default;
  25. void DOMPoint::initialize(JS::Realm& realm)
  26. {
  27. Base::initialize(realm);
  28. set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMPointPrototype>(realm, "DOMPoint"));
  29. }
  30. }