ladybird/Libraries/LibWeb/CSS/Invalidation/CustomElementInvalidator.cpp
Andreas Kling ddce686ed0 LibWeb: Propagate inherited style across slot boundaries
Make style updates reach a fixed point when slot invalidation dirties
assigned nodes after their traversal point. During inherited-style
cascades, only the topmost changed element scans for descendant slots.

Animation inherited-style updates now include the target slot and walk
shadow-including descendants, so host animations propagate inherited
values through shadow trees and assigned slottables. Animated inherited
longhands also carry the same inherited-style invalidation signal as
regular style changes.

Mark custom elements dirty when their :defined state flips, so upgraded
elements do not keep stale :not(:defined) computed style. Add coverage
for slotted menu invalidation, descendant-slot scan counts, target slot
animations, host shadow-tree animations, and explicit inherit from an
animated non-inherited longhand.
2026-05-22 09:38:59 +02:00

33 lines
921 B
C++

/*
* Copyright (c) 2026-present, the Ladybird developers
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/CSS/Invalidation/CustomElementInvalidator.h>
#include <LibWeb/CSS/InvalidationSet.h>
#include <LibWeb/CSS/Selector.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/StyleInvalidationReason.h>
namespace Web::CSS::Invalidation {
void invalidate_style_after_custom_element_state_change(DOM::Element& element)
{
DOM::StyleInvalidationOptions options;
options.invalidate_self = true;
element.invalidate_style(
DOM::StyleInvalidationReason::CustomElementStateChange,
{
{ .type = InvalidationSet::Property::Type::PseudoClass, .value = PseudoClass::Defined },
},
options);
}
void invalidate_style_after_custom_state_set_change(DOM::Element& element)
{
element.invalidate_style(DOM::StyleInvalidationReason::CustomStateSetChange);
}
}