Title: [241093] branches/safari-607-branch/Source/WebInspectorUI
Revision
241093
Author
alanc...@apple.com
Date
2019-02-06 14:18:14 -0800 (Wed, 06 Feb 2019)

Log Message

Cherry-pick r241003. rdar://problem/47842660

    Web Inspector: Elements tab: selection is broken after deleting the selected node
    https://bugs.webkit.org/show_bug.cgi?id=194300
    <rdar://problem/47829275>

    Reviewed by Devin Rousso.

    Deleting a TreeElement can cause an IndexSet including indexes
    outside the deleted range to be passed to SelectionController,
    corrupting the internal selection state.

    * UserInterface/Views/TreeOutline.js:
    (WI.TreeOutline.prototype._indexesForSubtree.numberOfElementsInSubtree): Added.
    (WI.TreeOutline.prototype._indexesForSubtree):
    Finding the last (rightmost leaf) TreeElement in the subtree used
    TreeElement.prototype.traverseNextElement to do a depth first traversal.
    This method did not stay within the subtree rooted at `treeElement`.

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

Modified Paths

Diff

Modified: branches/safari-607-branch/Source/WebInspectorUI/ChangeLog (241092 => 241093)


--- branches/safari-607-branch/Source/WebInspectorUI/ChangeLog	2019-02-06 22:18:12 UTC (rev 241092)
+++ branches/safari-607-branch/Source/WebInspectorUI/ChangeLog	2019-02-06 22:18:14 UTC (rev 241093)
@@ -1,5 +1,47 @@
 2019-02-06  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r241003. rdar://problem/47842660
+
+    Web Inspector: Elements tab: selection is broken after deleting the selected node
+    https://bugs.webkit.org/show_bug.cgi?id=194300
+    <rdar://problem/47829275>
+    
+    Reviewed by Devin Rousso.
+    
+    Deleting a TreeElement can cause an IndexSet including indexes
+    outside the deleted range to be passed to SelectionController,
+    corrupting the internal selection state.
+    
+    * UserInterface/Views/TreeOutline.js:
+    (WI.TreeOutline.prototype._indexesForSubtree.numberOfElementsInSubtree): Added.
+    (WI.TreeOutline.prototype._indexesForSubtree):
+    Finding the last (rightmost leaf) TreeElement in the subtree used
+    TreeElement.prototype.traverseNextElement to do a depth first traversal.
+    This method did not stay within the subtree rooted at `treeElement`.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241003 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-02-05  Matt Baker  <mattba...@apple.com>
+
+            Web Inspector: Elements tab: selection is broken after deleting the selected node
+            https://bugs.webkit.org/show_bug.cgi?id=194300
+            <rdar://problem/47829275>
+
+            Reviewed by Devin Rousso.
+
+            Deleting a TreeElement can cause an IndexSet including indexes
+            outside the deleted range to be passed to SelectionController,
+            corrupting the internal selection state.
+
+            * UserInterface/Views/TreeOutline.js:
+            (WI.TreeOutline.prototype._indexesForSubtree.numberOfElementsInSubtree): Added.
+            (WI.TreeOutline.prototype._indexesForSubtree):
+            Finding the last (rightmost leaf) TreeElement in the subtree used
+            TreeElement.prototype.traverseNextElement to do a depth first traversal.
+            This method did not stay within the subtree rooted at `treeElement`.
+
+2019-02-06  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r240946. rdar://problem/47830598
 
     Web Inspector: Styles: fix race conditions when editing

Modified: branches/safari-607-branch/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js (241092 => 241093)


--- branches/safari-607-branch/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js	2019-02-06 22:18:12 UTC (rev 241092)
+++ branches/safari-607-branch/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js	2019-02-06 22:18:14 UTC (rev 241093)
@@ -1089,26 +1089,25 @@
         if (!treeOutline)
             return null;
 
-        let firstChild = treeElement.children[0];
-        if (treeElement.root && !firstChild)
-            return null;
+        function numberOfElementsInSubtree(treeElement) {
+            let elements = treeElement.root ? Array.from(treeElement.children) : [treeElement];
+            let count = 0;
+            while (elements.length) {
+                let child = elements.pop();
+                if (child.hidden)
+                    continue;
 
-        let current = firstChild || treeElement;
-        let startIndex = treeOutline._indexOfTreeElement(current);
-        let endIndex = startIndex;
+                count++;
+                elements = elements.concat(child.children);
+            }
+            return count;
+        }
 
-        const skipUnrevealed = false;
-        const stayWithin = treeElement;
-        const dontPopulate = true;
-
-        while (current = current.traverseNextTreeElement(skipUnrevealed, stayWithin, dontPopulate))
-            endIndex++;
-
-        let count = endIndex - startIndex + 1;
-
+        let firstChild = treeElement.root ? treeElement.children[0] : treeElement;
+        let startIndex = treeOutline._indexOfTreeElement(firstChild);
+        let count = numberOfElementsInSubtree(treeElement);
         let indexes = new WI.IndexSet;
         indexes.addRange(startIndex, count);
-
         return indexes;
     }
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to