Commit 4fbe646e authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

Revert "Make :host account for its own pseudo-class specificity."

This reverts commit 1ef23c93.

Reason for revert: 
Caused several styling breakages across WebUI surfaces, see https://bugs.chromium.org/p/chromium/issues/detail?id=890030

Original change's description:
> Make :host account for its own pseudo-class specificity.
> 
> Otherwise `:host div` is equally specific to `div`, which seems undesirable and
> doesn't match any spec.
> 
> Bug: 857415
> Change-Id: I0a012ada134acb022dab85c3912b33ac5d0bd1dd
> Reviewed-on: https://chromium-review.googlesource.com/1238445
> Commit-Queue: Emilio Cobos Álvarez <emilio@chromium.org>
> Reviewed-by: Rune Lillesveen <futhark@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#594745}

TBR=emilio@chromium.org,futhark@chromium.org,andruud@chromium.org

Change-Id: I98ce78a982a1d71356f18ec60a01e9616d5f9eec
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 857415
Reviewed-on: https://chromium-review.googlesource.com/1250054Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594888}
parent 52e09e6c
...@@ -2975,7 +2975,8 @@ crbug.com/626703 [ Win7 ] external/wpt/resource-timing/resource_timing_buffer_fu ...@@ -2975,7 +2975,8 @@ crbug.com/626703 [ Win7 ] external/wpt/resource-timing/resource_timing_buffer_fu
crbug.com/626703 external/wpt/svg/rendering/order/z-index.svg [ Failure ] crbug.com/626703 external/wpt/svg/rendering/order/z-index.svg [ Failure ]
crbug.com/626703 external/wpt/web-animations/timing-model/timelines/update-and-send-events.html [ Timeout ] crbug.com/626703 external/wpt/web-animations/timing-model/timelines/update-and-send-events.html [ Timeout ]
crbug.com/626703 external/wpt/console/console-timing-logging-manual.html [ Skip ] crbug.com/626703 external/wpt/console/console-timing-logging-manual.html [ Skip ]
crbug.com/888042 external/wpt/css/css-scoping/slotted-specificity.html [ Failure ] crbug.com/626703 external/wpt/css/css-scoping/host-specificity-002.html [ Failure ]
crbug.com/626703 external/wpt/css/css-scoping/slotted-specificity.html [ Failure ]
crbug.com/626703 external/wpt/css/css-text/white-space/break-spaces-001.html [ Failure ] crbug.com/626703 external/wpt/css/css-text/white-space/break-spaces-001.html [ Failure ]
crbug.com/626703 [ Mac10.12 Mac10.13 ] external/wpt/compat/webkit-text-fill-color-property-002.html [ Failure ] crbug.com/626703 [ Mac10.12 Mac10.13 ] external/wpt/compat/webkit-text-fill-color-property-002.html [ Failure ]
crbug.com/626703 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-column-row-gap-001.html [ Failure ] crbug.com/626703 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-column-row-gap-001.html [ Failure ]
......
<!doctype html>
<meta charset="utf-8">
<title>CSS Test: the :host() selector affects specificity</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-scoping/#host-selector">
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/1915">
<link rel="help" href="https://bugzil.la/1454165">
<link rel="match" href="reference/green-box.html">
<p>Test passes if you see a single 100px by 100px green box below.</p>
<div id="host"></div>
<script>
host.attachShadow({ mode: 'open' }).innerHTML = `
<style>
:host(*) div {
width: 100px;
height: 100px;
background: green;
}
div {
background: red;
}
</style>
<div></div>
`;
</script>
...@@ -116,7 +116,7 @@ debug('Test that rules which has higher specificity win.'); ...@@ -116,7 +116,7 @@ debug('Test that rules which has higher specificity win.');
sandbox.appendChild( sandbox.appendChild(
createDOM('style', {}, createDOM('style', {},
document.createTextNode('#host { border: 1px solid red; }'))); document.createTextNode('div { border: 1px solid red; }')));
sandbox.appendChild( sandbox.appendChild(
createDOM('div', {'id': 'host'}, createDOM('div', {'id': 'host'},
createShadowRoot( createShadowRoot(
......
...@@ -104,7 +104,7 @@ inline unsigned CSSSelector::SpecificityForOneSelector() const { ...@@ -104,7 +104,7 @@ inline unsigned CSSSelector::SpecificityForOneSelector() const {
return 0; return 0;
switch (match_) { switch (match_) {
case kId: case kId:
return kIdSpecificity; return 0x010000;
case kPseudoClass: case kPseudoClass:
switch (GetPseudoType()) { switch (GetPseudoType()) {
case kPseudoHost: case kPseudoHost:
...@@ -122,7 +122,7 @@ inline unsigned CSSSelector::SpecificityForOneSelector() const { ...@@ -122,7 +122,7 @@ inline unsigned CSSSelector::SpecificityForOneSelector() const {
default: default:
break; break;
} }
return kClassLikeSpecificity; return 0x000100;
case kClass: case kClass:
case kPseudoElement: case kPseudoElement:
case kAttributeExact: case kAttributeExact:
...@@ -132,11 +132,11 @@ inline unsigned CSSSelector::SpecificityForOneSelector() const { ...@@ -132,11 +132,11 @@ inline unsigned CSSSelector::SpecificityForOneSelector() const {
case kAttributeContain: case kAttributeContain:
case kAttributeBegin: case kAttributeBegin:
case kAttributeEnd: case kAttributeEnd:
return kClassLikeSpecificity; return 0x000100;
case kTag: case kTag:
if (TagQName().LocalName() == UniversalSelectorAtom()) if (TagQName().LocalName() == UniversalSelectorAtom())
return 0; return 0;
return kTagSpecificity; return 0x000001;
case kUnknown: case kUnknown:
return 0; return 0;
} }
......
...@@ -103,10 +103,6 @@ class CORE_EXPORT CSSSelector { ...@@ -103,10 +103,6 @@ class CORE_EXPORT CSSSelector {
bool operator==(const CSSSelector&) const; bool operator==(const CSSSelector&) const;
static constexpr unsigned kIdSpecificity = 0x010000;
static constexpr unsigned kClassLikeSpecificity = 0x000100;
static constexpr unsigned kTagSpecificity = 0x000001;
// http://www.w3.org/TR/css3-selectors/#specificity // http://www.w3.org/TR/css3-selectors/#specificity
// We use 256 as the base of the specificity number system. // We use 256 as the base of the specificity number system.
unsigned Specificity() const; unsigned Specificity() const;
......
...@@ -1170,8 +1170,6 @@ bool SelectorChecker::CheckPseudoElement(const SelectorCheckingContext& context, ...@@ -1170,8 +1170,6 @@ bool SelectorChecker::CheckPseudoElement(const SelectorCheckingContext& context,
sub_context.treat_shadow_host_as_normal_scope = false; sub_context.treat_shadow_host_as_normal_scope = false;
// ::slotted() only allows one compound selector. // ::slotted() only allows one compound selector.
//
// TODO(emilio): Should account for specificity here.
DCHECK(selector.SelectorList()->First()); DCHECK(selector.SelectorList()->First());
DCHECK(!CSSSelectorList::Next(*selector.SelectorList()->First())); DCHECK(!CSSSelectorList::Next(*selector.SelectorList()->First()));
sub_context.selector = selector.SelectorList()->First(); sub_context.selector = selector.SelectorList()->First();
...@@ -1205,10 +1203,8 @@ bool SelectorChecker::CheckPseudoHost(const SelectorCheckingContext& context, ...@@ -1205,10 +1203,8 @@ bool SelectorChecker::CheckPseudoHost(const SelectorCheckingContext& context,
DCHECK(IsShadowHost(element)); DCHECK(IsShadowHost(element));
// For the case with no parameters, i.e. just :host. // For the case with no parameters, i.e. just :host.
if (!selector.SelectorList()) { if (!selector.SelectorList())
result.specificity += CSSSelector::kClassLikeSpecificity;
return true; return true;
}
SelectorCheckingContext sub_context(context); SelectorCheckingContext sub_context(context);
sub_context.is_sub_selector = true; sub_context.is_sub_selector = true;
...@@ -1249,7 +1245,7 @@ bool SelectorChecker::CheckPseudoHost(const SelectorCheckingContext& context, ...@@ -1249,7 +1245,7 @@ bool SelectorChecker::CheckPseudoHost(const SelectorCheckingContext& context,
} while (next_element); } while (next_element);
} }
if (matched) { if (matched) {
result.specificity += max_specificity + CSSSelector::kClassLikeSpecificity; result.specificity += max_specificity;
return true; return true;
} }
......
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