Changeset 217317 in webkit


Ignore:
Timestamp:
May 23, 2017 6:09:18 PM (7 years ago)
Author:
Matt Baker
Message:

Web Inspector: content views are not restored on reload if its tree element is filtered out
https://bugs.webkit.org/show_bug.cgi?id=165744
<rdar://problem/27461323>

Reviewed by Devin Rousso.

By default, NavigationSidebar should get the selected represented object
from its content browser, instead of relying on the tree selection. This
allows a filtered tree selection to persist across page loads.

  • UserInterface/Views/NavigationSidebarPanel.js:

(WebInspector.NavigationSidebarPanel.prototype.get currentRepresentedObject):
(WebInspector.NavigationSidebarPanel.prototype.saveStateToCookie):
Get the represented object from the content browser instead of relying
on the tree selection (which can be filtered out).

(WebInspector.NavigationSidebarPanel.prototype._updateFilter):
(WebInspector.NavigationSidebarPanel.prototype._treeElementAddedOrChanged):
(WebInspector.NavigationSidebarPanel.prototype._treeElementWasFiltered):
Reselect the represented object's tree element when it is shown due
to a change in the filter state.

(WebInspector.NavigationSidebarPanel.prototype.get hasSelectedElement): Deleted.
Not used.
(WebInspector.NavigationSidebarPanel.prototype.representedObjectWasFiltered): Deleted.
Not used. Replaced by _treeElementWasFiltered.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r217306 r217317  
     12017-05-23  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: content views are not restored on reload if its tree element is filtered out
     4        https://bugs.webkit.org/show_bug.cgi?id=165744
     5        <rdar://problem/27461323>
     6
     7        Reviewed by Devin Rousso.
     8
     9        By default, NavigationSidebar should get the selected represented object
     10        from its content browser, instead of relying on the tree selection. This
     11        allows a filtered tree selection to persist across page loads.
     12
     13        * UserInterface/Views/NavigationSidebarPanel.js:
     14        (WebInspector.NavigationSidebarPanel.prototype.get currentRepresentedObject):
     15        (WebInspector.NavigationSidebarPanel.prototype.saveStateToCookie):
     16        Get the represented object from the content browser instead of relying
     17        on the tree selection (which can be filtered out).
     18
     19        (WebInspector.NavigationSidebarPanel.prototype._updateFilter):
     20        (WebInspector.NavigationSidebarPanel.prototype._treeElementAddedOrChanged):
     21        (WebInspector.NavigationSidebarPanel.prototype._treeElementWasFiltered):
     22        Reselect the represented object's tree element when it is shown due
     23        to a change in the filter state.
     24
     25        (WebInspector.NavigationSidebarPanel.prototype.get hasSelectedElement): Deleted.
     26        Not used.
     27        (WebInspector.NavigationSidebarPanel.prototype.representedObjectWasFiltered): Deleted.
     28        Not used. Replaced by _treeElementWasFiltered.
     29
    1302017-05-23  Matt Baker  <mattbaker@apple.com>
    231
  • trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js

    r217258 r217317  
    101101    }
    102102
    103     get hasSelectedElement()
    104     {
    105         return !!this._contentTreeOutlineGroup.selectedTreeElement
     103    get currentRepresentedObject()
     104    {
     105        if (!this._contentBrowser)
     106            return null;
     107
     108        return this._contentBrowser.currentRepresentedObjects[0] || null;
    106109    }
    107110
     
    205208        console.assert(cookie);
    206209
    207         // This does not save folder selections, which lack a represented object and content view.
    208         var selectedTreeElement = null;
    209         this.contentTreeOutlines.forEach(function(outline) {
    210             if (outline.selectedTreeElement)
    211                 selectedTreeElement = outline.selectedTreeElement;
    212         });
    213 
    214         if (!selectedTreeElement)
    215             return;
    216 
    217         if (this._isTreeElementWithoutRepresentedObject(selectedTreeElement))
    218             return;
    219 
    220         var representedObject = selectedTreeElement.representedObject;
     210        if (!this._contentBrowser)
     211            return;
     212
     213        let representedObject = this.currentRepresentedObject;
     214        if (!representedObject)
     215            return;
     216
    221217        cookie[WebInspector.TypeIdentifierCookieKey] = representedObject.constructor.TypeIdentifier;
    222218
    223         if (representedObject.saveIdentityToCookie)
     219        if (representedObject.saveIdentityToCookie) {
    224220            representedObject.saveIdentityToCookie(cookie);
    225         else
    226             console.error("Error: TreeElement.representedObject is missing a saveIdentityToCookie implementation. TreeElement.constructor: ", selectedTreeElement.constructor);
     221            return;
     222        }
     223
     224        console.error("NavigationSidebarPanel representedObject is missing a saveIdentityToCookie implementation.", representedObject);
    227225    }
    228226
     
    426424    // Protected
    427425
    428     representedObjectWasFiltered(representedObject, filtered)
    429     {
    430         // Implemented by subclasses if needed.
    431     }
    432 
    433426    pruneStaleResourceTreeElements()
    434427    {
     
    571564                    this.applyFiltersToTreeElement(currentTreeElement);
    572565                    if (currentTreeElementWasHidden !== currentTreeElement.hidden)
    573                         this.representedObjectWasFiltered(currentTreeElement.representedObject, currentTreeElement.hidden);
     566                        this._treeElementWasFiltered(currentTreeElement);
    574567                }
    575568
     
    596589                this.applyFiltersToTreeElement(currentTreeElement);
    597590                if (currentTreeElementWasHidden !== currentTreeElement.hidden)
    598                     this.representedObjectWasFiltered(currentTreeElement.representedObject, currentTreeElement.hidden);
     591                    this._treeElementWasFiltered(currentTreeElement);
    599592            }
    600593
     
    746739        return emptyContentPlaceholderElement;
    747740    }
     741
     742    _treeElementWasFiltered(treeElement)
     743    {
     744        if (treeElement.selected || treeElement.hidden)
     745            return;
     746
     747        let representedObject = this.currentRepresentedObject;
     748        if (!representedObject || treeElement.representedObject !== representedObject)
     749            return;
     750
     751        const omitFocus = true;
     752        const selectedByUser = false;
     753        const suppressOnSelect = true;
     754        const suppressOnDeselect = true;
     755        treeElement.revealAndSelect(omitFocus, selectedByUser, suppressOnSelect, suppressOnDeselect);
     756    }
    748757};
    749758
Note: See TracChangeset for help on using the changeset viewer.