Index: Source/devtools/front_end/EventListenersSidebarPane.js |
diff --git a/Source/devtools/front_end/EventListenersSidebarPane.js b/Source/devtools/front_end/EventListenersSidebarPane.js |
index d2119ee2a31f0711a58d58a2bbb6ecea80cfeaa7..a639a53f2ffc2fbf47c437329ae2b1655d3ab278 100644 |
--- a/Source/devtools/front_end/EventListenersSidebarPane.js |
+++ b/Source/devtools/front_end/EventListenersSidebarPane.js |
@@ -87,12 +87,11 @@ WebInspector.EventListenersSidebarPane.prototype = { |
var self = this; |
/** |
- * @param {?Protocol.Error} error |
- * @param {!Array.<!DOMAgent.EventListener>} eventListeners |
+ * @param {?Array.<!WebInspector.DOMModel.EventListener>} eventListeners |
*/ |
- function callback(error, eventListeners) |
+ function callback(eventListeners) |
{ |
- if (error) |
+ if (!eventListeners) |
return; |
var selectedNodeOnly = "selected" === WebInspector.settings.eventListenersFilter.get(); |
@@ -100,13 +99,11 @@ WebInspector.EventListenersSidebarPane.prototype = { |
var sectionMap = {}; |
for (var i = 0; i < eventListeners.length; ++i) { |
var eventListener = eventListeners[i]; |
- if (selectedNodeOnly && (node.id !== eventListener.nodeId)) |
+ if (selectedNodeOnly && (node.id !== eventListener.payload().nodeId)) |
continue; |
- eventListener.node = node.target().domModel.nodeForId(eventListener.nodeId); |
- delete eventListener.nodeId; // no longer needed |
- if (/^function _inspectorCommandLineAPI_logEvent\(/.test(eventListener.handlerBody.toString())) |
+ if (/^function _inspectorCommandLineAPI_logEvent\(/.test(eventListener.payload().handlerBody.toString())) |
continue; // ignore event listeners generated by monitorEvent |
- var type = eventListener.type; |
+ var type = eventListener.payload().type; |
var section = sectionMap[type]; |
if (!section) { |
section = new WebInspector.EventListenersSection(type, node.id, self._linkifier); |
@@ -114,7 +111,7 @@ WebInspector.EventListenersSidebarPane.prototype = { |
sectionNames.push(type); |
self.sections.push(section); |
} |
- section.addListener(node.target(), eventListener); |
+ section.addListener(eventListener); |
} |
if (sectionNames.length === 0) { |
@@ -182,11 +179,11 @@ WebInspector.EventListenersSection = function(title, nodeId, linkifier) |
WebInspector.EventListenersSection.prototype = { |
/** |
- * @param {!WebInspector.Target} target |
+ * @param {!WebInspector.DOMModel.EventListener} eventListener |
*/ |
- addListener: function(target, eventListener) |
+ addListener: function(eventListener) |
{ |
- var eventListenerBar = new WebInspector.EventListenerBar(target, eventListener, this._nodeId, this._linkifier); |
+ var eventListenerBar = new WebInspector.EventListenerBar(eventListener, this._nodeId, this._linkifier); |
this._eventBars.appendChild(eventListenerBar.element); |
}, |
@@ -195,15 +192,18 @@ WebInspector.EventListenersSection.prototype = { |
/** |
* @constructor |
- * @param {!WebInspector.Target} target |
* @extends {WebInspector.ObjectPropertiesSection} |
+ * @param {!WebInspector.DOMModel.EventListener} eventListener |
+ * @param {!DOMAgent.NodeId} nodeId |
+ * @param {!WebInspector.Linkifier} linkifier |
*/ |
-WebInspector.EventListenerBar = function(target, eventListener, nodeId, linkifier) |
+WebInspector.EventListenerBar = function(eventListener, nodeId, linkifier) |
{ |
+ var target = eventListener.target(); |
WebInspector.ObjectPropertiesSection.call(this, target.runtimeModel.createRemoteObjectFromPrimitiveValue("")); |
this._runtimeModel = target.runtimeModel; |
- this.eventListener = eventListener; |
+ this._eventListener = eventListener; |
this._nodeId = nodeId; |
this._setNodeTitle(); |
this._setFunctionSubtitle(linkifier); |
@@ -223,29 +223,30 @@ WebInspector.EventListenerBar.prototype = { |
function updateWithNodeObject(nodeObject) |
{ |
var properties = []; |
+ var payload = this._eventListener.payload(); |
- properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("type", this.eventListener.type)); |
- properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("useCapture", this.eventListener.useCapture)); |
- properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("isAttribute", this.eventListener.isAttribute)); |
+ properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("type", payload.type)); |
+ properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("useCapture", payload.useCapture)); |
+ properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("isAttribute", payload.isAttribute)); |
if (nodeObject) |
properties.push(new WebInspector.RemoteObjectProperty("node", nodeObject)); |
- if (typeof this.eventListener.handler !== "undefined") { |
- var remoteObject = this._runtimeModel.createRemoteObject(this.eventListener.handler); |
+ if (typeof payload.handler !== "undefined") { |
+ var remoteObject = this._runtimeModel.createRemoteObject(payload.handler); |
properties.push(new WebInspector.RemoteObjectProperty("handler", remoteObject)); |
} |
- properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("listenerBody", this.eventListener.handlerBody)); |
- if (this.eventListener.sourceName) |
- properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("sourceName", this.eventListener.sourceName)); |
- properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("lineNumber", this.eventListener.location.lineNumber + 1)); |
+ properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("listenerBody", payload.handlerBody)); |
+ if (payload.sourceName) |
+ properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("sourceName", payload.sourceName)); |
+ properties.push(this._runtimeModel.createRemotePropertyFromPrimitiveValue("lineNumber", payload.location.lineNumber + 1)); |
this.updateProperties(properties); |
} |
- this.eventListener.node.resolveToObject(WebInspector.EventListenersSidebarPane._objectGroupName, updateWithNodeObject.bind(this)); |
+ this._eventListener.node().resolveToObject(WebInspector.EventListenersSidebarPane._objectGroupName, updateWithNodeObject.bind(this)); |
}, |
_setNodeTitle: function() |
{ |
- var node = this.eventListener.node; |
+ var node = this._eventListener.node(); |
if (!node) |
return; |
@@ -260,20 +261,13 @@ WebInspector.EventListenerBar.prototype = { |
} |
this.titleElement.removeChildren(); |
- this.titleElement.appendChild(WebInspector.DOMPresentationUtils.linkifyNodeReference(this.eventListener.node)); |
+ this.titleElement.appendChild(WebInspector.DOMPresentationUtils.linkifyNodeReference(node)); |
}, |
_setFunctionSubtitle: function(linkifier) |
{ |
this.subtitleElement.removeChildren(); |
- var urlElement = linkifier.linkifyRawLocation(this.eventListener.location); |
- if (!urlElement) { |
- var url = this.eventListener.sourceName; |
- var lineNumber = this.eventListener.location.lineNumber; |
- var columnNumber = 0; |
- urlElement = linkifier.linkifyLocation(url, lineNumber, columnNumber); |
- } |
- this.subtitleElement.appendChild(urlElement); |
+ this.subtitleElement.appendChild(linkifier.linkifyRawLocation(this._eventListener.location())); |
}, |
__proto__: WebInspector.ObjectPropertiesSection.prototype |