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

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/Dialog.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/Dialog.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js b/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
index 7b8c44354ecaf8597dc80fb42d92d823c4ac98e9..5499b122a90d35a70555c884b0f3275661206458 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/Dialog.js
@@ -74,14 +74,10 @@ WebInspector.Dialog.prototype = {
this._glassPane.element.addEventListener("click", this._onGlassPaneClick.bind(this), false);
this.element.ownerDocument.body.addEventListener("keydown", this._keyDownBound, false);
- // When a dialog closes, focus should be restored to the previous focused element when
- // possible, otherwise the default inspector view element.
- WebInspector.Dialog._previousFocusedElement = WebInspector.currentFocusElement();
-
WebInspector.Widget.prototype.show.call(this, this._glassPane.element);
this._position();
- this.focus();
+ this._focusRestorer = new WebInspector.WidgetFocusRestorer(this);
},
/**
@@ -89,16 +85,14 @@ WebInspector.Dialog.prototype = {
*/
detach: function()
{
+ this._focusRestorer.restore();
+
this.element.ownerDocument.body.removeEventListener("keydown", this._keyDownBound, false);
WebInspector.Widget.prototype.detach.call(this);
this._glassPane.dispose();
delete this._glassPane;
- if (WebInspector.Dialog._previousFocusedElement)
- WebInspector.Dialog._previousFocusedElement.focus();
- delete WebInspector.Dialog._previousFocusedElement;
-
this._restoreTabIndexOnElements();
delete WebInspector.Dialog._instance;

Powered by Google App Engine
This is Rietveld 408576698