summaryrefslogtreecommitdiffstats
path: root/webkit/glue/devtools/js
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue/devtools/js')
-rw-r--r--webkit/glue/devtools/js/devtools.html1
-rw-r--r--webkit/glue/devtools/js/devtools.js169
-rw-r--r--webkit/glue/devtools/js/devtools_host_stub.js119
-rw-r--r--webkit/glue/devtools/js/dom_agent.js746
-rw-r--r--webkit/glue/devtools/js/inject.js62
-rw-r--r--webkit/glue/devtools/js/inject_dispatch.js9
-rw-r--r--webkit/glue/devtools/js/inspector_controller_impl.js105
7 files changed, 51 insertions, 1160 deletions
diff --git a/webkit/glue/devtools/js/devtools.html b/webkit/glue/devtools/js/devtools.html
index 2bc83c7..a568f67 100644
--- a/webkit/glue/devtools/js/devtools.html
+++ b/webkit/glue/devtools/js/devtools.html
@@ -49,7 +49,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<script type="text/javascript" src="treeoutline.js"></script>
<script type="text/javascript" src="devtools_callback.js"></script>
<script type="text/javascript" src="debugger_agent.js"></script>
- <script type="text/javascript" src="dom_agent.js"></script>
<script type="text/javascript" src="inspector_controller.js"></script>
<script type="text/javascript" src="inspector.js"></script>
<script type="text/javascript" src="codemap.js"></script>
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js
index be76df6..16cbd0f 100644
--- a/webkit/glue/devtools/js/devtools.js
+++ b/webkit/glue/devtools/js/devtools.js
@@ -10,7 +10,6 @@
goog.provide('devtools.Tools');
goog.require('devtools.DebuggerAgent');
-goog.require('devtools.DomAgent');
/**
@@ -36,11 +35,8 @@ devtools.dispatch = function(remoteName, methodName, msg) {
devtools.ToolsAgent = function() {
- RemoteToolsAgent.DidEvaluateJavaScript = devtools.Callback.processCallback;
RemoteToolsAgent.DidExecuteUtilityFunction =
devtools.Callback.processCallback;
- RemoteToolsAgent.UpdateFocusedNode =
- goog.bind(this.updateFocusedNode_, this);
RemoteToolsAgent.FrameNavigate =
goog.bind(this.frameNavigate_, this);
RemoteToolsAgent.DispatchOnClient =
@@ -48,7 +44,6 @@ devtools.ToolsAgent = function() {
RemoteToolsAgent.SetResourcesPanelEnabled =
goog.bind(this.setResourcesPanelEnabled_, this);
this.debuggerAgent_ = new devtools.DebuggerAgent();
- this.domAgent_ = new devtools.DomAgent();
};
@@ -57,10 +52,7 @@ devtools.ToolsAgent = function() {
*/
devtools.ToolsAgent.prototype.reset = function() {
DevToolsHost.reset();
- this.domAgent_.reset();
this.debuggerAgent_.reset();
-
- this.domAgent_.getDocumentElementAsync();
};
@@ -72,16 +64,7 @@ devtools.ToolsAgent.prototype.reset = function() {
*/
devtools.ToolsAgent.prototype.evaluateJavaScript = function(script,
opt_callback) {
- var callbackId = devtools.Callback.wrap(function(result, exception) {
- if (opt_callback) {
- if (exception) {
- opt_callback(exception, true /* result is exception */);
- } else {
- opt_callback(JSON.parse(result), false);
- }
- }
- });
- RemoteToolsAgent.EvaluateJavaScript(callbackId, script);
+ InspectorController.evaluate(script, opt_callback || function() {});
};
@@ -92,24 +75,6 @@ devtools.ToolsAgent.prototype.getDebuggerAgent = function() {
return this.debuggerAgent_;
};
-/**
- * DomAgent accessor.
- * @return {devtools.DomAgent} Dom agent instance.
- */
-devtools.ToolsAgent.prototype.getDomAgent = function() {
- return this.domAgent_;
-};
-
-
-/**
- * @see tools_agent.h
- * @private
- */
-devtools.ToolsAgent.prototype.updateFocusedNode_ = function(nodeId) {
- var node = this.domAgent_.getNodeForId(nodeId);
- WebInspector.updateFocusedNode(node);
-};
-
/**
* @param {string} url Url frame navigated to.
@@ -251,94 +216,6 @@ var webkitUpdateChildren =
/**
- * @override
- */
-WebInspector.ElementsTreeElement.prototype.updateChildren = function() {
- var self = this;
- devtools.tools.getDomAgent().getChildNodesAsync(this.representedObject,
- function() {
- webkitUpdateChildren.call(self);
- });
-};
-
-
-/**
- * @override
- */
-WebInspector.ElementsPanel.prototype.performSearch = function(query) {
- this.searchCanceled();
- devtools.tools.getDomAgent().performSearch(query,
- goog.bind(this.performSearchCallback_, this));
-};
-
-
-WebInspector.ElementsPanel.prototype.performSearchCallback_ = function(nodes) {
- for (var i = 0; i < nodes.length; ++i) {
- var treeElement = this.treeOutline.findTreeElement(nodes[i]);
- if (treeElement)
- treeElement.highlighted = true;
- }
-
- if (nodes.length) {
- this.currentSearchResultIndex_ = 0;
- this.focusedDOMNode = nodes[0];
- }
-
- this.searchResultCount_ = nodes.length;
-};
-
-
-/**
- * @override
- */
-WebInspector.ElementsPanel.prototype.searchCanceled = function() {
- this.currentSearchResultIndex_ = 0;
- this.searchResultCount_ = 0;
- devtools.tools.getDomAgent().searchCanceled(
- goog.bind(this.searchCanceledCallback_, this));
-};
-
-
-WebInspector.ElementsPanel.prototype.searchCanceledCallback_ = function(nodes) {
- for (var i = 0; i < nodes.length; i++) {
- var treeElement = this.treeOutline.findTreeElement(nodes[i]);
- if (treeElement)
- treeElement.highlighted = false;
- }
-};
-
-
-/**
- * @override
- */
-WebInspector.ElementsPanel.prototype.jumpToNextSearchResult = function() {
- if (!this.searchResultCount_)
- return;
-
- if (++this.currentSearchResultIndex_ >= this.searchResultCount_)
- this.currentSearchResultIndex_ = 0;
-
- this.focusedDOMNode = devtools.tools.getDomAgent().
- getSearchResultNode(this.currentSearchResultIndex_);
-};
-
-
-/**
- * @override
- */
-WebInspector.ElementsPanel.prototype.jumpToPreviousSearchResult = function() {
- if (!this.searchResultCount_)
- return;
-
- if (--this.currentSearchResultIndex_ < 0)
- this.currentSearchResultIndex_ = this.searchResultCount_ - 1;
-
- this.focusedDOMNode = devtools.tools.getDomAgent().
- getSearchResultNode(this.currentSearchResultIndex_);
-};
-
-
-/**
* This override is necessary for adding script source asynchronously.
* @override
*/
@@ -382,39 +259,6 @@ WebInspector.ScriptView.prototype.didResolveScriptSource_ = function() {
/**
- * Callback function used with the getNodeProperties.
- */
-WebInspector.didGetNodePropertiesAsync_ = function(treeOutline, constructor,
- nodeId, path, json) {
- var props = JSON.parse(json);
- var properties = [];
- var obj = {};
- obj.devtools$$nodeId_ = nodeId;
- obj.devtools$$path_ = path;
- for (var i = 0; i < props.length; i += 4) {
- var type = props[i];
- var name = props[i + 1];
- var value = props[i + 2];
- var className = props[i + 3];
- properties.push(name);
- if (type == 'object' || type == 'function') {
- // fake object is going to be replaced on expand.
- obj[name] = new WebInspector.UnresolvedPropertyValue(type, className);
- } else {
- obj[name] = value;
- }
- }
- properties.sort();
- treeOutline.removeChildren();
-
- for (var i = 0; i < properties.length; ++i) {
- var propertyName = properties[i];
- treeOutline.appendChild(new constructor(obj, propertyName));
- }
-};
-
-
-/**
* @param {string} type Type of the the property value('object' or 'function').
* @param {string} className Class name of the property value.
* @constructor
@@ -655,17 +499,6 @@ WebInspector.ScriptsPanel.prototype.__defineGetter__(
WebInspector.searchableViews_);
-WebInspector.ConsoleView.prototype.doEvalInWindow =
- function(expression, callback) {
- if (!expression ) {
- // Empty expression should evaluate to the global object for completions to
- // work.
- expression = "this";
- }
- devtools.tools.evaluateJavaScript(expression, callback);
-};
-
-
WebInspector.ScriptsPanel.prototype.doEvalInCallFrame =
function(callFrame, expression, callback) {
if (!expression) {
diff --git a/webkit/glue/devtools/js/devtools_host_stub.js b/webkit/glue/devtools/js/devtools_host_stub.js
index 73255fe..783d29c 100644
--- a/webkit/glue/devtools/js/devtools_host_stub.js
+++ b/webkit/glue/devtools/js/devtools_host_stub.js
@@ -81,107 +81,6 @@ RemoteDebuggerAgentStub.prototype.GetNextLogLines = function() {
/**
* @constructor
*/
-RemoteDomAgentStub = function() {
-};
-
-
-RemoteDomAgentStub.sendDocumentElement_ = function() {
- RemoteDomAgent.SetDocumentElement([
- 1, // id
- 1, // type = Node.ELEMENT_NODE,
- 'HTML', // nodeName
- '', // nodeValue
- ['foo','bar'], // attributes
- 2, // childNodeCount
- ]);
-};
-
-
-RemoteDomAgentStub.sendChildNodes_ = function(id) {
- if (id == 1) {
- RemoteDomAgent.SetChildNodes(id,
- [
- [
- 2, // id
- 1, // type = Node.ELEMENT_NODE,
- 'DIV', // nodeName
- '', // nodeValue
- ['foo','bar'], // attributes
- 1, // childNodeCount
- ],
- [
- 3, // id
- 3, // type = Node.TEXT_NODE,
- '', // nodeName
- 'Text', // nodeValue
- ]
- ]);
- } else if (id == 2) {
- RemoteDomAgent.SetChildNodes(id,
- [
- [
- 4, // id
- 1, // type = Node.ELEMENT_NODE,
- 'span', // nodeName
- '', // nodeValue
- ['foo','bar'], // attributes
- 0, // childNodeCount
- ]
- ]);
- }
-};
-
-
-RemoteDomAgentStub.prototype.GetDocumentElement = function(callId) {
- setTimeout(function() {
- RemoteDomAgentStub.sendDocumentElement_();
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.GetChildNodes = function(callId, id) {
- setTimeout(function() {
- RemoteDomAgentStub.sendChildNodes_(id);
- RemoteDomAgent.DidGetChildNodes(callId);
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.SetAttribute = function(callId) {
- setTimeout(function() {
- RemoteDomAgent.DidApplyDomChange(callId, true);
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.RemoveAttribute = function(callId) {
- setTimeout(function() {
- RemoteDomAgent.DidApplyDomChange(callId, true);
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.SetTextNodeValue = function(callId) {
- setTimeout(function() {
- RemoteDomAgent.DidApplyDomChange(callId, true);
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.PerformSearch = function(callId, query) {
- setTimeout(function() {
- RemoteDomAgent.DidPerformSearch(callId, [1]);
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.DiscardBindings = function() {
-};
-
-
-/**
- * @constructor
- */
RemoteToolsAgentStub = function() {
};
@@ -259,18 +158,6 @@ RemoteToolsAgentStub.prototype.ExecuteUtilityFunction = function(callId,
};
-RemoteToolsAgentStub.prototype.GetNodePrototypes = function(callId, nodeId) {
- setTimeout(function() {
- RemoteToolsAgent.DidGetNodePrototypes(callId,
- JSON.stringify());
- }, 0);
-};
-
-
-RemoteToolsAgentStub.prototype.ClearConsoleMessages = function() {
-};
-
-
RemoteToolsAgentStub.prototype.SetResourceTrackingEnabled = function(enabled, always) {
RemoteToolsAgent.SetResourcesPanelEnabled(enabled);
if (enabled) {
@@ -384,12 +271,7 @@ function addDummyResource() {
DevToolsHostStub.prototype.loaded = function() {
- RemoteDomAgentStub.sendDocumentElement_();
- RemoteDomAgentStub.sendChildNodes_(1);
- RemoteDomAgentStub.sendChildNodes_(2);
- devtools.tools.updateFocusedNode_(4);
addDummyResource();
-
uiTests.runAllTests();
};
@@ -417,7 +299,6 @@ if (!window['DevToolsHost']) {
window['RemoteDebuggerAgent'] = new RemoteDebuggerAgentStub();
window['RemoteDebuggerCommandExecutor'] =
new RemoteDebuggerCommandExecutorStub();
- window['RemoteDomAgent'] = new RemoteDomAgentStub();
window['RemoteToolsAgent'] = new RemoteToolsAgentStub();
window['DevToolsHost'] = new DevToolsHostStub();
}
diff --git a/webkit/glue/devtools/js/dom_agent.js b/webkit/glue/devtools/js/dom_agent.js
deleted file mode 100644
index ca08205..0000000
--- a/webkit/glue/devtools/js/dom_agent.js
+++ /dev/null
@@ -1,746 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @fileoverview Dom and DomNode are used to represent remote DOM in the
- * web inspector.
- */
-goog.provide('devtools.DomAgent');
-goog.provide('devtools.DomDocument');
-goog.provide('devtools.DomNode');
-
-goog.require('devtools.Callback');
-
-
-/**
- * Defines indexes for the node payload properties.
- */
-devtools.PayloadIndex = {
- ID : 0,
- TYPE : 1,
- NAME : 2,
- VALUE : 3,
- ATTRS : 4,
- HAS_CHILDREN : 5,
- CHILD_NODES : 6
-};
-
-
-/**
- * Creates document node in a given document based on a given payload data.
- * @param {devtools.Doc} doc Document to create node in.
- * @param {Array.<Object>} payload Data to build node based upon.
- * @constructor
- */
-devtools.DomNode = function(doc, payload) {
- this.ownerDocument = doc;
-
- this.id_ = payload[devtools.PayloadIndex.ID];
- this.nodeType = payload[devtools.PayloadIndex.TYPE];
- this.nodeName = payload[devtools.PayloadIndex.NAME];
- this.nodeValue_ = payload[devtools.PayloadIndex.VALUE];
- this.textContent = this.nodeValue;
-
- this.attributes = [];
- this.attributesMap_ = {};
- if (payload.length > devtools.PayloadIndex.ATTRS) {
- this.setAttributesPayload_(payload[devtools.PayloadIndex.ATTRS]);
- }
-
- this.childNodesCount_ = payload[devtools.PayloadIndex.HAS_CHILDREN];
- this.children = null;
-
- this.nextSibling = null;
- this.prevSibling = null;
- this.firstChild = null;
- this.parentNode = null;
-
- if (payload.length > devtools.PayloadIndex.CHILD_NODES) {
- // Has children payloads
- this.setChildrenPayload_(
- payload[devtools.PayloadIndex.CHILD_NODES]);
- }
-};
-
-
-/**
- * Overrides for getters and setters.
- */
-devtools.DomNode.prototype = {
- get nodeValue() {
- return this.nodeValue_;
- },
-
- set nodeValue(value) {
- if (this.nodeType != Node.TEXT_NODE) {
- return;
- }
- var self = this;
- this.ownerDocument.domAgent_.setTextNodeValueAsync(this, value,
- function() {
- self.nodeValue_ = value;
- self.textContent = value;
- });
- }
-};
-
-
-/**
- * Sets attributes for a given node based on a given attrs payload.
- * @param {Array.<string>} attrs Attribute key-value pairs to set.
- * @private
- */
-devtools.DomNode.prototype.setAttributesPayload_ = function(attrs) {
- for (var i = 0; i < attrs.length; i += 2) {
- this.addAttribute_(attrs[i], attrs[i + 1]);
- }
-};
-
-
-/**
- * @return True iff node has attributes.
- */
-devtools.DomNode.prototype.hasAttributes = function() {
- return this.attributes.length > 0;
-};
-
-
-/**
- * @return True iff node has child nodes.
- */
-devtools.DomNode.prototype.hasChildNodes = function() {
- return this.childNodesCount_ > 0;
-};
-
-
-/**
- * Inserts child node into this node after a given anchor.
- * @param {devtools.DomNode} prev Node to insert child after.
- * @param {Array.<Object>} payload Child node data.
- * @private
- */
-devtools.DomNode.prototype.insertChild_ = function(prev, payload) {
- var node = new devtools.DomNode(this.ownerDocument, payload);
- if (!prev) {
- // First node
- this.children = [ node ];
- } else {
- this.children.splice(this.children.indexOf(prev) + 1, 0, node);
- }
- this.renumber_();
- return node;
-};
-
-
-/**
- * Removes child node from this node.
- * @param {devtools.DomNode} node Node to remove.
- * @private
- */
-devtools.DomNode.prototype.removeChild_ = function(node) {
- this.children.splice(this.children.indexOf(node), 1);
- node.parentNode = null;
- this.renumber_();
-};
-
-
-/**
- * Sets children for this node based on the given payload.
- * @param {Array.<Object>} payload Data for children.
- * @private
- */
-devtools.DomNode.prototype.setChildrenPayload_ = function(payloads) {
- this.children = [];
- for (var i = 0; i < payloads.length; ++i) {
- var payload = payloads[i];
- var node = new devtools.DomNode(this.ownerDocument, payload);
- this.children.push(node);
- }
- this.renumber_();
-};
-
-
-/**
- * Normalizes prev/next/parent/firstChild links for this node's children.
- * @private
- */
-devtools.DomNode.prototype.renumber_ = function() {
- this.childNodesCount_ = this.children.length;
- if (this.childNodesCount_ == 0) {
- this.firstChild = null;
- return;
- }
- this.firstChild = this.children[0];
- for (var i = 0; i < this.childNodesCount_; ++i) {
- var child = this.children[i];
- child.nextSibling = i + 1 < this.childNodesCount_ ?
- this.children[i + 1] : null;
- child.prevSibling = i - 1 >= 0 ? this.children[i - 1] : null;
- child.parentNode = this;
- }
-};
-
-
-/**
- * Returns attribute value.
- * @param {string} name Attribute name to get value for.
- * @return {string} Attribute value.
- */
-devtools.DomNode.prototype.getAttribute = function(name) {
- var attr = this.attributesMap_[name];
- return attr ? attr.value : undefined;
-};
-
-
-/**
- * Sends 'set attribute' command to the remote agent.
- * @param {string} name Attribute name to set value for.
- * @param {string} value Attribute value to set.
- */
-devtools.DomNode.prototype.setAttribute = function(name, value) {
- var self = this;
- this.ownerDocument.domAgent_.setAttributeAsync(this, name, value,
- function() {
- var attr = self.attributesMap_[name];
- if (attr) {
- attr.value = value;
- } else {
- attr = self.addAttribute_(name, value);
- }
- });
-};
-
-
-/**
- * Creates an attribute-like object and adds it to the object.
- * @param {string} name Attribute name to set value for.
- * @param {string} value Attribute value to set.
- */
-devtools.DomNode.prototype.addAttribute_ = function(name, value) {
- var attr = {
- 'name': name,
- 'value': value,
- node_: this
- };
-
- this.attributesMap_[name] = attr;
- this.attributes.push(attr);
-};
-
-
-/**
- * Sends 'remove attribute' command to the remote agent.
- * @param {string} name Attribute name to set value for.
- */
-devtools.DomNode.prototype.removeAttribute = function(name) {
- var self = this;
- this.ownerDocument.domAgent_.removeAttributeAsync(this, name, function() {
- delete self.attributesMap_[name];
- for (var i = 0; i < self.attributes.length; ++i) {
- if (self.attributes[i].name == name) {
- self.attributes.splice(i, 1);
- break;
- }
- }
- });
-};
-
-
-/**
- * Remote Dom document abstraction.
- * @param {devtools.DomAgent} domAgent owner agent.
- * @param {devtools.DomWindow} defaultView owner window.
- * @constructor.
- */
-devtools.DomDocument = function(domAgent, defaultView) {
- devtools.DomNode.call(this, null,
- [
- 0, // id
- 9, // type = Node.DOCUMENT_NODE,
- '', // nodeName
- '', // nodeValue
- [], // attributes
- 0, // childNodeCount
- ]);
- this.listeners_ = {};
- this.domAgent_ = domAgent;
- this.defaultView = defaultView;
-};
-goog.inherits(devtools.DomDocument, devtools.DomNode);
-
-
-/**
- * Adds event listener to the Dom.
- * @param {string} name Event name.
- * @param {function(Event):undefined} callback Listener callback.
- * @param {bool} useCapture Listener's useCapture settings.
- */
-devtools.DomDocument.prototype.addEventListener =
- function(name, callback, useCapture) {
- var listeners = this.listeners_[name];
- if (!listeners) {
- listeners = [];
- this.listeners_[name] = listeners;
- }
- listeners.push(callback);
-};
-
-
-/**
- * Removes event listener from the Dom.
- * @param {string} name Event name.
- * @param {function(Event):undefined} callback Listener callback.
- * @param {bool} useCapture Listener's useCapture settings.
- */
-devtools.DomDocument.prototype.removeEventListener =
- function(name, callback, useCapture) {
- var listeners = this.listeners_[name];
- if (!listeners) {
- return;
- }
- var index = listeners.indexOf(callback);
- if (index != -1) {
- listeners.splice(index, 1);
- }
-};
-
-
-/**
- * Fires Dom event to the listeners for given event type.
- * @param {string} name Event type.
- * @param {Event} event Event to fire.
- * @private
- */
-devtools.DomDocument.prototype.fireDomEvent_ = function(name, event) {
- var listeners = this.listeners_[name];
- if (!listeners) {
- return;
- }
- for (var i = 0; i < listeners.length; ++i) {
- listeners[i](event);
- }
-};
-
-
-
-/**
- * Simulation of inspected DOMWindow.
- * @param {devtools.DomAgent} domAgent owner agent.
- * @constructor
- */
-devtools.DomWindow = function(domAgent) {
- this.document = new devtools.DomDocument(domAgent, this);
-};
-
-
-/**
- * Represents DOM Node class.
- */
-devtools.DomWindow.prototype.__defineGetter__('Node', function() {
- return devtools.DomNode;
-});
-
-
-/**
- * Represents DOM NodeList class.
- * @constructor
- */
-devtools.DomWindow.prototype.__defineGetter__('NodeList', function() {
- return function() {};
-});
-
-
-/**
- * Represents DOM Element class.
- * @constructor
- */
-devtools.DomWindow.prototype.__defineGetter__('Element', function() {
- return devtools.DomNode;
-});
-
-
-/**
- * See usages in ScopeChainSidebarPane.js where it's called as
- * constructor.
- */
-devtools.DomWindow.prototype.Object = function() {
-};
-
-
-/**
- * Creates DomAgent Js representation.
- * @constructor
- */
-devtools.DomAgent = function() {
- RemoteDomAgent.DidGetChildNodes =
- devtools.Callback.processCallback;
- RemoteDomAgent.DidPerformSearch =
- devtools.Callback.processCallback;
- RemoteDomAgent.DidApplyDomChange =
- devtools.Callback.processCallback;
- RemoteDomAgent.DidRemoveAttribute =
- devtools.Callback.processCallback;
- RemoteDomAgent.DidSetTextNodeValue =
- devtools.Callback.processCallback;
- RemoteDomAgent.AttributesUpdated =
- goog.bind(this.attributesUpdated_, this);
- RemoteDomAgent.SetDocumentElement =
- goog.bind(this.setDocumentElement_, this);
- RemoteDomAgent.SetChildNodes =
- goog.bind(this.setChildNodes_, this);
- RemoteDomAgent.HasChildrenUpdated =
- goog.bind(this.hasChildrenUpdated_, this);
- RemoteDomAgent.ChildNodeInserted =
- goog.bind(this.childNodeInserted_, this);
- RemoteDomAgent.ChildNodeRemoved =
- goog.bind(this.childNodeRemoved_, this);
-
- /**
- * Top-level (and the only) document.
- * @type {devtools.DomWindow}
- * @private
- */
- this.window_ = null;
-
- /**
- * Id to node mapping.
- * @type {Object}
- * @private
- */
- this.idToDomNode_ = null;
-
- /**
- * @type {Array.<number>} Node ids for search results.
- * @private
- */
- this.searchResults_ = null;
-};
-
-
-/**
- * Resets dom agent to its initial state.
- */
-devtools.DomAgent.prototype.reset = function() {
- this.window_ = new devtools.DomWindow(this);
- this.idToDomNode_ = { 0 : this.getDocument() };
- this.searchResults_ = [];
-};
-
-
-/**
- * @return {devtools.DomWindow} Window for the top level (and the only) document.
- */
-devtools.DomAgent.prototype.getWindow = function() {
- return this.window_;
-};
-
-
-/**
- * @return {devtools.DomDocument} A document of the top level window.
- */
-devtools.DomAgent.prototype.getDocument = function() {
- return this.window_.document;
-};
-
-
-/**
- * Requests that the document element is sent from the agent.
- */
-devtools.DomAgent.prototype.getDocumentElementAsync = function() {
- if (this.getDocument().documentElement) {
- return;
- }
- RemoteDomAgent.GetDocumentElement();
-};
-
-
-/**
- * Asynchronously fetches children from the element with given id.
- * @param {devtools.DomNode} parent Element to get children for.
- * @param {function(devtools.DomNode):undefined} opt_callback Callback with
- * the result.
- */
-devtools.DomAgent.prototype.getChildNodesAsync = function(parent,
- opt_callback) {
- var children = parent.children;
- if (children && opt_callback) {
- opt_callback(children);
- return;
- }
- var mycallback = function() {
- if (opt_callback) {
- opt_callback(parent.children);
- }
- };
- var callId = devtools.Callback.wrap(mycallback);
- RemoteDomAgent.GetChildNodes(callId, parent.id_);
-};
-
-
-/**
- * Sends 'set attribute' command to the remote agent.
- * @param {devtools.DomNode} node Node to change.
- * @param {string} name Attribute name to set value for.
- * @param {string} value Attribute value to set.
- * @param {function():undefined} opt_callback Callback on success.
- */
-devtools.DomAgent.prototype.setAttributeAsync = function(node, name, value,
- callback) {
- var mycallback = goog.bind(this.didApplyDomChange_, this, node, callback);
- RemoteDomAgent.SetAttribute(devtools.Callback.wrap(mycallback),
- node.id_, name, value);
-};
-
-
-/**
- * Sends 'remove attribute' command to the remote agent.
- * @param {devtools.DomNode} node Node to change.
- * @param {string} name Attribute name to set value for.
- * @param {function():undefined} opt_callback Callback on success.
- */
-devtools.DomAgent.prototype.removeAttributeAsync = function(node, name,
- callback) {
- var mycallback = goog.bind(this.didApplyDomChange_, this, node, callback);
- RemoteDomAgent.RemoveAttribute(devtools.Callback.wrap(mycallback),
- node.id_, name);
-};
-
-
-/**
- * Sends 'set text node value' command to the remote agent.
- * @param {devtools.DomNode} node Node to change.
- * @param {string} text Text value to set.
- * @param {function():undefined} opt_callback Callback on success.
- */
-devtools.DomAgent.prototype.setTextNodeValueAsync = function(node, text,
- callback) {
- var mycallback = goog.bind(this.didApplyDomChange_, this, node, callback);
- RemoteDomAgent.SetTextNodeValue(devtools.Callback.wrap(mycallback),
- node.id_, text);
-};
-
-
-/**
- * Universal callback wrapper for edit dom operations.
- * @param {devtools.DomNode} node Node to apply local changes on.
- * @param {Function} callback Post-operation call.
- * @param {boolean} success True iff operation has completed successfully.
- * @private
- */
-devtools.DomAgent.prototype.didApplyDomChange_ = function(node,
- callback, success) {
- if (!success) {
- return;
- }
- callback();
- var elem = WebInspector.panels.elements.treeOutline.findTreeElement(node);
- if (elem) {
- elem._updateTitle();
- }
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.attributesUpdated_ = function(nodeId, attrsArray) {
- var node = this.idToDomNode_[nodeId];
- node.setAttributesPayload_(attrsArray);
-};
-
-
-/**
- * Returns node for id.
- * @param {number} nodeId Id to get node for.
- * @return {devtools.DomNode} Node with given id.
- */
-devtools.DomAgent.prototype.getNodeForId = function(nodeId) {
- return this.idToDomNode_[nodeId];
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.setDocumentElement_ = function(payload) {
- var doc = this.getDocument();
- if (doc.documentElement) {
- this.reset();
- doc = this.getDocument();
- }
- this.setChildNodes_(0, [payload]);
- doc.documentElement = doc.firstChild;
- doc.documentElement.ownerDocument = doc;
- WebInspector.panels.elements.reset();
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.setChildNodes_ = function(parentId, payloads) {
- var parent = this.idToDomNode_[parentId];
- if (parent.children) {
- return;
- }
- parent.setChildrenPayload_(payloads);
- this.bindNodes_(parent.children);
-};
-
-
-/**
- * Binds nodes to ids recursively.
- * @param {Array.<devtools.DomNode>} children Nodes to bind.
- * @private
- */
-devtools.DomAgent.prototype.bindNodes_ = function(children) {
- for (var i = 0; i < children.length; ++i) {
- var child = children[i];
- this.idToDomNode_[child.id_] = child;
- if (child.children) {
- this.bindNodes_(child.children);
- }
- }
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.hasChildrenUpdated_ = function(nodeId, newValue) {
- var node = this.idToDomNode_[nodeId];
- var outline = WebInspector.panels.elements.treeOutline;
- var treeElement = outline.findTreeElement(node);
- if (treeElement) {
- treeElement.hasChildren = newValue;
- treeElement.whitespaceIgnored = Preferences.ignoreWhitespace;
- }
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.childNodeInserted_ = function(
- parentId, prevId, payload) {
- var parent = this.idToDomNode_[parentId];
- var prev = this.idToDomNode_[prevId];
- var node = parent.insertChild_(prev, payload);
- this.idToDomNode_[node.id_] = node;
- var event = { target : node, relatedNode : parent };
- this.getDocument().fireDomEvent_('DOMNodeInserted', event);
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.childNodeRemoved_ = function(
- parentId, nodeId) {
- var parent = this.idToDomNode_[parentId];
- var node = this.idToDomNode_[nodeId];
- parent.removeChild_(node);
- var event = { target : node, relatedNode : parent };
- this.getDocument().fireDomEvent_('DOMNodeRemoved', event);
- delete this.idToDomNode_[nodeId];
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- */
-devtools.DomAgent.prototype.performSearch = function(query, callback) {
- this.searchResults_ = [];
- RemoteDomAgent.PerformSearch(
- devtools.Callback.wrap(
- goog.bind(this.performSearchCallback_, this, callback,
- this.searchResults_)),
- query);
-};
-
-
-/**
- * Invokes callback for nodes that needs to clear highlighting.
- * @param {function(Array.<devtools.DomNode>)} callback to accept the result.
- */
-devtools.DomAgent.prototype.searchCanceled = function(callback) {
- if (!this.searchResults_)
- return;
-
- var nodes = [];
- for (var i = 0; i < this.searchResults_.length; ++i) {
- var nodeId = this.searchResults_[i];
- var node = this.idToDomNode_[nodeId];
- nodes.push(node);
- }
-
- callback(nodes);
- this.searchResults_ = null;
-};
-
-
-/**
- * Invokes callback for each node that needs to gain highlighting.
- * @param {function(Array.<devtools.DomNode>)} callback to accept the result.
- * @param {Array.<number>} searchResults to be populated.
- * @param {Array.<number>} nodeIds Ids to highlight.
- * @private
- */
-devtools.DomAgent.prototype.performSearchCallback_ = function(callback,
- searchResults, nodeIds) {
-
- if (this.searchResults_ !== searchResults)
- return; // another search has requested and this results are obsolete
-
- var nodes = [];
-
- for (var i = 0; i < nodeIds.length; ++i) {
- var node = this.idToDomNode_[nodeIds[i]];
- searchResults.push(nodeIds[i]);
- nodes.push(node);
- }
-
- callback(nodes);
-};
-
-
-/**
- * Returns a node by index from the actual search results
- * (last performSearch).
- * @param {number} index in the results.
- * @return {devtools.DomNode}
- */
-devtools.DomAgent.prototype.getSearchResultNode = function(index) {
- return this.idToDomNode_[this.searchResults_[index]];
-};
-
-
-function firstChildSkippingWhitespace() {
- return this.firstChild;
-}
-
-
-function onlyTextChild() {
- if (!this.children) {
- return null;
- } else if (this.children.length == 1 &&
- this.children[0].nodeType == Node.TEXT_NODE) {
- return this.children[0];
- } else {
- return null;
- }
-}
diff --git a/webkit/glue/devtools/js/inject.js b/webkit/glue/devtools/js/inject.js
index 0d4e0e3..e214766 100644
--- a/webkit/glue/devtools/js/inject.js
+++ b/webkit/glue/devtools/js/inject.js
@@ -14,55 +14,6 @@ goog.provide('devtools.Injected');
* @constructor.
*/
devtools.Injected = function() {
- /**
- * This cache contains mapping from object it to an object instance for
- * all results of the evaluation / console logs.
- */
- this.cachedConsoleObjects_ = {};
-
- /**
- * Last id for the cache above.
- */
- this.lastCachedConsoleObjectId_ = 1;
-};
-
-
-/**
- * Caches console object for subsequent calls to getConsoleObjectProperties.
- * @param {Object} obj Object to cache.
- * @return {Object} console object wrapper.
- */
-devtools.Injected.prototype.wrapConsoleObject = function(obj) {
- var type = typeof obj;
- if ((type == 'object' && obj != null) || type == 'function') {
- var objId = '#consoleobj#' + this.lastCachedConsoleObjectId_++;
- this.cachedConsoleObjects_[objId] = obj;
- var result = { ___devtools_id : objId };
- result.___devtools_class_name = Object.describe(obj, true);
- // Loop below fills dummy object with properties for completion.
- for (var name in obj) {
- result[name] = '';
- }
- return result;
- }
- return obj;
-};
-
-
-/**
- * Caches console object for subsequent calls to getConsoleObjectProperties.
- * @param {Object} obj Object to cache.
- * @return {string} Console object wrapper serialized into a JSON string.
- */
-devtools.Injected.prototype.serializeConsoleObject = function(obj) {
- var result = this.wrapConsoleObject(obj);
- return JSON.stringify(result,
- function (key, value) {
- if (value === undefined) {
- return 'undefined';
- }
- return value;
- });
};
@@ -93,19 +44,6 @@ InjectedScript._window = function() {
};
-InjectedScript._nodeForId = function(nodeId) {
- return DevToolsAgentHost.getNodeForId(nodeId);
-};
-
-
-InjectedScript._objectForId = function(id) {
- if (typeof id == 'number') {
- return DevToolsAgentHost.getNodeForId(id);
- }
- return devtools$$obj.cachedConsoleObjects_[id];
-};
-
-
Object.type = function(obj, win)
{
if (obj === null)
diff --git a/webkit/glue/devtools/js/inject_dispatch.js b/webkit/glue/devtools/js/inject_dispatch.js
index 0416676..9cc68f7 100644
--- a/webkit/glue/devtools/js/inject_dispatch.js
+++ b/webkit/glue/devtools/js/inject_dispatch.js
@@ -40,14 +40,7 @@ var dispatch = function(method, var_args) {
// Handle all messages with non-primitieve arguments here.
var args = Array.prototype.slice.call(arguments);
- // Serialize objects here.
- if (method == 'addMessageToConsole') {
- // Skip first argument since it is serializable.
- // Method has index 0, first argument has index 1. Skip both.
- for (var i = 2; i < args.length; ++i) {
- args[i] = devtools$$obj.wrapConsoleObject(args[i]);
- }
- } else if (method == 'inspectedWindowCleared' ||
+ if (method == 'inspectedWindowCleared' ||
method == 'reset' ||
method == 'setAttachedWindow') {
// Filter out messages we don't need here.
diff --git a/webkit/glue/devtools/js/inspector_controller_impl.js b/webkit/glue/devtools/js/inspector_controller_impl.js
index 459d9c4..b0c6947 100644
--- a/webkit/glue/devtools/js/inspector_controller_impl.js
+++ b/webkit/glue/devtools/js/inspector_controller_impl.js
@@ -13,18 +13,32 @@ devtools.InspectorControllerImpl = function() {
devtools.InspectorController.call(this);
this.frame_element_id_ = 1;
- this.installInjectedScriptDelegate_('getStyles', true);
- this.installInjectedScriptDelegate_('getComputedStyle', true);
- this.installInjectedScriptDelegate_('getInlineStyle', true);
+ this.installInspectorControllerDelegate_('clearMessages');
+ this.installInspectorControllerDelegate_('storeLastActivePanel');
+ this.installInspectorControllerDelegate_('highlightDOMNode');
+ this.installInspectorControllerDelegate_('hideDOMNodeHighlight');
+ this.installInspectorControllerDelegate_('getChildNodes');
+ this.installInspectorControllerDelegate_('setAttribute');
+ this.installInspectorControllerDelegate_('removeAttribute');
+ this.installInspectorControllerDelegate_('setTextNodeValue');
+
+ this.installInjectedScriptDelegate_('getStyles');
+ this.installInjectedScriptDelegate_('getComputedStyle');
+ this.installInjectedScriptDelegate_('getInlineStyle');
this.installInjectedScriptDelegate_('applyStyleText');
this.installInjectedScriptDelegate_('setStyleText');
this.installInjectedScriptDelegate_('toggleStyleEnabled');
this.installInjectedScriptDelegate_('applyStyleRuleText');
this.installInjectedScriptDelegate_('addStyleSelector');
this.installInjectedScriptDelegate_('setStyleProperty');
- this.installInjectedScriptDelegate_('getPrototypes', true);
- this.installInjectedScriptDelegate_('getProperties', true);
- this.installInjectedScriptDelegate_('setPropertyValue', true);
+ this.installInjectedScriptDelegate_('getPrototypes');
+ this.installInjectedScriptDelegate_('getProperties');
+ this.installInjectedScriptDelegate_('setPropertyValue');
+
+ this.installInjectedScriptDelegate_('evaluate');
+ this.installInjectedScriptDelegate_('addInspectedNode');
+ this.installInjectedScriptDelegate_('performSearch');
+ this.installInjectedScriptDelegate_('searchCanceled');
};
goog.inherits(devtools.InspectorControllerImpl,
devtools.InspectorController);
@@ -65,24 +79,6 @@ devtools.InspectorControllerImpl.prototype.detach = function() {
/**
* {@inheritDoc}.
*/
-devtools.InspectorControllerImpl.prototype.storeLastActivePanel = function(panel) {
- RemoteToolsAgent.ExecuteUtilityFunction(
- devtools.Callback.wrap(undefined),
- 'InspectorController', JSON.stringify(['storeLastActivePanel', panel]));
-};
-
-
-/**
- * {@inheritDoc}.
- */
-devtools.InspectorControllerImpl.prototype.clearMessages = function() {
- RemoteToolsAgent.ClearConsoleMessages();
-};
-
-
-/**
- * {@inheritDoc}.
- */
devtools.InspectorControllerImpl.prototype.hiddenPanels = function() {
return 'databases';
};
@@ -130,25 +126,8 @@ devtools.InspectorControllerImpl.prototype.addResourceSourceToFrame =
/**
* {@inheritDoc}.
*/
-devtools.InspectorControllerImpl.prototype.hideDOMNodeHighlight = function() {
- RemoteToolsAgent.HideDOMNodeHighlight();
-};
-
-
-/**
- * {@inheritDoc}.
- */
-devtools.InspectorControllerImpl.prototype.highlightDOMNode =
- function(hoveredNode) {
- RemoteToolsAgent.HighlightDOMNode(hoveredNode.id_);
-};
-
-
-/**
- * {@inheritDoc}.
- */
devtools.InspectorControllerImpl.prototype.inspectedWindow = function() {
- return devtools.tools.getDomAgent().getWindow();
+ return null;
};
@@ -268,14 +247,11 @@ devtools.InspectorControllerImpl.prototype.storeLastActivePanel =
/**
* Installs delegating handler into the inspector controller.
- * @param {number} argsCound Number of the arguments in the delegating call
- * excluding callback.
* @param {string} methodName Method to install delegating handler for.
- * @parma {boolean} unwrap Replace first argument with its id.
*/
devtools.InspectorControllerImpl.prototype.installInjectedScriptDelegate_ =
- function(methodName, unwrap) {
- this[methodName] = goog.bind(this.callInjectedScript_, this, unwrap,
+ function(methodName) {
+ this[methodName] = goog.bind(this.callInjectedScript_, this,
methodName);
};
@@ -285,23 +261,40 @@ devtools.InspectorControllerImpl.prototype.installInjectedScriptDelegate_ =
* implementation.
*/
devtools.InspectorControllerImpl.prototype.callInjectedScript_ =
- function(unwrap, methodName, var_arg) {
+ function(methodName, var_arg) {
var allArgs = Array.prototype.slice.call(arguments);
var callback = allArgs[allArgs.length - 1];
- var args = Array.prototype.slice.call(allArgs, 1, allArgs.length - 1);
- if (unwrap) {
- if (args[1].id_) {
- args[1] = args[1].id_;
- } else if (args[1].objectId && args[1].objectId.id_) {
- args[1].objectId = args[1].objectId.id_;
- }
- }
+ var args = Array.prototype.slice.call(allArgs, 0, allArgs.length - 1);
RemoteToolsAgent.ExecuteUtilityFunction(
devtools.InspectorControllerImpl.parseWrap_(callback),
'InjectedScript', JSON.stringify(args));
};
+/**
+ * Installs delegating handler into the inspector controller.
+ * @param {string} methodName Method to install delegating handler for.
+ */
+devtools.InspectorControllerImpl.prototype.installInspectorControllerDelegate_
+ = function(methodName) {
+ this[methodName] = goog.bind(this.callInspectorController_, this,
+ methodName);
+};
+
+
+/**
+ * Bound function with the installInjectedScriptDelegate_ actual
+ * implementation.
+ */
+devtools.InspectorControllerImpl.prototype.callInspectorController_ =
+ function(methodName, var_arg) {
+ var args = Array.prototype.slice.call(arguments);
+ RemoteToolsAgent.ExecuteUtilityFunction(
+ devtools.InspectorControllerImpl.parseWrap_(undefined),
+ 'InspectorController', JSON.stringify(args));
+};
+
+
devtools.InspectorControllerImpl.parseWrap_ = function(callback) {
return devtools.Callback.wrap(
function(data) {