From e42eaa5d956fb27df131202f9684cfb3fdf7a055 Mon Sep 17 00:00:00 2001 From: davidot Date: Sat, 24 Jul 2021 01:10:21 +0200 Subject: LibWeb: Add a CustomHasProperty trait to WrapperGenerator We immediately use this in CSSStyleDeclaration to fix that "background" in element.style did not return true. This is the mechanism used in css3test.com for detecting support of features. --- .../Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp | 7 +++++++ Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.idl | 2 +- Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries/LibWeb') diff --git a/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp b/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp index d99d124cb5..15b9d29759 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp +++ b/Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp @@ -11,6 +11,13 @@ namespace Web::Bindings { +bool CSSStyleDeclarationWrapper::internal_has_property(JS::PropertyName const& name) const +{ + // FIXME: These should actually use camelCase versions of the property names! + auto property_id = CSS::property_id_from_string(name.to_string()); + return property_id != CSS::PropertyID::Invalid; +} + JS::Value CSSStyleDeclarationWrapper::internal_get(const JS::PropertyName& name, JS::Value receiver) const { // FIXME: These should actually use camelCase versions of the property names! diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.idl b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.idl index d4f425e9b4..987ae17337 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.idl +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.idl @@ -1,4 +1,4 @@ -[CustomGet,CustomSet] +[CustomGet,CustomSet,CustomHasProperty] interface CSSStyleDeclaration { readonly attribute unsigned long length; diff --git a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index a3cd0a03d0..f5067909b7 100644 --- a/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Userland/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -813,6 +813,12 @@ public: )~~~"); } + if (interface.extended_attributes.contains("CustomHasProperty")) { + generator.append(R"~~~( + virtual bool internal_has_property(JS::PropertyName const&) const override; +)~~~"); + } + if (interface.wrapper_base_class == "Wrapper") { generator.append(R"~~~( @fully_qualified_name@& impl() { return *m_impl; } -- cgit v1.2.3