Skip to content
Permalink
Browse files
REGRESSION (r195456): Web Inspector: Changing tabs in Styles sidebar …
…shouldn't change sidebar's width

https://bugs.webkit.org/show_bug.cgi?id=159646
<rdar://problem/27286338>

Reviewed by Brian Burg.

Remember sidebar width on per tab basis. For example, Node, Styles, and Layers sidebar panels in
Elements tab should all have the same width, but Resource sidebar panel in Debugger tab should NOT
share its width Element tab's sidebar.

TabContentView stores the width but TabBrowser manages saving and restoring it.
The same way collapsed sidebar state is handled.

* UserInterface/Views/Sidebar.js:
(WebInspector.Sidebar.prototype.set collapsed):
Don't change sidebar's width when sidebar panels change.

(WebInspector.Sidebar.prototype._recalculateWidth):
(WebInspector.Sidebar.prototype.set selectedSidebarPanel): Deleted.
Pass newWidth as an argument so it can be saved in TabBrowser.

* UserInterface/Views/SidebarPanel.js:
(WebInspector.SidebarPanel): Deleted.
(WebInspector.SidebarPanel.prototype.get savedWidth): Deleted.
(WebInspector.SidebarPanel.prototype.sizeDidChange): Deleted.
Remove the per sidebar panel width setting that was added in r195456.

* UserInterface/Views/TabBrowser.js:
(WebInspector.TabBrowser):
(WebInspector.TabBrowser.prototype._detailsSidebarWidthDidChange):
(WebInspector.TabBrowser.prototype._showDetailsSidebarPanelsForTabContentView):
* UserInterface/Views/TabContentView.js:
(WebInspector.TabContentView):
(WebInspector.TabContentView.prototype.get detailsSidebarWidthSetting):
Store details sidebar width on TabContentView.


Canonical link: https://commits.webkit.org/178500@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203912 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
NV committed Jul 29, 2016
1 parent 68b0710 commit 85a2d65ac575fd18ec31161c6f414b5a97396155
Showing 5 changed files with 66 additions and 24 deletions.
@@ -1,3 +1,41 @@
2016-07-29 Nikita Vasilyev <nvasilyev@apple.com>

REGRESSION (r195456): Web Inspector: Changing tabs in Styles sidebar shouldn't change sidebar's width
https://bugs.webkit.org/show_bug.cgi?id=159646
<rdar://problem/27286338>

Reviewed by Brian Burg.

Remember sidebar width on per tab basis. For example, Node, Styles, and Layers sidebar panels in
Elements tab should all have the same width, but Resource sidebar panel in Debugger tab should NOT
share its width Element tab's sidebar.

TabContentView stores the width but TabBrowser manages saving and restoring it.
The same way collapsed sidebar state is handled.

* UserInterface/Views/Sidebar.js:
(WebInspector.Sidebar.prototype.set collapsed):
Don't change sidebar's width when sidebar panels change.

(WebInspector.Sidebar.prototype._recalculateWidth):
(WebInspector.Sidebar.prototype.set selectedSidebarPanel): Deleted.
Pass newWidth as an argument so it can be saved in TabBrowser.

* UserInterface/Views/SidebarPanel.js:
(WebInspector.SidebarPanel): Deleted.
(WebInspector.SidebarPanel.prototype.get savedWidth): Deleted.
(WebInspector.SidebarPanel.prototype.sizeDidChange): Deleted.
Remove the per sidebar panel width setting that was added in r195456.

* UserInterface/Views/TabBrowser.js:
(WebInspector.TabBrowser):
(WebInspector.TabBrowser.prototype._detailsSidebarWidthDidChange):
(WebInspector.TabBrowser.prototype._showDetailsSidebarPanelsForTabContentView):
* UserInterface/Views/TabContentView.js:
(WebInspector.TabContentView):
(WebInspector.TabContentView.prototype.get detailsSidebarWidthSetting):
Store details sidebar width on TabContentView.

2016-07-29 Matt Baker <mattbaker@apple.com>

Web Inspector: Assertion in NetworkGridContentView when updating data grid for the first time
@@ -147,7 +147,6 @@ WebInspector.Sidebar = class Sidebar extends WebInspector.View
if (this._selectedSidebarPanel.visible) {
this._selectedSidebarPanel.shown();
this._selectedSidebarPanel.visibilityDidChange();
this._recalculateWidth(this._selectedSidebarPanel.savedWidth);
}
}

@@ -200,10 +199,9 @@ WebInspector.Sidebar = class Sidebar extends WebInspector.View
this._navigationBar.needsLayout();

