dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / css / invalidation / slot_invalidator.lucb
#==============================================================================================
#
# slot_invalidator - style invalidation of slotted nodes after their slot assignment or their slot's style changes
#
# DESCRIPTION:
# Port of LibWeb/CSS/Invalidation/SlotInvalidator.cpp (lines 1-38).
#
# Copyright (c) 2026-present, the Ladybird developers
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/CSS/Invalidation/SlotInvalidator.cpp:15 Web::CSS::Invalidation::invalidate_style_after_slottable_assignment_change.
pub func css_invalidation_invalidate_style_after_slottable_assignment_change(slottable: DomSlottable):
match slottable:
.dom_element(element):
dom_node_set_needs_style_update(element.dom_node(), true)
.dom_text(_):
return
## Ported from Libraries/LibWeb/CSS/Invalidation/SlotInvalidator.cpp:24 Web::CSS::Invalidation::invalidate_assigned_slottables_after_slot_style_change.
pub func css_invalidation_invalidate_assigned_slottables_after_slot_style_change(element: DomElement*):
# 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.
let slot = as_if_html_slot_element(element) else return
for slottable in dom_slot_assigned_nodes_internal(&slot.slot):
match slottable:
.dom_element(assigned_node):
dom_node_set_needs_style_update(assigned_node.dom_node(), true)
.dom_text(assigned_node):
dom_node_set_needs_style_update(assigned_node.dom_node(), true)