Commit 0904d89a authored by Erik Luo's avatar Erik Luo Committed by Commit Bot

DevTools: cleanup presentation of user agent styles

In the Styles sidebar pane, user agent style sections:
- Properties within an inherited section that do not contribute to
  the cascade (not inheritable) are hidden.
- Non-matching selector pieces are hidden.

The goal is to reduce visual noise in the UI without affecting style
debugging.

Screenshot: https://imgur.com/a/2s5wIn8

Bug: 929536
Change-Id: Icaea2edcbb8560273469605f263449edd51bade2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1500775Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Erik Luo <luoe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638731}
parent 5a49436d
...@@ -1394,6 +1394,8 @@ Elements.StylePropertiesSection = class { ...@@ -1394,6 +1394,8 @@ Elements.StylePropertiesSection = class {
const isShorthand = !!style.longhandProperties(property.name).length; const isShorthand = !!style.longhandProperties(property.name).length;
const inherited = this.isPropertyInherited(property.name); const inherited = this.isPropertyInherited(property.name);
const overloaded = this._isPropertyOverloaded(property); const overloaded = this._isPropertyOverloaded(property);
if (style.parentRule && style.parentRule.isUserAgent() && inherited)
continue;
const item = new Elements.StylePropertyTreeElement( const item = new Elements.StylePropertyTreeElement(
this._parentPane, this._matchedStyles, property, isShorthand, inherited, overloaded, false); this._parentPane, this._matchedStyles, property, isShorthand, inherited, overloaded, false);
this.propertiesTreeOutline.appendChild(item); this.propertiesTreeOutline.appendChild(item);
......
...@@ -38,6 +38,14 @@ SDK.CSSMatchedStyles = class { ...@@ -38,6 +38,14 @@ SDK.CSSMatchedStyles = class {
this._nodeForStyle = new Map(); this._nodeForStyle = new Map();
/** @type {!Set<!SDK.CSSStyleDeclaration>} */ /** @type {!Set<!SDK.CSSStyleDeclaration>} */
this._inheritedStyles = new Set(); this._inheritedStyles = new Set();
for (const result of matchedPayload)
cleanUserAgentSelectors(result);
for (const inheritedResult of inheritedPayload) {
for (const result of inheritedResult.matchedCSSRules)
cleanUserAgentSelectors(result);
}
this._mainDOMCascade = this._buildMainCascade(inlinePayload, attributesPayload, matchedPayload, inheritedPayload); this._mainDOMCascade = this._buildMainCascade(inlinePayload, attributesPayload, matchedPayload, inheritedPayload);
this._pseudoDOMCascades = this._buildPseudoCascades(pseudoPayload); this._pseudoDOMCascades = this._buildPseudoCascades(pseudoPayload);
...@@ -47,6 +55,18 @@ SDK.CSSMatchedStyles = class { ...@@ -47,6 +55,18 @@ SDK.CSSMatchedStyles = class {
for (const style of domCascade.styles()) for (const style of domCascade.styles())
this._styleToDOMCascade.set(style, domCascade); this._styleToDOMCascade.set(style, domCascade);
} }
/**
* @param {!Protocol.CSS.RuleMatch} ruleMatch
*/
function cleanUserAgentSelectors(ruleMatch) {
const {matchingSelectors, rule} = ruleMatch;
if (rule.origin !== 'user-agent' || !matchingSelectors.length)
return;
rule.selectorList.selectors = rule.selectorList.selectors.filter((item, i) => matchingSelectors.includes(i));
rule.selectorList.text = rule.selectorList.selectors.map(item => item.text).join(', ');
ruleMatch.matchingSelectors = matchingSelectors.map((item, i) => i);
}
} }
/** /**
......
...@@ -65,7 +65,6 @@ div { ...@@ -65,7 +65,6 @@ div {
display: block display: block
} }
html { html {
display: block
color: -internal-root-color color: -internal-root-color
} }
...@@ -21,7 +21,6 @@ div { ...@@ -21,7 +21,6 @@ div {
display: block display: block
} }
html { html {
display: block
color: -internal-root-color color: -internal-root-color
} }
#third::before { #third::before {
...@@ -52,7 +51,7 @@ Running: testDisplayProperty ...@@ -52,7 +51,7 @@ Running: testDisplayProperty
Filtering styles by: display Filtering styles by: display
[ HIDDEN ] Inherited from div#second [ HIDDEN ] Inherited from div#second
[ VISIBLE ] Inherited from div#first [ VISIBLE ] Inherited from div#first
[ VISIBLE ] Inherited from html [ HIDDEN ] Inherited from html
[ HIDDEN ] Pseudo ::before element [ HIDDEN ] Pseudo ::before element
[ VISIBLE ] Pseudo ::after element [ VISIBLE ] Pseudo ::after element
...@@ -13,7 +13,7 @@ Running: testPseudoSectionPropertyEdit ...@@ -13,7 +13,7 @@ Running: testPseudoSectionPropertyEdit
element.style { () element.style { ()
[expanded] [expanded]
article, aside, footer, header, hgroup, main, nav, section { (user agent stylesheet) section { (user agent stylesheet)
display: block; display: block;
======== Inherited from html ======== ======== Inherited from html ========
......
...@@ -12,7 +12,7 @@ rect { (svg-style.xhtml:6 -> svg-style.xhtml:6:16) ...@@ -12,7 +12,7 @@ rect { (svg-style.xhtml:6 -> svg-style.xhtml:6:16)
svg:rect[Attributes Style] { () svg:rect[Attributes Style] { ()
[expanded] [expanded]
:not(svg), :not(foreignObject) > svg { (user agent stylesheet) :not(svg) { (user agent stylesheet)
transform-origin: 0px 0px; transform-origin: 0px 0px;
======== Inherited from html ======== ======== Inherited from html ========
......
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