Changeset 201840 in webkit
- Timestamp:
- Jun 8, 2016, 4:04:11 PM (10 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
UserInterface/Views/DOMTreeElement.js (modified) (11 diffs)
-
UserInterface/Views/DOMTreeOutline.css (modified) (4 diffs)
-
UserInterface/Views/DOMTreeOutline.js (modified) (6 diffs)
-
UserInterface/Views/FormattedValue.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r201839 r201840 1 2016-06-08 Brian Burg <bburg@apple.com> 2 3 Web Inspector: DOMTreeOutline selection areas should be created and updated lazily 4 https://bugs.webkit.org/show_bug.cgi?id=158513 5 <rdar://problem/26689646> 6 7 Reviewed by Timothy Hatcher. 8 9 Selection areas for DOMTreeElements are used for several things: drag markers, 10 element hover styles, element selection styles, and showing forced pseudo states 11 for an element. Fortunately it's easy to tell when any of these things is necessary. 12 13 Change DOMTreeOutline and DOMTreeElement so they don't create selection areas 14 unless they are needed for one of these tasks. This significantly reduces 15 forced layouts that are required to update the selection area height in case the 16 element has new attributes that cause the tag to become more or less wrapped. 17 18 * UserInterface/Views/DOMTreeElement.js: 19 (WebInspector.DOMTreeElement.prototype.set hovered): 20 Modernize this method a bit. 21 22 (WebInspector.DOMTreeElement.prototype.updateSelectionArea): 23 If a selection area is not necessary, don't create one. 24 If one exists and it's not needed, then remove it. 25 26 (WebInspector.DOMTreeElement.prototype.onattach): 27 Remove redundant calls to updateSelection(). This is already called in 28 updateTitle(). 29 30 (WebInspector.DOMTreeElement.prototype.onselect): 31 Ask the DOMTreeOutline to update the selection rather than forcing the 32 element to do it. This is consistent with other updates to user selection. 33 34 (WebInspector.DOMTreeElement.prototype._insertInLastAttributePosition): 35 (WebInspector.DOMTreeElement.prototype._startEditingAsHTML.dispose): 36 (WebInspector.DOMTreeElement.prototype._startEditingAsHTML): 37 Use renamed method. 38 39 (WebInspector.DOMTreeElement.prototype.updateTitle): 40 Add a comment to explain why the selection area is nulled out here. 41 42 (WebInspector.DOMTreeElement.prototype.get pseudoClassesEnabled): 43 (WebInspector.DOMTreeElement.prototype._nodePseudoClassesDidChange): 44 Update the selection area in case one does not exist for this tree element. 45 The indicator for forced pseudo classes is a pseudo element of the selection area. 46 47 (WebInspector.DOMTreeElement.prototype.updateSelection): Renamed. 48 (WebInspector.DOMTreeElement.prototype.onexpand): 49 (WebInspector.DOMTreeElement.prototype.oncollapse): 50 Remove redundant calls to updateSelection(). This is already called in 51 updateTitle(). 52 53 * UserInterface/Views/DOMTreeOutline.css: 54 (.tree-outline.dom): 55 (.tree-outline.dom li.hovered:not(.selected) .selection-area): 56 (.tree-outline.dom li .selection-area): 57 (.tree-outline.dom li.selected .selection-area): 58 (.tree-outline.dom li.elements-drag-over .selection-area): 59 (.tree-outline.dom:focus li.selected .selection-area): 60 (.tree-outline.dom li.pseudo-class-enabled > .selection-area::before): 61 (.tree-outline.dom:focus li.selected.pseudo-class-enabled > .selection-area::before): 62 (.tree-outline.dom li.hovered:not(.selected) .selection): Deleted. 63 (.tree-outline.dom li .selection): Deleted. 64 (.tree-outline.dom li.selected .selection): Deleted. 65 (.tree-outline.dom li.elements-drag-over .selection): Deleted. 66 (.tree-outline.dom:focus li.selected .selection): Deleted. 67 (.tree-outline.dom li.pseudo-class-enabled > .selection::before): Deleted. 68 (.tree-outline.dom:focus li.selected.pseudo-class-enabled > .selection::before): Deleted. 69 Rename the selector to be less ambiguous. 70 71 * UserInterface/Views/DOMTreeOutline.js: 72 (WebInspector.DOMTreeOutline.prototype.updateSelection): Simplify. The call 73 to update the selection area will bail out if there is nothing to be done. 74 75 (WebInspector.DOMTreeOutline.prototype.findTreeElement): 76 (WebInspector.DOMTreeOutline.prototype._onmousemove): 77 (WebInspector.DOMTreeOutline.prototype._onmouseout): 78 Clean up and use let and arrow functions. 79 80 (WebInspector.DOMTreeOutline.prototype._ondragover): 81 (WebInspector.DOMTreeOutline.prototype._clearDragOverTreeElementMarker): 82 Clear the dragging element before updating the selection area since it looks at 83 the dragging element to determine whether anything needs to be done. 84 85 * UserInterface/Views/FormattedValue.css: 86 (.formatted-node > .tree-outline.dom li.hovered:not(.selected) .selection-area): 87 (.formatted-node > .tree-outline.dom li.hovered:not(.selected) .selection): Deleted. 88 Rename the selector to be less ambiguous. 89 1 90 2016-06-08 Brian Burg <bburg@apple.com> 2 91 -
trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js
r201833 r201840 145 145 } 146 146 147 set hovered( x)148 { 149 if (this._hovered === x)150 return; 151 152 this._hovered = x;147 set hovered(value) 148 { 149 if (this._hovered === value) 150 return; 151 152 this._hovered = value; 153 153 154 154 if (this.listItemElement) { 155 if (x) { 156 this.updateSelection(); 157 this.listItemElement.classList.add("hovered"); 158 } else { 159 this.listItemElement.classList.remove("hovered"); 160 } 155 this.listItemElement.classList.toggle("hovered", this._hovered); 156 this.updateSelectionArea(); 161 157 } 162 158 } … … 263 259 } 264 260 265 updateSelection ()266 { 267 varlistItemElement = this.listItemElement;261 updateSelectionArea() 262 { 263 let listItemElement = this.listItemElement; 268 264 if (!listItemElement) 269 265 return; 270 266 271 if (!this.selectionElement) { 272 this.selectionElement = document.createElement("div"); 273 this.selectionElement.className = "selection selected"; 274 listItemElement.insertBefore(this.selectionElement, listItemElement.firstChild); 275 } 276 277 this.selectionElement.style.height = listItemElement.offsetHeight + "px"; 267 // If there's no reason to have a selection area, remove the DOM element. 268 let indicatesTreeOutlineState = this.treeOutline && (this.treeOutline.dragOverTreeElement === this || this.treeOutline.selectedTreeElement === this); 269 if (!this.hovered && !this.pseudoClassesEnabled && !indicatesTreeOutlineState) { 270 if (this._selectionElement) { 271 this._selectionElement.remove(); 272 this._selectionElement = null; 273 } 274 275 return; 276 } 277 278 if (!this._selectionElement) { 279 this._selectionElement = document.createElement("div"); 280 this._selectionElement.className = "selection-area"; 281 listItemElement.insertBefore(this._selectionElement, listItemElement.firstChild); 282 } 283 284 this._selectionElement.style.height = listItemElement.offsetHeight + "px"; 278 285 } 279 286 280 287 onattach() 281 288 { 282 if (this._hovered) { 283 this.updateSelection(); 289 if (this.hovered) 284 290 this.listItemElement.classList.add("hovered"); 285 }286 291 287 292 this.updateTitle(); … … 485 490 486 491 this.updateTitle(); 487 this.treeOutline.updateSelection();488 492 } 489 493 … … 494 498 495 499 this.updateTitle(); 496 this.treeOutline.updateSelection();497 500 } 498 501 … … 514 517 if (selectedByUser) 515 518 WebInspector.domTreeManager.highlightDOMNode(this.representedObject.id); 516 this. updateSelection();519 this.treeOutline.updateSelection(); 517 520 this.treeOutline.suppressRevealAndSelect = false; 518 521 } … … 589 592 } 590 593 591 this.updateSelection ();594 this.updateSelectionArea(); 592 595 } 593 596 … … 855 858 this.listItemElement.appendChild(this._htmlEditElement); 856 859 857 this.updateSelection ();860 this.updateSelectionArea(); 858 861 859 862 function commit() … … 880 883 } 881 884 882 this.updateSelection ();885 this.updateSelectionArea(); 883 886 } 884 887 … … 1074 1077 } 1075 1078 1076 this.selectionElement = null; 1077 this.updateSelection(); 1079 // Setting this.title will implicitly remove all children. Clear the 1080 // selection element so that we properly recreate it if necessary. 1081 this._selectionElement = null; 1082 this.updateSelectionArea(); 1078 1083 this._highlightSearchResults(); 1079 1084 } … … 1519 1524 } 1520 1525 1526 get pseudoClassesEnabled() 1527 { 1528 return !!this.representedObject.enabledPseudoClasses.length; 1529 } 1530 1521 1531 _nodePseudoClassesDidChange(event) 1522 1532 { … … 1524 1534 return; 1525 1535 1536 this.updateSelectionArea(); 1526 1537 this._listItemNode.classList.toggle("pseudo-class-enabled", !!this.representedObject.enabledPseudoClasses.length); 1527 1538 } -
trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.css
r201454 r201840 35 35 list-style-type: none; 36 36 37 /* Needed to make the negative z-index on .selection works. Otherwise the background-color from .syntax-highlighted hides the selection. */37 /* Needed to make the negative z-index on .selection-area works. Otherwise the background-color from .syntax-highlighted hides the selection. */ 38 38 background-color: transparent !important; 39 39 color: black; 40 40 } 41 41 42 .tree-outline.dom li.hovered:not(.selected) .selection {42 .tree-outline.dom li.hovered:not(.selected) .selection-area { 43 43 background-color: hsla(209, 100%, 49%, 0.1); 44 44 } 45 45 46 .tree-outline.dom li .selection {46 .tree-outline.dom li .selection-area { 47 47 position: absolute; 48 48 left: 0; … … 52 52 } 53 53 54 .tree-outline.dom li.selected .selection {54 .tree-outline.dom li.selected .selection-area { 55 55 background-color: hsl(0, 0%, 83%); 56 56 } 57 57 58 .tree-outline.dom li.elements-drag-over .selection {58 .tree-outline.dom li.elements-drag-over .selection-area { 59 59 margin-top: -2px; 60 60 border-top: 2px solid hsl(209, 100%, 49%); 61 61 } 62 62 63 .tree-outline.dom:focus li.selected .selection {63 .tree-outline.dom:focus li.selected .selection-area { 64 64 background-color: hsl(209, 100%, 49%); 65 65 } … … 110 110 } 111 111 112 .tree-outline.dom li.pseudo-class-enabled > .selection ::before {112 .tree-outline.dom li.pseudo-class-enabled > .selection-area::before { 113 113 display: inline-block; 114 114 position: absolute; … … 130 130 } 131 131 132 .tree-outline.dom:focus li.selected.pseudo-class-enabled > .selection ::before {132 .tree-outline.dom:focus li.selected.pseudo-class-enabled > .selection-area::before { 133 133 background-color: hsl(0, 100%, 100%); 134 134 } -
trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js
r200539 r201840 190 190 updateSelection() 191 191 { 192 if (!this.selectedTreeElement) 193 return; 194 var element = this.treeOutline.selectedTreeElement; 195 element.updateSelection(); 192 // This will miss updating selection areas used for the hovered tree element and 193 // and those used to show forced pseudo class indicators, but this should be okay. 194 // The hovered element will update when user moves the mouse, and indicators don't need the 195 // selection area height to be accurate since they use ::before to place the indicator. 196 if (this.selectedTreeElement) 197 this.selectedTreeElement.updateSelectionArea(); 196 198 } 197 199 … … 203 205 findTreeElement(node) 204 206 { 205 function isAncestorNode(ancestor, node) 206 { 207 return ancestor.isAncestor(node); 208 } 209 210 function parentNode(node) 211 { 212 return node.parentNode; 213 } 214 215 var treeElement = super.findTreeElement(node, isAncestorNode, parentNode); 207 let isAncestorNode = (ancestor, node) => ancestor.isAncestor(node); 208 let parentNode = (node) => node.parentNode; 209 let treeElement = super.findTreeElement(node, isAncestorNode, parentNode); 216 210 if (!treeElement && node.nodeType() === Node.TEXT_NODE) { 217 211 // The text node might have been inlined if it was short, so try to find the parent element. … … 342 336 if (this._previousHoveredElement) { 343 337 this._previousHoveredElement.hovered = false; 344 delete this._previousHoveredElement;338 this._previousHoveredElement = null; 345 339 } 346 340 … … 365 359 if (this._previousHoveredElement) { 366 360 this._previousHoveredElement.hovered = false; 367 delete this._previousHoveredElement;361 this._previousHoveredElement = null; 368 362 } 369 363 … … 408 402 } 409 403 410 t reeElement.updateSelection();404 this.dragOverTreeElement = treeElement; 411 405 treeElement.listItemElement.classList.add("elements-drag-over"); 412 this._dragOverTreeElement = treeElement; 406 treeElement.updateSelectionArea(); 407 413 408 event.preventDefault(); 414 409 event.dataTransfer.dropEffect = "move"; … … 482 477 _clearDragOverTreeElementMarker() 483 478 { 484 if (this._dragOverTreeElement) { 485 this._dragOverTreeElement.updateSelection(); 486 this._dragOverTreeElement.listItemElement.classList.remove("elements-drag-over"); 487 delete this._dragOverTreeElement; 479 if (this.dragOverTreeElement) { 480 let element = this.dragOverTreeElement; 481 this.dragOverTreeElement = null; 482 483 element.listItemElement.classList.remove("elements-drag-over"); 484 element.updateSelectionArea(); 488 485 } 489 486 } -
trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.css
r195303 r201840 77 77 } 78 78 79 .formatted-node > .tree-outline.dom li.hovered:not(.selected) .selection {79 .formatted-node > .tree-outline.dom li.hovered:not(.selected) .selection-area { 80 80 display: block; 81 81 left: -1px;
Note:
See TracChangeset
for help on using the changeset viewer.