Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(963)

Unified Diff: Source/devtools/front_end/DOMModel.js

Issue 220903002: DevTools: wrap DebuggerAgent.Location with DebuggerModel.Location. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: All tests!!! Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/ConsoleViewMessage.js ('k') | Source/devtools/front_end/DebuggerModel.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/DOMModel.js
diff --git a/Source/devtools/front_end/DOMModel.js b/Source/devtools/front_end/DOMModel.js
index ced709aea9c63bdba3f637a5bddcc59c2aea5070..cc31a23eb3508d66c1d9a0d3df5c4cdfce25fe9c 100644
--- a/Source/devtools/front_end/DOMModel.js
+++ b/Source/devtools/front_end/DOMModel.js
@@ -38,7 +38,7 @@
* @param {!DOMAgent.Node} payload
*/
WebInspector.DOMNode = function(domModel, doc, isInShadowTree, payload) {
- WebInspector.TargetAware.call(this, domModel._target);
+ WebInspector.TargetAware.call(this, domModel.target());
this._domModel = domModel;
this._agent = domModel._agent;
this.ownerDocument = doc;
@@ -468,11 +468,27 @@ WebInspector.DOMNode.prototype = {
/**
* @param {string} objectGroupId
- * @param {function(?Protocol.Error, !Array.<!DOMAgent.EventListener>)=} callback
+ * @param {function(?Array.<!WebInspector.DOMModel.EventListener>)} callback
*/
eventListeners: function(objectGroupId, callback)
{
- this._agent.getEventListenersForNode(this.id, objectGroupId, callback);
+ var target = this.target();
+
+ /**
+ * @param {?Protocol.Error} error
+ * @param {!Array.<!DOMAgent.EventListener>} payloads
+ */
+ function mycallback(error, payloads)
+ {
+ if (error) {
+ callback(null);
+ return;
+ }
+ callback(payloads.map(function(payload) {
+ return new WebInspector.DOMModel.EventListener(target, payload);
+ }));
+ }
+ this._agent.getEventListenersForNode(this.id, objectGroupId, mycallback);
},
/**
@@ -860,12 +876,13 @@ WebInspector.DOMDocument.prototype = {
}
/**
- * @extends {WebInspector.Object}
* @constructor
+ * @extends {WebInspector.TargetAwareObject}
* @param {!WebInspector.Target} target
*/
WebInspector.DOMModel = function(target) {
- this._target = target;
+ WebInspector.TargetAwareObject.call(this, target);
+
this._agent = target.domAgent();
/** @type {!Object.<number, !WebInspector.DOMNode>} */
@@ -1551,7 +1568,7 @@ WebInspector.DOMModel.prototype = {
this._highlighter = highlighter || this._defaultHighlighter;
},
- __proto__: WebInspector.Object.prototype
+ __proto__: WebInspector.TargetAwareObject.prototype
}
/**
@@ -1689,6 +1706,54 @@ WebInspector.DOMDispatcher.prototype = {
}
/**
+ * @constructor
+ * @extends {WebInspector.TargetAware}
+ * @param {!WebInspector.Target} target
+ * @param {!DOMAgent.EventListener} payload
+ */
+WebInspector.DOMModel.EventListener = function(target, payload)
+{
+ WebInspector.TargetAware.call(this, target);
+ this._payload = payload;
+}
+
+WebInspector.DOMModel.EventListener.prototype = {
+ /**
+ * @return {!DOMAgent.EventListener}
+ */
+ payload: function()
+ {
+ return this._payload;
+ },
+
+ /**
+ * @return {?WebInspector.DOMNode}
+ */
+ node: function()
+ {
+ return this.target().domModel.nodeForId(this._payload.nodeId);
+ },
+
+ /**
+ * @return {!WebInspector.DebuggerModel.Location}
+ */
+ location: function()
+ {
+ return WebInspector.DebuggerModel.Location.fromPayload(this.target(), this._payload.location);
+ },
+
+ /**
+ * @return {?WebInspector.RemoteObject}
+ */
+ handler: function()
+ {
+ return this._payload.handler ? this.target().runtimeModel.createRemoteObject(this._payload.handler) : null;
+ },
+
+ __proto__: WebInspector.TargetAware.prototype
+}
+
+/**
* @interface
*/
WebInspector.DOMNodeHighlighter = function() {
« no previous file with comments | « Source/devtools/front_end/ConsoleViewMessage.js ('k') | Source/devtools/front_end/DebuggerModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698