Web Inspector: Styles: `::-webkit-scrollbar*` rules aren't shown
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Mar 2019 09:33:24 +0000 (09:33 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Mar 2019 09:33:24 +0000 (09:33 +0000)
commitb70f359606088a7a58ba62b5f98d88efc54dcfa6
tree6730a6dda3e005f15e9cb0ff1f25558a47631ca4
parentd2adc3d2b656e25c3bca0366e1c03edec1b9f543
Web Inspector: Styles: `::-webkit-scrollbar*` rules aren't shown
https://bugs.webkit.org/show_bug.cgi?id=195123
<rdar://problem/48450148>

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

* inspector/protocol/CSS.json:
Add `CSS.PseudoId` enum, rather than send a number, so that we have more knowledge about
which pseudo type the rule corresponds to (e.g. a string is more descriptive than a number).

Source/WebCore:

Test: inspector/css/getMatchedStylesForNode.html

* inspector/agents/InspectorCSSAgent.cpp:
(WebCore::protocolValueForPseudoId): Added.
(WebCore::InspectorCSSAgent::getMatchedStylesForNode):

Source/WebInspectorUI:

* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.displayNameForPseudoId): Added.

* UserInterface/Models/DOMNodeStyles.js:
(WI.DOMNodeStyles.static uniqueOrderedStyles): Added.
(WI.DOMNodeStyles.prototype.get uniqueOrderedStyles):

* UserInterface/Views/SpreadsheetRulesStyleDetailsPanel.js:
(WI.SpreadsheetRulesStyleDetailsPanel.prototype.layout):
(WI.SpreadsheetRulesStyleDetailsPanel.prototype._handleSectionFilterApplied):
Rather than iterate over the `WI.DOMNode`'s list of pseudo-elements (which is only ::before
and ::after), we iterate over the `WI.DOMNodeStyle`'s list of pseudo-element rules. This is
an object where the key is a `CSS.PseudoId` and the value is an object containing all the
matched rules and ordered styles for that pseudo-type. We can preserve the current
functionality by using the ::before/::after `WI.DOMNode` when we encounter one of those
pseudo-ids.

An additional benefit of this change is that `::before`/`::after` styles will still appear
in the Rules panel even if they don't have a `content` property set (e.g. when the
`::before`/`::after` pseudo-element doesn't exist). This is because the styles are no longer
fetched from those pseudo-element nodes directly, but rather as a matched style for the
parent node. As such, editing a `content` property to become invalid/disablde in a
`::before`/`::after` rule won't make the entire rule disappeaer.

LayoutTests:

* inspector/css/getMatchedStylesForNode.html: Added.
* inspector/css/getMatchedStylesForNode-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242939 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/css/getMatchedStylesForNode-expected.txt [new file with mode: 0644]
LayoutTests/inspector/css/getMatchedStylesForNode.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/CSS.json
Source/WebCore/ChangeLog
Source/WebCore/inspector/agents/InspectorCSSAgent.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Controllers/CSSManager.js
Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js
Source/WebInspectorUI/UserInterface/Views/SpreadsheetRulesStyleDetailsPanel.js