LibWeb: Implement DOMPoint/DOMPointReadOnly.fromPoint()
This commit is contained in:
parent
0823a3c422
commit
ab19c5fab8
Notes:
sideshowbarker
2024-07-17 20:33:50 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/ab19c5fab8 Pull-request: https://github.com/SerenityOS/serenity/pull/15483 Reviewed-by: https://github.com/linusg ✅
6 changed files with 38 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* 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"));
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -17,6 +18,8 @@ class DOMPoint final : public DOMPointReadOnly {
|
|||
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> from_point(JS::VM&, DOMPointInit const&);
|
||||
|
||||
virtual ~DOMPoint() override;
|
||||
|
||||
double x() const { return m_x; }
|
||||
|
|
|
@ -6,7 +6,7 @@ interface DOMPoint : DOMPointReadOnly {
|
|||
constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||
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 y;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* 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"));
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -12,6 +13,13 @@
|
|||
|
||||
namespace Web::Geometry {
|
||||
|
||||
struct DOMPointInit {
|
||||
double x { 0 };
|
||||
double y { 0 };
|
||||
double z { 0 };
|
||||
double w { 1 };
|
||||
};
|
||||
|
||||
// https://drafts.fxtf.org/geometry/#dompointreadonly
|
||||
class DOMPointReadOnly : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject);
|
||||
|
@ -19,6 +27,8 @@ class DOMPointReadOnly : public Bindings::PlatformObject {
|
|||
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> from_point(JS::VM&, DOMPointInit const&);
|
||||
|
||||
virtual ~DOMPointReadOnly() override;
|
||||
|
||||
double x() const { return m_x; }
|
||||
|
|
|
@ -4,7 +4,7 @@ interface DOMPointReadOnly {
|
|||
constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||
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 y;
|
||||
|
@ -15,3 +15,10 @@ interface DOMPointReadOnly {
|
|||
|
||||
// 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
Reference in a new issue