mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 21:20:18 +00:00
LibWeb: Make Custom Properties cascading consider !important
Make so that !important properties are always applied last, prioritizing them over normal properties
This commit is contained in:
parent
71c8ee31fb
commit
13748a8c19
Notes:
github-actions[bot]
2025-09-30 08:55:37 +00:00
Author: https://github.com/luizgfranca
Commit: 13748a8c19
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6329
Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 16 additions and 3 deletions
|
@ -44,6 +44,7 @@
|
|||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/SelectorEngine.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/CSS/StyleProperty.h>
|
||||
#include <LibWeb/CSS/StyleSheet.h>
|
||||
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
|
||||
|
@ -864,19 +865,32 @@ static void cascade_custom_properties(DOM::AbstractElement abstract_element, Vec
|
|||
|
||||
custom_properties.ensure_capacity(custom_properties.size() + needed_capacity);
|
||||
|
||||
OrderedHashMap<FlyString, StyleProperty> important_custom_properties;
|
||||
for (auto const& matching_rule : matching_rules) {
|
||||
for (auto const& it : matching_rule->declaration().custom_properties()) {
|
||||
auto style_value = it.value.value;
|
||||
if (style_value->is_revert_layer())
|
||||
continue;
|
||||
|
||||
if (it.value.important == Important::Yes) {
|
||||
important_custom_properties.set(it.key, it.value);
|
||||
}
|
||||
custom_properties.set(it.key, it.value);
|
||||
}
|
||||
}
|
||||
|
||||
if (!abstract_element.pseudo_element().has_value()) {
|
||||
if (auto const inline_style = abstract_element.element().inline_style())
|
||||
custom_properties.update(inline_style->custom_properties());
|
||||
if (auto const inline_style = abstract_element.element().inline_style()) {
|
||||
for (auto const& it : inline_style->custom_properties()) {
|
||||
if (it.value.important == Important::Yes) {
|
||||
important_custom_properties.set(it.key, it.value);
|
||||
}
|
||||
custom_properties.set(it.key, it.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
custom_properties.update(important_custom_properties);
|
||||
}
|
||||
|
||||
void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element, GC::Ref<Animations::KeyframeEffect> effect, ComputedProperties& computed_properties) const
|
||||
|
@ -2415,7 +2429,6 @@ GC::Ptr<ComputedProperties> StyleComputer::compute_style_impl(DOM::AbstractEleme
|
|||
auto old_custom_properties = abstract_element.custom_properties();
|
||||
|
||||
// Resolve all the CSS custom properties ("variables") for this element:
|
||||
// FIXME: Also resolve !important custom properties, in a second cascade.
|
||||
if (!abstract_element.pseudo_element().has_value() || pseudo_element_supports_property(*abstract_element.pseudo_element(), PropertyID::Custom)) {
|
||||
OrderedHashMap<FlyString, StyleProperty> custom_properties;
|
||||
for (auto& layer : matching_rule_set.author_rules) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue