Title: [242577] trunk/Source/WebInspectorUI
Revision
242577
Author
mattba...@apple.com
Date
2019-03-06 16:09:23 -0800 (Wed, 06 Mar 2019)

Log Message

REGRESSION: Elements tab: Uncaught Exception: No node with given id found
https://bugs.webkit.org/show_bug.cgi?id=194299
<rdar://problem/47828647>

Reviewed by Devin Rousso.

When removing the selection, TreeOutline subclasses should have more
control over which item becomes selected after the selection is removed.
DOMTreeOutline should track the items that are being removed, and prevent
them or their descendants from becoming selected.

* UserInterface/Views/DOMTreeOutline.js:
(WI.DOMTreeOutline):
(WI.DOMTreeOutline.prototype.ondelete):
(WI.DOMTreeOutline.prototype.canSelectTreeElement):

* UserInterface/Views/TreeOutline.js:
(WI.TreeOutline.prototype.selectionControllerLastSelectableItem):
(WI.TreeOutline.prototype.selectionControllerPreviousSelectableItem):
(WI.TreeOutline.prototype.selectionControllerNextSelectableItem):
(WI.TreeOutline.prototype.canSelectTreeElement):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (242576 => 242577)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-03-07 00:06:47 UTC (rev 242576)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-03-07 00:09:23 UTC (rev 242577)
@@ -1,3 +1,27 @@
+2019-03-06  Matt Baker  <mattba...@apple.com>
+
+        REGRESSION: Elements tab: Uncaught Exception: No node with given id found
+        https://bugs.webkit.org/show_bug.cgi?id=194299
+        <rdar://problem/47828647>
+
+        Reviewed by Devin Rousso.
+
+        When removing the selection, TreeOutline subclasses should have more
+        control over which item becomes selected after the selection is removed.
+        DOMTreeOutline should track the items that are being removed, and prevent
+        them or their descendants from becoming selected.
+
+        * UserInterface/Views/DOMTreeOutline.js:
+        (WI.DOMTreeOutline):
+        (WI.DOMTreeOutline.prototype.ondelete):
+        (WI.DOMTreeOutline.prototype.canSelectTreeElement):
+
+        * UserInterface/Views/TreeOutline.js:
+        (WI.TreeOutline.prototype.selectionControllerLastSelectableItem):
+        (WI.TreeOutline.prototype.selectionControllerPreviousSelectableItem):
+        (WI.TreeOutline.prototype.selectionControllerNextSelectableItem):
+        (WI.TreeOutline.prototype.canSelectTreeElement):
+
 2019-03-06  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: CPU Usage Timeline - Allow clicking a bar in the overview to select a tight time range around it

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js (242576 => 242577)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js	2019-03-07 00:06:47 UTC (rev 242576)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js	2019-03-07 00:09:23 UTC (rev 242577)
@@ -49,6 +49,7 @@
         this._excludeRevealElementContextMenu = excludeRevealElementContextMenu;
         this._rootDOMNode = null;
         this._selectedDOMNode = null;
+        this._treeElementsToRemove = null;
 
         this._editable = false;
         this._editing = false;
@@ -284,7 +285,7 @@
         if (!this._editable)
             return false;
 
-        let selectedTreeElements = this.selectedTreeElements;
+        this._treeElementsToRemove = this.selectedTreeElements;
         this._selectionController.removeSelectedItems();
 
         let levelMap = new Map;
@@ -303,13 +304,13 @@
 
         // Sort in descending order by node level. This ensures that child nodes
         // are removed before their ancestors.
-        selectedTreeElements.sort((a, b) => getLevel(b) - getLevel(a));
+        this._treeElementsToRemove.sort((a, b) => getLevel(b) - getLevel(a));
 
         // Track removed elements, since the opening and closing tags for the
         // same WI.DOMNode can both be selected.
         let removedTreeElements = new Set;
 
-        for (let treeElement of selectedTreeElements) {
+        for (let treeElement of this._treeElementsToRemove) {
             if (removedTreeElements.has(treeElement))
                 continue;
             removedTreeElements.add(treeElement)
@@ -316,11 +317,29 @@
             treeElement.remove();
         }
 
+        this._treeElementsToRemove = null;
+
         return true;
     }
 
     // Protected
 
+    canSelectTreeElement(treeElement)
+    {
+        if (!super.canSelectTreeElement(treeElement))
+            return false;
+
+        let willRemoveAncestorOrSelf = false;
+        if (this._treeElementsToRemove) {
+            while (treeElement && !willRemoveAncestorOrSelf) {
+                willRemoveAncestorOrSelf = this._treeElementsToRemove.includes(treeElement);
+                treeElement = treeElement.parent;
+            }
+        }
+
+        return !willRemoveAncestorOrSelf;
+    }
+
     objectForSelection(treeElement)
     {
         if (treeElement instanceof WI.DOMTreeElement && treeElement.isCloseTag()) {

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js (242576 => 242577)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js	2019-03-07 00:06:47 UTC (rev 242576)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js	2019-03-07 00:09:23 UTC (rev 242577)
@@ -817,7 +817,7 @@
             treeElement = treeElement.children.lastValue;
 
         let item = this.objectForSelection(treeElement);
-        if (treeElement.selectable)
+        if (this.canSelectTreeElement(treeElement))
             return item;
         return this.selectionControllerPreviousSelectableItem(controller, item);
     }
@@ -834,7 +834,7 @@
         const dontPopulate = true;
 
         while (treeElement = treeElement.traversePreviousTreeElement(skipUnrevealed, stayWithin, dontPopulate)) {
-            if (treeElement.selectable)
+            if (this.canSelectTreeElement(treeElement))
                 return this.objectForSelection(treeElement);
         }
 
@@ -853,7 +853,7 @@
         const dontPopulate = true;
 
         while (treeElement = treeElement.traverseNextTreeElement(skipUnrevealed, stayWithin, dontPopulate)) {
-            if (treeElement.selectable)
+            if (this.canSelectTreeElement(treeElement))
                 return this.objectForSelection(treeElement);
         }
 
@@ -862,6 +862,13 @@
 
     // Protected
 
+    canSelectTreeElement(treeElement)
+    {
+        // Can be overridden by subclasses.
+
+        return treeElement.selectable;
+    }
+
     objectForSelection(treeElement)
     {
         return treeElement.representedObject;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to