if (this._selectedSidebarPanel) {
if (this._selectedSidebarPanel.visible) {
if (this._selectedSidebarPanel.visible)
this._selectedSidebarPanel.shown();
this._recalculateWidth(this._selectedSidebarPanel.savedWidth);
} else
else
this._selectedSidebarPanel.hidden();

this._selectedSidebarPanel.visibilityDidChange();
@@ -266,16 +264,16 @@ WebInspector.Sidebar = class Sidebar extends WebInspector.View
_recalculateWidth(newWidth = this.width)
{
// Need to add 1 because of the 1px border-right.
newWidth = Number.constrain(newWidth, this.minimumWidth + 1, this.maximumWidth);
this.element.style.width = Math.ceil(newWidth) + "px";
newWidth = Math.ceil(Number.constrain(newWidth, this.minimumWidth + 1, this.maximumWidth));
this.element.style.width = `${newWidth}px`;

if (!this.collapsed && this._navigationBar)
this._navigationBar.needsLayout();

if (!this.collapsed && this._selectedSidebarPanel)
this._selectedSidebarPanel.updateLayout(WebInspector.View.LayoutReason.Resize);

this.dispatchEventToListeners(WebInspector.Sidebar.Event.WidthDidChange);
this.dispatchEventToListeners(WebInspector.Sidebar.Event.WidthDidChange, {newWidth});
}

_navigationItemSelected(event)
@@ -33,7 +33,6 @@ WebInspector.SidebarPanel = class SidebarPanel extends WebInspector.View
this._displayName = displayName;
this._selected = false;

this._widthSetting = new WebInspector.Setting(identifier + "-sidebar-panel-width", 300);
this._savedScrollPosition = 0;

this.element.classList.add("panel", identifier);
@@ -93,11 +92,6 @@ WebInspector.SidebarPanel = class SidebarPanel extends WebInspector.View
return 0;
}

get savedWidth()
{
return this._widthSetting.value;
}

show()
{
if (!this.parentSidebar)
@@ -151,15 +145,4 @@ WebInspector.SidebarPanel = class SidebarPanel extends WebInspector.View
{
// Implemented by subclasses.
}

// Protected

sizeDidChange()
{
let width = this.element.realOffsetWidth;
if (width && width !== this._widthSetting.value)
this._widthSetting.value = width;

// Implemented by subclasses.
}
};
@@ -43,6 +43,7 @@ WebInspector.TabBrowser = class TabBrowser extends WebInspector.View
if (this._detailsSidebar) {
this._detailsSidebar.addEventListener(WebInspector.Sidebar.Event.CollapsedStateDidChange, this._sidebarCollapsedStateDidChange, this);
this._detailsSidebar.addEventListener(WebInspector.Sidebar.Event.SidebarPanelSelected, this._sidebarPanelSelected, this);
this._detailsSidebar.addEventListener(WebInspector.Sidebar.Event.WidthDidChange, this._detailsSidebarWidthDidChange, this);
}

this._contentViewContainer = new WebInspector.ContentViewContainer;
@@ -275,6 +276,19 @@ WebInspector.TabBrowser = class TabBrowser extends WebInspector.View
tabContentView.detailsSidebarCollapsedSetting.value = this._detailsSidebar.collapsed;
}

_detailsSidebarWidthDidChange(event)
{
if (this._ignoreSidebarEvents)
return;

let tabContentView = this.selectedTabContentView;
if (!tabContentView)
return;

if (event.target === this._detailsSidebar && event.data)
tabContentView.detailsSidebarWidthSetting.value = event.data.newWidth;
}

_showNavigationSidebarPanelForTabContentView(tabContentView)
{
if (!this._navigationSidebar)
@@ -323,6 +337,9 @@ WebInspector.TabBrowser = class TabBrowser extends WebInspector.View
return;
}

if (tabContentView.detailsSidebarWidthSetting.value)
this._detailsSidebar.width = tabContentView.detailsSidebarWidthSetting.value;

if (tabContentView.managesDetailsSidebarPanels) {
tabContentView.showDetailsSidebarPanels();
this._ignoreSidebarEvents = false;
@@ -51,6 +51,7 @@ WebInspector.TabContentView = class TabContentView extends WebInspector.ContentV

this._detailsSidebarCollapsedSetting = new WebInspector.Setting(identifier + "-details-sidebar-collapsed", true);
this._detailsSidebarSelectedPanelSetting = new WebInspector.Setting(identifier + "-details-sidebar-selected-panel", null);
this._detailsSidebarWidthSetting = new WebInspector.Setting(identifier + "-details-sidebar-width", 0);

this._cookieSetting = new WebInspector.Setting(identifier + "-tab-cookie", {});
}
@@ -177,6 +178,11 @@ WebInspector.TabContentView = class TabContentView extends WebInspector.ContentV
return this._navigationSidebarCollapsedSetting;
}

get detailsSidebarWidthSetting()
{
return this._detailsSidebarWidthSetting;
}

get detailsSidebarPanels()
{
return this._detailsSidebarPanels;

0 comments on commit 85a2d65

Please sign in to comment.