Commit b4b7f265 authored by Fergal Daly's avatar Fergal Daly Committed by Commit Bot

Simplify docs on MatchAuthorRules now that MatchScopedRules is gone.

Move the docs inline as method docs and just link from the md file.

Change-Id: I286db306b4f01553ac6fa09a271aa65457c76de8
Reviewed-on: https://chromium-review.googlesource.com/1011764Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Fergal Daly <fergal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550880}
parent 916f3358
...@@ -186,6 +186,9 @@ static inline ScopedStyleResolver* ScopedResolverFor(const Element& element) { ...@@ -186,6 +186,9 @@ static inline ScopedStyleResolver* ScopedResolverFor(const Element& element) {
return tree_scope->GetScopedStyleResolver(); return tree_scope->GetScopedStyleResolver();
} }
// Matches :host and :host-context rules if the element is a shadow host.
// It matches rules from the ShadowHostRules of the ScopedStyleResolver
// of the attached shadow root.
static void MatchHostRules(const Element& element, static void MatchHostRules(const Element& element,
ElementRuleCollector& collector) { ElementRuleCollector& collector) {
ShadowRoot* shadow_root = element.GetShadowRoot(); ShadowRoot* shadow_root = element.GetShadowRoot();
...@@ -200,6 +203,10 @@ static void MatchHostRules(const Element& element, ...@@ -200,6 +203,10 @@ static void MatchHostRules(const Element& element,
} }
} }
// Matches `::slotted` selectors. It matches rules in the element's slot's
// scope. If that slot is itself slotted it will match rules in the slot's
// slot's scope and so on. The result is that it considers a chain of scopes
// descending from the element's own scope.
static void MatchSlottedRules(const Element& element, static void MatchSlottedRules(const Element& element,
ElementRuleCollector& collector) { ElementRuleCollector& collector) {
HTMLSlotElement* slot = element.AssignedSlot(); HTMLSlotElement* slot = element.AssignedSlot();
...@@ -220,6 +227,8 @@ static void MatchSlottedRules(const Element& element, ...@@ -220,6 +227,8 @@ static void MatchSlottedRules(const Element& element,
} }
} }
// Matches rules from the element's scope. The selectors may cross shadow
// boundaries during matching, like for :host-context.
static void MatchElementScopeRules(const Element& element, static void MatchElementScopeRules(const Element& element,
ScopedStyleResolver* element_scope_resolver, ScopedStyleResolver* element_scope_resolver,
ElementRuleCollector& collector) { ElementRuleCollector& collector) {
......
...@@ -165,6 +165,8 @@ class CORE_EXPORT StyleResolver final ...@@ -165,6 +165,8 @@ class CORE_EXPORT StyleResolver final
void MatchRuleSet(ElementRuleCollector&, RuleSet*); void MatchRuleSet(ElementRuleCollector&, RuleSet*);
void MatchUARules(ElementRuleCollector&); void MatchUARules(ElementRuleCollector&);
void MatchUserRules(ElementRuleCollector&); void MatchUserRules(ElementRuleCollector&);
// This matches `::part` selectors. It looks in ancestor scopes as far as
// part mapping requires.
void MatchPseudoPartRules(const Element&, ElementRuleCollector&); void MatchPseudoPartRules(const Element&, ElementRuleCollector&);
void MatchScopedRulesV0(const Element&, void MatchScopedRulesV0(const Element&,
ElementRuleCollector&, ElementRuleCollector&,
......
...@@ -148,39 +148,13 @@ which matches the rules from the ...@@ -148,39 +148,13 @@ which matches the rules from the
[`MatchAuthorRules`](https://cs.chromium.org/?q=symbol:%5Eblink::StyleResolver::MatchAuthorRules$) [`MatchAuthorRules`](https://cs.chromium.org/?q=symbol:%5Eblink::StyleResolver::MatchAuthorRules$)
[`MatchAuthorRules`](https://cs.chromium.org/?q=symbol:%5Eblink::StyleResolver::MatchAuthorRules$) [`MatchAuthorRules`](https://cs.chromium.org/?q=symbol:%5Eblink::StyleResolver::MatchAuthorRules$)
splits into two cases. splits applies the following steps (read the method docs):
- [`MatchHostRules`](https://cs.chromium.org/?q=symbol:%5Eblink::MatchHostRules$)
- [`MatchSlottedRules`](https://cs.chromium.org/?q=symbol:%5Eblink::MatchSlottedRules$)
- [`MatchElementScopeRules`](https://cs.chromium.org/?q=symbol:%5Eblink::MatchElementScopeRules$)
- [`MatchPseudoPartRules`](https://cs.chromium.org/?q=symbol:%5Eblink::StyleResolver::MatchPseudoPartRules$)
#### [`MatchHostRules`](https://cs.chromium.org/?q=symbol:%5Eblink::MatchHostRules$)
This method matches :host and :host-context rules for shadow host elements.
This does nothing if the element in question is not a shadow host.
If it is a shadow host,
it examines the `ScopedStyleResolver` of its shadow root.
Any host related rules will be in the `ShadowHostRules` list of that `ScopedStyleResolver`
#### [`MatchScopedRules`](https://cs.chromium.org/?q=symbol:%5Eblink::StyleResolver::MatchScopedRules$)
For V1 Shadow DOM, this simply calls 3 functions explained below.
##### ['MatchSlottedRules'](https://cs.chromium.org/?q=symbol:%5Eblink::MatchSlottedRules)
This matches `::slotted` selectors.
It matches rules in the element's slot's scope.
If that slot is itself slotted it will match rules in the slot's slot's scope and so on.
The result is that it considers a chain of scopes descending from the element's own scope.
##### ['MatchElementScopeRules'](https://cs.chromium.org/?q=symbol:%5Eblink::MatchElementScopeRules)
This matches rules from the element's scope.
The selectors may cross shadow boundaries during matching,
like for :host-context.
##### ['MatchPseudoPartRules'](https://cs.chromium.org/?q=symbol:%5Eblink::StyleResolver::MatchPseudoPartRules)
This matches `::part` selectors.
It looks in ancestor scopes as far as part mapping requires.
#### <a name="CollectMatchingRulesForList"></a>[`CollectMatchingRulesForList`](https://cs.chromium.org/?q=symbol:%5Eblink::ElementRuleCollector::CollectMatchingRulesForList$) - testing some rules against an element #### <a name="CollectMatchingRulesForList"></a>[`CollectMatchingRulesForList`](https://cs.chromium.org/?q=symbol:%5Eblink::ElementRuleCollector::CollectMatchingRulesForList$) - testing some rules against an element
......
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