Title: [100143] trunk/Source/WebCore
- Revision
- 100143
- Author
- [email protected]
- Date
- 2011-11-14 07:56:03 -0800 (Mon, 14 Nov 2011)
Log Message
Web Inspector: add 'Show function definition' context menu item for function values
https://bugs.webkit.org/show_bug.cgi?id=72265
Allow navigating to _javascript_ function definition using context menu.
Reviewed by Pavel Feldman.
* English.lproj/localizedStrings.js:
* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.prototype.rawLocationToUILocation):
* inspector/front-end/ObjectPropertiesSection.js:
(WebInspector.ObjectPropertyTreeElement.prototype.update):
(WebInspector.ObjectPropertyTreeElement.prototype._functionContextMenuEventFired):
(WebInspector.ObjectPropertyTreeElement.prototype._functionContextMenuEventFired.revealFunction):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype.showFunctionDefinition):
* inspector/front-end/inspector.js:
(WebInspector.showPanelForAnchorNavigation):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (100142 => 100143)
--- trunk/Source/WebCore/ChangeLog 2011-11-14 15:44:57 UTC (rev 100142)
+++ trunk/Source/WebCore/ChangeLog 2011-11-14 15:56:03 UTC (rev 100143)
@@ -1,3 +1,24 @@
+2011-11-14 Yury Semikhatsky <[email protected]>
+
+ Web Inspector: add 'Show function definition' context menu item for function values
+ https://bugs.webkit.org/show_bug.cgi?id=72265
+
+ Allow navigating to _javascript_ function definition using context menu.
+
+ Reviewed by Pavel Feldman.
+
+ * English.lproj/localizedStrings.js:
+ * inspector/front-end/DebuggerPresentationModel.js:
+ (WebInspector.DebuggerPresentationModel.prototype.rawLocationToUILocation):
+ * inspector/front-end/ObjectPropertiesSection.js:
+ (WebInspector.ObjectPropertyTreeElement.prototype.update):
+ (WebInspector.ObjectPropertyTreeElement.prototype._functionContextMenuEventFired):
+ (WebInspector.ObjectPropertyTreeElement.prototype._functionContextMenuEventFired.revealFunction):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype.showFunctionDefinition):
+ * inspector/front-end/inspector.js:
+ (WebInspector.showPanelForAnchorNavigation):
+
2011-11-14 Pavel Feldman <[email protected]>
Web Inspector: console's protocol payload does not have url and line properties.
Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js
(Binary files differ)
Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (100142 => 100143)
--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js 2011-11-14 15:44:57 UTC (rev 100142)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js 2011-11-14 15:56:03 UTC (rev 100143)
@@ -88,6 +88,18 @@
return new WebInspector.DebuggerPresentationModel.CallFramePlacard(callFrame);
},
+ /*
+ * @param {DebuggerAgent.Location} rawLocation
+ * @return {?WebInspector.UILocation}
+ */
+ rawLocationToUILocation: function(rawLocation)
+ {
+ var rawSourceCode = this._rawSourceCodeForScriptId[rawLocation.scriptId];
+ if (!rawSourceCode.sourceMapping)
+ return null;
+ return rawSourceCode.sourceMapping.rawLocationToUILocation(rawLocation);
+ },
+
/**
* @param {WebInspector.Event} event
*/
Modified: trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js (100142 => 100143)
--- trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js 2011-11-14 15:44:57 UTC (rev 100142)
+++ trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js 2011-11-14 15:56:03 UTC (rev 100143)
@@ -218,6 +218,9 @@
} else
this.valueElement.textContent = description;
+ if (this.property.value.type === "function")
+ this.valueElement.addEventListener("contextmenu", this._functionContextMenuEventFired.bind(this), false);
+
if (this.property.wasThrown)
this.valueElement.addStyleClass("error");
if (this.property.value.subtype)
@@ -253,6 +256,27 @@
contextMenu.show(event);
},
+ _functionContextMenuEventFired: function(event)
+ {
+ function didGetLocation(error, response)
+ {
+ if (error) {
+ console.error(error);
+ return;
+ }
+ WebInspector.panels.scripts.showFunctionDefinition(response);
+ }
+
+ function revealFunction()
+ {
+ DebuggerAgent.getFunctionLocation(this.property.value.objectId, didGetLocation.bind(this));
+ }
+
+ var contextMenu = new WebInspector.ContextMenu();
+ contextMenu.appendItem(WebInspector.UIString("Show function definition"), revealFunction.bind(this));
+ contextMenu.show(event);
+ },
+
updateSiblings: function()
{
if (this.parent.root)
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (100142 => 100143)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-11-14 15:44:57 UTC (rev 100142)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-11-14 15:56:03 UTC (rev 100143)
@@ -605,6 +605,13 @@
this._showSourceLine(anchor.uiSourceCode, anchor.lineNumber);
},
+ showFunctionDefinition: function(functionLocation)
+ {
+ WebInspector.showPanelForAnchorNavigation(this);
+ var uiLocation = this._presentationModel.rawLocationToUILocation(functionLocation);
+ this._showSourceLine(uiLocation.uiSourceCode, uiLocation.lineNumber);
+ },
+
_showSourceLine: function(uiSourceCode, lineNumber)
{
var sourceFrame = this._showSourceFrameAndAddToHistory(uiSourceCode);
Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (100142 => 100143)
--- trunk/Source/WebCore/inspector/front-end/inspector.js 2011-11-14 15:44:57 UTC (rev 100142)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js 2011-11-14 15:56:03 UTC (rev 100143)
@@ -828,12 +828,15 @@
anchor.addStyleClass("webkit-html-resource-link");
}
+ this.showPanelForAnchorNavigation(panel);
+ panel.showAnchorLocation(anchor);
+ return true;
+}
+
+WebInspector.showPanelForAnchorNavigation = function(panel)
+{
WebInspector.searchController.disableSearchUntilExplicitAction();
WebInspector.inspectorView.setCurrentPanel(panel);
- if (this.drawer)
- this.drawer.immediatelyFinishAnimation();
- WebInspector.inspectorView.currentPanel().showAnchorLocation(anchor);
- return true;
}
WebInspector.showProfileForURL = function(url)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes