Web Inspector: REGRESSION(r238599): Multiple Selection: restoring selection when...
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2018 23:16:25 +0000 (23:16 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2018 23:16:25 +0000 (23:16 +0000)
commit13b1b950c3be7ba7bdf3b152c4326f7e36b572f0
tree446de21d7bcdd212f5e13598e1321b793d919d4d
parent9cdb3a9b15e8f7c6a759d1b55a49a6a452231722
Web Inspector: REGRESSION(r238599): Multiple Selection: restoring selection when opening WebInspector puts the TreeElement into a permanent selected state
https://bugs.webkit.org/show_bug.cgi?id=192091
<rdar://problem/46321795>

Reviewed by Devin Rousso.

* UserInterface/Controllers/SelectionController.js:
(WI.SelectionController.prototype.didInsertItem):
Fix a bug where selected indexes were overwritten by the inserted index.

* UserInterface/Views/TreeOutline.js:
(WI.TreeOutline):
(WI.TreeOutline.prototype.insertChild):
Update the SelectionController with the newly inserted index before
attaching the TreeElement. Attaching the TreeElement can cause it to
become selected, which would add the index to the SelectionController,
only to have it immediately incremented by the call to `didInsertItem`.
Additionally, change `insertionIndex` to be the index of the inserted
item instead of the inserted item's previous sibling.

(WI.TreeOutline.prototype._rememberTreeElement):
(WI.TreeOutline.prototype._forgetTreeElement):
(WI.TreeOutline.prototype._indexOfTreeElement.previousElement): Deleted.
Eliminate TreeElement index caching, which could become stale and cause
the wrong index to be calculated. Additionally, instead of walking up the
parent chain to determine the index, start at the root and use existing
method `traverseNextTreeElement`.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/SelectionController.js
Source/WebInspectorUI/UserInterface/Views/TreeOutline.js