mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 10:18:15 +09:00
LibWeb: Use invalidation sets for :defined
style invalidation
This commit is contained in:
parent
51a5ebb91d
commit
a6bea99959
Notes:
github-actions[bot]
2025-02-06 19:08:10 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: a6bea99959
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3476
Reviewed-by: https://github.com/AtkinsSJ
4 changed files with 8 additions and 16 deletions
|
@ -2656,9 +2656,6 @@ void StyleComputer::collect_selector_insights(Selector const& selector, Selector
|
||||||
if (simple_selector.pseudo_class().type == PseudoClass::Has) {
|
if (simple_selector.pseudo_class().type == PseudoClass::Has) {
|
||||||
insights.has_has_selectors = true;
|
insights.has_has_selectors = true;
|
||||||
}
|
}
|
||||||
if (simple_selector.pseudo_class().type == PseudoClass::Defined) {
|
|
||||||
insights.has_defined_selectors = true;
|
|
||||||
}
|
|
||||||
for (auto const& argument_selector : simple_selector.pseudo_class().argument_selector_list) {
|
for (auto const& argument_selector : simple_selector.pseudo_class().argument_selector_list) {
|
||||||
collect_selector_insights(*argument_selector, insights);
|
collect_selector_insights(*argument_selector, insights);
|
||||||
}
|
}
|
||||||
|
@ -3175,13 +3172,4 @@ bool StyleComputer::may_have_has_selectors() const
|
||||||
return m_selector_insights->has_has_selectors;
|
return m_selector_insights->has_has_selectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StyleComputer::may_have_defined_selectors() const
|
|
||||||
{
|
|
||||||
if (!has_valid_rule_cache())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
build_rule_cache_if_needed();
|
|
||||||
return m_selector_insights->has_defined_selectors;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,6 @@ public:
|
||||||
void collect_animation_into(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, GC::Ref<Animations::KeyframeEffect> animation, ComputedProperties&, AnimationRefresh = AnimationRefresh::No) const;
|
void collect_animation_into(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, GC::Ref<Animations::KeyframeEffect> animation, ComputedProperties&, AnimationRefresh = AnimationRefresh::No) const;
|
||||||
|
|
||||||
[[nodiscard]] bool may_have_has_selectors() const;
|
[[nodiscard]] bool may_have_has_selectors() const;
|
||||||
[[nodiscard]] bool may_have_defined_selectors() const;
|
|
||||||
|
|
||||||
size_t number_of_css_font_faces_with_loading_in_progress() const;
|
size_t number_of_css_font_faces_with_loading_in_progress() const;
|
||||||
|
|
||||||
|
@ -257,7 +256,6 @@ private:
|
||||||
|
|
||||||
struct SelectorInsights {
|
struct SelectorInsights {
|
||||||
bool has_has_selectors { false };
|
bool has_has_selectors { false };
|
||||||
bool has_defined_selectors { false };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RuleCache {
|
struct RuleCache {
|
||||||
|
|
|
@ -69,6 +69,7 @@ static void collect_properties_used_in_has(Selector::SimpleSelector const& selec
|
||||||
switch (pseudo_class.type) {
|
switch (pseudo_class.type) {
|
||||||
case PseudoClass::Enabled:
|
case PseudoClass::Enabled:
|
||||||
case PseudoClass::Disabled:
|
case PseudoClass::Disabled:
|
||||||
|
case PseudoClass::Defined:
|
||||||
case PseudoClass::PlaceholderShown:
|
case PseudoClass::PlaceholderShown:
|
||||||
case PseudoClass::Checked:
|
case PseudoClass::Checked:
|
||||||
if (in_has)
|
if (in_has)
|
||||||
|
@ -122,6 +123,7 @@ static void build_invalidation_sets_for_simple_selector(Selector::SimpleSelector
|
||||||
auto const& pseudo_class = selector.pseudo_class();
|
auto const& pseudo_class = selector.pseudo_class();
|
||||||
switch (pseudo_class.type) {
|
switch (pseudo_class.type) {
|
||||||
case PseudoClass::Enabled:
|
case PseudoClass::Enabled:
|
||||||
|
case PseudoClass::Defined:
|
||||||
case PseudoClass::Disabled:
|
case PseudoClass::Disabled:
|
||||||
case PseudoClass::PlaceholderShown:
|
case PseudoClass::PlaceholderShown:
|
||||||
case PseudoClass::Checked:
|
case PseudoClass::Checked:
|
||||||
|
|
|
@ -1183,6 +1183,9 @@ bool Element::includes_properties_from_invalidation_set(CSS::InvalidationSet con
|
||||||
case CSS::PseudoClass::Disabled: {
|
case CSS::PseudoClass::Disabled: {
|
||||||
return is_actually_disabled();
|
return is_actually_disabled();
|
||||||
}
|
}
|
||||||
|
case CSS::PseudoClass::Defined: {
|
||||||
|
return is_defined();
|
||||||
|
}
|
||||||
case CSS::PseudoClass::Checked: {
|
case CSS::PseudoClass::Checked: {
|
||||||
// FIXME: This could be narrowed down to return true only if element is actually checked.
|
// FIXME: This could be narrowed down to return true only if element is actually checked.
|
||||||
return is<HTML::HTMLInputElement>(*this) || is<HTML::HTMLOptionElement>(*this);
|
return is<HTML::HTMLInputElement>(*this) || is<HTML::HTMLOptionElement>(*this);
|
||||||
|
@ -2366,8 +2369,9 @@ void Element::set_custom_element_state(CustomElementState state)
|
||||||
return;
|
return;
|
||||||
m_custom_element_state = state;
|
m_custom_element_state = state;
|
||||||
|
|
||||||
if (document().style_computer().may_have_defined_selectors())
|
Vector<CSS::InvalidationSet::Property, 1> changed_properties;
|
||||||
invalidate_style(StyleInvalidationReason::CustomElementStateChange);
|
changed_properties.append({ .type = CSS::InvalidationSet::Property::Type::PseudoClass, .value = CSS::PseudoClass::Defined });
|
||||||
|
invalidate_style(StyleInvalidationReason::CustomElementStateChange, changed_properties, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/dom.html#html-element-constructors
|
// https://html.spec.whatwg.org/multipage/dom.html#html-element-constructors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue