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

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

Issue 2377193004: [DevTools] Rework some focus code. (Closed)
Patch Set: 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/Widget.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/Widget.js b/third_party/WebKit/Source/devtools/front_end/ui/Widget.js
index bc4af9ba13e484b657ff7ac471fe64203eaaaa76..5691997e2dd70e3676319696f619367345dea6bf 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/Widget.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/Widget.js
@@ -424,7 +424,7 @@ WebInspector.Widget.prototype = {
},
/**
- * @param {!Element} element
+ * @param {?Element} element
*/
setDefaultFocusedElement: function(element)
{
@@ -442,9 +442,13 @@ WebInspector.Widget.prototype = {
focus: function()
{
+ if (!this.isShowing())
+ return;
+
var element = this._defaultFocusedElement;
- if (element && !element.isAncestor(this.element.ownerDocument.activeElement)) {
- WebInspector.setCurrentFocusElement(element);
+ if (element) {
+ if (!element.hasFocus())
+ element.focus();
return;
}
@@ -466,8 +470,7 @@ WebInspector.Widget.prototype = {
*/
hasFocus: function()
{
- var activeElement = this.element.ownerDocument.activeElement;
- return activeElement && activeElement.isSelfOrDescendant(this.element);
+ return this.element.hasFocus();
},
/**

Powered by Google App Engine
This is Rietveld 408576698