Changeset 239870 in webkit


Ignore:
Timestamp:
Jan 11, 2019 1:02:28 PM (5 years ago)
Author:
Matt Baker
Message:

Web Inspector: REGRESSION: deleting an audit puts selection in a selected but invisible state
https://bugs.webkit.org/show_bug.cgi?id=192917
<rdar://problem/46875285>

Reviewed by Devin Rousso.

SelectionController should not be notified of removed children until the
child items have been removed from the TreeOutline. Doing so at this stage
is unsafe, since this method checks this.selectedTreeElement, which could
return the adjusted index from the SelectionController before anything has
actually been removed from the TreeOutline.

The number of calls to SelectionController.prototype.didRemoveItems is also
reduced somewhat, since we're no longer calling it for every TreeElement.

  • UserInterface/Views/TreeOutline.js:

(WI.TreeOutline.prototype.removeChildAtIndex):
(WI.TreeOutline.prototype.removeChildren):
(WI.TreeOutline.prototype._forgetTreeElement):
(WI.TreeOutline.prototype._indexesForSubtree): Added.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r239858 r239870  
     12019-01-11  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: REGRESSION: deleting an audit puts selection in a selected but invisible state
     4        https://bugs.webkit.org/show_bug.cgi?id=192917
     5        <rdar://problem/46875285>
     6
     7        Reviewed by Devin Rousso.
     8
     9        SelectionController should not be notified of removed children until the
     10        child items have been removed from the TreeOutline. Doing so at this stage
     11        is unsafe, since this method checks `this.selectedTreeElement`, which could
     12        return the adjusted index from the SelectionController before anything has
     13        actually been removed from the TreeOutline.
     14
     15        The number of calls to SelectionController.prototype.didRemoveItems is also
     16        reduced somewhat, since we're no longer calling it for every TreeElement.
     17
     18        * UserInterface/Views/TreeOutline.js:
     19        (WI.TreeOutline.prototype.removeChildAtIndex):
     20        (WI.TreeOutline.prototype.removeChildren):
     21        (WI.TreeOutline.prototype._forgetTreeElement):
     22        (WI.TreeOutline.prototype._indexesForSubtree): Added.       
     23
    1242019-01-10  Devin Rousso  <drousso@apple.com>
    225
  • trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js

    r239405 r239870  
    330330        }
    331331
     332        let removedIndexes = this._indexesForSubtree(child);
     333
    332334        if (child.previousSibling)
    333335            child.previousSibling.nextSibling = child.nextSibling;
     
    343345        child.previousSibling = null;
    344346
    345         if (treeOutline)
     347        if (treeOutline) {
     348            treeOutline._selectionController.didRemoveItems(removedIndexes);
    346349            treeOutline.dispatchEventToListeners(WI.TreeOutline.Event.ElementRemoved, {element: child});
     350        }
    347351    }
    348352
     
    379383            }
    380384
     385            let removedIndexes = treeOutline._indexesForSubtree(child);
     386
    381387            child._detach();
    382388            child.treeOutline = null;
     
    385391            child.previousSibling = null;
    386392
    387             if (treeOutline)
     393            this.children.shift();
     394
     395            if (treeOutline) {
     396                treeOutline._selectionController.didRemoveItems(removedIndexes);
    388397                treeOutline.dispatchEventToListeners(WI.TreeOutline.Event.ElementRemoved, {element: child});
    389 
    390             this.children.shift();
     398            }
    391399        }
    392400    }
     
    420428        }
    421429        if (this._knownTreeElements[element.identifier]) {
    422             let index = this._indexOfTreeElement(element);
    423             if (index >= 0)
    424                 this._selectionController.didRemoveItems(new WI.IndexSet([index]));
    425 
    426430            this._knownTreeElements[element.identifier].remove(element, true);
    427431            this._cachedNumberOfDescendents--;
     
    10731077        this.dispatchEventToListeners(WI.TreeOutline.Event.SelectionDidChange, {selectedByUser});
    10741078    }
     1079
     1080    _indexesForSubtree(treeElement)
     1081    {
     1082        let treeOutline = treeElement.treeOutline;
     1083        if (!treeOutline)
     1084            return new WI.IndexSet;
     1085
     1086        let firstChild = treeElement.children[0];
     1087        if (!firstChild)
     1088            return new WI.IndexSet;
     1089
     1090        let startIndex = treeOutline._indexOfTreeElement(firstChild);
     1091        let endIndex = startIndex;
     1092
     1093        const skipUnrevealed = false;
     1094        const stayWithin = treeElement;
     1095        const dontPopulate = true;
     1096
     1097        let current = firstChild;
     1098        while (current = current.traverseNextTreeElement(skipUnrevealed, stayWithin, dontPopulate))
     1099            endIndex++;
     1100
     1101        // Include the index of the subtree's root, unless it's the TreeOutline root.
     1102        if (!treeElement.root)
     1103            startIndex--;
     1104
     1105        let count = endIndex - startIndex + 1;
     1106
     1107        let indexes = new WI.IndexSet;
     1108        indexes.addRange(startIndex, count);
     1109
     1110        return indexes;
     1111    }
    10751112};
    10761113
Note: See TracChangeset for help on using the changeset viewer.