Title: [282610] trunk/Source/WebInspectorUI
Revision
282610
Author
[email protected]
Date
2021-09-16 15:35:25 -0700 (Thu, 16 Sep 2021)

Log Message

Web Inspector: Don't maintain a back-forward stack for `ContentBrowser`/`ContentViewContainer` when not necessary
https://bugs.webkit.org/show_bug.cgi?id=230286

Reviewed by Devin Rousso.

We currently maintain a back/forward stack for all ContentViewContainers, even if other history entries won't be
used. Instead, subclasses of ContentBrowserTabContentView should be able to disable the history stack, which
helps us ensure that outdated content views are not kept around for these subclasses and their views.

This does not line up one-to-one with views that hide the back/forward buttons, as the back/forward stack is
used in some places to provide a memory of selection across different views, like in the Graphics tab.

* UserInterface/Views/AuditTabContentView.js:
(WI.AuditTabContentView):
* UserInterface/Views/ConsoleTabContentView.js:
(WI.ConsoleTabContentView):
* UserInterface/Views/ContentBrowser.js:
* UserInterface/Views/ContentBrowserTabContentView.js:
* UserInterface/Views/ContentViewContainer.js:
(WI.ContentViewContainer.prototype.showContentView):
(WI.ContentViewContainer.prototype.replaceContentView):
* UserInterface/Views/ElementsTabContentView.js:
(WI.ElementsTabContentView):
* UserInterface/Views/GraphicsTabContentView.js:
(WI.GraphicsTabContentView):
* UserInterface/Views/LayersTabContentView.js:
(WI.LayersTabContentView):
* UserInterface/Views/NetworkDetailView.js:
(WI.NetworkDetailView.prototype.initialLayout):
* UserInterface/Views/NetworkTabContentView.js:
(WI.NetworkTabContentView):
* UserInterface/Views/TimelineRecordingContentView.js:
(WI.TimelineRecordingContentView):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (282609 => 282610)


--- trunk/Source/WebInspectorUI/ChangeLog	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/ChangeLog	2021-09-16 22:35:25 UTC (rev 282610)
@@ -1,5 +1,41 @@
 2021-09-16  Patrick Angle  <[email protected]>
 
