REGRESSION(?): Web Inspector: Can have multiple Timelines selected after edit mode
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Jan 2019 19:53:20 +0000 (19:53 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Jan 2019 19:53:20 +0000 (19:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193808
<rdar://problem/47537734>

Reviewed by Devin Rousso.

* UserInterface/Controllers/SelectionController.js:
(WI.SelectionController.prototype.didRemoveItems):

* UserInterface/Views/TreeOutline.js:
(WI.TreeOutline.prototype._indexesForSubtree):
Fix a bug where no IndexSet was returned when passed a TreeElement with
no children. This caused the Timelines tree selection to be corrupted when
entering and exiting edit mode, as TreeElements are inserted and removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240594 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/SelectionController.js
Source/WebInspectorUI/UserInterface/Views/TreeOutline.js

index f954955..cf161ea 100644 (file)
@@ -1,3 +1,20 @@
+2019-01-28  Matt Baker  <mattbaker@apple.com>
+
+        REGRESSION(?): Web Inspector: Can have multiple Timelines selected after edit mode
+        https://bugs.webkit.org/show_bug.cgi?id=193808
+        <rdar://problem/47537734>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Controllers/SelectionController.js:
+        (WI.SelectionController.prototype.didRemoveItems):
+
+        * UserInterface/Views/TreeOutline.js:
+        (WI.TreeOutline.prototype._indexesForSubtree):
+        Fix a bug where no IndexSet was returned when passed a TreeElement with
+        no children. This caused the Timelines tree selection to be corrupted when
+        entering and exiting edit mode, as TreeElements are inserted and removed.
+
 2019-01-28  Nikita Vasilyev  <nvasilyev@apple.com>
 
         Web Inspector: Add Changes panel to Elements tab
index b65f9f0..75cbcf5 100644 (file)
@@ -221,9 +221,12 @@ WI.SelectionController = class SelectionController extends WI.Object
 
     didRemoveItems(indexes)
     {
+        if (!indexes)
+            return;
+
         console.assert(indexes instanceof WI.IndexSet);
 
-        if (!this._selectedIndexes.size)
+        if (!indexes.size || !this._selectedIndexes.size)
             return;
 
         let firstRemovedIndex = indexes.firstIndex;
index a47e60b..02cd7b4 100644 (file)
@@ -1082,27 +1082,23 @@ WI.TreeOutline = class TreeOutline extends WI.Object
     {
         let treeOutline = treeElement.treeOutline;
         if (!treeOutline)
-            return new WI.IndexSet;
+            return null;
 
         let firstChild = treeElement.children[0];
-        if (!firstChild)
-            return new WI.IndexSet;
+        if (treeElement.root && !firstChild)
+            return null;
 
-        let startIndex = treeOutline._indexOfTreeElement(firstChild);
+        let current = firstChild || treeElement;
+        let startIndex = treeOutline._indexOfTreeElement(current);
         let endIndex = startIndex;
 
         const skipUnrevealed = false;
         const stayWithin = treeElement;
         const dontPopulate = true;
 
-        let current = firstChild;
         while (current = current.traverseNextTreeElement(skipUnrevealed, stayWithin, dontPopulate))
             endIndex++;
 
-        // Include the index of the subtree's root, unless it's the TreeOutline root.
-        if (!treeElement.root)
-            startIndex--;
-
         let count = endIndex - startIndex + 1;
 
         let indexes = new WI.IndexSet;