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

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.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/SwatchPopoverHelper.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.js b/third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.js
index ae761d33eb43aafdce5afd60f4bff4e324ece546..60d17ce143aa1d4d8e84f7a9918444ce14cb6595 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.js
@@ -67,13 +67,12 @@ WebInspector.SwatchPopoverHelper.prototype = {
reposition: function()
{
- if (!this._previousFocusElement)
- this._previousFocusElement = WebInspector.currentFocusElement();
// Unbind "blur" listener to avoid reenterability: |popover.showView| will hide the popover and trigger it synchronously.
this._view.contentElement.removeEventListener("focusout", this._boundFocusOut, false);
this._popover.showView(this._view, this._anchorElement);
this._view.contentElement.addEventListener("focusout", this._boundFocusOut, false);
- WebInspector.setCurrentFocusElement(this._view.contentElement);
+ if (!this._focusRestorer)
+ this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._view);
},
/**
@@ -93,8 +92,7 @@ WebInspector.SwatchPopoverHelper.prototype = {
if (this._hiddenCallback)
this._hiddenCallback.call(null, !!commitEdit);
- WebInspector.setCurrentFocusElement(this._previousFocusElement);
- delete this._previousFocusElement;
+ this._focusRestorer.restore();
delete this._anchorElement;
if (this._view) {
this._view.detach();

Powered by Google App Engine
This is Rietveld 408576698