+        Web Inspector: Don't maintain a back-forward stack for `ContentBrowser`/`ContentViewContainer` when not necessary
+        https://bugs.webkit.org/show_bug.cgi?id=230286
+
+        Reviewed by Devin Rousso.
+
+        We currently maintain a back/forward stack for all ContentViewContainers, even if other history entries won't be
+        used. Instead, subclasses of ContentBrowserTabContentView should be able to disable the history stack, which
+        helps us ensure that outdated content views are not kept around for these subclasses and their views.
+
+        This does not line up one-to-one with views that hide the back/forward buttons, as the back/forward stack is
+        used in some places to provide a memory of selection across different views, like in the Graphics tab.
+
+        * UserInterface/Views/AuditTabContentView.js:
+        (WI.AuditTabContentView):
+        * UserInterface/Views/ConsoleTabContentView.js:
+        (WI.ConsoleTabContentView):
+        * UserInterface/Views/ContentBrowser.js:
+        * UserInterface/Views/ContentBrowserTabContentView.js:
+        * UserInterface/Views/ContentViewContainer.js:
+        (WI.ContentViewContainer.prototype.showContentView):
+        (WI.ContentViewContainer.prototype.replaceContentView):
+        * UserInterface/Views/ElementsTabContentView.js:
+        (WI.ElementsTabContentView):
+        * UserInterface/Views/GraphicsTabContentView.js:
+        (WI.GraphicsTabContentView):
+        * UserInterface/Views/LayersTabContentView.js:
+        (WI.LayersTabContentView):
+        * UserInterface/Views/NetworkDetailView.js:
+        (WI.NetworkDetailView.prototype.initialLayout):
+        * UserInterface/Views/NetworkTabContentView.js:
+        (WI.NetworkTabContentView):
+        * UserInterface/Views/TimelineRecordingContentView.js:
+        (WI.TimelineRecordingContentView):
+
+2021-09-16  Patrick Angle  <[email protected]>
+
         Web Inspector: `FrameDOMTreeContentView` may update after it has `closed` called, causing hangs on some webpages on reload
         https://bugs.webkit.org/show_bug.cgi?id=230186
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/AuditTabContentView.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/AuditTabContentView.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/AuditTabContentView.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -29,7 +29,7 @@
     {
         super(AuditTabContentView.tabInfo(), {
             navigationSidebarPanelConstructor: WI.AuditNavigationSidebarPanel,
-            disableBackForward: true,
+            hideBackForwardButtons: true,
         });
 
         this._startStopShortcut = new WI.KeyboardShortcut(null, WI.KeyboardShortcut.Key.Space, this._handleSpace.bind(this));

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleTabContentView.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleTabContentView.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleTabContentView.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -27,7 +27,7 @@
 {
     constructor()
     {
-        super(ConsoleTabContentView.tabInfo(), {disableBackForward: true});
+        super(ConsoleTabContentView.tabInfo(), {hideBackForwardButtons: true, disableBackForwardNavigation: true});
 
         this._wasShowingSplitConsole = false;
     }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -25,7 +25,7 @@
 
 WI.ContentBrowser = class ContentBrowser extends WI.View
 {
-    constructor(element, delegate, disableBackForward, disableFindBanner, flexibleNavigationItem, contentViewNavigationItemGroup)
+    constructor(element, delegate, {hideBackForwardButtons, disableBackForwardNavigation, disableFindBanner, flexibleNavigationItem, contentViewNavigationItemGroup} = {})
     {
         super(element);
 
@@ -34,11 +34,11 @@
         this._navigationBar = new WI.NavigationBar;
         this.addSubview(this._navigationBar);
 
-        this._contentViewContainer = new WI.ContentViewContainer;
+        this._contentViewContainer = new WI.ContentViewContainer({disableBackForwardNavigation});
         this._contentViewContainer.addEventListener(WI.ContentViewContainer.Event.CurrentContentViewDidChange, this._currentContentViewDidChange, this);
         this.addSubview(this._contentViewContainer);
 
-        if (!disableBackForward) {
+        if (!hideBackForwardButtons) {
             let isRTL = WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL;
 
             let goBack = () => { this.goBack(); };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -25,13 +25,13 @@
 
 WI.ContentBrowserTabContentView = class ContentBrowserTabContentView extends WI.TabContentView
 {
-    constructor(tabInfo, {navigationSidebarPanelConstructor, detailsSidebarPanelConstructors, disableBackForward, flexibleNavigationItem} = {})
+    constructor(tabInfo, {navigationSidebarPanelConstructor, detailsSidebarPanelConstructors, hideBackForwardButtons, disableBackForwardNavigation, flexibleNavigationItem} = {})
     {
         super(tabInfo, {navigationSidebarPanelConstructor, detailsSidebarPanelConstructors});
 
         const contentBrowserElement = null;
         const disableFindBanner = false;
-        this._contentBrowser = new WI.ContentBrowser(contentBrowserElement, this, disableBackForward, disableFindBanner, flexibleNavigationItem);
+        this._contentBrowser = new WI.ContentBrowser(contentBrowserElement, this, {hideBackForwardButtons, disableBackForwardNavigation, flexibleNavigationItem});
 
         this._ignoreNavigationSidebarPanelCollapsedEvent = false;
         this._ignoreDetailsSidebarPanelCollapsedEvent = false;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -25,10 +25,12 @@
 
 WI.ContentViewContainer = class ContentViewContainer extends WI.View
 {
-    constructor()
+    constructor({disableBackForwardNavigation} = {})
     {
         super();
 
+        this._disableBackForwardNavigation = !!disableBackForwardNavigation;
+
         this.element.classList.add("content-view-container");
 
         this._backForwardList = [];
@@ -79,6 +81,11 @@
 
     showContentView(contentView, cookie)
     {
+        if (this._disableBackForwardNavigation && this.currentContentView) {
+            this.replaceContentView(this.currentContentView, contentView, cookie);
+            return;
+        }
+
         console.assert(contentView instanceof WI.ContentView);
         if (!(contentView instanceof WI.ContentView))
             return null;
@@ -140,6 +147,8 @@
 
         this.showBackForwardEntryForIndex(newIndex);
 
+        console.assert(!this._disableBackForwardNavigation || this._backForwardList.length <= 1);
+
         return contentView;
     }
 
@@ -164,7 +173,7 @@
         this.dispatchEventToListeners(WI.ContentViewContainer.Event.CurrentContentViewDidChange);
     }
 
-    replaceContentView(oldContentView, newContentView)
+    replaceContentView(oldContentView, newContentView, newCookie)
     {
         console.assert(oldContentView instanceof WI.ContentView);
         if (!(oldContentView instanceof WI.ContentView))
@@ -196,7 +205,7 @@
         for (var i = 0; i < this._backForwardList.length; ++i) {
             if (this._backForwardList[i].contentView === oldContentView) {
                 console.assert(!this._backForwardList[i].tombstone);
-                let currentCookie = this._backForwardList[i].cookie;
+                let currentCookie = newCookie ?? this._backForwardList[i].cookie;
                 this._backForwardList[i] = new WI.BackForwardEntry(newContentView, currentCookie);
             }
         }
@@ -208,6 +217,8 @@
             this._showEntry(this.currentBackForwardEntry);
             this.dispatchEventToListeners(WI.ContentViewContainer.Event.CurrentContentViewDidChange);
         }
+
+        console.assert(!this._disableBackForwardNavigation || this._backForwardList.length <= 1);
     }
 
     closeContentView(contentViewToClose)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ElementsTabContentView.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ElementsTabContentView.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ElementsTabContentView.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -43,7 +43,7 @@
         if (InspectorBackend.hasDomain("LayerTree"))
             detailsSidebarPanelConstructors.push(WI.LayerTreeDetailsSidebarPanel);
 
-        super(ElementsTabContentView.tabInfo(), {detailsSidebarPanelConstructors, disableBackForward: true});
+        super(ElementsTabContentView.tabInfo(), {detailsSidebarPanelConstructors, hideBackForwardButtons: true, disableBackForwardNavigation: true});
     }
 
     static tabInfo()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/GraphicsTabContentView.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/GraphicsTabContentView.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/GraphicsTabContentView.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -35,7 +35,7 @@
                 WI.CanvasDetailsSidebarPanel,
                 WI.AnimationDetailsSidebarPanel,
             ],
-            disableBackForward: true,
+            hideBackForwardButtons: true,
         });
 
         this._canvasesTreeOutline = new WI.TreeOutline;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LayersTabContentView.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LayersTabContentView.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LayersTabContentView.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -29,7 +29,8 @@
     {
         super(LayersTabContentView.tabInfo(), {
             detailsSidebarPanelConstructors: [WI.LayerDetailsSidebarPanel],
-            disableBackForward: true,
+            hideBackForwardButtons: true,
+            disableBackForwardNavigation: true,
         });
 
         this._layerDetailsSidebarPanel = this.detailsSidebarPanels[0];

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkDetailView.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkDetailView.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkDetailView.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -80,14 +80,12 @@
         closeNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleCloseButton, this);
         closeNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.High;
 
-        let contentViewNavigationItemsGroup = new WI.GroupNavigationItem;
-        let contentViewNavigationItemsFlexItem = new WI.FlexibleSpaceNavigationItem(contentViewNavigationItemsGroup, WI.FlexibleSpaceNavigationItem.Align.End);
-        contentViewNavigationItemsFlexItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
+        let contentViewNavigationItemGroup = new WI.GroupNavigationItem;
+        let flexibleNavigationItem = new WI.FlexibleSpaceNavigationItem(contentViewNavigationItemGroup, WI.FlexibleSpaceNavigationItem.Align.End);
+        flexibleNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
 
         const element = null;
-        const disableBackForward = true;
-        const disableFindBanner = false;
-        this._contentBrowser = new WI.ContentBrowser(element, this, disableBackForward, disableFindBanner, contentViewNavigationItemsFlexItem, contentViewNavigationItemsGroup);
+        this._contentBrowser = new WI.ContentBrowser(element, this, {hideBackForwardButtons: true, flexibleNavigationItem, contentViewNavigationItemGroup});
 
         // Insert all of our custom navigation items at the start of the ContentBrowser's NavigationBar.
         let index = 0;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTabContentView.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTabContentView.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTabContentView.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -31,9 +31,7 @@
 
         this._networkTableContentView = new WI.NetworkTableContentView;
 
-        const disableBackForward = true;
-        const disableFindBanner = true;
-        this._contentBrowser = new WI.ContentBrowser(null, this, disableBackForward, disableFindBanner);
+        this._contentBrowser = new WI.ContentBrowser(null, this, {hideBackForwardButtons: true, disableFindBanner: true});
         this._contentBrowser.showContentView(this._networkTableContentView);
 
         let filterNavigationItems = this._networkTableContentView.filterNavigationItems;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js (282609 => 282610)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2021-09-16 22:28:57 UTC (rev 282609)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2021-09-16 22:35:25 UTC (rev 282610)
@@ -41,9 +41,7 @@
         this._timelineOverview.addEventListener(WI.TimelineOverview.Event.EditingInstrumentsDidChange, this._editingInstrumentsDidChange, this);
         this.addSubview(this._timelineOverview);
 
-        const disableBackForward = true;
-        const disableFindBanner = true;
-        this._timelineContentBrowser = new WI.ContentBrowser(null, this, disableBackForward, disableFindBanner);
+        this._timelineContentBrowser = new WI.ContentBrowser(null, this, {hideBackForwardButtons: true, disableFindBanner: true});
         this._timelineContentBrowser.addEventListener(WI.ContentBrowser.Event.CurrentContentViewDidChange, this._currentContentViewDidChange, this);
 
         this._entireRecordingPathComponent = this._createTimelineRangePathComponent(WI.UIString("Entire Recording"));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to