Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js

Issue 2377193004: [DevTools] Rework some focus code. (Closed)
Patch Set: FocusRestorer Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js b/third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js
index ac06a4f9254645399c57e7418c34e66b38e8f103..6f031d87708a6d5bdc56aadfc505b771e3c1a9bc 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/InspectorView.js
@@ -47,12 +47,12 @@ WebInspector.InspectorView = function()
this._drawerSplitWidget.show(this.element);
// Create drawer tabbed pane.
- this._drawerTabbedLocation = WebInspector.viewManager.createTabbedLocation(this.showDrawer.bind(this), "drawer-view", true);
+ this._drawerTabbedLocation = WebInspector.viewManager.createTabbedLocation(this._showDrawer.bind(this, false), "drawer-view", true);
this._drawerTabbedLocation.enableMoreTabsButton();
this._drawerTabbedPane = this._drawerTabbedLocation.tabbedPane();
this._drawerTabbedPane.setMinimumSize(0, 27);
var closeDrawerButton = new WebInspector.ToolbarButton(WebInspector.UIString("Close drawer"), "delete-toolbar-item");
- closeDrawerButton.addEventListener("click", this.closeDrawer.bind(this));
+ closeDrawerButton.addEventListener("click", this._closeDrawer.bind(this));
this._drawerTabbedPane.rightToolbar().appendToolbarItem(closeDrawerButton);
this._drawerSplitWidget.installResizer(this._drawerTabbedPane.headerElement());
this._drawerSplitWidget.setSidebarWidget(this._drawerTabbedPane);
@@ -363,11 +363,18 @@ WebInspector.InspectorView.prototype = {
return panel;
},
- showDrawer: function()
+ /**
+ * @param {boolean} focus
+ */
+ _showDrawer: function(focus)
{
- if (!this._drawerTabbedPane.isShowing())
- this._drawerSplitWidget.showBoth();
- this._drawerTabbedPane.focus();
+ if (this._drawerTabbedPane.isShowing())
+ return;
+ this._drawerSplitWidget.showBoth();
+ if (focus)
+ this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._drawerTabbedPane);
+ else
+ this._focusRestorer = null;
},
/**
@@ -378,11 +385,12 @@ WebInspector.InspectorView.prototype = {
return this._drawerTabbedPane.isShowing();
},
- closeDrawer: function()
+ _closeDrawer: function()
{
if (!this._drawerTabbedPane.isShowing())
return;
- WebInspector.restoreFocusFromElement(this._drawerTabbedPane.element);
+ if (this._focusRestorer)
+ this._focusRestorer.restore();
this._drawerSplitWidget.hideSidebar(true);
},
@@ -592,9 +600,9 @@ WebInspector.InspectorView.DrawerToggleActionDelegate.prototype = {
handleAction: function(context, actionId)
{
if (WebInspector.inspectorView.drawerVisible())
- WebInspector.inspectorView.closeDrawer();
+ WebInspector.inspectorView._closeDrawer();
else
- WebInspector.inspectorView.showDrawer();
+ WebInspector.inspectorView._showDrawer(true);
return true;
}
}

Powered by Google App Engine
This is Rietveld 408576698