Files
ladybird/Tests/LibWeb/TestCSSStyleSheetInvalidation.cpp
Andreas Kling b6559d3846 LibWeb: Narrow inline stylesheet insertRule() invalidation
Avoid forcing a full style update when a connected inline <style> sheet
inserts an ordinary style rule. Build a targeted invalidation set from
the inserted rule and walk only the affected roots instead.

Introduce the shared StyleSheetInvalidation helper so later stylesheet
mutation paths can reuse the same selector analysis and root application
logic. It handles trailing-universal selectors, pseudo-element-only
rightmost compounds, and shadow-host escapes through ::slotted(...) and
:host combinators.

Keep the broad invalidate_owners() path for constructed stylesheets and
other sheet kinds whose TreeScope interactions still require it.
2026-04-23 16:45:22 +02:00

24 lines
766 B
C++

/*
* Copyright (c) 2026-present, The Ladybird developers
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibTest/TestCase.h>
#include <LibWeb/CSS/StyleSheetInvalidation.h>
namespace Web {
TEST_CASE(selector_escape_to_light_dom_under_shadow_host)
{
EXPECT(!CSS::selector_may_match_light_dom_under_shadow_host(":host"sv));
EXPECT(!CSS::selector_may_match_light_dom_under_shadow_host(":host(.active)"sv));
EXPECT(CSS::selector_may_match_light_dom_under_shadow_host(":host > *"sv));
EXPECT(CSS::selector_may_match_light_dom_under_shadow_host(":host + .item"sv));
EXPECT(CSS::selector_may_match_light_dom_under_shadow_host(":host ~ .item"sv));
EXPECT(CSS::selector_may_match_light_dom_under_shadow_host("::slotted(.item)"sv));
}
}