LibWeb: Support shorthand properties as presentational hints

This commit is contained in:
Callum Law 2025-05-21 14:07:27 +12:00 committed by Jelle Raaijmakers
commit 45689936f2
Notes: github-actions[bot] 2025-05-29 10:05:54 +00:00
4 changed files with 23 additions and 19 deletions

View file

@ -7,6 +7,8 @@
#include <LibWeb/CSS/CSSStyleDeclaration.h> #include <LibWeb/CSS/CSSStyleDeclaration.h>
#include <LibWeb/CSS/CascadedProperties.h> #include <LibWeb/CSS/CascadedProperties.h>
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
#include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Element.h>
namespace Web::CSS { namespace Web::CSS {
@ -99,18 +101,20 @@ void CascadedProperties::set_property(PropertyID property_id, NonnullRefPtr<CSSS
void CascadedProperties::set_property_from_presentational_hint(PropertyID property_id, NonnullRefPtr<CSSStyleValue const> value) void CascadedProperties::set_property_from_presentational_hint(PropertyID property_id, NonnullRefPtr<CSSStyleValue const> value)
{ {
auto& entries = m_properties.ensure(property_id); StyleComputer::for_each_property_expanding_shorthands(property_id, value, [this](PropertyID longhand_property_id, CSSStyleValue const& longhand_value) {
auto& entries = m_properties.ensure(longhand_property_id);
entries.append(Entry { entries.append(Entry {
.property = StyleProperty { .property = StyleProperty {
.important = Important::No, .important = Important::No,
.property_id = property_id, .property_id = longhand_property_id,
.value = value, .value = longhand_value,
}, },
.origin = CascadeOrigin::Author, .origin = CascadeOrigin::Author,
.layer_name = {}, .layer_name = {},
.source = nullptr, .source = nullptr,
}); });
});
} }
RefPtr<CSSStyleValue const> CascadedProperties::property(PropertyID property_id) const RefPtr<CSSStyleValue const> CascadedProperties::property(PropertyID property_id) const

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 42 tests Found 42 tests
37 Pass 38 Pass
5 Fail 4 Fail
Pass clip-path presentation attribute supported on an irrelevant element Pass clip-path presentation attribute supported on an irrelevant element
Pass clip-rule presentation attribute supported on an irrelevant element Pass clip-rule presentation attribute supported on an irrelevant element
Pass color presentation attribute supported on an irrelevant element Pass color presentation attribute supported on an irrelevant element
@ -25,7 +25,7 @@ Pass letter-spacing presentation attribute supported on an irrelevant element
Pass mask-type presentation attribute supported on an irrelevant element Pass mask-type presentation attribute supported on an irrelevant element
Pass mask presentation attribute supported on an irrelevant element Pass mask presentation attribute supported on an irrelevant element
Pass opacity presentation attribute supported on an irrelevant element Pass opacity presentation attribute supported on an irrelevant element
Fail overflow presentation attribute supported on an irrelevant element Pass overflow presentation attribute supported on an irrelevant element
Pass pointer-events presentation attribute supported on an irrelevant element Pass pointer-events presentation attribute supported on an irrelevant element
Pass stop-color presentation attribute supported on an irrelevant element Pass stop-color presentation attribute supported on an irrelevant element
Pass stop-opacity presentation attribute supported on an irrelevant element Pass stop-opacity presentation attribute supported on an irrelevant element

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 52 tests Found 52 tests
40 Pass 41 Pass
12 Fail 11 Fail
Pass clip-path presentation attribute supported on a relevant element Pass clip-path presentation attribute supported on a relevant element
Pass clip-rule presentation attribute supported on a relevant element Pass clip-rule presentation attribute supported on a relevant element
Pass color presentation attribute supported on a relevant element Pass color presentation attribute supported on a relevant element
@ -28,7 +28,7 @@ Pass letter-spacing presentation attribute supported on a relevant element
Pass mask-type presentation attribute supported on a relevant element Pass mask-type presentation attribute supported on a relevant element
Pass mask presentation attribute supported on a relevant element Pass mask presentation attribute supported on a relevant element
Pass opacity presentation attribute supported on a relevant element Pass opacity presentation attribute supported on a relevant element
Fail overflow presentation attribute supported on a relevant element Pass overflow presentation attribute supported on a relevant element
Pass pointer-events presentation attribute supported on a relevant element Pass pointer-events presentation attribute supported on a relevant element
Pass r presentation attribute supported on a relevant element Pass r presentation attribute supported on a relevant element
Fail rx presentation attribute supported on a relevant element Fail rx presentation attribute supported on a relevant element

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 42 tests Found 42 tests
37 Pass 38 Pass
5 Fail 4 Fail
Pass clip-path presentation attribute supported on an unknown SVG element Pass clip-path presentation attribute supported on an unknown SVG element
Pass clip-rule presentation attribute supported on an unknown SVG element Pass clip-rule presentation attribute supported on an unknown SVG element
Pass color presentation attribute supported on an unknown SVG element Pass color presentation attribute supported on an unknown SVG element
@ -25,7 +25,7 @@ Pass letter-spacing presentation attribute supported on an unknown SVG element
Pass mask-type presentation attribute supported on an unknown SVG element Pass mask-type presentation attribute supported on an unknown SVG element
Pass mask presentation attribute supported on an unknown SVG element Pass mask presentation attribute supported on an unknown SVG element
Pass opacity presentation attribute supported on an unknown SVG element Pass opacity presentation attribute supported on an unknown SVG element
Fail overflow presentation attribute supported on an unknown SVG element Pass overflow presentation attribute supported on an unknown SVG element
Pass pointer-events presentation attribute supported on an unknown SVG element Pass pointer-events presentation attribute supported on an unknown SVG element
Pass stop-color presentation attribute supported on an unknown SVG element Pass stop-color presentation attribute supported on an unknown SVG element
Pass stop-opacity presentation attribute supported on an unknown SVG element Pass stop-opacity presentation attribute supported on an unknown SVG element