Commit 93067ecd authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Chromium LUCI CQ

Remove tree-boundary-crossing rules

No longer needed since Shadow DOM v0 is gone.

Change-Id: I12910feaef55671f4ed432c30981a71909e56e42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592801
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837537}
parent 73479df7
...@@ -510,7 +510,6 @@ TEST_F(ApplyRulesetsTest, RemoveSheetFromShadowTree) { ...@@ -510,7 +510,6 @@ TEST_F(ApplyRulesetsTest, RemoveSheetFromShadowTree) {
shadow_root.setInnerHTML("<style>::slotted(#dummy){color:pink}</style>"); shadow_root.setInnerHTML("<style>::slotted(#dummy){color:pink}</style>");
UpdateAllLifecyclePhasesForTest(); UpdateAllLifecyclePhasesForTest();
EXPECT_TRUE(GetStyleEngine().TreeBoundaryCrossingScopes().IsEmpty());
ASSERT_EQ(1u, shadow_root.StyleSheets().length()); ASSERT_EQ(1u, shadow_root.StyleSheets().length());
StyleSheet* sheet = shadow_root.StyleSheets().item(0); StyleSheet* sheet = shadow_root.StyleSheets().item(0);
...@@ -523,8 +522,6 @@ TEST_F(ApplyRulesetsTest, RemoveSheetFromShadowTree) { ...@@ -523,8 +522,6 @@ TEST_F(ApplyRulesetsTest, RemoveSheetFromShadowTree) {
std::make_pair(css_sheet, &css_sheet->Contents()->GetRuleSet())); std::make_pair(css_sheet, &css_sheet->Contents()->GetRuleSet()));
GetStyleEngine().ApplyRuleSetChanges(shadow_root, old_style_sheets, GetStyleEngine().ApplyRuleSetChanges(shadow_root, old_style_sheets,
ActiveStyleSheetVector()); ActiveStyleSheetVector());
EXPECT_TRUE(GetStyleEngine().TreeBoundaryCrossingScopes().IsEmpty());
} }
} // namespace blink } // namespace blink
...@@ -111,7 +111,6 @@ void ScopedStyleResolver::AppendActiveStyleSheets( ...@@ -111,7 +111,6 @@ void ScopedStyleResolver::AppendActiveStyleSheets(
AddFontFaceRules(rule_set); AddFontFaceRules(rule_set);
if (!rule_set.CounterStyleRules().IsEmpty()) if (!rule_set.CounterStyleRules().IsEmpty())
EnsureCounterStyleMap().AddCounterStyles(rule_set); EnsureCounterStyleMap().AddCounterStyles(rule_set);
AddTreeBoundaryCrossingRules(rule_set, sheet, index);
AddSlottedRules(rule_set, sheet, index++); AddSlottedRules(rule_set, sheet, index++);
} }
} }
...@@ -133,10 +132,6 @@ void ScopedStyleResolver::CollectFeaturesTo( ...@@ -133,10 +132,6 @@ void ScopedStyleResolver::CollectFeaturesTo(
features.Add(contents->GetRuleSet().Features()); features.Add(contents->GetRuleSet().Features());
} }
if (tree_boundary_crossing_rule_set_) {
for (const auto& rules : *tree_boundary_crossing_rule_set_)
features.Add(rules->rule_set_->Features());
}
if (slotted_rule_set_) { if (slotted_rule_set_) {
for (const auto& rules : *slotted_rule_set_) for (const auto& rules : *slotted_rule_set_)
features.Add(rules->rule_set_->Features()); features.Add(rules->rule_set_->Features());
...@@ -149,9 +144,7 @@ void ScopedStyleResolver::ResetStyle() { ...@@ -149,9 +144,7 @@ void ScopedStyleResolver::ResetStyle() {
device_dependent_media_query_results_.clear(); device_dependent_media_query_results_.clear();
keyframes_rule_map_.clear(); keyframes_rule_map_.clear();
counter_style_map_.Clear(); counter_style_map_.Clear();
tree_boundary_crossing_rule_set_ = nullptr;
slotted_rule_set_ = nullptr; slotted_rule_set_ = nullptr;
has_deep_or_shadow_selector_ = false;
needs_append_all_sheets_ = false; needs_append_all_sheets_ = false;
} }
...@@ -298,18 +291,6 @@ void ScopedStyleResolver::CollectMatchingSlottedRules( ...@@ -298,18 +291,6 @@ void ScopedStyleResolver::CollectMatchingSlottedRules(
} }
} }
void ScopedStyleResolver::CollectMatchingTreeBoundaryCrossingRules(
ElementRuleCollector& collector) {
if (!tree_boundary_crossing_rule_set_)
return;
for (const auto& rules : *tree_boundary_crossing_rule_set_) {
MatchRequest request(rules->rule_set_.Get(), &GetTreeScope().RootNode(),
rules->parent_style_sheet_, rules->parent_index_);
collector.CollectMatchingRules(request, true);
}
}
void ScopedStyleResolver::CollectMatchingPartPseudoRules( void ScopedStyleResolver::CollectMatchingPartPseudoRules(
ElementRuleCollector& collector, ElementRuleCollector& collector,
PartNames& part_names, PartNames& part_names,
...@@ -336,7 +317,6 @@ void ScopedStyleResolver::Trace(Visitor* visitor) const { ...@@ -336,7 +317,6 @@ void ScopedStyleResolver::Trace(Visitor* visitor) const {
visitor->Trace(style_sheets_); visitor->Trace(style_sheets_);
visitor->Trace(keyframes_rule_map_); visitor->Trace(keyframes_rule_map_);
visitor->Trace(counter_style_map_); visitor->Trace(counter_style_map_);
visitor->Trace(tree_boundary_crossing_rule_set_);
visitor->Trace(slotted_rule_set_); visitor->Trace(slotted_rule_set_);
} }
...@@ -350,35 +330,6 @@ static void AddRules(RuleSet* rule_set, ...@@ -350,35 +330,6 @@ static void AddRules(RuleSet* rule_set,
} }
} }
void ScopedStyleResolver::AddTreeBoundaryCrossingRules(
const RuleSet& rules,
CSSStyleSheet* parent_style_sheet,
unsigned sheet_index) {
bool is_document_scope = GetTreeScope().RootNode().IsDocumentNode();
if (rules.DeepCombinatorOrShadowPseudoRules().IsEmpty() &&
(is_document_scope || (rules.ContentPseudoElementRules().IsEmpty())))
return;
if (!rules.DeepCombinatorOrShadowPseudoRules().IsEmpty())
has_deep_or_shadow_selector_ = true;
auto* rule_set_for_scope = MakeGarbageCollected<RuleSet>();
AddRules(rule_set_for_scope, rules.DeepCombinatorOrShadowPseudoRules());
if (!is_document_scope)
AddRules(rule_set_for_scope, rules.ContentPseudoElementRules());
if (!tree_boundary_crossing_rule_set_) {
tree_boundary_crossing_rule_set_ =
MakeGarbageCollected<CSSStyleSheetRuleSubSet>();
GetTreeScope().GetDocument().GetStyleEngine().AddTreeBoundaryCrossingScope(
GetTreeScope());
}
tree_boundary_crossing_rule_set_->push_back(MakeGarbageCollected<RuleSubSet>(
parent_style_sheet, sheet_index, rule_set_for_scope));
}
void ScopedStyleResolver::AddSlottedRules(const RuleSet& rules, void ScopedStyleResolver::AddSlottedRules(const RuleSet& rules,
CSSStyleSheet* parent_style_sheet, CSSStyleSheet* parent_style_sheet,
unsigned sheet_index) { unsigned sheet_index) {
......
...@@ -45,8 +45,8 @@ class StyleSheetContents; ...@@ -45,8 +45,8 @@ class StyleSheetContents;
// ScopedStyleResolver collects the style sheets that occur within a TreeScope // ScopedStyleResolver collects the style sheets that occur within a TreeScope
// and provides methods to collect the rules that apply to a given element, // and provides methods to collect the rules that apply to a given element,
// broken down by what kind of scope they apply to (e.g. shadow host, // broken down by what kind of scope they apply to (e.g. shadow host, slotted,
// tree-boundary-crossing, etc). // etc).
class CORE_EXPORT ScopedStyleResolver final class CORE_EXPORT ScopedStyleResolver final
: public GarbageCollected<ScopedStyleResolver> { : public GarbageCollected<ScopedStyleResolver> {
public: public:
...@@ -70,7 +70,6 @@ class CORE_EXPORT ScopedStyleResolver final ...@@ -70,7 +70,6 @@ class CORE_EXPORT ScopedStyleResolver final
void CollectMatchingElementScopeRules(ElementRuleCollector&); void CollectMatchingElementScopeRules(ElementRuleCollector&);
void CollectMatchingShadowHostRules(ElementRuleCollector&); void CollectMatchingShadowHostRules(ElementRuleCollector&);
void CollectMatchingSlottedRules(ElementRuleCollector&); void CollectMatchingSlottedRules(ElementRuleCollector&);
void CollectMatchingTreeBoundaryCrossingRules(ElementRuleCollector&);
void CollectMatchingPartPseudoRules(ElementRuleCollector&, void CollectMatchingPartPseudoRules(ElementRuleCollector&,
PartNames& part_names, PartNames& part_names,
bool for_shadow_pseudo); bool for_shadow_pseudo);
...@@ -79,7 +78,6 @@ class CORE_EXPORT ScopedStyleResolver final ...@@ -79,7 +78,6 @@ class CORE_EXPORT ScopedStyleResolver final
HeapHashSet<Member<const StyleSheetContents>>& HeapHashSet<Member<const StyleSheetContents>>&
visited_shared_style_sheet_contents) const; visited_shared_style_sheet_contents) const;
void ResetStyle(); void ResetStyle();
bool HasDeepOrShadowSelector() const { return has_deep_or_shadow_selector_; }
void SetHasUnresolvedKeyframesRule() { void SetHasUnresolvedKeyframesRule() {
has_unresolved_keyframes_rule_ = true; has_unresolved_keyframes_rule_ = true;
} }
...@@ -91,9 +89,6 @@ class CORE_EXPORT ScopedStyleResolver final ...@@ -91,9 +89,6 @@ class CORE_EXPORT ScopedStyleResolver final
void Trace(Visitor*) const; void Trace(Visitor*) const;
private: private:
void AddTreeBoundaryCrossingRules(const RuleSet&,
CSSStyleSheet*,
unsigned sheet_index);
void AddSlottedRules(const RuleSet&, CSSStyleSheet*, unsigned sheet_index); void AddSlottedRules(const RuleSet&, CSSStyleSheet*, unsigned sheet_index);
void AddFontFaceRules(const RuleSet&); void AddFontFaceRules(const RuleSet&);
void AddKeyframeRules(const RuleSet&); void AddKeyframeRules(const RuleSet&);
...@@ -128,10 +123,8 @@ class CORE_EXPORT ScopedStyleResolver final ...@@ -128,10 +123,8 @@ class CORE_EXPORT ScopedStyleResolver final
}; };
using CSSStyleSheetRuleSubSet = HeapVector<Member<RuleSubSet>>; using CSSStyleSheetRuleSubSet = HeapVector<Member<RuleSubSet>>;
Member<CSSStyleSheetRuleSubSet> tree_boundary_crossing_rule_set_;
Member<CSSStyleSheetRuleSubSet> slotted_rule_set_; Member<CSSStyleSheetRuleSubSet> slotted_rule_set_;
bool has_deep_or_shadow_selector_ = false;
bool has_unresolved_keyframes_rule_ = false; bool has_unresolved_keyframes_rule_ = false;
bool needs_append_all_sheets_ = false; bool needs_append_all_sheets_ = false;
}; };
......
...@@ -431,7 +431,6 @@ static void MatchElementScopeRules(const Element& element, ...@@ -431,7 +431,6 @@ static void MatchElementScopeRules(const Element& element,
if (element_scope_resolver) { if (element_scope_resolver) {
collector.ClearMatchedRules(); collector.ClearMatchedRules();
element_scope_resolver->CollectMatchingElementScopeRules(collector); element_scope_resolver->CollectMatchingElementScopeRules(collector);
element_scope_resolver->CollectMatchingTreeBoundaryCrossingRules(collector);
collector.SortAndTransferMatchedRules(); collector.SortAndTransferMatchedRules();
} }
......
...@@ -610,13 +610,7 @@ void StyleEngine::ShadowRootRemovedFromDocument(ShadowRoot* shadow_root) { ...@@ -610,13 +610,7 @@ void StyleEngine::ShadowRootRemovedFromDocument(ShadowRoot* shadow_root) {
ResetAuthorStyle(*shadow_root); ResetAuthorStyle(*shadow_root);
} }
void StyleEngine::AddTreeBoundaryCrossingScope(const TreeScope& tree_scope) {
tree_boundary_crossing_scopes_.Add(&tree_scope.RootNode());
}
void StyleEngine::ResetAuthorStyle(TreeScope& tree_scope) { void StyleEngine::ResetAuthorStyle(TreeScope& tree_scope) {
tree_boundary_crossing_scopes_.Remove(&tree_scope.RootNode());
ScopedStyleResolver* scoped_resolver = tree_scope.GetScopedStyleResolver(); ScopedStyleResolver* scoped_resolver = tree_scope.GetScopedStyleResolver();
if (!scoped_resolver) if (!scoped_resolver)
return; return;
...@@ -672,7 +666,6 @@ void StyleEngine::DidDetach() { ...@@ -672,7 +666,6 @@ void StyleEngine::DidDetach() {
if (global_rule_set_) if (global_rule_set_)
global_rule_set_->Dispose(); global_rule_set_->Dispose();
global_rule_set_ = nullptr; global_rule_set_ = nullptr;
tree_boundary_crossing_scopes_.Clear();
dirty_tree_scopes_.clear(); dirty_tree_scopes_.clear();
active_tree_scopes_.clear(); active_tree_scopes_.clear();
viewport_resolver_ = nullptr; viewport_resolver_ = nullptr;
...@@ -2393,7 +2386,6 @@ void StyleEngine::Trace(Visitor* visitor) const { ...@@ -2393,7 +2386,6 @@ void StyleEngine::Trace(Visitor* visitor) const {
visitor->Trace(style_sheet_collection_map_); visitor->Trace(style_sheet_collection_map_);
visitor->Trace(dirty_tree_scopes_); visitor->Trace(dirty_tree_scopes_);
visitor->Trace(active_tree_scopes_); visitor->Trace(active_tree_scopes_);
visitor->Trace(tree_boundary_crossing_scopes_);
visitor->Trace(resolver_); visitor->Trace(resolver_);
visitor->Trace(vision_deficiency_filter_); visitor->Trace(vision_deficiency_filter_);
visitor->Trace(viewport_resolver_); visitor->Trace(viewport_resolver_);
......
...@@ -228,10 +228,6 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>, ...@@ -228,10 +228,6 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
void ShadowRootInsertedToDocument(ShadowRoot&); void ShadowRootInsertedToDocument(ShadowRoot&);
void ShadowRootRemovedFromDocument(ShadowRoot*); void ShadowRootRemovedFromDocument(ShadowRoot*);
void AddTreeBoundaryCrossingScope(const TreeScope&);
const TreeOrderedList& TreeBoundaryCrossingScopes() const {
return tree_boundary_crossing_scopes_;
}
void ResetAuthorStyle(TreeScope&); void ResetAuthorStyle(TreeScope&);
StyleResolver& GetStyleResolver() const { StyleResolver& GetStyleResolver() const {
...@@ -589,7 +585,6 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>, ...@@ -589,7 +585,6 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
bool user_style_dirty_{false}; bool user_style_dirty_{false};
UnorderedTreeScopeSet dirty_tree_scopes_; UnorderedTreeScopeSet dirty_tree_scopes_;
UnorderedTreeScopeSet active_tree_scopes_; UnorderedTreeScopeSet active_tree_scopes_;
TreeOrderedList tree_boundary_crossing_scopes_;
String preferred_stylesheet_set_name_; String preferred_stylesheet_set_name_;
......
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