Diff
Modified: trunk/Source/WebCore/ChangeLog (99572 => 99573)
--- trunk/Source/WebCore/ChangeLog 2011-11-08 16:26:26 UTC (rev 99572)
+++ trunk/Source/WebCore/ChangeLog 2011-11-08 16:38:04 UTC (rev 99573)
@@ -1,3 +1,26 @@
+2011-11-08 Andrey Kosyakov <ca...@chromium.org>
+
+ Web Inspector: add "Evaluate in console" as a shortcut and context menu items to scripts panel
+ https://bugs.webkit.org/show_bug.cgi?id=71817
+
+ Reviewed by Pavel Feldman.
+
+ * English.lproj/localizedStrings.js:
+ * inspector/front-end/ConsoleView.js:
+ (WebInspector.ConsoleView.prototype.evaluate):
+ (WebInspector.ConsoleView.prototype._enterKeyPressed):
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame.prototype.populateTextAreaContextMenu):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype._evaluateSelectionInConsole):
+ * inspector/front-end/ShortcutsScreen.js:
+ (WebInspector.ShortcutsSection.prototype.addRelatedKeys):
+ (WebInspector.ShortcutsSection.prototype.addAlternateKeys):
+ * inspector/front-end/externs.js:
+ (WebInspector.evaluateInConsole):
+ * inspector/front-end/inspector.js:
+ (WebInspector.evaluateInConsole):
+
2011-11-08 Andreas Kling <kl...@webkit.org>
CSSValue: Devirtualize cssText().
Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js
(Binary files differ)
Modified: trunk/Source/WebCore/inspector/front-end/ConsoleView.js (99572 => 99573)
--- trunk/Source/WebCore/inspector/front-end/ConsoleView.js 2011-11-08 16:26:26 UTC (rev 99572)
+++ trunk/Source/WebCore/inspector/front-end/ConsoleView.js 2011-11-08 16:38:04 UTC (rev 99573)
@@ -608,6 +608,11 @@
RuntimeAgent.evaluate(_expression_, objectGroup, includeCommandLineAPI, doNotPauseOnExceptions, this._currentEvaluationContextId(), returnByValue, evalCallback);
},
+ evaluateUsingTextPrompt: function(_expression_)
+ {
+ this._appendCommand(_expression_, this.prompt.text);
+ },
+
_enterKeyPressed: function(event)
{
if (event.altKey || event.ctrlKey || event.shiftKey)
@@ -621,8 +626,12 @@
var str = this.prompt.text;
if (!str.length)
return;
+ this._appendCommand(str, "");
+ },
- var commandMessage = new WebInspector.ConsoleCommand(str);
+ _appendCommand: function(text, newPromptText)
+ {
+ var commandMessage = new WebInspector.ConsoleCommand(text);
WebInspector.console.interruptRepeatCount();
this._appendConsoleMessage(commandMessage);
@@ -631,14 +640,14 @@
if (!result)
return;
- this.prompt.pushHistoryItem(str);
- this.prompt.text = "";
+ this.prompt.pushHistoryItem(text);
+ this.prompt.text = newPromptText;
WebInspector.settings.consoleHistory.set(this.prompt.historyData.slice(-30));
this._appendConsoleMessage(new WebInspector.ConsoleCommandResult(result, wasThrown, commandMessage, this._linkifier));
}
- this.evalInInspectedWindow(str, "console", true, false, false, printResult.bind(this));
+ this.evalInInspectedWindow(text, "console", true, false, false, printResult.bind(this));
WebInspector.userMetrics.ConsoleEvaluated.record();
},
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (99572 => 99573)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2011-11-08 16:26:26 UTC (rev 99572)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2011-11-08 16:38:04 UTC (rev 99573)
@@ -148,6 +148,7 @@
if (selection.type !== "Range" || selection.isCollapsed)
return;
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Add to watch" : "Add to Watch"), this._delegate.addToWatch.bind(this._delegate, selection.toString()));
+ contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Evaluate in console" : "Evaluate in Console"), WebInspector.evaluateInConsole.bind(WebInspector, selection.toString()));
},
afterTextChanged: function(oldRange, newRange)
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (99572 => 99573)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-11-08 16:26:26 UTC (rev 99572)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-11-08 16:38:04 UTC (rev 99573)
@@ -133,6 +133,9 @@
var helpSection = WebInspector.shortcutsScreen.section(WebInspector.UIString("Scripts Panel"));
this.sidebarPanes.callstack.registerShortcuts(helpSection, this.registerShortcut.bind(this));
+ var evaluateInConsoleShortcut = WebInspector.KeyboardShortcut.makeDescriptor("e", WebInspector.KeyboardShortcut.Modifiers.Shift | WebInspector.KeyboardShortcut.Modifiers.Ctrl);
+ helpSection.addKey(evaluateInConsoleShortcut.name, WebInspector.UIString("Evaluate selection in console"));
+ this.registerShortcut(evaluateInConsoleShortcut.key, this._evaluateSelectionInConsole.bind(this));
var panelEnablerHeading = WebInspector.UIString("You need to enable debugging before you can use the Scripts panel.");
var panelEnablerDisclaimer = WebInspector.UIString("Enabling debugging will make scripts run slower.");
@@ -1000,6 +1003,13 @@
}
},
+ _evaluateSelectionInConsole: function()
+ {
+ var selection = window.getSelection();
+ if (selection.type === "Range" && !selection.isCollapsed)
+ WebInspector.evaluateInConsole(selection.toString());
+ },
+
elementsToRestoreScrollPositionsFor: function()
{
return [ this.sidebarElement ];
Modified: trunk/Source/WebCore/inspector/front-end/ShortcutsScreen.js (99572 => 99573)
--- trunk/Source/WebCore/inspector/front-end/ShortcutsScreen.js 2011-11-08 16:26:26 UTC (rev 99572)
+++ trunk/Source/WebCore/inspector/front-end/ShortcutsScreen.js 2011-11-08 16:38:04 UTC (rev 99573)
@@ -120,12 +120,12 @@
addRelatedKeys: function(keys, description)
{
- this.addLine(this._renderSequence(keys,"/"), description);
+ this.addLine(this._renderSequence(keys, "/"), description);
},
addAlternateKeys: function(keys, description)
{
- this.addLine(this._renderSequence(keys,WebInspector.UIString("or")), description);
+ this.addLine(this._renderSequence(keys, WebInspector.UIString("or")), description);
},
addLine: function(htmlKey, description)
Modified: trunk/Source/WebCore/inspector/front-end/externs.js (99572 => 99573)
--- trunk/Source/WebCore/inspector/front-end/externs.js 2011-11-08 16:26:26 UTC (rev 99572)
+++ trunk/Source/WebCore/inspector/front-end/externs.js 2011-11-08 16:38:04 UTC (rev 99573)
@@ -119,6 +119,8 @@
WebInspector.openRequestInNetworkPanel = function(request) {}
+WebInspector.evaluateInConsole = function(_expression_) {}
+
var InjectedFakeWorker = function() {}
WebInspector.queryParamsObject = {}
Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (99572 => 99573)
--- trunk/Source/WebCore/inspector/front-end/inspector.js 2011-11-08 16:26:26 UTC (rev 99572)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js 2011-11-08 16:38:04 UTC (rev 99573)
@@ -842,6 +842,12 @@
WebInspector.panels.profiles.showProfileForURL(url);
}
+WebInspector.evaluateInConsole = function(_expression_)
+{
+ this.showConsole();
+ this.consoleView.evaluateUsingTextPrompt(_expression_);
+}
+
WebInspector.addMainEventListeners = function(doc)
{
doc.addEventListener("keydown", this.documentKeyDown.bind(this), false);