mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:07:35 +00:00
LibWeb: Actually instantiate ::before/::after pseudo elements when found
Regressed in 3e970540b4
.
Thanks to Luke for noticing the issue on YouTube! :^)
This commit is contained in:
parent
e6dc3c291e
commit
c598c092c2
2 changed files with 10 additions and 6 deletions
|
@ -867,7 +867,7 @@ static ErrorOr<void> cascade_custom_properties(DOM::Element& element, Vector<Mat
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-cascade/#cascading
|
// https://www.w3.org/TR/css-cascade/#cascading
|
||||||
ErrorOr<void> StyleComputer::compute_cascaded_values(StyleProperties& style, DOM::Element& element, Optional<CSS::Selector::PseudoElement> pseudo_element, bool& did_match_any_pseudo_element_rules) const
|
ErrorOr<void> StyleComputer::compute_cascaded_values(StyleProperties& style, DOM::Element& element, Optional<CSS::Selector::PseudoElement> pseudo_element, bool& did_match_any_pseudo_element_rules, ComputeStyleMode mode) const
|
||||||
{
|
{
|
||||||
// First, we collect all the CSS rules whose selectors match `element`:
|
// First, we collect all the CSS rules whose selectors match `element`:
|
||||||
MatchingRuleSet matching_rule_set;
|
MatchingRuleSet matching_rule_set;
|
||||||
|
@ -876,9 +876,13 @@ ErrorOr<void> StyleComputer::compute_cascaded_values(StyleProperties& style, DOM
|
||||||
matching_rule_set.author_rules = collect_matching_rules(element, CascadeOrigin::Author, pseudo_element);
|
matching_rule_set.author_rules = collect_matching_rules(element, CascadeOrigin::Author, pseudo_element);
|
||||||
sort_matching_rules(matching_rule_set.author_rules);
|
sort_matching_rules(matching_rule_set.author_rules);
|
||||||
|
|
||||||
if (pseudo_element.has_value() && matching_rule_set.author_rules.is_empty() && matching_rule_set.user_agent_rules.is_empty()) {
|
if (mode == ComputeStyleMode::CreatePseudoElementStyleIfNeeded) {
|
||||||
did_match_any_pseudo_element_rules = false;
|
VERIFY(pseudo_element.has_value());
|
||||||
return {};
|
if (matching_rule_set.author_rules.is_empty() && matching_rule_set.user_agent_rules.is_empty()) {
|
||||||
|
did_match_any_pseudo_element_rules = false;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
did_match_any_pseudo_element_rules = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then we resolve all the CSS custom properties ("variables") for this element:
|
// Then we resolve all the CSS custom properties ("variables") for this element:
|
||||||
|
@ -1422,7 +1426,7 @@ ErrorOr<RefPtr<StyleProperties>> StyleComputer::compute_style_impl(DOM::Element&
|
||||||
auto style = StyleProperties::create();
|
auto style = StyleProperties::create();
|
||||||
// 1. Perform the cascade. This produces the "specified style"
|
// 1. Perform the cascade. This produces the "specified style"
|
||||||
bool did_match_any_pseudo_element_rules = false;
|
bool did_match_any_pseudo_element_rules = false;
|
||||||
TRY(compute_cascaded_values(style, element, pseudo_element, did_match_any_pseudo_element_rules));
|
TRY(compute_cascaded_values(style, element, pseudo_element, did_match_any_pseudo_element_rules, mode));
|
||||||
|
|
||||||
if (mode == ComputeStyleMode::CreatePseudoElementStyleIfNeeded && !did_match_any_pseudo_element_rules)
|
if (mode == ComputeStyleMode::CreatePseudoElementStyleIfNeeded && !did_match_any_pseudo_element_rules)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -86,7 +86,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
ErrorOr<RefPtr<StyleProperties>> compute_style_impl(DOM::Element&, Optional<CSS::Selector::PseudoElement>, ComputeStyleMode) const;
|
ErrorOr<RefPtr<StyleProperties>> compute_style_impl(DOM::Element&, Optional<CSS::Selector::PseudoElement>, ComputeStyleMode) const;
|
||||||
ErrorOr<void> compute_cascaded_values(StyleProperties&, DOM::Element&, Optional<CSS::Selector::PseudoElement>, bool& did_match_any_pseudo_element_rules) const;
|
ErrorOr<void> compute_cascaded_values(StyleProperties&, DOM::Element&, Optional<CSS::Selector::PseudoElement>, bool& did_match_any_pseudo_element_rules, ComputeStyleMode) const;
|
||||||
void compute_font(StyleProperties&, DOM::Element const*, Optional<CSS::Selector::PseudoElement>) const;
|
void compute_font(StyleProperties&, DOM::Element const*, Optional<CSS::Selector::PseudoElement>) const;
|
||||||
void compute_defaulted_values(StyleProperties&, DOM::Element const*, Optional<CSS::Selector::PseudoElement>) const;
|
void compute_defaulted_values(StyleProperties&, DOM::Element const*, Optional<CSS::Selector::PseudoElement>) const;
|
||||||
void absolutize_values(StyleProperties&, DOM::Element const*, Optional<CSS::Selector::PseudoElement>) const;
|
void absolutize_values(StyleProperties&, DOM::Element const*, Optional<CSS::Selector::PseudoElement>) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue