mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 18:57:40 +00:00
LibWeb: Implement DOMPoint/DOMPointReadOnly.fromPoint()
This commit is contained in:
parent
0823a3c422
commit
ab19c5fab8
6 changed files with 38 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -20,6 +21,13 @@ DOMPoint::DOMPoint(JS::Realm& realm, double x, double y, double z, double w)
|
||||||
set_prototype(&Bindings::cached_web_prototype(realm, "DOMPoint"));
|
set_prototype(&Bindings::cached_web_prototype(realm, "DOMPoint"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://drafts.fxtf.org/geometry/#dom-dompoint-frompoint
|
||||||
|
JS::NonnullGCPtr<DOMPoint> DOMPoint::from_point(JS::VM& vm, DOMPointInit const& other)
|
||||||
|
{
|
||||||
|
// The fromPoint(other) static method on DOMPoint must create a DOMPoint from the dictionary other.
|
||||||
|
return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w);
|
||||||
|
}
|
||||||
|
|
||||||
DOMPoint::~DOMPoint() = default;
|
DOMPoint::~DOMPoint() = default;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -17,6 +18,8 @@ class DOMPoint final : public DOMPointReadOnly {
|
||||||
public:
|
public:
|
||||||
static JS::NonnullGCPtr<DOMPoint> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
|
static JS::NonnullGCPtr<DOMPoint> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
|
||||||
|
|
||||||
|
static JS::NonnullGCPtr<DOMPoint> from_point(JS::VM&, DOMPointInit const&);
|
||||||
|
|
||||||
virtual ~DOMPoint() override;
|
virtual ~DOMPoint() override;
|
||||||
|
|
||||||
double x() const { return m_x; }
|
double x() const { return m_x; }
|
||||||
|
|
|
@ -6,7 +6,7 @@ interface DOMPoint : DOMPointReadOnly {
|
||||||
constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||||
optional unrestricted double z = 0, optional unrestricted double w = 1);
|
optional unrestricted double z = 0, optional unrestricted double w = 1);
|
||||||
|
|
||||||
// FIXME: [NewObject] static DOMPoint fromPoint(optional DOMPointInit other = {});
|
[NewObject] static DOMPoint fromPoint(optional DOMPointInit other = {});
|
||||||
|
|
||||||
inherit attribute unrestricted double x;
|
inherit attribute unrestricted double x;
|
||||||
inherit attribute unrestricted double y;
|
inherit attribute unrestricted double y;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -24,6 +25,13 @@ DOMPointReadOnly::DOMPointReadOnly(JS::Realm& realm, double x, double y, double
|
||||||
set_prototype(&Bindings::cached_web_prototype(realm, "DOMPointReadOnly"));
|
set_prototype(&Bindings::cached_web_prototype(realm, "DOMPointReadOnly"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://drafts.fxtf.org/geometry/#dom-dompointreadonly-frompoint
|
||||||
|
JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::from_point(JS::VM& vm, DOMPointInit const& other)
|
||||||
|
{
|
||||||
|
// The fromPoint(other) static method on DOMPointReadOnly must create a DOMPointReadOnly from the dictionary other.
|
||||||
|
return construct_impl(*vm.current_realm(), other.x, other.y, other.z, other.w);
|
||||||
|
}
|
||||||
|
|
||||||
DOMPointReadOnly::~DOMPointReadOnly() = default;
|
DOMPointReadOnly::~DOMPointReadOnly() = default;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +13,13 @@
|
||||||
|
|
||||||
namespace Web::Geometry {
|
namespace Web::Geometry {
|
||||||
|
|
||||||
|
struct DOMPointInit {
|
||||||
|
double x { 0 };
|
||||||
|
double y { 0 };
|
||||||
|
double z { 0 };
|
||||||
|
double w { 1 };
|
||||||
|
};
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry/#dompointreadonly
|
// https://drafts.fxtf.org/geometry/#dompointreadonly
|
||||||
class DOMPointReadOnly : public Bindings::PlatformObject {
|
class DOMPointReadOnly : public Bindings::PlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject);
|
WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject);
|
||||||
|
@ -19,6 +27,8 @@ class DOMPointReadOnly : public Bindings::PlatformObject {
|
||||||
public:
|
public:
|
||||||
static JS::NonnullGCPtr<DOMPointReadOnly> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
|
static JS::NonnullGCPtr<DOMPointReadOnly> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
|
||||||
|
|
||||||
|
static JS::NonnullGCPtr<DOMPointReadOnly> from_point(JS::VM&, DOMPointInit const&);
|
||||||
|
|
||||||
virtual ~DOMPointReadOnly() override;
|
virtual ~DOMPointReadOnly() override;
|
||||||
|
|
||||||
double x() const { return m_x; }
|
double x() const { return m_x; }
|
||||||
|
|
|
@ -4,7 +4,7 @@ interface DOMPointReadOnly {
|
||||||
constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||||
optional unrestricted double z = 0, optional unrestricted double w = 1);
|
optional unrestricted double z = 0, optional unrestricted double w = 1);
|
||||||
|
|
||||||
// FIXME: [NewObject] static DOMPointReadOnly fromPoint(optional DOMPointInit other = {});
|
[NewObject] static DOMPointReadOnly fromPoint(optional DOMPointInit other = {});
|
||||||
|
|
||||||
readonly attribute unrestricted double x;
|
readonly attribute unrestricted double x;
|
||||||
readonly attribute unrestricted double y;
|
readonly attribute unrestricted double y;
|
||||||
|
@ -15,3 +15,10 @@ interface DOMPointReadOnly {
|
||||||
|
|
||||||
// FIXME: [Default] object toJSON();
|
// FIXME: [Default] object toJSON();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dictionary DOMPointInit {
|
||||||
|
unrestricted double x = 0;
|
||||||
|
unrestricted double y = 0;
|
||||||
|
unrestricted double z = 0;
|
||||||
|
unrestricted double w = 1;
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue