Reviewed by Timothy Hatcher.
WebInspector: suggest global properties based on async evaluation.
https://bugs.webkit.org/show_bug.cgi?id=26976
Before this change, empty string was evaluated to the global object
(or scope chain object) synchronously. This is now fixed and global
object is evaluated using the same control flow.
* inspector/front-end/Console.js:
(WebInspector.Console.prototype.completions):
(WebInspector.Console.prototype._evalInInspectedWindow):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._variablesInScope):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45562
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2009-07-06 Pavel Feldman <pfeldman@chromium.org>
+
+ Reviewed by Timothy Hatcher.
+
+ WebInspector: suggest global properties based on async evaluation.
+
+ https://bugs.webkit.org/show_bug.cgi?id=26976
+
+ Before this change, empty string was evaluated to the global object
+ (or scope chain object) synchronously. This is now fixed and global
+ object is evaluated using the same control flow.
+
+ * inspector/front-end/Console.js:
+ (WebInspector.Console.prototype.completions):
+ (WebInspector.Console.prototype._evalInInspectedWindow):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype._variablesInScope):
+
2009-07-06 Ojan Vafai <ojan@chromium.org>
Reviewed by Eric Seidel.
return;
var reportCompletions = this._reportCompletions.bind(this, bestMatchOnly, completionsReadyCallback, dotNotation, bracketNotation, prefix);
- if (expressionString) {
- this._evalInInspectedWindow(expressionString, reportCompletions);
- } else {
- // There is no expressionString, so the completion should happen against global properties.
- // Or if the debugger is paused, against properties in scope of the selected call frame.
- if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused)
- reportCompletions(WebInspector.panels.scripts.variablesInScopeForSelectedCallFrame());
- else
- reportCompletions(InspectorController.inspectedWindow());
- }
+ this._evalInInspectedWindow(expressionString, reportCompletions);
},
_reportCompletions: function(bestMatchOnly, completionsReadyCallback, dotNotation, bracketNotation, prefix, result) {
WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression, false, callback);
return;
}
-
this.doEvalInWindow(expression, callback);
},
doEvalInWindow: function(expression, callback)
{
+ if (!expression) {
+ // There is no expression, so the completion should happen against global properties.
+ expression = "this";
+ }
+
// Surround the expression in with statements to inject our command line API so that
// the window object properties still take more precedent than our API functions.
expression = "with (window._inspectorCommandLineAPI) { with (window) { " + expression + " } }";
doEvalInCallFrame: function(callFrame, code, callback)
{
+ var panel = this;
function delayedEvaluation()
{
+ if (!code) {
+ // Evaluate into properties in scope of the selected call frame.
+ callback(panel._variablesInScope(callFrame));
+ return;
+ }
try {
callback(callFrame.evaluate(code));
} catch (e) {
setTimeout(delayedEvaluation, 0);
},
- variablesInScopeForSelectedCallFrame: function()
+ _variablesInScope: function(callFrame)
{
- var selectedCallFrame = this.sidebarPanes.callstack.selectedCallFrame;
- if (!this._paused || !selectedCallFrame)
- return {};
-
var result = {};
- var scopeChain = selectedCallFrame.scopeChain;
+ var scopeChain = callFrame.scopeChain;
for (var i = 0; i < scopeChain.length; ++i) {
var scopeObject = scopeChain[i];
for (var property in scopeObject)
result[property] = true;
}
-
return result;
},