Commit 9d1248f5 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Chromium LUCI CQ

Do bloom filter rejection for ::slotted selectors

After we started doing style recalc in flat tree order, disabling fast
rejection for ::slotted should not be necessary.

Bug: 1159206
Change-Id: I746eefa85aaaa2d53ec80de5c837a55fa0e108e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2596296
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838009}
parent 4d73a39a
......@@ -169,9 +169,6 @@ void SelectorFilter::CollectIdentifierHashes(
skip_over_subselectors = true;
break;
case CSSSelector::kShadowSlot:
// Disable fastRejectSelector.
*identifier_hashes = 0;
return;
case CSSSelector::kDescendant:
case CSSSelector::kChild:
case CSSSelector::kUAShadow:
......
......@@ -3877,4 +3877,45 @@ TEST_F(StyleEngineTest, FastRejectForHostChild) {
EXPECT_EQ(1u, stats->rules_fast_rejected);
}
TEST_F(StyleEngineTest, RejectSlottedSelector) {
GetDocument().body()->setInnerHTML(R"HTML(
<div id="host">
<span id="slotted"></span>
</div>
)HTML");
Element* host = GetDocument().getElementById("host");
ASSERT_TRUE(host);
ShadowRoot& shadow_root =
host->AttachShadowRootInternal(ShadowRootType::kOpen);
shadow_root.setInnerHTML(R"HTML(
<style>
.notfound ::slotted(span) {
color: pink;
}
</style>
<slot></slot>
)HTML");
UpdateAllLifecyclePhases();
StyleEngine& engine = GetStyleEngine();
// If the Stats() were already enabled, we would not start with 0 counts.
EXPECT_FALSE(engine.Stats());
engine.SetStatsEnabled(true);
StyleResolverStats* stats = engine.Stats();
ASSERT_TRUE(stats);
EXPECT_EQ(0u, stats->rules_fast_rejected);
Element* span = GetDocument().getElementById("slotted");
ASSERT_TRUE(span);
span->SetInlineStyleProperty(CSSPropertyID::kColor, "green");
GetDocument().Lifecycle().AdvanceTo(DocumentLifecycle::kInStyleRecalc);
GetStyleEngine().RecalcStyle();
// Should fast reject ".notfound ::slotted(span)"
EXPECT_EQ(1u, stats->rules_fast_rejected);
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment