OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 { | 80 { |
81 RuntimeAgent.releaseObjectGroup(WebInspector.EventListenersSidebarPane._
objectGroupName); | 81 RuntimeAgent.releaseObjectGroup(WebInspector.EventListenersSidebarPane._
objectGroupName); |
82 this._linkifier.reset(); | 82 this._linkifier.reset(); |
83 | 83 |
84 var body = this.bodyElement; | 84 var body = this.bodyElement; |
85 body.removeChildren(); | 85 body.removeChildren(); |
86 this.sections = []; | 86 this.sections = []; |
87 | 87 |
88 var self = this; | 88 var self = this; |
89 /** | 89 /** |
90 * @param {?Protocol.Error} error | 90 * @param {?Array.<!WebInspector.DOMModel.EventListener>} eventListeners |
91 * @param {!Array.<!DOMAgent.EventListener>} eventListeners | |
92 */ | 91 */ |
93 function callback(error, eventListeners) | 92 function callback(eventListeners) |
94 { | 93 { |
95 if (error) | 94 if (!eventListeners) |
96 return; | 95 return; |
97 | 96 |
98 var selectedNodeOnly = "selected" === WebInspector.settings.eventLis
tenersFilter.get(); | 97 var selectedNodeOnly = "selected" === WebInspector.settings.eventLis
tenersFilter.get(); |
99 var sectionNames = []; | 98 var sectionNames = []; |
100 var sectionMap = {}; | 99 var sectionMap = {}; |
101 for (var i = 0; i < eventListeners.length; ++i) { | 100 for (var i = 0; i < eventListeners.length; ++i) { |
102 var eventListener = eventListeners[i]; | 101 var eventListener = eventListeners[i]; |
103 if (selectedNodeOnly && (node.id !== eventListener.nodeId)) | 102 if (selectedNodeOnly && (node.id !== eventListener.payload().nod
eId)) |
104 continue; | 103 continue; |
105 eventListener.node = node.target().domModel.nodeForId(eventListe
ner.nodeId); | 104 if (/^function _inspectorCommandLineAPI_logEvent\(/.test(eventLi
stener.payload().handlerBody.toString())) |
106 delete eventListener.nodeId; // no longer needed | |
107 if (/^function _inspectorCommandLineAPI_logEvent\(/.test(eventLi
stener.handlerBody.toString())) | |
108 continue; // ignore event listeners generated by monitorEven
t | 105 continue; // ignore event listeners generated by monitorEven
t |
109 var type = eventListener.type; | 106 var type = eventListener.payload().type; |
110 var section = sectionMap[type]; | 107 var section = sectionMap[type]; |
111 if (!section) { | 108 if (!section) { |
112 section = new WebInspector.EventListenersSection(type, node.
id, self._linkifier); | 109 section = new WebInspector.EventListenersSection(type, node.
id, self._linkifier); |
113 sectionMap[type] = section; | 110 sectionMap[type] = section; |
114 sectionNames.push(type); | 111 sectionNames.push(type); |
115 self.sections.push(section); | 112 self.sections.push(section); |
116 } | 113 } |
117 section.addListener(node.target(), eventListener); | 114 section.addListener(eventListener); |
118 } | 115 } |
119 | 116 |
120 if (sectionNames.length === 0) { | 117 if (sectionNames.length === 0) { |
121 var div = document.createElement("div"); | 118 var div = document.createElement("div"); |
122 div.className = "info"; | 119 div.className = "info"; |
123 div.textContent = WebInspector.UIString("No Event Listeners"); | 120 div.textContent = WebInspector.UIString("No Event Listeners"); |
124 body.appendChild(div); | 121 body.appendChild(div); |
125 return; | 122 return; |
126 } | 123 } |
127 | 124 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 delete this.propertiesElement; | 172 delete this.propertiesElement; |
176 delete this.propertiesTreeOutline; | 173 delete this.propertiesTreeOutline; |
177 | 174 |
178 this._eventBars = document.createElement("div"); | 175 this._eventBars = document.createElement("div"); |
179 this._eventBars.className = "event-bars"; | 176 this._eventBars.className = "event-bars"; |
180 this.element.appendChild(this._eventBars); | 177 this.element.appendChild(this._eventBars); |
181 } | 178 } |
182 | 179 |
183 WebInspector.EventListenersSection.prototype = { | 180 WebInspector.EventListenersSection.prototype = { |
184 /** | 181 /** |
185 * @param {!WebInspector.Target} target | 182 * @param {!WebInspector.DOMModel.EventListener} eventListener |
186 */ | 183 */ |
187 addListener: function(target, eventListener) | 184 addListener: function(eventListener) |
188 { | 185 { |
189 var eventListenerBar = new WebInspector.EventListenerBar(target, eventLi
stener, this._nodeId, this._linkifier); | 186 var eventListenerBar = new WebInspector.EventListenerBar(eventListener,
this._nodeId, this._linkifier); |
190 this._eventBars.appendChild(eventListenerBar.element); | 187 this._eventBars.appendChild(eventListenerBar.element); |
191 }, | 188 }, |
192 | 189 |
193 __proto__: WebInspector.PropertiesSection.prototype | 190 __proto__: WebInspector.PropertiesSection.prototype |
194 } | 191 } |
195 | 192 |
196 /** | 193 /** |
197 * @constructor | 194 * @constructor |
198 * @param {!WebInspector.Target} target | |
199 * @extends {WebInspector.ObjectPropertiesSection} | 195 * @extends {WebInspector.ObjectPropertiesSection} |
| 196 * @param {!WebInspector.DOMModel.EventListener} eventListener |
| 197 * @param {!DOMAgent.NodeId} nodeId |
| 198 * @param {!WebInspector.Linkifier} linkifier |
200 */ | 199 */ |
201 WebInspector.EventListenerBar = function(target, eventListener, nodeId, linkifie
r) | 200 WebInspector.EventListenerBar = function(eventListener, nodeId, linkifier) |
202 { | 201 { |
| 202 var target = eventListener.target(); |
203 WebInspector.ObjectPropertiesSection.call(this, target.runtimeModel.createRe
moteObjectFromPrimitiveValue("")); | 203 WebInspector.ObjectPropertiesSection.call(this, target.runtimeModel.createRe
moteObjectFromPrimitiveValue("")); |
204 | 204 |
205 this._runtimeModel = target.runtimeModel; | 205 this._runtimeModel = target.runtimeModel; |
206 this.eventListener = eventListener; | 206 this._eventListener = eventListener; |
207 this._nodeId = nodeId; | 207 this._nodeId = nodeId; |
208 this._setNodeTitle(); | 208 this._setNodeTitle(); |
209 this._setFunctionSubtitle(linkifier); | 209 this._setFunctionSubtitle(linkifier); |
210 this.editable = false; | 210 this.editable = false; |
211 this.element.className = "event-bar"; /* Changed from "section" */ | 211 this.element.className = "event-bar"; /* Changed from "section" */ |
212 this.headerElement.classList.add("source-code"); | 212 this.headerElement.classList.add("source-code"); |
213 this.propertiesElement.className = "event-properties properties-tree source-
code"; /* Changed from "properties" */ | 213 this.propertiesElement.className = "event-properties properties-tree source-
code"; /* Changed from "properties" */ |
214 } | 214 } |
215 | 215 |
216 WebInspector.EventListenerBar.prototype = { | 216 WebInspector.EventListenerBar.prototype = { |
217 update: function() | 217 update: function() |
218 { | 218 { |
219 /** | 219 /** |
220 * @param {?WebInspector.RemoteObject} nodeObject | 220 * @param {?WebInspector.RemoteObject} nodeObject |
221 * @this {WebInspector.EventListenerBar} | 221 * @this {WebInspector.EventListenerBar} |
222 */ | 222 */ |
223 function updateWithNodeObject(nodeObject) | 223 function updateWithNodeObject(nodeObject) |
224 { | 224 { |
225 var properties = []; | 225 var properties = []; |
| 226 var payload = this._eventListener.payload(); |
226 | 227 |
227 properties.push(this._runtimeModel.createRemotePropertyFromPrimitive
Value("type", this.eventListener.type)); | 228 properties.push(this._runtimeModel.createRemotePropertyFromPrimitive
Value("type", payload.type)); |
228 properties.push(this._runtimeModel.createRemotePropertyFromPrimitive
Value("useCapture", this.eventListener.useCapture)); | 229 properties.push(this._runtimeModel.createRemotePropertyFromPrimitive
Value("useCapture", payload.useCapture)); |
229 properties.push(this._runtimeModel.createRemotePropertyFromPrimitive
Value("isAttribute", this.eventListener.isAttribute)); | 230 properties.push(this._runtimeModel.createRemotePropertyFromPrimitive
Value("isAttribute", payload.isAttribute)); |
230 if (nodeObject) | 231 if (nodeObject) |
231 properties.push(new WebInspector.RemoteObjectProperty("node", no
deObject)); | 232 properties.push(new WebInspector.RemoteObjectProperty("node", no
deObject)); |
232 if (typeof this.eventListener.handler !== "undefined") { | 233 if (typeof payload.handler !== "undefined") { |
233 var remoteObject = this._runtimeModel.createRemoteObject(this.ev
entListener.handler); | 234 var remoteObject = this._runtimeModel.createRemoteObject(payload
.handler); |
234 properties.push(new WebInspector.RemoteObjectProperty("handler",
remoteObject)); | 235 properties.push(new WebInspector.RemoteObjectProperty("handler",
remoteObject)); |
235 } | 236 } |
236 properties.push(this._runtimeModel.createRemotePropertyFromPrimitive
Value("listenerBody", this.eventListener.handlerBody)); | 237 properties.push(this._runtimeModel.createRemotePropertyFromPrimitive
Value("listenerBody", payload.handlerBody)); |
237 if (this.eventListener.sourceName) | 238 if (payload.sourceName) |
238 properties.push(this._runtimeModel.createRemotePropertyFromPrimi
tiveValue("sourceName", this.eventListener.sourceName)); | 239 properties.push(this._runtimeModel.createRemotePropertyFromPrimi
tiveValue("sourceName", payload.sourceName)); |
239 properties.push(this._runtimeModel.createRemotePropertyFromPrimitive
Value("lineNumber", this.eventListener.location.lineNumber + 1)); | 240 properties.push(this._runtimeModel.createRemotePropertyFromPrimitive
Value("lineNumber", payload.location.lineNumber + 1)); |
240 | 241 |
241 this.updateProperties(properties); | 242 this.updateProperties(properties); |
242 } | 243 } |
243 this.eventListener.node.resolveToObject(WebInspector.EventListenersSideb
arPane._objectGroupName, updateWithNodeObject.bind(this)); | 244 this._eventListener.node().resolveToObject(WebInspector.EventListenersSi
debarPane._objectGroupName, updateWithNodeObject.bind(this)); |
244 }, | 245 }, |
245 | 246 |
246 _setNodeTitle: function() | 247 _setNodeTitle: function() |
247 { | 248 { |
248 var node = this.eventListener.node; | 249 var node = this._eventListener.node(); |
249 if (!node) | 250 if (!node) |
250 return; | 251 return; |
251 | 252 |
252 if (node.nodeType() === Node.DOCUMENT_NODE) { | 253 if (node.nodeType() === Node.DOCUMENT_NODE) { |
253 this.titleElement.textContent = "document"; | 254 this.titleElement.textContent = "document"; |
254 return; | 255 return; |
255 } | 256 } |
256 | 257 |
257 if (node.id === this._nodeId) { | 258 if (node.id === this._nodeId) { |
258 this.titleElement.textContent = WebInspector.DOMPresentationUtils.si
mpleSelector(node); | 259 this.titleElement.textContent = WebInspector.DOMPresentationUtils.si
mpleSelector(node); |
259 return; | 260 return; |
260 } | 261 } |
261 | 262 |
262 this.titleElement.removeChildren(); | 263 this.titleElement.removeChildren(); |
263 this.titleElement.appendChild(WebInspector.DOMPresentationUtils.linkifyN
odeReference(this.eventListener.node)); | 264 this.titleElement.appendChild(WebInspector.DOMPresentationUtils.linkifyN
odeReference(node)); |
264 }, | 265 }, |
265 | 266 |
266 _setFunctionSubtitle: function(linkifier) | 267 _setFunctionSubtitle: function(linkifier) |
267 { | 268 { |
268 this.subtitleElement.removeChildren(); | 269 this.subtitleElement.removeChildren(); |
269 var urlElement = linkifier.linkifyRawLocation(this.eventListener.locatio
n); | 270 this.subtitleElement.appendChild(linkifier.linkifyRawLocation(this._even
tListener.location())); |
270 if (!urlElement) { | |
271 var url = this.eventListener.sourceName; | |
272 var lineNumber = this.eventListener.location.lineNumber; | |
273 var columnNumber = 0; | |
274 urlElement = linkifier.linkifyLocation(url, lineNumber, columnNumber
); | |
275 } | |
276 this.subtitleElement.appendChild(urlElement); | |
277 }, | 271 }, |
278 | 272 |
279 __proto__: WebInspector.ObjectPropertiesSection.prototype | 273 __proto__: WebInspector.ObjectPropertiesSection.prototype |
280 } | 274 } |
OLD | NEW |