dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / css / invalidation / part_invalidator.lucb
#==============================================================================================
#
# part_invalidator - style invalidation after the part or exportparts attribute changes
#
# DESCRIPTION:
# Port of LibWeb/CSS/Invalidation/PartInvalidator.cpp (lines 1-34).
#
# Copyright (c) 2026-present, the Ladybird developers
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/CSS/Invalidation/PartInvalidator.cpp:14 Web::CSS::Invalidation::invalidate_style_after_part_attribute_change.
pub func css_invalidation_invalidate_style_after_part_attribute_change(element: DomElement*):
# ::part(...) rules in the outer scope target this element by part name, so the element's computed style must
# be recomputed when its part tokens change.
dom_node_set_needs_style_update(element.dom_node(), true)
## Ported from Libraries/LibWeb/CSS/Invalidation/PartInvalidator.cpp:21 Web::CSS::Invalidation::invalidate_style_after_exportparts_attribute_change.
pub func css_invalidation_invalidate_style_after_exportparts_attribute_change(element: DomElement*):
# When exportparts changes on a shadow host, elements with part tokens inside its shadow tree may newly become
# or stop being targets of ::part() rules in the outer scope.
if let shadow_root = dom_element_shadow_root(element):
# shadow_root->for_each_in_subtree_of_type<DOM::Element>(...)
for node in dom_node_subtree(shadow_root.dom_node()):
let descendant = as_if_dom_element(node) else continue
if dom_element_part_names(descendant).length != 0:
dom_node_set_needs_style_update(descendant.dom_node(), true)