Changeset 243242 in webkit
- Timestamp:
- Mar 20, 2019, 2:49:13 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/unit-tests/array-utilities-expected.txt (modified) (1 diff)
-
LayoutTests/inspector/unit-tests/array-utilities.html (modified) (1 diff)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Base/Utilities.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Views/TreeElement.js (modified) (5 diffs)
-
Source/WebInspectorUI/UserInterface/Views/TreeOutline.js (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243241 r243242 1 2019-03-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Debugger: virtualize the list of variables in the Scope sidebar 4 https://bugs.webkit.org/show_bug.cgi?id=192648 5 <rdar://problem/46800949> 6 7 Reviewed by Joseph Pecoraro. 8 9 * inspector/unit-tests/array-utilities.html: 10 * inspector/unit-tests/array-utilities-expected.txt: 11 1 12 2019-03-20 Dean Jackson <dino@apple.com> 2 13 -
trunk/LayoutTests/inspector/unit-tests/array-utilities-expected.txt
r240559 r243242 97 97 98 98 -- Running test case: Array.prototype.remove 99 PASS: remove should return true when removing a value that exists. 99 100 PASS: remove should only remove the first matching value. 101 PASS: remove should return true when removing a value that exists. 102 PASS: remove should return false when removing a value that does not exist. 100 103 PASS: remove should only remove values that strictly match. 104 PASS: remove should return false when removing a value that does not exist. 105 PASS: remove should return false when removing a value that does not exist. 106 PASS: remove should not affect the array if the value does not exist. 101 107 102 108 -- Running test case: Array.prototype.removeAll -
trunk/LayoutTests/inspector/unit-tests/array-utilities.html
r240559 r243242 214 214 test() { 215 215 let arr1 = [1, 2, 3, 1]; 216 arr1.remove(1);216 InspectorTest.expectThat(arr1.remove(1), "remove should return true when removing a value that exists."); 217 217 InspectorTest.expectShallowEqual(arr1, [2, 3, 1], "remove should only remove the first matching value."); 218 218 219 219 let arr2 = ["1", "2", 3, 1]; 220 arr2.remove("1");221 arr2.remove(2);220 InspectorTest.expectThat(arr2.remove("1"), "remove should return true when removing a value that exists."); 221 InspectorTest.expectFalse(arr2.remove(2), "remove should return false when removing a value that does not exist."); 222 222 InspectorTest.expectShallowEqual(arr2, ["2", 3, 1], "remove should only remove values that strictly match."); 223 223 224 return true; 224 let arr3 = [1, 2, 3]; 225 InspectorTest.expectFalse(arr3.remove("1"), "remove should return false when removing a value that does not exist."); 226 InspectorTest.expectFalse(arr3.remove(4), "remove should return false when removing a value that does not exist."); 227 InspectorTest.expectShallowEqual(arr3, [1, 2, 3], "remove should not affect the array if the value does not exist."); 225 228 } 226 229 }); -
trunk/Source/WebInspectorUI/ChangeLog
r243238 r243242 1 2019-03-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Debugger: virtualize the list of variables in the Scope sidebar 4 https://bugs.webkit.org/show_bug.cgi?id=192648 5 <rdar://problem/46800949> 6 7 Reviewed by Joseph Pecoraro. 8 9 * UserInterface/Views/ScopeChainDetailsSidebarPanel.js: 10 (WI.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection): 11 12 * UserInterface/Views/TreeElement.js: 13 (WI.TreeElement.prototype.set hidden): 14 (WI.TreeElement.prototype._attach): 15 (WI.TreeElement.prototype._detach): 16 (WI.TreeElement.prototype.collapse): 17 (WI.TreeElement.prototype.expand): 18 Move `updateVirtualizedElements` calls to the owner `WI.TreeOutline` to ensure that they get 19 called. Make the remaining calls use rAF debouncing to better coalesce updates. 20 21 * UserInterface/Views/TreeOutline.js: 22 (WI.TreeOutline.prototype._rememberTreeElement): 23 (WI.TreeOutline.prototype._forgetTreeElement): 24 (WI.TreeOutline.prototype.registerScrollVirtualizer): 25 (WI.TreeOutline.prototype._updateVirtualizedElements.calculateOffsetFromContainer): Added. 26 (WI.TreeOutline.prototype._updateVirtualizedElements): 27 (WI.TreeOutline.prototype._calculateVirtualizedValues): Deleted. 28 Calculate the `WI.TreeOutline`'s top offset within the scroll container so that it will only 29 update when it's within the visual area. 30 31 * UserInterface/Views/Utilities.js: 32 (Array.prototype.remove): 33 Return whether the item was actually removed from the array. 34 1 35 2019-03-20 Joseph Pecoraro <pecoraro@apple.com> 2 36 -
trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js
r242562 r243242 586 586 if (this[i] === value) { 587 587 this.splice(i, 1); 588 return ;588 return true; 589 589 } 590 590 } 591 return false; 591 592 } 592 593 }); -
trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js
r238005 r243242 262 262 263 263 let treeOutline = objectTree.treeOutline; 264 treeOutline.registerScrollVirtualizer(this.contentView.element, 16); 264 265 treeOutline.addEventListener(WI.TreeOutline.Event.ElementAdded, this._treeElementAdded.bind(this, detailsSectionIdentifier), this); 265 266 treeOutline.addEventListener(WI.TreeOutline.Event.ElementDisclosureDidChanged, this._treeElementDisclosureDidChange.bind(this, detailsSectionIdentifier), this); -
trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js
r242017 r243242 166 166 167 167 if (this.treeOutline) { 168 if (this.treeOutline.virtualized) { 169 let focusedTreeElement = null; 170 if (!this._hidden && this.selected) 171 focusedTreeElement = this; 172 this.treeOutline.updateVirtualizedElementsDebouncer.delayForTime(0, focusedTreeElement); 173 } 168 if (this.treeOutline.virtualized) 169 this.treeOutline.updateVirtualizedElementsDebouncer.delayForFrame(); 174 170 175 171 this.treeOutline.dispatchEventToListeners(WI.TreeOutline.Event.ElementVisibilityDidChange, {element: this}); … … 270 266 } 271 267 272 if (this.treeOutline && this.treeOutline.virtualized)273 this.treeOutline.updateVirtualizedElementsDebouncer.delayForTime(0);274 275 268 if (this.selected) 276 269 this.select(); … … 287 280 if (this._childrenListNode && this._childrenListNode.parentNode) 288 281 this._childrenListNode.parentNode.removeChild(this._childrenListNode); 289 290 if (this.treeOutline && this.treeOutline.virtualized)291 this.treeOutline.updateVirtualizedElementsDebouncer.delayForTime(0);292 282 } 293 283 … … 355 345 this.oncollapse(this); 356 346 357 if (this.treeOutline && this.treeOutline.virtualized) { 358 this.treeOutline.updateVirtualizedElementsDebouncer.delayForTime(0, this); 347 if (this.treeOutline) { 348 if (this.treeOutline.virtualized) 349 this.treeOutline.updateVirtualizedElementsDebouncer.delayForFrame(); 359 350 360 351 this.treeOutline.dispatchEventToListeners(WI.TreeOutline.Event.ElementDisclosureDidChanged, {element: this}); … … 422 413 this.onexpand(this); 423 414 424 if (this.treeOutline && this.treeOutline.virtualized) { 425 this.treeOutline.updateVirtualizedElementsDebouncer.delayForTime(0, this); 415 if (this.treeOutline) { 416 if (this.treeOutline.virtualized) 417 this.treeOutline.updateVirtualizedElementsDebouncer.delayForFrame(); 426 418 427 419 this.treeOutline.dispatchEventToListeners(WI.TreeOutline.Event.ElementDisclosureDidChanged, {element: this}); -
trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js
r242897 r243242 443 443 this._knownTreeElements[element.identifier] = []; 444 444 445 // check if the element is already known446 445 var elements = this._knownTreeElements[element.identifier]; 447 if (elements.indexOf(element) !== -1) 448 return; 449 450 // add the element 451 elements.push(element); 452 this._cachedNumberOfDescendents++; 446 if (!elements.includes(element)) { 447 elements.push(element); 448 this._cachedNumberOfDescendents++; 449 } 450 451 if (this.virtualized) 452 this._virtualizedDebouncer.delayForFrame(); 453 453 } 454 454 … … 459 459 this.selectedTreeElement = null; 460 460 } 461 461 462 if (this._knownTreeElements[element.identifier]) { 462 this._knownTreeElements[element.identifier].remove(element, true); 463 this._cachedNumberOfDescendents--; 464 } 463 if (this._knownTreeElements[element.identifier].remove(element)) 464 this._cachedNumberOfDescendents--; 465 } 466 467 if (this.virtualized) 468 this._virtualizedDebouncer.delayForFrame(); 465 469 } 466 470 … … 728 732 registerScrollVirtualizer(scrollContainer, treeItemHeight) 729 733 { 734 console.assert(scrollContainer); 730 735 console.assert(!isNaN(treeItemHeight)); 736 console.assert(!this.virtualized); 731 737 732 738 let boundUpdateVirtualizedElements = (focusedTreeElement) => { … … 746 752 throttler.fire(); 747 753 }); 754 755 this._updateVirtualizedElements(); 748 756 } 749 757 … … 964 972 } 965 973 966 _calculateVirtualizedValues()967 {968 let numberVisible = Math.ceil(this._virtualizedScrollContainer.offsetHeight / this._virtualizedTreeItemHeight);969 let extraRows = Math.max(numberVisible * 5, 50);970 let firstItem = Math.floor(this._virtualizedScrollContainer.scrollTop / this._virtualizedTreeItemHeight) - extraRows;971 let lastItem = firstItem + numberVisible + (extraRows * 2);972 return {973 numberVisible,974 extraRows,975 firstItem,976 lastItem,977 };978 }979 980 974 _updateVirtualizedElements(focusedTreeElement) 981 975 { 982 976 console.assert(this.virtualized); 977 978 this._virtualizedDebouncer.cancel(); 983 979 984 980 function walk(parent, callback, count = 0) { … … 1003 999 } 1004 1000 1005 let {numberVisible, extraRows, firstItem, lastItem} = this._calculateVirtualizedValues(); 1001 function calculateOffsetFromContainer(node, target) { 1002 let top = 0; 1003 while (node !== target) { 1004 top += node.offsetTop; 1005 node = node.offsetParent; 1006 if (!node) 1007 return 0; 1008 } 1009 return top; 1010 } 1011 1012 let offsetFromContainer = calculateOffsetFromContainer(this._virtualizedTopSpacer.parentNode ? this._virtualizedTopSpacer : this.element, this._virtualizedScrollContainer); 1013 let numberVisible = Math.ceil(Math.max(0, this._virtualizedScrollContainer.offsetHeight - offsetFromContainer) / this._virtualizedTreeItemHeight); 1014 let extraRows = Math.max(numberVisible * 5, 50); 1015 let firstItem = Math.floor((this._virtualizedScrollContainer.scrollTop - offsetFromContainer) / this._virtualizedTreeItemHeight) - extraRows; 1016 let lastItem = firstItem + numberVisible + (extraRows * 2); 1006 1017 1007 1018 let shouldScroll = false; … … 1031 1042 if (count >= firstItem + extraRows && count <= lastItem - extraRows) 1032 1043 visibleTreeElements.add(treeElement); 1033 } else if (treeElement. element.parentNode)1044 } else if (treeElement._listItemNode.parentNode) 1034 1045 treeElementsToDetach.add(treeElement); 1035 1046 … … 1051 1062 1052 1063 for (let treeElement of treeElementsToDetach) 1053 treeElement. element.remove();1064 treeElement._listItemNode.remove(); 1054 1065 1055 1066 for (let treeElement of treeElementsToAttach) { 1056 treeElement.parent._childrenListNode.appendChild(treeElement. element);1067 treeElement.parent._childrenListNode.appendChild(treeElement._listItemNode); 1057 1068 if (treeElement._childrenListNode) 1058 1069 treeElement.parent._childrenListNode.appendChild(treeElement._childrenListNode); 1059 1070 } 1060 1071 1061 this._virtualizedTopSpacer.style.height = ( Math.max(firstItem, 0) * this._virtualizedTreeItemHeight) + "px";1072 this._virtualizedTopSpacer.style.height = (Number.constrain(firstItem, 0, totalItems) * this._virtualizedTreeItemHeight) + "px"; 1062 1073 if (this.element.previousElementSibling !== this._virtualizedTopSpacer) 1063 1074 this.element.parentNode.insertBefore(this._virtualizedTopSpacer, this.element); 1064 1075 1065 this._virtualizedBottomSpacer.style.height = ( Math.max(totalItems - lastItem, 0) * this._virtualizedTreeItemHeight) + "px";1076 this._virtualizedBottomSpacer.style.height = (Number.constrain(totalItems - lastItem, 0, totalItems) * this._virtualizedTreeItemHeight) + "px"; 1066 1077 if (this.element.nextElementSibling !== this._virtualizedBottomSpacer) 1067 1078 this.element.parentNode.insertBefore(this._virtualizedBottomSpacer, this.element.nextElementSibling); 1068 1079 1069 1080 if (shouldScroll) 1070 this._virtualizedScrollContainer.scrollTop = (firstItem + extraRows) * this._virtualizedTreeItemHeight;1081 this._virtualizedScrollContainer.scrollTop = offsetFromContainer + ((firstItem + extraRows) * this._virtualizedTreeItemHeight); 1071 1082 } 1072 1083
Note:
See TracChangeset
for help on using the changeset viewer.