Skip to content

Commit

Permalink
Add use counter for /deep/ and ::shadow usage in querySelector()
Browse files Browse the repository at this point in the history
Bug: 771111

Change-Id: I7f791cb0c5c32d92adf1e05c6719a37fca871475
Reviewed-on: https://chromium-review.googlesource.com/697190
Commit-Queue: Takayoshi Kochi <kochi@chromium.org>
Reviewed-by: Hayato Ito <hayato@chromium.org>
Reviewed-by: nainar <nainar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506722}
  • Loading branch information
TakayoshiKochi authored and Commit Bot committed Oct 5, 2017
1 parent 5899dbd commit 9055c1f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
22 changes: 15 additions & 7 deletions third_party/WebKit/Source/core/css/SelectorChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,13 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation(
return kSelectorFailsAllSiblings;

case CSSSelector::kShadowPseudo: {
if (RuntimeEnabledFeatures::
ShadowPseudoElementInCSSDynamicProfileEnabled()) {
if (!is_ua_rule_ && mode_ != kQueryingRules &&
context.selector->GetPseudoType() == CSSSelector::kPseudoShadow) {
if (!is_ua_rule_ &&
context.selector->GetPseudoType() == CSSSelector::kPseudoShadow) {
if (mode_ == kQueryingRules) {
UseCounter::Count(context.element->GetDocument(),
WebFeature::kPseudoShadowInStaticProfile);
} else if (RuntimeEnabledFeatures::
ShadowPseudoElementInCSSDynamicProfileEnabled()) {
Deprecation::CountDeprecation(context.element->GetDocument(),
WebFeature::kCSSSelectorPseudoShadow);
}
Expand All @@ -437,9 +440,14 @@ SelectorChecker::MatchStatus SelectorChecker::MatchForRelation(
}

case CSSSelector::kShadowDeep: {
if (!is_ua_rule_ && mode_ != kQueryingRules) {
Deprecation::CountDeprecation(context.element->GetDocument(),
WebFeature::kCSSDeepCombinator);
if (!is_ua_rule_) {
if (mode_ == kQueryingRules) {
UseCounter::Count(context.element->GetDocument(),
WebFeature::kDeepCombinatorInStaticProfile);
} else {
Deprecation::CountDeprecation(context.element->GetDocument(),
WebFeature::kCSSDeepCombinator);
}
}
if (ShadowRoot* root = context.element->ContainingShadowRoot()) {
if (root->GetType() == ShadowRootType::kUserAgent)
Expand Down
2 changes: 2 additions & 0 deletions third_party/WebKit/public/platform/web_feature.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,8 @@ enum WebFeature {
kAsyncXhrInPageDismissal = 2160,
kV8LineOrParagraphSeparatorAsLineTerminator = 2161,
kAnimationSetPlaybackRateCompensatorySeek = 2162,
kDeepCombinatorInStaticProfile = 2163,
kPseudoShadowInStaticProfile = 2164,

// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
Expand Down
2 changes: 2 additions & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16436,6 +16436,8 @@ uploading your change for review. These are checked by presubmit scripts.
<int value="2160" label="AsyncXhrInPageDismissal"/>
<int value="2161" label="V8LineOrParagraphSeparatorAsLineTerminator"/>
<int value="2162" label="AnimationSetPlaybackRateCompensatorySeek"/>
<int value="2163" label="DeepCombinatorInStaticProfile"/>
<int value="2164" label="PseudoShadowInStaticProfile"/>
</enum>

<enum name="FeedbackSource">
Expand Down

0 comments on commit 9055c1f

Please sign in to comment.