summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/devtools/js/debugger_agent.js43
-rw-r--r--webkit/glue/devtools/js/devtools.js42
2 files changed, 84 insertions, 1 deletions
diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js
index 8f34ca8..9f0c2a3 100644
--- a/webkit/glue/devtools/js/debugger_agent.js
+++ b/webkit/glue/devtools/js/debugger_agent.js
@@ -122,11 +122,45 @@ devtools.DebuggerAgent.prototype.requestScripts = function() {
return;
}
var cmd = new devtools.DebugCommand('scripts', {
+ 'includeSource': false
+ });
+ devtools.DebuggerAgent.sendCommand_(cmd);
+ // Force v8 execution so that it gets to processing the requested command.
+ devtools.tools.evaluateJavaScript('javascript:void(0)');
+};
+
+
+/**
+ * Asynchronously requests the debugger for the script source.
+ * @param {number} scriptId Id of the script whose source should be resolved.
+ * @param {function(source:?string):void} callback Function that will be called
+ * when the source resolution is completed. 'source' parameter will be null
+ * if the resolution fails.
+ */
+devtools.DebuggerAgent.prototype.resolveScriptSource = function(
+ scriptId, callback) {
+ var script = this.parsedScripts_[scriptId];
+ if (!script) {
+ callback(null);
+ return;
+ }
+
+ var cmd = new devtools.DebugCommand('scripts', {
+ 'ids': [scriptId],
'includeSource': true
});
devtools.DebuggerAgent.sendCommand_(cmd);
// Force v8 execution so that it gets to processing the requested command.
devtools.tools.evaluateJavaScript('javascript:void(0)');
+
+ this.requestSeqToCallback_[cmd.getSequenceNumber()] = function(msg) {
+ if (msg.isSuccess()) {
+ var scriptJson = msg.getBody()[0];
+ callback(scriptJson.source);
+ } else {
+ callback(null);
+ }
+ };
};
@@ -491,6 +525,10 @@ devtools.DebuggerAgent.prototype.handleExceptionEvent_ = function(msg) {
* @param {devtools.DebuggerMessage} msg
*/
devtools.DebuggerAgent.prototype.handleScriptsResponse_ = function(msg) {
+ if (this.invokeCallbackForResponse_(msg)) {
+ return;
+ }
+
var scripts = msg.getBody();
for (var i = 0; i < scripts.length; i++) {
var script = scripts[i];
@@ -644,15 +682,18 @@ devtools.DebuggerAgent.prototype.handleBacktraceResponse_ = function(msg) {
/**
* Handles response to a command by invoking its callback (if any).
* @param {devtools.DebuggerMessage} msg
+ * @return {boolean} Whether a callback for the given message was found and
+ * excuted.
*/
devtools.DebuggerAgent.prototype.invokeCallbackForResponse_ = function(msg) {
var callback = this.requestSeqToCallback_[msg.getRequestSeq()];
if (!callback) {
// It may happend if reset was called.
- return;
+ return false;
}
delete this.requestSeqToCallback_[msg.getRequestSeq()];
callback(msg);
+ return true;
};
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js
index f201fb3..d7c0072 100644
--- a/webkit/glue/devtools/js/devtools.js
+++ b/webkit/glue/devtools/js/devtools.js
@@ -509,6 +509,48 @@ WebInspector.SourceView.prototype.setupSourceFrameIfNeeded = function() {
/**
+ * This override is necessary for adding script source asynchronously.
+ * @override
+ */
+WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded = function() {
+ if (!this._frameNeedsSetup) {
+ return;
+ }
+
+ this.attach();
+
+ if (this.script.source) {
+ this.didResolveScriptSource_();
+ } else {
+ var self = this;
+ devtools.tools.getDebuggerAgent().resolveScriptSource(
+ this.script.sourceID,
+ function(source) {
+ self.script.source = source || '<source is not available>';
+ self.didResolveScriptSource_();
+ });
+ }
+};
+
+
+/**
+ * Performs source frame setup when script source is aready resolved.
+ */
+WebInspector.ScriptView.prototype.didResolveScriptSource_ = function() {
+ if (!InspectorController.addSourceToFrame(
+ "text/javascript", this.script.source, this.sourceFrame.element)) {
+ return;
+ }
+
+ delete this._frameNeedsSetup;
+
+ this.sourceFrame.addEventListener(
+ "syntax highlighting complete", this._syntaxHighlightingComplete, this);
+ this.sourceFrame.syntaxHighlightJavascript();
+};
+
+
+/**
* Dummy object used during properties inspection.
* @see WebInspector.didGetNodePropertiesAsync_
*/