[DevTools] Refactor WebInspector.EventListener

Move logic from cstor for reusing it in future CLs.

R=pfeldman@chromium.org

Review URL: https://codereview.chromium.org/1319613002

git-svn-id: svn://svn.chromium.org/blink/trunk@201165 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 19625a92
......@@ -8,7 +8,7 @@ type: scroll
useCapture: true
location: 16, 78
handler: function foo() {}
sourceName: domdebugger-getEventListeners.html
sourceURL: domdebugger-getEventListeners.html
Running: testDivEventListeners
......@@ -16,13 +16,13 @@ type: click
useCapture: true
location: 16, 79
handler: function boo() {}
sourceName: domdebugger-getEventListeners.html
sourceURL: domdebugger-getEventListeners.html
type: mouseout
useCapture: false
location: 16, 78
handler: function foo() {}
sourceName: domdebugger-getEventListeners.html
sourceURL: domdebugger-getEventListeners.html
type: click
useCapture: false
......@@ -30,7 +30,7 @@ location: 37, 75
handler: function onclick(event) {
return 42;
}
sourceName: domdebugger-getEventListeners.html
sourceURL: domdebugger-getEventListeners.html
Running: testDivWithoutEventListeners
......
......@@ -12,15 +12,15 @@ function test()
{
for (var i = 0; i < listeners.length; ++i) {
delete listeners[i]._location.scriptId;
var sourceName = listeners[i]._sourceName;
sourceName = sourceName.substr(sourceName.lastIndexOf('/') + 1);
listeners[i]._sourceName = sourceName;
var sourceURL = listeners[i]._sourceURL;
sourceURL = sourceURL.substr(sourceURL.lastIndexOf('/') + 1);
listeners[i]._sourceURL = sourceURL;
InspectorTest.addResult("type: " + listeners[i].type());
InspectorTest.addResult("useCapture: " + listeners[i].useCapture());
InspectorTest.addResult("location: " + listeners[i].location().columnNumber + ", " + listeners[i].location().lineNumber);
InspectorTest.addResult("handler: " + listeners[i].handler().description);
InspectorTest.addResult("sourceName: " + listeners[i].sourceName());
InspectorTest.addResult("sourceURL: " + listeners[i].sourceURL());
InspectorTest.addResult("");
}
next();
......
......@@ -170,7 +170,7 @@ WebInspector.ObjectEventListenerBar.prototype = {
{
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()));
subtitle.appendChild(linkifier.linkifyRawLocation(this._eventListener.location(), this._eventListener.sourceURL()));
title.appendChild(WebInspector.ObjectPropertiesSection.createValueElement(object, false));
},
......
......@@ -555,7 +555,11 @@ WebInspector.RemoteObjectImpl.prototype = {
*/
function createEventListener(payload)
{
return new WebInspector.EventListener(this._debuggerModel, payload, this._objectId);
return new WebInspector.EventListener(this._target,
payload.type,
payload.useCapture,
payload.handler ? this.target().runtimeModel.createRemoteObject(payload.handler) : null,
WebInspector.DebuggerModel.Location.fromPayload(this._debuggerModel, payload.location));
}
}
},
......
......@@ -493,20 +493,20 @@ WebInspector.ExecutionContext.prototype = {
/**
* @constructor
* @extends {WebInspector.SDKObject}
* @param {!WebInspector.DebuggerModel} debuggerModel
* @param {!DOMDebuggerAgent.EventListener} payload
* @param {!RuntimeAgent.RemoteObjectId} objectId
* @param {!WebInspector.Target} target
* @param {string} type
* @param {boolean} useCapture
* @param {?WebInspector.RemoteObject} handler
* @param {!WebInspector.DebuggerModel.Location} location
*/
WebInspector.EventListener = function(debuggerModel, payload, objectId)
WebInspector.EventListener = function(target, type, useCapture, handler, location)
{
WebInspector.SDKObject.call(this, debuggerModel.target());
this._type = payload.type;
this._useCapture = payload.useCapture;
this._location = WebInspector.DebuggerModel.Location.fromPayload(debuggerModel, payload.location);
this._handler = payload.handler ? this.target().runtimeModel.createRemoteObject(payload.handler) : null;
var script = debuggerModel.scriptForId(payload.location.scriptId);
this._sourceName = script ? script.contentURL() : "";
this._objectId = objectId;
WebInspector.SDKObject.call(this, target);
this._type = type;
this._useCapture = useCapture;
this._handler = handler;
this._location = location;
this._sourceURL = location.script().contentURL();
}
WebInspector.EventListener.prototype = {
......@@ -526,14 +526,6 @@ WebInspector.EventListener.prototype = {
return this._useCapture;
},
/**
* @return {!WebInspector.DebuggerModel.Location}
*/
location: function()
{
return this._location;
},
/**
* @return {?WebInspector.RemoteObject}
*/
......@@ -543,20 +535,20 @@ WebInspector.EventListener.prototype = {
},
/**
* @return {string}
* @return {!WebInspector.DebuggerModel.Location}
*/
sourceName: function()
location: function()
{
return this._sourceName;
return this._location;
},
/**
* @return {!RuntimeAgent.RemoteObjectId}
* @return {string}
*/
objectId: function()
{
return this._objectId;
},
sourceURL: function()
{
return this._sourceURL;
},
__proto__: WebInspector.SDKObject.prototype
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment