diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 123a69317c..e98e31d076 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -142,6 +142,7 @@ set(SOURCES CSS/CSSStyleSheet.cpp CSS/CSSStyleValue.cpp CSS/CSSSupportsRule.cpp + CSS/CSSTransformComponent.cpp CSS/CSSTransition.cpp CSS/CSSUnitValue.cpp CSS/CSSUnparsedValue.cpp diff --git a/Libraries/LibWeb/CSS/CSSTransformComponent.cpp b/Libraries/LibWeb/CSS/CSSTransformComponent.cpp new file mode 100644 index 0000000000..86dc4d0409 --- /dev/null +++ b/Libraries/LibWeb/CSS/CSSTransformComponent.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025, Sam Atkins + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include "CSSTransformComponent.h" +#include +#include + +namespace Web::CSS { + +GC_DEFINE_ALLOCATOR(CSSTransformComponent); + +CSSTransformComponent::CSSTransformComponent(JS::Realm& realm, Is2D is_2d) + : Bindings::PlatformObject(realm) + , m_is_2d(is_2d == Is2D::Yes) +{ +} + +CSSTransformComponent::~CSSTransformComponent() = default; + +void CSSTransformComponent::initialize(JS::Realm& realm) +{ + WEB_SET_PROTOTYPE_FOR_INTERFACE(CSSTransformComponent); + Base::initialize(realm); +} + +} diff --git a/Libraries/LibWeb/CSS/CSSTransformComponent.h b/Libraries/LibWeb/CSS/CSSTransformComponent.h new file mode 100644 index 0000000000..ffabca6d66 --- /dev/null +++ b/Libraries/LibWeb/CSS/CSSTransformComponent.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025, Sam Atkins + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::CSS { + +// https://drafts.css-houdini.org/css-typed-om-1/#csstransformcomponent +class CSSTransformComponent : public Bindings::PlatformObject { + WEB_PLATFORM_OBJECT(CSSTransformComponent, Bindings::PlatformObject); + GC_DECLARE_ALLOCATOR(CSSTransformComponent); + +public: + enum class Is2D : u8 { + No, + Yes, + }; + + virtual void initialize(JS::Realm&) override; + virtual ~CSSTransformComponent() override; + + virtual WebIDL::ExceptionOr to_string() const = 0; + + bool is_2d() const { return m_is_2d; } + virtual void set_is_2d(bool value) { m_is_2d = value; } + + virtual WebIDL::ExceptionOr> to_matrix() const = 0; + +protected: + explicit CSSTransformComponent(JS::Realm&, Is2D is_2d); + +private: + bool m_is_2d; +}; + +} diff --git a/Libraries/LibWeb/CSS/CSSTransformComponent.idl b/Libraries/LibWeb/CSS/CSSTransformComponent.idl new file mode 100644 index 0000000000..66055e9fe8 --- /dev/null +++ b/Libraries/LibWeb/CSS/CSSTransformComponent.idl @@ -0,0 +1,9 @@ +#import + +// https://drafts.css-houdini.org/css-typed-om-1/#csstransformcomponent +[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)] +interface CSSTransformComponent { + stringifier; + [ImplementedAs=is_2d] attribute boolean is2D; + DOMMatrix toMatrix(); +}; diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 3d2506ab68..7fec4a5ff7 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -267,6 +267,7 @@ class CSSStyleRule; class CSSStyleSheet; class CSSStyleValue; class CSSSupportsRule; +class CSSTransformComponent; class CSSUnitValue; class CSSUnparsedValue; class CSSVariableReferenceValue; diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake index 4bc0e24116..e419a55867 100644 --- a/Libraries/LibWeb/idl_files.cmake +++ b/Libraries/LibWeb/idl_files.cmake @@ -62,6 +62,7 @@ libweb_js_bindings(CSS/CSSStyleRule) libweb_js_bindings(CSS/CSSStyleSheet) libweb_js_bindings(CSS/CSSStyleValue) libweb_js_bindings(CSS/CSSSupportsRule) +libweb_js_bindings(CSS/CSSTransformComponent) libweb_js_bindings(CSS/CSSTransition) libweb_js_bindings(CSS/CSSUnitValue) libweb_js_bindings(CSS/CSSUnparsedValue) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 7047e0b723..fe78cfaafa 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -58,6 +58,7 @@ static bool is_platform_object(Type const& type) "CSSNumericArray"sv, "CSSNumericValue"sv, "CSSStyleValue"sv, + "CSSTransformComponent"sv, "CSSUnitValue"sv, "CSSUnparsedValue"sv, "CSSVariableReferenceValue"sv, diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt index a6d0439a5e..7d534d791d 100644 --- a/Tests/LibWeb/Text/expected/all-window-properties.txt +++ b/Tests/LibWeb/Text/expected/all-window-properties.txt @@ -74,6 +74,7 @@ CSSStyleRule CSSStyleSheet CSSStyleValue CSSSupportsRule +CSSTransformComponent CSSTransition CSSUnitValue CSSUnparsedValue diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/idlharness.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/idlharness.txt index 5e9caa4a1e..87cfcfbc77 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/idlharness.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/idlharness.txt @@ -2,8 +2,8 @@ Harness status: OK Found 545 tests -287 Pass -258 Fail +296 Pass +249 Fail Pass idl_test setup Pass idl_test validation Pass Partial interface Element: original interface defined @@ -267,15 +267,15 @@ Pass CSSStyleValue interface: transformValue must inherit property "parse(USVStr Pass CSSStyleValue interface: calling parse(USVString, USVString) on transformValue with too few arguments must throw TypeError Pass CSSStyleValue interface: transformValue must inherit property "parseAll(USVString, USVString)" with the proper type Pass CSSStyleValue interface: calling parseAll(USVString, USVString) on transformValue with too few arguments must throw TypeError -Fail CSSTransformComponent interface: existence and properties of interface object -Fail CSSTransformComponent interface object length -Fail CSSTransformComponent interface object name -Fail CSSTransformComponent interface: existence and properties of interface prototype object -Fail CSSTransformComponent interface: existence and properties of interface prototype object's "constructor" property -Fail CSSTransformComponent interface: existence and properties of interface prototype object's @@unscopables property -Fail CSSTransformComponent interface: stringifier -Fail CSSTransformComponent interface: attribute is2D -Fail CSSTransformComponent interface: operation toMatrix() +Pass CSSTransformComponent interface: existence and properties of interface object +Pass CSSTransformComponent interface object length +Pass CSSTransformComponent interface object name +Pass CSSTransformComponent interface: existence and properties of interface prototype object +Pass CSSTransformComponent interface: existence and properties of interface prototype object's "constructor" property +Pass CSSTransformComponent interface: existence and properties of interface prototype object's @@unscopables property +Pass CSSTransformComponent interface: stringifier +Pass CSSTransformComponent interface: attribute is2D +Pass CSSTransformComponent interface: operation toMatrix() Fail CSSTranslate interface: existence and properties of interface object Fail CSSTranslate interface object length Fail CSSTranslate interface object name