Serenity Operating System
at master 45 lines 1.5 kB view raw
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 8#include <LibWeb/Bindings/Intrinsics.h> 9#include <LibWeb/Geometry/DOMPointReadOnly.h> 10#include <LibWeb/WebIDL/ExceptionOr.h> 11 12namespace Web::Geometry { 13 14WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPointReadOnly>> DOMPointReadOnly::construct_impl(JS::Realm& realm, double x, double y, double z, double w) 15{ 16 return MUST_OR_THROW_OOM(realm.heap().allocate<DOMPointReadOnly>(realm, realm, x, y, z, w)); 17} 18 19DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm, double x, double y, double z, double w) 20 : PlatformObject(realm) 21 , m_x(x) 22 , m_y(y) 23 , m_z(z) 24 , m_w(w) 25{ 26} 27 28// https://drafts.fxtf.org/geometry/#dom-dompointreadonly-frompoint 29WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPointReadOnly>> DOMPointReadOnly::from_point(JS::VM& vm, DOMPointInit const& other) 30{ 31 // The fromPoint(other) static method on DOMPointReadOnly must create a DOMPointReadOnly from the dictionary other. 32 return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w); 33} 34 35DOMPointReadOnly::~DOMPointReadOnly() = default; 36 37JS::ThrowCompletionOr<void> DOMPointReadOnly::initialize(JS::Realm& realm) 38{ 39 MUST_OR_THROW_OOM(Base::initialize(realm)); 40 set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMPointReadOnlyPrototype>(realm, "DOMPointReadOnly")); 41 42 return {}; 43} 44 45}