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

Unified Diff: webkit/glue/devtools/js/dom_agent.js

Issue 54002: Make DevTools client survive 'refresh' of the inspectable tab. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | « webkit/glue/devtools/js/devtools_host_stub.js ('k') | webkit/glue/devtools/js/inspector_controller_impl.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/devtools/js/dom_agent.js
===================================================================
--- webkit/glue/devtools/js/dom_agent.js (revision 12442)
+++ webkit/glue/devtools/js/dom_agent.js (working copy)
@@ -252,8 +252,6 @@
* @constructor
*/
devtools.DomAgent = function() {
- this.document = new devtools.DomDocument();
- this.idToDomNode_ = { 0 : this.document };
RemoteDomAgent.DidGetChildNodes =
devtools.Callback.processCallback;
RemoteDomAgent.DidPerformSearch =
@@ -270,18 +268,55 @@
goog.bind(this.childNodeInserted, this);
RemoteDomAgent.ChildNodeRemoved =
goog.bind(this.childNodeRemoved, this);
+
/**
+ * Top-level (and the only) document.
+ * @type {devtools.DomDocument}
+ * @private
+ */
+ this.document_ = null;
+
+ /**
+ * Id to node mapping.
+ * @type {Object}
+ * @private
+ */
+ this.idToDomNode_ = null;
+
+ /**
* @type {Array.<number>} Node ids for search results.
+ * @private
*/
+ this.searchResults_ = null;
+
+ this.reset();
+};
+
+
+/**
+ * Rests dom agent to its initial state.
+ */
+devtools.DomAgent.prototype.reset = function() {
+ RemoteDomAgent.DiscardBindings();
+ this.document_ = new devtools.DomDocument();
+ this.idToDomNode_ = { 0 : this.document_ };
this.searchResults_ = [];
};
/**
+ * @return {devtools.DomDocument} Top level (and the only) document.
+ */
+devtools.DomAgent.prototype.getDocument = function() {
+ return this.document_;
+};
+
+
+/**
* Requests that the document element is sent from the agent.
*/
devtools.DomAgent.prototype.getDocumentElementAsync = function() {
- if (this.document.documentElement) {
+ if (this.document_.documentElement) {
return;
}
RemoteDomAgent.GetDocumentElement();
@@ -337,13 +372,13 @@
* {@inheritDoc}.
*/
devtools.DomAgent.prototype.setDocumentElement = function(payload) {
- if (this.document.documentElement) {
+ if (this.document_.documentElement) {
return;
}
this.setChildNodes(0, [payload]);
- this.document.documentElement = this.document.firstChild;
- this.document.documentElement.ownerDocument = this.document;
- this.document.fireDomEvent_("DOMContentLoaded");
+ this.document_.documentElement = this.document_.firstChild;
+ this.document_.documentElement.ownerDocument = this.document_;
+ this.document_.fireDomEvent_("DOMContentLoaded");
};
@@ -395,7 +430,7 @@
var node = parent.insertChild_(prev, payload);
this.idToDomNode_[node.id] = node;
var event = { target : node, relatedNode : parent };
- this.document.fireDomEvent_("DOMNodeInserted", event);
+ this.document_.fireDomEvent_("DOMNodeInserted", event);
};
@@ -409,7 +444,7 @@
var node = this.idToDomNode_[nodeId];
parent.removeChild_(node);
var event = { target : node, relatedNode : parent };
- this.document.fireDomEvent_("DOMNodeRemoved", event);
+ this.document_.fireDomEvent_("DOMNodeRemoved", event);
delete this.idToDomNode_[nodeId];
};
« no previous file with comments | « webkit/glue/devtools/js/devtools_host_stub.js ('k') | webkit/glue/devtools/js/inspector_controller_impl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698