| Index: third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js b/third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js
|
| index 8437dba1e2aca78e3f2daa7db43aa5410dc9960f..4c1cf24b4f71b55007cabc9c561b55050889f03f 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/platform/DOMExtension.js
|
| @@ -902,19 +902,8 @@ Node.prototype.setTextContentTruncatedIfNeeded = function(text, placeholder)
|
| */
|
| Event.prototype.deepElementFromPoint = function()
|
| {
|
| - // 1. climb to the component root.
|
| - var node = this.target;
|
| - while (node && node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE && node.nodeType !== Node.DOCUMENT_NODE)
|
| - node = node.parentNode;
|
| -
|
| - if (!node)
|
| - return null;
|
| -
|
| - // 2. Find deepest node by coordinates.
|
| - node = node.elementFromPoint(this.pageX, this.pageY);
|
| - while (node && node.shadowRoot)
|
| - node = node.shadowRoot.elementFromPoint(this.pageX, this.pageY);
|
| - return node;
|
| + var root = this.target && this.target.getComponentRoot();
|
| + return root ? root.deepElementFromPoint(this.pageX, this.pageY) : null;
|
| }
|
|
|
| /**
|
| @@ -922,10 +911,8 @@ Event.prototype.deepElementFromPoint = function()
|
| */
|
| Event.prototype.deepActiveElement = function()
|
| {
|
| - var activeElement = this.target && this.target.ownerDocument ? this.target.ownerDocument.activeElement : null;
|
| - while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
|
| - activeElement = activeElement.shadowRoot.activeElement;
|
| - return activeElement;
|
| + var document = this.target && this.target.ownerDocument;
|
| + return document ? document.deepActiveElement() : null;
|
| }
|
|
|
| /**
|
| @@ -941,6 +928,41 @@ Document.prototype.deepElementFromPoint = function(x, y)
|
| return node;
|
| }
|
|
|
| +DocumentFragment.prototype.deepElementFromPoint = Document.prototype.deepElementFromPoint;
|
| +
|
| +/**
|
| + * @return {?Element}
|
| + */
|
| +Document.prototype.deepActiveElement = function()
|
| +{
|
| + var activeElement = this.activeElement;
|
| + while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
|
| + activeElement = activeElement.shadowRoot.activeElement;
|
| + return activeElement;
|
| +}
|
| +
|
| +DocumentFragment.prototype.deepActiveElement = Document.prototype.deepActiveElement;
|
| +
|
| +/**
|
| + * @return {boolean}
|
| + */
|
| +Element.prototype.hasFocus = function()
|
| +{
|
| + var root = this.getComponentRoot();
|
| + return !!root && this.isSelfOrAncestor(root.activeElement);
|
| +}
|
| +
|
| +/**
|
| + * @return {?Document|?DocumentFragment}
|
| + */
|
| +Node.prototype.getComponentRoot = function()
|
| +{
|
| + var node = this;
|
| + while (node && node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE && node.nodeType !== Node.DOCUMENT_NODE)
|
| + node = node.parentNode;
|
| + return /** @type {?Document|?DocumentFragment} */ (node);
|
| +}
|
| +
|
| /**
|
| * @param {!Event} event
|
| * @return {boolean}
|
|
|