From 8953638c3fa7069d8d73877abaae2fccc0e440dd Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Fri, 22 Jun 2012 13:56:17 +0000 Subject: [PATCH] Web Inspector: Support 'Restart frame' in inspector frontend https://bugs.webkit.org/show_bug.cgi?id=89678 Patch by Peter Rybin on 2012-06-22 Reviewed by Pavel Feldman. Action is added to call frame placard's context menu. Context menu is now built on a call frame level rather than on callback sidebar level. * English.lproj/localizedStrings.js: * inspector/front-end/CallStackSidebarPane.js: (WebInspector.CallStackSidebarPane): (WebInspector.CallStackSidebarPane.prototype.update): (WebInspector.CallStackSidebarPane.Placard): (WebInspector.CallStackSidebarPane.Placard.prototype._update): (WebInspector.CallStackSidebarPane.Placard.prototype._placardContextMenu): (_restartFrame): * inspector/front-end/DebuggerModel.js: (WebInspector.DebuggerModel.prototype.rawLocationToUILocation): (WebInspector.DebuggerModel.prototype.callStackModified): (WebInspector.DebuggerModel.CallFrame.prototype.restart): * inspector/front-end/Script.js: (WebInspector.Script.prototype.editSource): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121021 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 25 ++++++++++++++ Source/WebCore/English.lproj/localizedStrings.js | 1 + .../inspector/front-end/CallStackSidebarPane.js | 36 ++++++++++++-------- .../WebCore/inspector/front-end/DebuggerModel.js | 39 ++++++++++++++++++++++ Source/WebCore/inspector/front-end/Script.js | 1 + 5 files changed, 89 insertions(+), 13 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 2b25841..95d28c7 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,28 @@ +2012-06-22 Peter Rybin + + Web Inspector: Support 'Restart frame' in inspector frontend + https://bugs.webkit.org/show_bug.cgi?id=89678 + + Reviewed by Pavel Feldman. + + Action is added to call frame placard's context menu. Context menu is now built + on a call frame level rather than on callback sidebar level. + + * English.lproj/localizedStrings.js: + * inspector/front-end/CallStackSidebarPane.js: + (WebInspector.CallStackSidebarPane): + (WebInspector.CallStackSidebarPane.prototype.update): + (WebInspector.CallStackSidebarPane.Placard): + (WebInspector.CallStackSidebarPane.Placard.prototype._update): + (WebInspector.CallStackSidebarPane.Placard.prototype._placardContextMenu): + (_restartFrame): + * inspector/front-end/DebuggerModel.js: + (WebInspector.DebuggerModel.prototype.rawLocationToUILocation): + (WebInspector.DebuggerModel.prototype.callStackModified): + (WebInspector.DebuggerModel.CallFrame.prototype.restart): + * inspector/front-end/Script.js: + (WebInspector.Script.prototype.editSource): + 2012-06-22 Jocelyn Turcotte [Qt] Fix the remote inspector loading problems on Mac diff --git a/Source/WebCore/English.lproj/localizedStrings.js b/Source/WebCore/English.lproj/localizedStrings.js index f4d2e3a..236d44b 100644 --- a/Source/WebCore/English.lproj/localizedStrings.js +++ b/Source/WebCore/English.lproj/localizedStrings.js @@ -543,6 +543,7 @@ localizedStrings["property"] = "property"; localizedStrings["Object types:"] = "Object types:"; localizedStrings["%s() at %s"] = "%s() at %s"; localizedStrings["Copy Stack Trace"] = "Copy Stack Trace"; +localizedStrings["Restart Frame"] = "Restart Frame"; localizedStrings["Collect Garbage"] = "Collect Garbage"; localizedStrings["JSON"] = "JSON"; localizedStrings["Catch"] = "Catch"; diff --git a/Source/WebCore/inspector/front-end/CallStackSidebarPane.js b/Source/WebCore/inspector/front-end/CallStackSidebarPane.js index 9bddf5a..6ab3ec8 100644 --- a/Source/WebCore/inspector/front-end/CallStackSidebarPane.js +++ b/Source/WebCore/inspector/front-end/CallStackSidebarPane.js @@ -32,7 +32,6 @@ WebInspector.CallStackSidebarPane = function() WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack")); this._model = WebInspector.debuggerModel; - this.bodyElement.addEventListener("contextmenu", this._contextMenu.bind(this), true); this.bodyElement.addEventListener("keydown", this._keyDown.bind(this), true); this.bodyElement.tabIndex = 0; } @@ -53,7 +52,7 @@ WebInspector.CallStackSidebarPane.prototype = { for (var i = 0; i < callFrames.length; ++i) { var callFrame = callFrames[i]; - var placard = new WebInspector.CallStackSidebarPane.Placard(callFrame); + var placard = new WebInspector.CallStackSidebarPane.Placard(callFrame, this); placard.element.addEventListener("click", this._placardSelected.bind(this, placard), false); this.placards.push(placard); this.bodyElement.appendChild(placard.element); @@ -108,16 +107,6 @@ WebInspector.CallStackSidebarPane.prototype = { this._model.setSelectedCallFrame(placard._callFrame); }, - _contextMenu: function(event) - { - if (!this.placards.length) - return; - - var contextMenu = new WebInspector.ContextMenu(); - contextMenu.appendItem(WebInspector.UIString("Copy Stack Trace"), this._copyStackTrace.bind(this)); - contextMenu.show(event); - }, - _copyStackTrace: function() { var text = ""; @@ -175,18 +164,39 @@ WebInspector.CallStackSidebarPane.prototype.__proto__ = WebInspector.SidebarPane * @constructor * @extends {WebInspector.Placard} * @param {WebInspector.DebuggerModel.CallFrame} callFrame + * @param {WebInspector.CallStackSidebarPane} pane */ -WebInspector.CallStackSidebarPane.Placard = function(callFrame) +WebInspector.CallStackSidebarPane.Placard = function(callFrame, pane) { WebInspector.Placard.call(this, callFrame.functionName || WebInspector.UIString("(anonymous function)"), ""); callFrame.createLiveLocation(this._update.bind(this)); + this.element.addEventListener("contextmenu", this._placardContextMenu.bind(this), true); this._callFrame = callFrame; + this._pane = pane; } WebInspector.CallStackSidebarPane.Placard.prototype = { _update: function(uiLocation) { this.subtitle = WebInspector.displayNameForURL(uiLocation.uiSourceCode.url) + ":" + (uiLocation.lineNumber + 1); + }, + + _placardContextMenu: function(event) + { + var contextMenu = new WebInspector.ContextMenu(); + + if (WebInspector.debuggerModel.canSetScriptSource()) { + contextMenu.appendItem(WebInspector.UIString("Restart Frame"), this._restartFrame.bind(this)); + contextMenu.appendSeparator(); + } + contextMenu.appendItem(WebInspector.UIString("Copy Stack Trace"), this._pane._copyStackTrace.bind(this._pane)); + + contextMenu.show(event); + }, + + _restartFrame: function() + { + this._callFrame.restart(undefined); } } diff --git a/Source/WebCore/inspector/front-end/DebuggerModel.js b/Source/WebCore/inspector/front-end/DebuggerModel.js index 2f0f7bc..23470a4 100644 --- a/Source/WebCore/inspector/front-end/DebuggerModel.js +++ b/Source/WebCore/inspector/front-end/DebuggerModel.js @@ -541,6 +541,24 @@ WebInspector.DebuggerModel.prototype = { if (!script) return null; return script.rawLocationToUILocation(rawLocation.lineNumber, rawLocation.columnNumber); + }, + + /** + * Handles notification from JavaScript VM about updated stack (liveedit or frame restart action). + * @this {WebInspector.DebuggerModel} + * @param {Array.=} newCallFrames + * @param {Object=} details + */ + callStackModified: function(newCallFrames, details) + { + // FIXME: declare this property in protocol and in JavaScript. + if (details && details["stack_update_needs_step_in"]) + DebuggerAgent.stepInto(); + else { + if (newCallFrames && newCallFrames.length) + this._pausedScript(newCallFrames, this._debuggerPausedDetails.reason, this._debuggerPausedDetails.auxData); + + } } } @@ -710,6 +728,27 @@ WebInspector.DebuggerModel.CallFrame.prototype = { }, /** + * @param {function(?Protocol.Error=)=} callback + */ + restart: function(callback) + { + /** + * @this {WebInspector.DebuggerModel.CallFrame} + * @param {?Protocol.Error} error + * @param {Array.=} callFrames + * @param {Object=} details + */ + function protocolCallback(error, callFrames, details) + { + if (!error) + WebInspector.debuggerModel.callStackModified(callFrames, details); + if (callback) + callback(error); + } + DebuggerAgent.restartFrame(this._payload.callFrameId, protocolCallback); + }, + + /** * @param {function(WebInspector.UILocation):(boolean|undefined)} updateDelegate */ createLiveLocation: function(updateDelegate) diff --git a/Source/WebCore/inspector/front-end/Script.js b/Source/WebCore/inspector/front-end/Script.js index c9fcd3a..e973fc5 100644 --- a/Source/WebCore/inspector/front-end/Script.js +++ b/Source/WebCore/inspector/front-end/Script.js @@ -138,6 +138,7 @@ WebInspector.Script.prototype = { */ function didEditScriptSource(error, callFrames, debugData) { + // FIXME: support debugData.stack_update_needs_step_in flag by calling WebInspector.debugger_model.callStackModified if (!error) this._source = newSource; callback(error, callFrames); -- 2.7.4