Changeset 238602 in webkit
- Timestamp:
- Nov 27, 2018 10:49:34 PM (5 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r238599 r238602 1 2018-11-27 Matt Baker <mattbaker@apple.com> 2 3 Web Inspector: Elements tab should allow selecting/deleting multiple DOM nodes 4 https://bugs.webkit.org/show_bug.cgi?id=192059 5 <rdar://problem/46294827> 6 7 Reviewed by Devin Rousso. 8 9 Enable multiple DOM node selection in the DOMTreeContentView. 10 11 * UserInterface/Controllers/SelectionController.js: 12 (WI.SelectionController): 13 (WI.SelectionController.prototype.get allowsEmptySelection): 14 (WI.SelectionController.prototype.set allowsEmptySelection): 15 Allow clients to control whether the last selected item can be deselected. 16 (WI.SelectionController.prototype.deselectItem): 17 (WI.SelectionController.prototype.didInsertItem): 18 Rewritten to prevent infinite loop. 19 (WI.SelectionController.prototype.didRemoveItem): 20 (WI.SelectionController.prototype._updateSelectedItems): 21 (WI.SelectionController.prototype._adjustIndexesAfter): Deleted. 22 23 * UserInterface/Views/DOMTreeContentView.js: 24 (WI.DOMTreeContentView): 25 26 * UserInterface/Views/DOMTreeElement.js: 27 (WI.DOMTreeElement.prototype.updateSelectionArea): 28 * UserInterface/Views/DOMTreeOutline.js: 29 (WI.DOMTreeOutline.prototype.updateSelection): 30 Updating the selection area DOM element should not assume that only one 31 TreeElement is selected at a time. 32 33 * UserInterface/Views/TreeOutline.js: 34 (WI.TreeOutline.prototype.get allowsEmptySelection): 35 (WI.TreeOutline.prototype.set allowsEmptySelection): 36 (WI.TreeOutline.prototype.set selectedTreeElement): 37 (WI.TreeOutline.prototype.get selectedTreeElements): 38 (WI.TreeOutline.prototype._treeKeyDown): 39 40 * UserInterface/Views/TreeOutlineGroup.js: 41 (WI.TreeOutlineGroup): 42 (WI.TreeOutlineGroup.prototype._removeConflictingTreeSelections): 43 Eliminate use of `TreeElement.prototype.deselect`. 44 1 45 2018-11-27 Matt Baker <mattbaker@apple.com> 2 46 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/SelectionController.js
r238599 r238602 33 33 this._delegate = delegate; 34 34 35 this._allowsEmptySelection = true; 35 36 this._allowsMultipleSelection = false; 36 37 this._lastSelectedIndex = NaN; … … 49 50 get selectedItems() { return this._selectedIndexes; } 50 51 52 get allowsEmptySelection() { return this._allowsEmptySelection; } 53 set allowsEmptySelection(flag) { this._allowsEmptySelection = flag; } 54 51 55 get allowsMultipleSelection() 52 56 { … … 104 108 105 109 if (!this.hasSelectedItem(index)) 110 return; 111 112 if (!this._allowsEmptySelection && this._selectedIndexes.size === 1) 106 113 return; 107 114 … … 195 202 didInsertItem(index) 196 203 { 197 this._adjustIndexesAfter(index - 1, 1); 204 let current = this._selectedIndexes.lastIndex; 205 while (current >= index) { 206 this._selectedIndexes.delete(index); 207 this._selectedIndexes.add(index + 1); 208 209 current = this._selectedIndexes.indexLessThan(current); 210 } 198 211 } 199 212 … … 203 216 this.deselectItem(index); 204 217 205 this._adjustIndexesAfter(index, -1); 218 while (index = this._selectedIndexes.indexGreaterThan(index)) { 219 this._selectedIndexes.delete(index); 220 this._selectedIndexes.add(index - 1); 221 } 206 222 } 207 223 … … 375 391 this._delegate.selectionControllerSelectionDidChange(this, deselectedItems, selectedItems); 376 392 } 377 378 _adjustIndexesAfter(index, delta)379 {380 while (index = this._selectedIndexes.indexGreaterThan(index)) {381 this._selectedIndexes.delete(index);382 this._selectedIndexes.add(index + delta);383 }384 }385 393 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js
r238570 r238602 65 65 66 66 this._domTreeOutline = new WI.DOMTreeOutline(true, true, true); 67 this._domTreeOutline.allowsEmptySelection = false; 68 this._domTreeOutline.allowsMultipleSelection = true; 67 69 this._domTreeOutline.addEventListener(WI.TreeOutline.Event.ElementAdded, this._domTreeElementAdded, this); 68 70 this._domTreeOutline.addEventListener(WI.DOMTreeOutline.Event.SelectedNodeChanged, this._selectedNodeDidChange, this); -
trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js
r238599 r238602 368 368 369 369 // If there's no reason to have a selection area, remove the DOM element. 370 let indicatesTreeOutlineState = this.treeOutline && (this.treeOutline.dragOverTreeElement === this || this. treeOutline.selectedTreeElement === this|| this._animatingHighlight);370 let indicatesTreeOutlineState = this.treeOutline && (this.treeOutline.dragOverTreeElement === this || this.selected || this._animatingHighlight); 371 371 if (!this.hovered && !this.pseudoClassesEnabled && !indicatesTreeOutlineState) { 372 372 if (this._selectionElement) { -
trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js
r238599 r238602 192 192 // The hovered element will update when user moves the mouse, and indicators don't need the 193 193 // selection area height to be accurate since they use ::before to place the indicator. 194 if (this.selectedTreeElement) 195 this.selectedTreeElement.updateSelectionArea(); 194 let selectedTreeElements = this.selectedTreeElements; 195 for (let treeElement of selectedTreeElements) 196 treeElement.updateSelectionArea(); 196 197 } 197 198 -
trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js
r238599 r238602 82 82 // Public 83 83 84 get allowsEmptySelection() 85 { 86 return this._selectionController.allowsEmptySelection; 87 } 88 89 set allowsEmptySelection(flag) 90 { 91 this._selectionController.allowsEmptySelection = flag; 92 } 93 84 94 get allowsMultipleSelection() 85 95 { … … 100 110 set selectedTreeElement(treeElement) 101 111 { 102 let index = this._indexOfTreeElement(treeElement); 103 this._selectionController.selectItem(index); 112 if (treeElement) { 113 let index = this._indexOfTreeElement(treeElement); 114 this._selectionController.selectItem(index); 115 } else 116 this._selectionController.deselectAll(); 117 } 118 119 get selectedTreeElements() 120 { 121 if (this.allowsMultipleSelection) { 122 let treeElements = []; 123 for (let index of this._selectionController.selectedItems) 124 treeElements.push(this._treeElementAtIndex(index)); 125 return treeElements; 126 } 127 128 let selectedTreeElement = this.selectedTreeElement; 129 if (selectedTreeElement) 130 return [selectedTreeElement]; 131 132 return []; 104 133 } 105 134 … … 608 637 } 609 638 } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 /* Delete */) { 610 if (this.selectedTreeElement.ondelete) 611 handled = this.selectedTreeElement.ondelete(); 639 for (let treeElement of this.selectedTreeElements) { 640 if (treeElement.ondelete && treeElement.ondelete()) 641 handled = true; 642 } 612 643 if (!handled && this.treeOutline.ondelete) 613 644 handled = this.treeOutline.ondelete(this.selectedTreeElement); -
trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutlineGroup.js
r231391 r238602 88 88 continue; 89 89 90 if (treeOutline.selectedTreeElement) 91 treeOutline.selectedTreeElement.deselect(); 90 treeOutline.selectedTreeElement = null; 92 91 } 93 92 }
Note: See TracChangeset
for help on using the changeset viewer.