mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 13:02:09 +02:00
Document.cpp still knew how style changes on a slot propagate to assigned light-DOM nodes. Move that flat-tree inheritance invalidation into CSS::Invalidation::SlotInvalidator. The style update walk continues to decide when an element's style changed. The helper now owns the ::slotted() consequence of dirtying assigned slottables for a changed slot.
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2026-present, the Ladybird developers
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/CSS/Invalidation/SlotInvalidator.h>
|
|
#include <LibWeb/DOM/Element.h>
|
|
#include <LibWeb/DOM/Slottable.h>
|
|
#include <LibWeb/DOM/Text.h>
|
|
#include <LibWeb/HTML/HTMLSlotElement.h>
|
|
|
|
namespace Web::CSS::Invalidation {
|
|
|
|
void invalidate_style_after_slottable_assignment_change(DOM::Slottable const& slottable)
|
|
{
|
|
slottable.visit(
|
|
[](GC::Ref<DOM::Element> const& element) {
|
|
element->set_needs_style_update(true);
|
|
},
|
|
[](GC::Ref<DOM::Text> const&) {});
|
|
}
|
|
|
|
void invalidate_assigned_slottables_after_slot_style_change(DOM::Element& element)
|
|
{
|
|
// Slotted elements inherit from their assigned slot in the flat tree, but they are DOM children of the shadow
|
|
// host, so the normal DOM tree walk won't propagate inherited style changes to them.
|
|
auto* slot = as_if<HTML::HTMLSlotElement>(element);
|
|
if (!slot)
|
|
return;
|
|
for (auto const& slottable : slot->assigned_nodes_internal()) {
|
|
slottable.visit([](auto const& assigned_node) {
|
|
assigned_node->set_needs_style_update(true);
|
|
});
|
|
}
|
|
}
|
|
|
|
}
|