diff options
author | davidot <david.tuin@gmail.com> | 2021-07-24 01:10:21 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-07-26 15:56:15 +0100 |
commit | e42eaa5d956fb27df131202f9684cfb3fdf7a055 (patch) | |
tree | b58567e092d457ef363741869175d460a6db0ad8 | |
parent | 0b74cc4712b4ab41b8aac9b0008f8a315cc7e432 (diff) | |
download | serenity-e42eaa5d956fb27df131202f9684cfb3fdf7a055.zip |
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.
3 files changed, 14 insertions, 1 deletions
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; } |