<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[180891] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/180891">180891</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2015-03-02 11:32:49 -0800 (Mon, 02 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: Add Context Menus to Object Tree properties
https://bugs.webkit.org/show_bug.cgi?id=142125
Reviewed by Timothy Hatcher.
Source/JavaScriptCore:
* inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::functionDetails):
Update to include columnNumber.
Source/WebInspectorUI:
* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Views/ObjectPropertiesSection.js:
(WebInspector.ObjectPropertyTreeElement.prototype._functionContextMenuEventFired):
(WebInspector.ObjectPropertyTreeElement.prototype._functionContextMenuEventFired.revealFunction):
Fix legacy implementation.
* UserInterface/Views/ObjectTreeArrayIndexTreeElement.js:
* UserInterface/Views/ObjectTreePropertyTreeElement.js:
(WebInspector.ObjectTreePropertyTreeElement.prototype._createTitlePrototype):
Give prototype buttons a tooltip.
(WebInspector.ObjectTreePropertyTreeElement.prototype.oncontextmenu):
(WebInspector.ObjectTreePropertyTreeElement.prototype._contextMenuHandler):
(WebInspector.ObjectTreePropertyTreeElement.prototype._appendMenusItemsForObject):
Context Menus based on the selected object.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorJSInjectedScriptHostcpp">trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs">trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsObjectPropertiesSectionjs">trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPropertiesSection.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsObjectTreeArrayIndexTreeElementjs">trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeArrayIndexTreeElement.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsObjectTreePropertyTreeElementjs">trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (180890 => 180891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-03-02 19:08:06 UTC (rev 180890)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-03-02 19:32:49 UTC (rev 180891)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-03-02 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Add Context Menus to Object Tree properties
+ https://bugs.webkit.org/show_bug.cgi?id=142125
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/JSInjectedScriptHost.cpp:
+ (Inspector::JSInjectedScriptHost::functionDetails):
+ Update to include columnNumber.
+
</ins><span class="cx"> 2015-03-01 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> BytecodeGenerator shouldn't emit op_resolve_scope as a roundabout way of returning the scopeRegister
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorJSInjectedScriptHostcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp (180890 => 180891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp        2015-03-02 19:08:06 UTC (rev 180890)
+++ trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp        2015-03-02 19:32:49 UTC (rev 180891)
</span><span class="lines">@@ -166,19 +166,26 @@
</span><span class="cx"> if (!value.asCell()->inherits(JSFunction::info()))
</span><span class="cx"> return jsUndefined();
</span><span class="cx">
</span><ins>+ // FIXME: This should provide better details for JSBoundFunctions.
+
</ins><span class="cx"> JSFunction* function = jsCast<JSFunction*>(value);
</span><span class="cx"> const SourceCode* sourceCode = function->sourceCode();
</span><span class="cx"> if (!sourceCode)
</span><span class="cx"> return jsUndefined();
</span><span class="cx">
</span><ins>+ // In the inspector protocol all positions are 0-based while in SourceCode they are 1-based
</ins><span class="cx"> int lineNumber = sourceCode->firstLine();
</span><span class="cx"> if (lineNumber)
</span><del>- lineNumber -= 1; // In the inspector protocol all positions are 0-based while in SourceCode they are 1-based
</del><ins>+ lineNumber -= 1;
+ int columnNumber = sourceCode->startColumn();
+ if (columnNumber)
+ columnNumber -= 1;
</ins><span class="cx">
</span><span class="cx"> String scriptID = String::number(sourceCode->provider()->asID());
</span><span class="cx"> JSObject* location = constructEmptyObject(exec);
</span><ins>+ location->putDirect(exec->vm(), Identifier(exec, "scriptId"), jsString(exec, scriptID));
</ins><span class="cx"> location->putDirect(exec->vm(), Identifier(exec, "lineNumber"), jsNumber(lineNumber));
</span><del>- location->putDirect(exec->vm(), Identifier(exec, "scriptId"), jsString(exec, scriptID));
</del><ins>+ location->putDirect(exec->vm(), Identifier(exec, "columnNumber"), jsNumber(columnNumber));
</ins><span class="cx">
</span><span class="cx"> JSObject* result = constructEmptyObject(exec);
</span><span class="cx"> result->putDirect(exec->vm(), Identifier(exec, "location"), location);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (180890 => 180891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2015-03-02 19:08:06 UTC (rev 180890)
+++ trunk/Source/WebInspectorUI/ChangeLog        2015-03-02 19:32:49 UTC (rev 180891)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2015-03-02 Joseph Pecoraro <pecoraro@apple.com>
+
+ Web Inspector: Add Context Menus to Object Tree properties
+ https://bugs.webkit.org/show_bug.cgi?id=142125
+
+ Reviewed by Timothy Hatcher.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ * UserInterface/Views/ObjectPropertiesSection.js:
+ (WebInspector.ObjectPropertyTreeElement.prototype._functionContextMenuEventFired):
+ (WebInspector.ObjectPropertyTreeElement.prototype._functionContextMenuEventFired.revealFunction):
+ Fix legacy implementation.
+
+ * UserInterface/Views/ObjectTreeArrayIndexTreeElement.js:
+ * UserInterface/Views/ObjectTreePropertyTreeElement.js:
+ (WebInspector.ObjectTreePropertyTreeElement.prototype._createTitlePrototype):
+ Give prototype buttons a tooltip.
+
+ (WebInspector.ObjectTreePropertyTreeElement.prototype.oncontextmenu):
+ (WebInspector.ObjectTreePropertyTreeElement.prototype._contextMenuHandler):
+ (WebInspector.ObjectTreePropertyTreeElement.prototype._appendMenusItemsForObject):
+ Context Menus based on the selected object.
+
</ins><span class="cx"> 2015-02-27 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Use Maps in ResourceCollection instead of objects
</span></span></pre></div>
<a id="trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (180890 => 180891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2015-03-02 19:08:06 UTC (rev 180890)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2015-03-02 19:32:49 UTC (rev 180891)
</span><span class="lines">@@ -118,6 +118,7 @@
</span><span class="cx"> localizedStrings["Continue to Here"] = "Continue to Here";
</span><span class="cx"> localizedStrings["Controls"] = "Controls";
</span><span class="cx"> localizedStrings["Cookies"] = "Cookies";
</span><ins>+localizedStrings["Copy Path to Property"] = "Copy Path to Property";
</ins><span class="cx"> localizedStrings["Copy Row"] = "Copy Row";
</span><span class="cx"> localizedStrings["Copy as HTML"] = "Copy as HTML";
</span><span class="cx"> localizedStrings["Could not fetch properties. Object may no longer exist."] = "Could not fetch properties. Object may no longer exist.";
</span><span class="lines">@@ -262,6 +263,7 @@
</span><span class="cx"> localizedStrings["Invalid"] = "Invalid";
</span><span class="cx"> localizedStrings["Invoke getter"] = "Invoke getter";
</span><span class="cx"> localizedStrings["JavaScript & Events"] = "JavaScript & Events";
</span><ins>+localizedStrings["Jump to Definition"] = "Jump to Definition";
</ins><span class="cx"> localizedStrings["Keep Log on Reload"] = "Keep Log on Reload";
</span><span class="cx"> localizedStrings["Key"] = "Key";
</span><span class="cx"> localizedStrings["Label"] = "Label";
</span><span class="lines">@@ -413,7 +415,6 @@
</span><span class="cx"> localizedStrings["Show compositing borders"] = "Show compositing borders";
</span><span class="cx"> localizedStrings["Show console (%s)"] = "Show console (%s)";
</span><span class="cx"> localizedStrings["Show full-height console"] = "Show full-height console";
</span><del>-localizedStrings["Show function definition"] = "Show function definition";
</del><span class="cx"> localizedStrings["Show shadow DOM nodes"] = "Show shadow DOM nodes";
</span><span class="cx"> localizedStrings["Show split console"] = "Show split console";
</span><span class="cx"> localizedStrings["Show the %s details sidebar"] = "Show the %s details sidebar";
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsObjectPropertiesSectionjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPropertiesSection.js (180890 => 180891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPropertiesSection.js        2015-03-02 19:08:06 UTC (rev 180890)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPropertiesSection.js        2015-03-02 19:32:49 UTC (rev 180891)
</span><span class="lines">@@ -257,20 +257,25 @@
</span><span class="cx"> {
</span><span class="cx"> function didGetLocation(error, response)
</span><span class="cx"> {
</span><del>- if (error) {
- console.error(error);
</del><ins>+ if (error)
</ins><span class="cx"> return;
</span><del>- }
- WebInspector.panels.scripts.showFunctionDefinition(response);
</del><ins>+
+ var location = response.location;
+ var sourceCode = WebInspector.debuggerManager.scriptForIdentifier(location.scriptId);
+ if (!sourceCode)
+ return;
+
+ var sourceCodeLocation = sourceCode.createSourceCodeLocation(location.lineNumber, location.columnNumber || 0);
+ WebInspector.resourceSidebarPanel.showSourceCodeLocation(sourceCodeLocation);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function revealFunction()
</span><span class="cx"> {
</span><del>- DebuggerAgent.getFunctionLocation(this.property.value.objectId, didGetLocation.bind(this));
</del><ins>+ DebuggerAgent.getFunctionDetails(this.property.value.objectId, didGetLocation);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> var contextMenu = new WebInspector.ContextMenu(event);
</span><del>- contextMenu.appendItem(WebInspector.UIString("Show function definition"), revealFunction.bind(this));
</del><ins>+ contextMenu.appendItem(WebInspector.UIString("Jump to Definition"), revealFunction.bind(this));
</ins><span class="cx"> contextMenu.show();
</span><span class="cx"> },
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsObjectTreeArrayIndexTreeElementjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeArrayIndexTreeElement.js (180890 => 180891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeArrayIndexTreeElement.js        2015-03-02 19:08:06 UTC (rev 180890)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeArrayIndexTreeElement.js        2015-03-02 19:32:49 UTC (rev 180891)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx"> * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-// FIXME: This should share more code with ObjectTreePropertyTreeElement.
</del><ins>+// FIXME: This should share more code with ObjectTreePropertyTreeElement. (getters, resolved values, context menus)
</ins><span class="cx">
</span><span class="cx"> WebInspector.ObjectTreeArrayIndexTreeElement = function(property, propertyPath)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsObjectTreePropertyTreeElementjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js (180890 => 180891)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js        2015-03-02 19:08:06 UTC (rev 180890)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js        2015-03-02 19:32:49 UTC (rev 180891)
</span><span class="lines">@@ -88,6 +88,11 @@
</span><span class="cx"> this._previewView.showPreview();
</span><span class="cx"> },
</span><span class="cx">
</span><ins>+ oncontextmenu: function(event)
+ {
+ this._contextMenuHandler(event);
+ },
+
</ins><span class="cx"> // Private
</span><span class="cx">
</span><span class="cx"> _resolvedValue: function()
</span><span class="lines">@@ -185,6 +190,7 @@
</span><span class="cx"> var nameElement = document.createElement("span");
</span><span class="cx"> nameElement.className = "prototype-name";
</span><span class="cx"> nameElement.textContent = WebInspector.UIString("%s Prototype").format(this._sanitizedPrototypeString(this._property.value));
</span><ins>+ nameElement.title = this._propertyPathString(this._thisPropertyPath());
</ins><span class="cx"> return nameElement;
</span><span class="cx"> },
</span><span class="cx">
</span><span class="lines">@@ -219,7 +225,6 @@
</span><span class="cx"> valueOrGetterElement.textContent = this._functionPropertyString();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // FIXME: Context Menu for Value. (See ObjectPropertiesSection).
</del><span class="cx"> // FIXME: Option+Click for Value.
</span><span class="cx"> } else {
</span><span class="cx"> valueOrGetterElement = document.createElement("span");
</span><span class="lines">@@ -466,5 +471,61 @@
</span><span class="cx"> var emptyMessageElement = WebInspector.ObjectTreeView.emptyMessageElement(WebInspector.UIString("No Properties."));
</span><span class="cx"> this.appendChild(new TreeElement(emptyMessageElement, null, false));
</span><span class="cx"> }
</span><ins>+ },
+
+ _contextMenuHandler: function(event)
+ {
+ var resolvedValue = this._resolvedValue();
+ if (!resolvedValue)
+ return;
+
+ var contextMenu = new WebInspector.ContextMenu(event);
+
+ var propertyPath = this._resolvedValuePropertyPath();
+ if (propertyPath && !propertyPath.isFullPathImpossible()) {
+ contextMenu.appendItem(WebInspector.UIString("Copy Path to Property"), function() {
+ InspectorFrontendHost.copyText(propertyPath.displayPath(WebInspector.PropertyPath.Type.Value));
+ }.bind(this));
+ }
+
+ contextMenu.appendSeparator();
+
+ this._appendMenusItemsForObject(contextMenu, resolvedValue);
+
+ if (!contextMenu.isEmpty())
+ contextMenu.show();
+ },
+
+ _appendMenusItemsForObject: function(contextMenu, resolvedValue)
+ {
+ if (resolvedValue.type === "function") {
+ // FIXME: We should better handle bound functions.
+ if (!isFunctionStringNativeCode(resolvedValue.description)) {
+ contextMenu.appendItem(WebInspector.UIString("Jump to Definition"), function() {
+ DebuggerAgent.getFunctionDetails(resolvedValue.objectId, function(error, response) {
+ if (error)
+ return;
+
+ var location = response.location;
+ var sourceCode = WebInspector.debuggerManager.scriptForIdentifier(location.scriptId);
+ if (!sourceCode)
+ return;
+
+ var sourceCodeLocation = sourceCode.createSourceCodeLocation(location.lineNumber, location.columnNumber || 0);
+ WebInspector.resourceSidebarPanel.showSourceCodeLocation(sourceCodeLocation);
+ });
+ });
+ }
+ return;
+ }
+
+ if (resolvedValue.subtype === "node") {
+ contextMenu.appendItem(WebInspector.UIString("Reveal in DOM Tree"), function() {
+ resolvedValue.pushNodeToFrontend(function(nodeId) {
+ WebInspector.domTreeManager.inspectElement(nodeId);
+ });
+ });
+ return;
+ }
</ins><span class="cx"> }
</span><span class="cx"> };
</span></span></pre>
</div>
</div>
</body>
</html>