| 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 e01fd5b4fbe56db95b7ddd284983b98bc457d374..6322a817ff52051ca91540e7e343ee607df60114 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/ui/Widget.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/ui/Widget.js
|
| @@ -437,7 +437,7 @@ WebInspector.Widget.prototype = {
|
| },
|
|
|
| /**
|
| - * @param {!Element} element
|
| + * @param {?Element} element
|
| */
|
| setDefaultFocusedElement: function(element)
|
| {
|
| @@ -455,9 +455,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;
|
| }
|
|
|
| @@ -479,8 +483,7 @@ WebInspector.Widget.prototype = {
|
| */
|
| hasFocus: function()
|
| {
|
| - var activeElement = this.element.ownerDocument.activeElement;
|
| - return activeElement && activeElement.isSelfOrDescendant(this.element);
|
| + return this.element.hasFocus();
|
| },
|
|
|
| /**
|
| @@ -746,6 +749,29 @@ WebInspector.VBoxWithResizeCallback.prototype = {
|
| }
|
|
|
| /**
|
| + * @param {!WebInspector.Widget} widget
|
| + * @constructor
|
| + */
|
| +WebInspector.WidgetFocusRestorer = function(widget)
|
| +{
|
| + this._widget = widget;
|
| + this._previous = widget.element.ownerDocument.deepActiveElement();
|
| + widget.focus();
|
| +}
|
| +
|
| +WebInspector.WidgetFocusRestorer.prototype = {
|
| + restore: function()
|
| + {
|
| + if (!this._widget)
|
| + return;
|
| + if (this._widget.hasFocus() && this._previous)
|
| + this._previous.focus();
|
| + this._previous = null;
|
| + this._widget = null;
|
| + }
|
| +}
|
| +
|
| +/**
|
| * @override
|
| * @param {?Node} child
|
| * @return {?Node}
|
|
|