Web Inspector: Modifying CSS selector by pressing Enter or Tab causes 2 CSS.setRuleSe...
authornvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Oct 2019 00:55:10 +0000 (00:55 +0000)
committernvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Oct 2019 00:55:10 +0000 (00:55 +0000)
commit7f5718677a0e2e014c28598c543ff9bcc8b4123a
tree6d62cbd71ff7aff1ca15c7550ad9f99ed4a0fa88
parentae4a282e9417e31ad2ccb41918c8164d7aa31bcf
Web Inspector: Modifying CSS selector by pressing Enter or Tab causes 2 CSS.setRuleSelector backend calls
https://bugs.webkit.org/show_bug.cgi?id=202769
<rdar://problem/56132166>

Reviewed by Matt Baker.

Previously, spreadsheetSelectorFieldDidChange would get called twice:
1. On Enter or Tab key press.
2. On blur event.

With this patch, it only gets called on blur event.

* UserInterface/Models/CSSRule.js:
(WI.CSSRule.prototype.set selectorText):
Remove dead code. Calling `_selectorResolved(true)` would cause an uncaught exception.

* UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
(WI.SpreadsheetCSSStyleDeclarationSection.prototype.spreadsheetSelectorFieldDidChange): Removed.
(WI.SpreadsheetCSSStyleDeclarationSection.prototype.spreadsheetSelectorFieldDidCommit): Added.
(WI.SpreadsheetCSSStyleDeclarationSection.prototype.spreadsheetSelectorFieldWillNavigate): Added.
Split spreadsheetSelectorFieldDidChange into spreadsheetSelectorFieldDidCommit and spreadsheetSelectorFieldWillNavigate.

* UserInterface/Views/SpreadsheetSelectorField.js:
(WI.SpreadsheetSelectorField):
(WI.SpreadsheetSelectorField.prototype.startEditing):
(WI.SpreadsheetSelectorField.prototype.stopEditing):
(WI.SpreadsheetSelectorField.prototype._handleBlur):
(WI.SpreadsheetSelectorField.prototype._handleKeyDown):
Add `_valueBeforeEditing` to check if the value was modified before the blur event.
Similar logic exists in SpreadsheetTextField.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250948 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/CSSRule.js
Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js
Source/WebInspectorUI/UserInterface/Views/SpreadsheetSelectorField.js