| Index: Source/devtools/front_end/elements/EventListenersSidebarPane.js
|
| diff --git a/Source/devtools/front_end/elements/EventListenersSidebarPane.js b/Source/devtools/front_end/elements/EventListenersSidebarPane.js
|
| index a50aa49d50ebca82feee727f209f3d5ff6a3ca01..d83367f582445fe62ef584e6dc265418c624b884 100644
|
| --- a/Source/devtools/front_end/elements/EventListenersSidebarPane.js
|
| +++ b/Source/devtools/front_end/elements/EventListenersSidebarPane.js
|
| @@ -34,13 +34,8 @@
|
| WebInspector.EventListenersSidebarPane = function()
|
| {
|
| WebInspector.ElementsSidebarPane.call(this, WebInspector.UIString("Event Listeners"));
|
| - this.registerRequiredCSS("components/objectValue.css");
|
| this.bodyElement.classList.add("events-pane");
|
|
|
| - this._treeOutline = new TreeOutline(true);
|
| - this._treeOutline.element.classList.add("event-listener-tree", "outline-disclosure", "monospace");
|
| - this.bodyElement.appendChild(this._treeOutline.element);
|
| -
|
| var refreshButton = this.titleElement.createChild("button", "pane-title-button refresh");
|
| refreshButton.addEventListener("click", this.update.bind(this), false);
|
| refreshButton.title = WebInspector.UIString("Refresh");
|
| @@ -64,10 +59,10 @@ WebInspector.EventListenersSidebarPane = function()
|
| this.settingsSelectElement.addEventListener("click", consumeEvent, false);
|
| this.settingsSelectElement.addEventListener("change", this._changeSetting.bind(this), false);
|
|
|
| - this._linkifier = new WebInspector.Linkifier();
|
| + this._eventListenersView = new WebInspector.EventListenersView(this.bodyElement, WebInspector.EventListenersSidebarPane._objectGroupName);
|
| }
|
|
|
| -WebInspector.EventListenersSidebarPane._objectGroupName = "event-listeners-sidebar-pane";
|
| +WebInspector.EventListenersSidebarPane._objectGroupName = "event-listeners-panel";
|
|
|
| WebInspector.EventListenersSidebarPane.prototype = {
|
| /**
|
| @@ -81,74 +76,34 @@ WebInspector.EventListenersSidebarPane.prototype = {
|
| this._lastRequestedNode.target().runtimeAgent().releaseObjectGroup(WebInspector.EventListenersSidebarPane._objectGroupName);
|
| delete this._lastRequestedNode;
|
| }
|
| -
|
| - this._linkifier.reset();
|
| -
|
| - var body = this.bodyElement;
|
| - body.removeChildren();
|
| - this._treeOutline.removeChildren();
|
| -
|
| + this._eventListenersView.reset();
|
| var node = this.node();
|
| if (!node) {
|
| + this._eventListenersArivedForTest();
|
| finishCallback();
|
| return;
|
| }
|
|
|
| - this._lastRequestedNode = node;
|
| - node.eventListeners(WebInspector.EventListenersSidebarPane._objectGroupName, this._onEventListeners.bind(this, finishCallback));
|
| - },
|
| -
|
| - /**
|
| - * @param {!WebInspector.Throttler.FinishCallback} finishCallback
|
| - * @param {?Array.<!WebInspector.DOMModel.EventListener>} eventListeners
|
| - */
|
| - _onEventListeners: function(finishCallback, eventListeners)
|
| - {
|
| - if (!eventListeners) {
|
| - finishCallback();
|
| - return;
|
| - }
|
| -
|
| - var body = this.bodyElement;
|
| - var node = this.node();
|
| var selectedNodeOnly = "selected" === this._eventListenersFilterSetting.get();
|
| - var treeItemMap = new Map();
|
| - eventListeners.stableSort(compareListeners);
|
| -
|
| + var promises = [];
|
| + promises.push(this._eventListenersView.addNodeEventListeners(node));
|
| + if (!selectedNodeOnly) {
|
| + var currentNode = node.parentNode;
|
| + while (currentNode) {
|
| + promises.push(this._eventListenersView.addNodeEventListeners(currentNode));
|
| + currentNode = currentNode.parentNode;
|
| + }
|
| + }
|
| + Promise.all(promises).then(mycallback.bind(this));
|
| /**
|
| - * @param {!WebInspector.DOMModel.EventListener} a
|
| - * @param {!WebInspector.DOMModel.EventListener} b
|
| - * @return {number}
|
| + * @this {WebInspector.EventListenersSidebarPane}
|
| */
|
| - function compareListeners(a, b)
|
| + function mycallback()
|
| {
|
| - var aType = a.payload().type;
|
| - var bType = b.payload().type;
|
| - return aType === bType ? 0 :
|
| - aType > bType ? 1 : -1;
|
| - }
|
| -
|
| - for (var i = 0; i < eventListeners.length; ++i) {
|
| - var eventListener = eventListeners[i];
|
| - if (selectedNodeOnly && (node.id !== eventListener.payload().nodeId))
|
| - continue;
|
| - if (eventListener.location().script().isInternalScript())
|
| - continue; // ignore event listeners generated by monitorEvent
|
| - var type = eventListener.payload().type;
|
| - var treeItem = treeItemMap.get(type);
|
| - if (!treeItem) {
|
| - treeItem = new WebInspector.EventListenersTreeElement(type, node.id, this._linkifier);
|
| - treeItemMap.set(type, treeItem);
|
| - this._treeOutline.appendChild(treeItem);
|
| - }
|
| - treeItem.addListener(eventListener);
|
| + this._lastRequestedNode = node;
|
| + this._eventListenersArivedForTest();
|
| + finishCallback();
|
| }
|
| - if (treeItemMap.size === 0)
|
| - body.createChild("div", "info").textContent = WebInspector.UIString("No Event Listeners");
|
| - else
|
| - body.appendChild(this._treeOutline.element);
|
| -
|
| - finishCallback();
|
| },
|
|
|
| _changeSetting: function()
|
| @@ -158,107 +113,9 @@ WebInspector.EventListenersSidebarPane.prototype = {
|
| this.update();
|
| },
|
|
|
| - __proto__: WebInspector.ElementsSidebarPane.prototype
|
| -}
|
| -
|
| -/**
|
| - * @constructor
|
| - * @extends {TreeElement}
|
| - */
|
| -WebInspector.EventListenersTreeElement = function(title, nodeId, linkifier)
|
| -{
|
| - this._nodeId = nodeId;
|
| - this._linkifier = linkifier;
|
| -
|
| - TreeElement.call(this, title);
|
| - this.toggleOnClick = true;
|
| - this.selectable = false;
|
| -}
|
| -
|
| -WebInspector.EventListenersTreeElement.prototype = {
|
| - /**
|
| - * @param {!WebInspector.DOMModel.EventListener} eventListener
|
| - */
|
| - addListener: function(eventListener)
|
| + _eventListenersArivedForTest: function()
|
| {
|
| - var treeElement = new WebInspector.EventListenerBar(eventListener, this._nodeId, this._linkifier);
|
| - this.appendChild(treeElement);
|
| },
|
|
|
| - __proto__: TreeElement.prototype
|
| -}
|
| -
|
| -/**
|
| - * @constructor
|
| - * @extends {TreeElement}
|
| - * @param {!WebInspector.DOMModel.EventListener} eventListener
|
| - * @param {!DOMAgent.NodeId} nodeId
|
| - * @param {!WebInspector.Linkifier} linkifier
|
| - */
|
| -WebInspector.EventListenerBar = function(eventListener, nodeId, linkifier)
|
| -{
|
| - TreeElement.call(this, "", true);
|
| -
|
| - var target = eventListener.target();
|
| - this._runtimeModel = target.runtimeModel;
|
| - this._eventListener = eventListener;
|
| - this._nodeId = nodeId;
|
| - this._setNodeTitle(linkifier);
|
| - this.editable = false;
|
| -}
|
| -
|
| -WebInspector.EventListenerBar.prototype = {
|
| - onpopulate: function()
|
| - {
|
| - /**
|
| - * @param {?WebInspector.RemoteObject} nodeObject
|
| - * @this {WebInspector.EventListenerBar}
|
| - */
|
| - function updateWithNodeObject(nodeObject)
|
| - {
|
| - var properties = [];
|
| - var payload = this._eventListener.payload();
|
| -
|
| - properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("useCapture", payload.useCapture));
|
| - properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("attachment", payload.isAttribute ? "attribute" : "script"));
|
| - if (nodeObject)
|
| - properties.push(new WebInspector.RemoteObjectProperty("node", nodeObject));
|
| - if (typeof payload.handler !== "undefined") {
|
| - var remoteObject = this._runtimeModel.createRemoteObject(payload.handler);
|
| - properties.push(new WebInspector.RemoteObjectProperty("handler", remoteObject));
|
| - }
|
| -
|
| - WebInspector.ObjectPropertyTreeElement.populateWithProperties(this, properties, [], true, null);
|
| - }
|
| - this._eventListener.node().resolveToObject(WebInspector.EventListenersSidebarPane._objectGroupName, updateWithNodeObject.bind(this));
|
| - },
|
| -
|
| - /**
|
| - * @param {!WebInspector.Linkifier} linkifier
|
| - */
|
| - _setNodeTitle: function(linkifier)
|
| - {
|
| - var node = this._eventListener.node();
|
| - if (!node)
|
| - return;
|
| -
|
| - this.listItemElement.removeChildren();
|
| - var title = this.listItemElement.createChild("span");
|
| - var subtitle = this.listItemElement.createChild("span", "event-listener-tree-subtitle");
|
| - subtitle.appendChild(linkifier.linkifyRawLocation(this._eventListener.location(), this._eventListener.sourceName()));
|
| -
|
| - if (node.nodeType() === Node.DOCUMENT_NODE) {
|
| - title.textContent = "document";
|
| - return;
|
| - }
|
| -
|
| - if (node.id === this._nodeId) {
|
| - title.textContent = WebInspector.DOMPresentationUtils.simpleSelector(node);
|
| - return;
|
| - }
|
| -
|
| - title.appendChild(WebInspector.DOMPresentationUtils.linkifyNodeReference(node));
|
| - },
|
| -
|
| - __proto__: TreeElement.prototype
|
| + __proto__: WebInspector.ElementsSidebarPane.prototype
|
| }
|
|
|