Web Inspector: Styles Redesign: Editing selector should not hide the rule
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 00:22:06 +0000 (00:22 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 00:22:06 +0000 (00:22 +0000)
commit935f071b9b5bf18f9c91c62745263a483298f97b
treea3a70df6e5f9b3283f9145d4b6ea9467aec4ab2e
parent45e9a9587854bb807a9f9c414ffcc0aec2cfb00c
Web Inspector: Styles Redesign: Editing selector should not hide the rule
https://bugs.webkit.org/show_bug.cgi?id=178489
<rdar://problem/35062434>

Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

Extracts the selector payload parsing logic inside `WI.DOMNodeStyles` into static functions
so that when the user changes the selector of a `WI.CSSRule`, it's able to process and
update itself with the new selector. This is mainly useful in the case where the `WI.CSSRule`
no longer applies to the selected node (meaning it won't be part of that node's
`WI.DOMNodeStyles`) in that it allows the `WI.SpreadsheetCSSStyleDeclarationSection` to
display the new selector text and the owner `WI.SpreadsheetRulesStyleDetailsPanel` to keep
that section visible even though it isn't applicable to the current node anymore.

* UserInterface/Models/DOMNodeStyles.js:
(WI.DOMNodeStyles):
(WI.DOMNodeStyles.parseSelectorListPayload): Added.
(WI.DOMNodeStyles.createSourceCodeLocation): Added.
(WI.DOMNodeStyles.prototype.refresh):
(WI.DOMNodeStyles.prototype.refresh.fetchedMatchedStyles):
(WI.DOMNodeStyles.prototype.refresh.fetchedInlineStyles):
(WI.DOMNodeStyles.prototype.refresh.fetchedComputedStyle):
(WI.DOMNodeStyles.prototype._parseStyleDeclarationPayload):
(WI.DOMNodeStyles.prototype._parseRulePayload):
(WI.DOMNodeStyles.prototype._styleSheetContentDidChange):
(WI.DOMNodeStyles.prototype.refresh.parseRuleMatchArrayPayload): Deleted.
(WI.DOMNodeStyles.prototype._createSourceCodeLocation): Deleted.
(WI.DOMNodeStyles.prototype._parseSelectorListPayload): Deleted.
Keep track of all `WI.CSSRule` and `WI.CSSStyleDeclaration` that have ever been associated
with this object, so that if a rule's selector is changed to no longer match, and then is
changed back to match again, we are able to update that rule instead of creating a new one.

* UserInterface/Views/SpreadsheetRulesStyleDetailsPanel.js:
(WI.SpreadsheetRulesStyleDetailsPanel.prototype.layout):
(WI.SpreadsheetRulesStyleDetailsPanel.prototype._handleSectionFilterApplied):
(WI.SpreadsheetRulesStyleDetailsPanel.prototype._handleSectionSelectorWillChange): Added.
Attempt to preserve the position of any sections that are changed and no longer apply to the
current node.

* UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
(WI.SpreadsheetCSSStyleDeclarationSection.prototype.spreadsheetSelectorFieldDidChange):
(WI.SpreadsheetCSSStyleDeclarationSection.prototype._renderSelector):
Drive-by: remove unused CSS classes.
* UserInterface/Models/CSSRule.js:
(WI.CSSRule.prototype.update):
(WI.CSSRule.prototype._selectorResolved):
Drive-by: remove unused event.
* UserInterface/Base/Multimap.js:
(Multimap.prototype.has): Added.
(Multimap.prototype.sets): Added.
(Multimap.prototype.copy): Added.

LayoutTests:

* inspector/unit-tests/multimap.html: Added.
* inspector/unit-tests/multimap-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243264 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/inspector/unit-tests/multimap-expected.txt [new file with mode: 0644]
LayoutTests/inspector/unit-tests/multimap.html [new file with mode: 0644]
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Multimap.js
Source/WebInspectorUI/UserInterface/Models/CSSRule.js
Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js
Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js
Source/WebInspectorUI/UserInterface/Views/SpreadsheetRulesStyleDetailsPanel.js