Diff
Modified: trunk/LayoutTests/ChangeLog (121672 => 121673)
--- trunk/LayoutTests/ChangeLog 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/LayoutTests/ChangeLog 2012-07-02 12:51:57 UTC (rev 121673)
@@ -1,3 +1,13 @@
+2012-06-22 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Implement snippets evaluation.
+ https://bugs.webkit.org/show_bug.cgi?id=88707
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/debugger/script-snippet-model-expected.txt:
+ * inspector/debugger/script-snippet-model.html:
+
2012-07-02 Christophe Dumez <[email protected]>
[EFL] Rebaseline needed after r121296 and r121599
Modified: trunk/LayoutTests/inspector/debugger/script-snippet-model-expected.txt (121672 => 121673)
--- trunk/LayoutTests/inspector/debugger/script-snippet-model-expected.txt 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/LayoutTests/inspector/debugger/script-snippet-model-expected.txt 2012-07-02 12:51:57 UTC (rev 121673)
@@ -3,11 +3,17 @@
Debugger was enabled.
Running: testEvaluate
-Last evaluation source url for snippet: snippets://1_1
-Snippet script added, sourceURL = snippets://1_1
-Last evaluation source url for snippet: snippets://2_2
-Snippet script added, sourceURL = snippets://2_2
-Last evaluation source url for snippet: snippets://1_3
-Snippet script added, sourceURL = snippets://1_3
+Last evaluation source url for snippet: snippets:///1_1
+Snippet script added, sourceURL = snippets:///1_1
+Snippet execution result: undefined
+Last evaluation source url for snippet: snippets:///2_2
+Snippet script added, sourceURL = snippets:///2_2
+Snippet execution result: function doesNothing()
+{
+ var i = 2+2;
+}
+Last evaluation source url for snippet: snippets:///1_3
+Snippet script added, sourceURL = snippets:///1_3
+Snippet execution result: undefined
Debugger was disabled.
Modified: trunk/LayoutTests/inspector/debugger/script-snippet-model.html (121672 => 121673)
--- trunk/LayoutTests/inspector/debugger/script-snippet-model.html 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/LayoutTests/inspector/debugger/script-snippet-model.html 2012-07-02 12:51:57 UTC (rev 121673)
@@ -26,29 +26,37 @@
var content = "";
content += "// This snippet does nothing.\n";
content += "var i = 2+2;\n";
- WebInspector.scriptSnippetModel.setScriptSnippetContent(snippetJavaScriptSource1, content);
+ WebInspector.scriptSnippetModel._setScriptSnippetContent(snippetJavaScriptSource1, content);
var snippetJavaScriptSource2 = WebInspector.scriptSnippetModel.createScriptSnippet();
WebInspector.scriptSnippetModel.renameScriptSnippet(snippetJavaScriptSource2, "Snippet2");
content = "";
- content += "// This snippet creates a function that does nothing.\n";
+ content += "// This snippet creates a function that does nothing and returns it.\n";
content += "function doesNothing()\n";
content += "{\n";
content += " var i = 2+2;\n";
- content += "}\n";
- WebInspector.scriptSnippetModel.setScriptSnippetContent(snippetJavaScriptSource2, content);
+ content += "};\n";
+ content += "doesNothing;\n";
+ WebInspector.scriptSnippetModel._setScriptSnippetContent(snippetJavaScriptSource2, content);
function evaluateSnippetAndDumpEvaluationDetails(snippetJavaScriptSource, callback)
{
InspectorTest.addSniffer(WebInspector.SnippetScriptMapping.prototype, "addScript", dumpScript);
+ InspectorTest.addSniffer(WebInspector.ConsoleView.prototype, "_printResult", dumpResult);
WebInspector.scriptSnippetModel.evaluateScriptSnippet(snippetJavaScriptSource);
- var snippet = WebInspector.scriptSnippetModel._snippetStorage.snippetForId(snippetJavaScriptSource.snippetId);
- InspectorTest.addResult("Last evaluation source url for snippet: " + snippet._lastEvaluationSourceURL);
- InspectorTest.assertEquals(snippet, WebInspector.scriptSnippetModel._snippetForSourceURL(snippet._lastEvaluationSourceURL), "Snippet can not be identified by its evaluation sourceURL.");
+ var evaluationSourceURL = WebInspector.scriptSnippetModel._evaluationSourceURL(snippetJavaScriptSource);
+ var snippetId = snippetJavaScriptSource.snippetId;
+ InspectorTest.addResult("Last evaluation source url for snippet: " + evaluationSourceURL);
+ InspectorTest.assertEquals(snippetId, WebInspector.scriptSnippetModel._snippetIdForSourceURL(evaluationSourceURL), "Snippet can not be identified by its evaluation sourceURL.");
function dumpScript(script)
{
InspectorTest.addResult("Snippet script added, sourceURL = " + script.sourceURL);
+ }
+
+ function dumpResult(result, wasThrown)
+ {
+ InspectorTest.addResult("Snippet execution result: " + result.description);
callback();
}
}
Modified: trunk/Source/WebCore/ChangeLog (121672 => 121673)
--- trunk/Source/WebCore/ChangeLog 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/Source/WebCore/ChangeLog 2012-07-02 12:51:57 UTC (rev 121673)
@@ -1,3 +1,47 @@
+2012-06-22 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Implement snippets evaluation.
+ https://bugs.webkit.org/show_bug.cgi?id=88707
+
+ Reviewed by Pavel Feldman.
+
+ Implemented snippet evaluation and adjusted breakpoints behavior when editing snippet.
+ Snippets are evaluated using separate compile and run.
+ Breakpoints are updated after compilation (once scriptId is available they can be set in debugger).
+ If separate compile and run is not supported by port or debugger is paused we fall back to evaluation in console.
+
+ * inspector/front-end/ConsoleView.js:
+ (WebInspector.ConsoleView.prototype.runScript.runCallback):
+ (WebInspector.ConsoleView.prototype.runScript):
+ (WebInspector.ConsoleView.prototype._printResult):
+ * inspector/front-end/_javascript_Source.js:
+ (WebInspector._javascript_Source.prototype.supportsEnabledBreakpointsWhileEditing):
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame.prototype.afterTextChanged):
+ (WebInspector._javascript_SourceFrame.prototype.beforeTextChanged):
+ (WebInspector._javascript_SourceFrame.prototype._didEditContent):
+ (WebInspector._javascript_SourceFrame.prototype._removeBreakpointsBeforeEditing):
+ (WebInspector._javascript_SourceFrame.prototype._restoreBreakpointsAfterEditing):
+ (WebInspector._javascript_SourceFrame.prototype._addBreakpointDecoration):
+ (WebInspector._javascript_SourceFrame.prototype._onMouseDown):
+ * inspector/front-end/ScriptSnippetModel.js:
+ (WebInspector.ScriptSnippetModel.prototype.deleteScriptSnippet):
+ (WebInspector.ScriptSnippetModel.prototype._setScriptSnippetContent):
+ (WebInspector.ScriptSnippetModel.prototype.evaluateScriptSnippet.compileCallback):
+ (WebInspector.ScriptSnippetModel.prototype.evaluateScriptSnippet):
+ (WebInspector.ScriptSnippetModel.prototype._rawLocationToUILocation):
+ (WebInspector.ScriptSnippetModel.prototype._removeBreakpoints):
+ (WebInspector.ScriptSnippetModel.prototype._restoreBreakpoints):
+ (WebInspector.ScriptSnippetModel.prototype._evaluationSourceURL):
+ (WebInspector.SnippetJavaScriptSource.prototype.isDivergedFromVM):
+ (WebInspector.SnippetJavaScriptSource.prototype.workingCopyCommitted):
+ (WebInspector.SnippetJavaScriptSource.prototype.workingCopyChanged):
+ (WebInspector.SnippetJavaScriptSource.prototype.evaluate):
+ (WebInspector.SnippetJavaScriptSource.prototype.supportsEnabledBreakpointsWhileEditing):
+ (WebInspector.SnippetJavaScriptSource.prototype.breakpointStorageId):
+ * inspector/front-end/ScriptsNavigator.js:
+ (WebInspector.SnippetsNavigatorView.prototype._handleEvaluateSnippet):
+
2012-06-26 Vsevolod Vlasov <[email protected]>
Web Inspector: StyleSource should set content using CSSStyleModelResourceBinding directly.
Modified: trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp (121672 => 121673)
--- trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp 2012-07-02 12:51:57 UTC (rev 121673)
@@ -451,6 +451,8 @@
void ScriptDebugServer::runScript(ScriptState* state, const String& scriptId, ScriptValue* result, bool* wasThrown, String* exceptionMessage)
{
+ if (!m_compiledScripts.contains(scriptId))
+ return;
v8::HandleScope handleScope;
OwnHandle<v8::Script>* scriptOwnHandle = m_compiledScripts.get(scriptId);
v8::Local<v8::Script> script = v8::Local<v8::Script>::New(scriptOwnHandle->get());
Modified: trunk/Source/WebCore/inspector/front-end/ConsoleView.js (121672 => 121673)
--- trunk/Source/WebCore/inspector/front-end/ConsoleView.js 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/Source/WebCore/inspector/front-end/ConsoleView.js 2012-07-02 12:51:57 UTC (rev 121673)
@@ -712,6 +712,36 @@
this._appendCommand(str, "", true, false);
},
+ runScript: function(scriptId)
+ {
+ var contextId = WebInspector.consoleView._currentEvaluationContextId();
+ DebuggerAgent.runScript(scriptId, contextId, "console", false, runCallback.bind(this));
+ WebInspector.userMetrics.ConsoleEvaluated.record();
+
+ /**
+ * @param {?string} error
+ * @param {?RuntimeAgent.RemoteObject} result
+ * @param {boolean=} wasThrown
+ */
+ function runCallback(error, result, wasThrown)
+ {
+ if (error) {
+ console.error(error);
+ return;
+ }
+
+ this._printResult(result, wasThrown);
+ }
+ },
+
+ _printResult: function(result, wasThrown)
+ {
+ if (!result)
+ return;
+
+ this._appendConsoleMessage(new WebInspector.ConsoleCommandResult(result, wasThrown, null, this._linkifier));
+ },
+
_appendCommand: function(text, newPromptText, useCommandLineAPI, showResultOnly)
{
if (!showResultOnly) {
@@ -730,8 +760,8 @@
this.prompt.pushHistoryItem(text);
WebInspector.settings.consoleHistory.set(this.prompt.historyData.slice(-30));
}
-
- this._appendConsoleMessage(new WebInspector.ConsoleCommandResult(result, wasThrown, commandMessage, this._linkifier));
+
+ this._printResult(result, wasThrown);
}
this.evalInInspectedWindow(text, "console", useCommandLineAPI, false, false, printResult.bind(this));
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_Source.js (121672 => 121673)
--- trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-07-02 12:51:57 UTC (rev 121673)
@@ -160,6 +160,14 @@
},
/**
+ * @return {boolean}
+ */
+ supportsEnabledBreakpointsWhileEditing: function()
+ {
+ return false;
+ },
+
+ /**
* @return {string}
*/
breakpointStorageId: function()
@@ -188,7 +196,7 @@
* @param {function(?string)} callback
*/
workingCopyCommitted: function(callback)
- {
+ {
/**
* @param {?string} error
*/
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (121672 => 121673)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-07-02 12:51:57 UTC (rev 121673)
@@ -149,14 +149,32 @@
afterTextChanged: function(oldRange, newRange)
{
+ WebInspector.SourceFrame.prototype.afterTextChanged.call(this, oldRange, newRange);
this._javaScriptSource.setWorkingCopy(this.textModel.text);
- if (!this._javaScriptSource.isDirty())
- this._didEditContent(null);
+ this._restoreBreakpointsAfterEditing();
},
beforeTextChanged: function()
{
- if (!this._javaScriptSource.isDirty()) {
+ WebInspector.SourceFrame.prototype.beforeTextChanged.call(this);
+ this._removeBreakpointsBeforeEditing();
+ },
+
+ _didEditContent: function(error)
+ {
+ delete this._isCommittingEditing;
+
+ if (error) {
+ WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
+ return;
+ }
+ if (!this._javaScriptSource.supportsEnabledBreakpointsWhileEditing())
+ this._restoreBreakpointsAfterEditing();
+ },
+
+ _removeBreakpointsBeforeEditing: function()
+ {
+ if (!this._javaScriptSource.isDirty() || this._javaScriptSource.supportsEnabledBreakpointsWhileEditing()) {
// Disable all breakpoints in the model, store them as muted breakpoints.
var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._javaScriptSource);
var lineNumbers = {};
@@ -168,27 +186,20 @@
}
this.clearExecutionLine();
}
-
- WebInspector.SourceFrame.prototype.beforeTextChanged.call(this);
},
- _didEditContent: function(error)
+ _restoreBreakpointsAfterEditing: function()
{
- delete this._isCommittingEditing;
-
- if (error) {
- WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
- return;
- }
-
- // Restore all muted breakpoints.
- for (var lineNumber = 0; lineNumber < this.textModel.linesCount; ++lineNumber) {
- var breakpointDecoration = this.textModel.getAttribute(lineNumber, "breakpoint");
- if (breakpointDecoration) {
- // Remove fake decoration
- this._removeBreakpointDecoration(lineNumber);
- // Set new breakpoint
- this._setBreakpoint(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled);
+ if (!this._javaScriptSource.isDirty() || this._javaScriptSource.supportsEnabledBreakpointsWhileEditing()) {
+ // Restore all muted breakpoints.
+ for (var lineNumber = 0; lineNumber < this.textModel.linesCount; ++lineNumber) {
+ var breakpointDecoration = this.textModel.getAttribute(lineNumber, "breakpoint");
+ if (breakpointDecoration) {
+ // Remove fake decoration
+ this._removeBreakpointDecoration(lineNumber);
+ // Set new breakpoint
+ this._setBreakpoint(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled);
+ }
}
}
},
@@ -326,7 +337,7 @@
this.textViewer.beginUpdates();
this.textViewer.addDecoration(lineNumber, "webkit-breakpoint");
- if (!enabled || mutedWhileEditing)
+ if (!enabled || (mutedWhileEditing && !this._javaScriptSource.supportsEnabledBreakpointsWhileEditing()))
this.textViewer.addDecoration(lineNumber, "webkit-breakpoint-disabled");
else
this.textViewer.removeDecoration(lineNumber, "webkit-breakpoint-disabled");
@@ -349,7 +360,7 @@
_onMouseDown: function(event)
{
- if (this._javaScriptSource.isDirty())
+ if (this._javaScriptSource.isDirty() && !this._javaScriptSource.supportsEnabledBreakpointsWhileEditing())
return;
if (event.button != 0 || event.altKey || event.ctrlKey || event.metaKey)
Modified: trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js (121672 => 121673)
--- trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-07-02 12:51:57 UTC (rev 121673)
@@ -47,8 +47,7 @@
this._addScriptSnippet(snippets[i]);
}
-WebInspector.ScriptSnippetModel.evaluatedSnippetExtraLinesCount = 2;
-WebInspector.ScriptSnippetModel.snippetSourceURLPrefix = "snippets://";
+WebInspector.ScriptSnippetModel.snippetSourceURLPrefix = "snippets:///";
WebInspector.ScriptSnippetModel.prototype = {
/**
@@ -87,6 +86,7 @@
{
var snippet = this._snippetStorage.snippetForId(snippetJavaScriptSource.snippetId);
this._snippetStorage.deleteSnippet(snippet);
+ this._removeBreakpoints(snippetJavaScriptSource);
this._releaseSnippetScript(snippetJavaScriptSource);
delete this._snippetJavaScriptSourceForSnippetId[snippet.id];
this._snippetScriptMapping._fireUISourceCodeRemoved(snippetJavaScriptSource);
@@ -107,9 +107,19 @@
/**
* @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
+ * @return {boolean}
+ */
+ _isDivergedFromVM: function(snippetJavaScriptSource)
+ {
+ var script = this._scriptForUISourceCode.get(snippetJavaScriptSource);
+ return !script;
+ },
+
+ /**
+ * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
* @param {string} newContent
*/
- setScriptSnippetContent: function(snippetJavaScriptSource, newContent)
+ _setScriptSnippetContent: function(snippetJavaScriptSource, newContent)
{
var snippet = this._snippetStorage.snippetForId(snippetJavaScriptSource.snippetId);
snippet.content = newContent;
@@ -119,17 +129,86 @@
/**
* @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
*/
- evaluateScriptSnippet: function(snippetJavaScriptSource)
+ _scriptSnippetEdited: function(snippetJavaScriptSource)
{
+ var script = this._scriptForUISourceCode.get(snippetJavaScriptSource);
+ if (!script)
+ return;
+
+ var breakpointLocations = this._removeBreakpoints(snippetJavaScriptSource);
this._releaseSnippetScript(snippetJavaScriptSource);
+ this._restoreBreakpoints(snippetJavaScriptSource, breakpointLocations);
+ },
+
+ /**
+ * @param {string} snippetId
+ * @return {number}
+ */
+ _nextEvaluationIndex: function(snippetId)
+ {
var evaluationIndex = this._lastSnippetEvaluationIndexSetting.get() + 1;
this._lastSnippetEvaluationIndexSetting.set(evaluationIndex);
+ return evaluationIndex;
+ },
- var snippet = this._snippetStorage.snippetForId(snippetJavaScriptSource.snippetId);
- var sourceURL = this._sourceURLForSnippet(snippet, evaluationIndex);
- snippet._lastEvaluationSourceURL = sourceURL;
- var _expression_ = "\n//@ sourceURL=" + sourceURL + "\n" + snippet.content;
- WebInspector.evaluateInConsole(_expression_, true);
+ /**
+ * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
+ */
+ evaluateScriptSnippet: function(snippetJavaScriptSource)
+ {
+ var breakpointLocations = this._removeBreakpoints(snippetJavaScriptSource);
+ this._releaseSnippetScript(snippetJavaScriptSource);
+ this._restoreBreakpoints(snippetJavaScriptSource, breakpointLocations);
+ var evaluationIndex = this._nextEvaluationIndex(snippetJavaScriptSource.snippetId);
+ snippetJavaScriptSource._evaluationIndex = evaluationIndex;
+ var evaluationUrl = this._evaluationSourceURL(snippetJavaScriptSource);
+
+ var _expression_ = snippetJavaScriptSource.workingCopy();
+
+ // In order to stop on the breakpoints during the snippet evaluation we need to compile and run it separately.
+ // If separate compilation and execution is not supported by the port we fall back to evaluation in console.
+ // In case we don't need that since debugger is already paused.
+ // We do the same when we are stopped on the call frame since debugger is already paused and can not stop on breakpoint anymore.
+ if (WebInspector.debuggerModel.selectedCallFrame() || !Capabilities.separateScriptCompilationAndExecutionEnabled) {
+ _expression_ = snippetJavaScriptSource.workingCopy() + "\n//@ sourceURL=" + snippetJavaScriptSource.url + "\n";
+ WebInspector.evaluateInConsole(_expression_, true);
+ return;
+ }
+
+ WebInspector.showConsole();
+ DebuggerAgent.compileScript(_expression_, evaluationUrl, compileCallback.bind(this));
+
+ /**
+ * @param {?string} error
+ * @param {string=} scriptId
+ * @param {string=} syntaxErrorMessage
+ */
+ function compileCallback(error, scriptId, syntaxErrorMessage)
+ {
+ if (!snippetJavaScriptSource || snippetJavaScriptSource._evaluationIndex !== evaluationIndex)
+ return;
+
+ if (error) {
+ console.error(error);
+ return;
+ }
+
+ if (!scriptId) {
+ var consoleMessage = WebInspector.ConsoleMessage.create(
+ WebInspector.ConsoleMessage.MessageSource.JS,
+ WebInspector.ConsoleMessage.MessageLevel.Error,
+ syntaxErrorMessage || "",
+ WebInspector.ConsoleMessage.MessageType.Log,
+ "", 0, 1, null, null, null);
+ WebInspector.console.addMessage(consoleMessage);
+ return;
+ }
+
+ var breakpointLocations = this._removeBreakpoints(snippetJavaScriptSource);
+ this._restoreBreakpoints(snippetJavaScriptSource, breakpointLocations);
+
+ WebInspector.consoleView.runScript(scriptId);
+ }
},
/**
@@ -139,11 +218,6 @@
_rawLocationToUILocation: function(rawLocation)
{
var uiSourceCode = this._uiSourceCodeForScriptId[rawLocation.scriptId];
- if (uiSourceCode.isSnippet) {
- var uiLineNumber = rawLocation.lineNumber - WebInspector.ScriptSnippetModel.evaluatedSnippetExtraLinesCount;
- return new WebInspector.UILocation(uiSourceCode, uiLineNumber, rawLocation.columnNumber || 0);
- }
-
return new WebInspector.UILocation(uiSourceCode, rawLocation.lineNumber, rawLocation.columnNumber || 0);
},
@@ -159,11 +233,6 @@
if (!script)
return null;
- if (uiSourceCode.isSnippet) {
- var rawLineNumber = lineNumber + WebInspector.ScriptSnippetModel.evaluatedSnippetExtraLinesCount;
- return WebInspector.debuggerModel.createRawLocation(script, rawLineNumber, columnNumber);
- }
-
return WebInspector.debuggerModel.createRawLocation(script, lineNumber, columnNumber);
},
@@ -199,7 +268,8 @@
{
var snippetId = this._snippetIdForSourceURL(script.sourceURL);
var snippetJavaScriptSource = this._snippetJavaScriptSourceForSnippetId[snippetId];
- if (!snippetJavaScriptSource) {
+
+ if (!snippetJavaScriptSource || this._evaluationSourceURL(snippetJavaScriptSource) !== script.sourceURL) {
this._createUISourceCodeForScript(script);
return;
}
@@ -225,7 +295,32 @@
/**
* @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
+ * @return {Array.<Object>}
*/
+ _removeBreakpoints: function(snippetJavaScriptSource)
+ {
+ var breakpointLocations = WebInspector.breakpointManager.breakpointLocationsForUISourceCode(snippetJavaScriptSource);
+ for (var i = 0; i < breakpointLocations.length; ++i)
+ breakpointLocations[i].breakpoint.remove();
+ return breakpointLocations;
+ },
+
+ /**
+ * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
+ * @param {Array.<Object>} breakpointLocations
+ */
+ _restoreBreakpoints: function(snippetJavaScriptSource, breakpointLocations)
+ {
+ for (var i = 0; i < breakpointLocations.length; ++i) {
+ var uiLocation = breakpointLocations[i].uiLocation;
+ var breakpoint = breakpointLocations[i].breakpoint;
+ WebInspector.breakpointManager.setBreakpoint(uiLocation.uiSourceCode, uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled());
+ }
+ },
+
+ /**
+ * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
+ */
_releaseSnippetScript: function(snippetJavaScriptSource)
{
var script = this._scriptForUISourceCode.get(snippetJavaScriptSource);
@@ -234,20 +329,19 @@
delete this._uiSourceCodeForScriptId[script.scriptId];
this._scriptForUISourceCode.remove(snippetJavaScriptSource);
-
+ delete snippetJavaScriptSource._evaluationIndex;
this._createUISourceCodeForScript(script);
},
/**
- * @param {WebInspector.Snippet} snippet
- * @param {string} evaluationIndex
+ * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
* @return {string}
*/
- _sourceURLForSnippet: function(snippet, evaluationIndex)
+ _evaluationSourceURL: function(snippetJavaScriptSource)
{
var snippetPrefix = WebInspector.ScriptSnippetModel.snippetSourceURLPrefix;
- var evaluationSuffix = evaluationIndex ? "_" + evaluationIndex : "";
- return snippetPrefix + snippet.id + evaluationSuffix;
+ var evaluationSuffix = "_" + snippetJavaScriptSource._evaluationIndex;
+ return snippetPrefix + snippetJavaScriptSource.snippetId + evaluationSuffix;
},
/**
@@ -264,21 +358,6 @@
return snippetId;
},
- /**
- * @param {string} sourceURL
- * @return {WebInspector.Snippet|null}
- */
- _snippetForSourceURL: function(sourceURL)
- {
- var snippetId = this._snippetIdForSourceURL(sourceURL);
- if (!snippetId)
- return null;
- var snippet = this._snippetStorage.snippetForId(snippetId);
- if (!snippet || snippet._lastEvaluationSourceURL !== sourceURL)
- return null;
- return snippet;
- },
-
_reset: function()
{
var removedUISourceCodes = this._releasedUISourceCodes();
@@ -317,17 +396,51 @@
},
/**
+ * @return {boolean}
+ */
+ isDivergedFromVM: function()
+ {
+ return this._scriptSnippetModel._isDivergedFromVM(this);
+ },
+
+ /**
* @param {function(?string)} callback
*/
workingCopyCommitted: function(callback)
{
- this._scriptSnippetModel.setScriptSnippetContent(this, this.workingCopy());
+ this._scriptSnippetModel._setScriptSnippetContent(this, this.workingCopy());
callback(null);
},
+ workingCopyChanged: function()
+ {
+ this._scriptSnippetModel._scriptSnippetEdited(this);
+ },
+
+ evaluate: function()
+ {
+ this._scriptSnippetModel.evaluateScriptSnippet(this);
+ },
+
/**
+ * @return {boolean}
+ */
+ supportsEnabledBreakpointsWhileEditing: function()
+ {
+ return true;
+ },
+
+ /**
* @return {string}
*/
+ breakpointStorageId: function()
+ {
+ return WebInspector.ScriptSnippetModel.snippetSourceURLPrefix + this.snippetId;
+ },
+
+ /**
+ * @return {string}
+ */
get snippetId()
{
return this._snippetId;
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js (121672 => 121673)
--- trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js 2012-07-02 12:51:57 UTC (rev 121673)
@@ -232,7 +232,10 @@
*/
_handleEvaluateSnippet: function(uiSourceCode, event)
{
- // FIXME: To be implemented.
+ if (!uiSourceCode.isSnippet)
+ return;
+ var snippetJavaScriptSource = /** @type {WebInspector.SnippetJavaScriptSource} */ uiSourceCode;
+ snippetJavaScriptSource.evaluate();
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/externs.js (121672 => 121673)
--- trunk/Source/WebCore/inspector/front-end/externs.js 2012-07-02 12:13:19 UTC (rev 121672)
+++ trunk/Source/WebCore/inspector/front-end/externs.js 2012-07-02 12:51:57 UTC (rev 121673)
@@ -147,6 +147,8 @@
WebInspector.openResource = function(url, external) {}
+WebInspector.showConsole = function() {}
+
/**
* @param {string} _expression_
* @param {boolean=} showResultOnly