Changeset 221756 in webkit


Ignore:
Timestamp:
Sep 7, 2017 1:55:50 PM (7 years ago)
Author:
webkit@devinrousso.com
Message:

Web Inspector: Canvas RecordingAction tree outline virtualization is broken
https://bugs.webkit.org/show_bug.cgi?id=176547

Reviewed by Joseph Pecoraro.

  • UserInterface/Views/TreeOutline.js:

(WI.TreeOutline.prototype.updateVirtualizedElements.walk):
(WI.TreeOutline.prototype.updateVirtualizedElements):
Pass the current count to each recursive call of walk so that the cumulative index of a
TreeElement in any given sub-tree is correct.
Drive-by: if there is a focused TreeElement when scrolling, only change the current
scrollTop if it is not already visible. Also rewrote some loops for clarity.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r221748 r221756  
     12017-09-07  Devin Rousso  <webkit@devinrousso.com>
     2
     3        Web Inspector: Canvas RecordingAction tree outline virtualization is broken
     4        https://bugs.webkit.org/show_bug.cgi?id=176547
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * UserInterface/Views/TreeOutline.js:
     9        (WI.TreeOutline.prototype.updateVirtualizedElements.walk):
     10        (WI.TreeOutline.prototype.updateVirtualizedElements):
     11        Pass the current `count` to each recursive call of `walk` so that the cumulative index of a
     12        TreeElement in any given sub-tree is correct.
     13        Drive-by: if there is a focused TreeElement when scrolling, only change the current
     14        `scrollTop` if it is not already visible. Also rewrote some loops for clarity.
     15
    1162017-09-07  Devin Rousso  <webkit@devinrousso.com>
    217
  • trunk/Source/WebInspectorUI/UserInterface/Views/TreeOutline.js

    r220180 r221756  
    663663            return;
    664664
    665         function walk(parent, callback) {
    666             let count = 0;
     665        function walk(parent, callback, count = 0) {
    667666            let shouldReturn = false;
    668             for (let i = 0; i < parent.children.length; ++i) {
    669                 if (!parent.children[i].revealed(false))
     667            for (let child of parent.children) {
     668                if (!child.revealed(false))
    670669                    continue;
    671670
    672671                shouldReturn = callback({
    673672                    parent,
    674                     treeElement: parent.children[i],
     673                    treeElement: child,
    675674                    count,
    676675                });
     
    679678
    680679                ++count;
    681                 if (parent.children[i].expanded) {
    682                     let result = walk(parent.children[i], callback);
    683                     count += result.count;
     680                if (child.expanded) {
     681                    let result = walk(child, callback, count);
     682                    count = result.count;
    684683                    if (result.shouldReturn)
    685684                        break;
     
    694693        let lastItem = firstItem + numberVisible + (extraRows * 2);
    695694
     695        let shouldScroll = false;
    696696        if (focusedTreeElement && focusedTreeElement.revealed(false)) {
    697697            let index = walk(this, ({treeElement}) => treeElement === focusedTreeElement).count;
     
    703703                lastItem = index + extraRows;
    704704            }
     705
     706            shouldScroll = index < firstItem || index > lastItem;
    705707        }
    706708
    707709        let totalItems = walk(this, ({parent, treeElement, count}) => {
    708             if (count < firstItem || count > lastItem)
    709                 treeElement.element.remove();
    710             else {
     710            if (count >= firstItem && count <= lastItem) {
    711711                parent._childrenListNode.appendChild(treeElement.element);
    712712                if (treeElement._childrenListNode)
    713713                    parent._childrenListNode.appendChild(treeElement._childrenListNode);
    714             }
     714            } else
     715                treeElement.element.remove();
     716
    715717            return false;
    716718        }).count;
     
    722724        this.element.parentNode.insertBefore(this._virtualizedBottomSpacer, this.element.nextElementSibling);
    723725
    724         if (focusedTreeElement)
     726        if (shouldScroll)
    725727            this._virtualizedScrollContainer.scrollTop = (firstItem + extraRows) * this._virtualizedTreeItemHeight;
    726728    }
Note: See TracChangeset for help on using the changeset viewer.