DOMPoint.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. #include <LibWeb/WebIDL/ExceptionOr.h>
  10. namespace Web::Geometry {
  11. WebIDL::ExceptionOr<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).release_value_but_fixme_should_propagate_errors();
  24. }
  25. DOMPoint::~DOMPoint() = default;
  26. void DOMPoint::initialize(JS::Realm& realm)
  27. {
  28. Base::initialize(realm);
  29. set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMPointPrototype>(realm, "DOMPoint"));
  30. }
  31. }