Title: [126706] trunk/Source/WebCore
Revision
126706
Author
[email protected]
Date
2012-08-26 06:58:59 -0700 (Sun, 26 Aug 2012)

Log Message

Web Inspector: provide "show function definition" and "reveal in elements panel" using context menu provider.
https://bugs.webkit.org/show_bug.cgi?id=94932

Reviewed by Vsevolod Vlasov.

Moved corresponding context menu providers into scripts and elements panels.

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/compile-front-end.py:
* inspector/front-end/ElementsPanel.js:
(WebInspector.ElementsPanel.prototype.revealAndSelectNode):
(WebInspector.ElementsPanel.prototype.appendApplicableItems.selectNode):
(WebInspector.ElementsPanel.prototype.appendApplicableItems.revealElement):
(WebInspector.ElementsPanel.prototype.appendApplicableItems):
* inspector/front-end/ElementsPanelDescriptor.js: Copied from Source/WebCore/inspector/front-end/ScriptsPanelDescriptor.js.
(WebInspector.ElementsPanelDescriptor):
(WebInspector.ElementsPanelDescriptor.prototype.appendApplicableItems):
* inspector/front-end/ObjectPropertiesSection.js:
(WebInspector.ObjectPropertiesSection.prototype._contextMenuEventFired):
(WebInspector.ObjectPropertyTreeElement.prototype.update):
(WebInspector.ObjectPropertyTreeElement.prototype._contextMenuFired):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype.appendApplicableItems):
(WebInspector.ScriptsPanel.prototype._appendUISourceCodeItems):
(WebInspector.ScriptsPanel.prototype._appendFunctionItems.didGetDetails):
(WebInspector.ScriptsPanel.prototype._appendFunctionItems.revealFunction):
(WebInspector.ScriptsPanel.prototype._appendFunctionItems):
* inspector/front-end/ScriptsPanelDescriptor.js:
(WebInspector.ScriptsPanelDescriptor.prototype.appendApplicableItems):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:
* inspector/front-end/inspector.js:
(WebInspector._panelDescriptors):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (126705 => 126706)


--- trunk/Source/WebCore/ChangeLog	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/ChangeLog	2012-08-26 13:58:59 UTC (rev 126706)
@@ -1,3 +1,40 @@
+2012-08-26  Pavel Feldman  <[email protected]>
+
+        Web Inspector: provide "show function definition" and "reveal in elements panel" using context menu provider.
+        https://bugs.webkit.org/show_bug.cgi?id=94932
+
+        Reviewed by Vsevolod Vlasov.
+
+        Moved corresponding context menu providers into scripts and elements panels.
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/compile-front-end.py:
+        * inspector/front-end/ElementsPanel.js:
+        (WebInspector.ElementsPanel.prototype.revealAndSelectNode):
+        (WebInspector.ElementsPanel.prototype.appendApplicableItems.selectNode):
+        (WebInspector.ElementsPanel.prototype.appendApplicableItems.revealElement):
+        (WebInspector.ElementsPanel.prototype.appendApplicableItems):
+        * inspector/front-end/ElementsPanelDescriptor.js: Copied from Source/WebCore/inspector/front-end/ScriptsPanelDescriptor.js.
+        (WebInspector.ElementsPanelDescriptor):
+        (WebInspector.ElementsPanelDescriptor.prototype.appendApplicableItems):
+        * inspector/front-end/ObjectPropertiesSection.js:
+        (WebInspector.ObjectPropertiesSection.prototype._contextMenuEventFired):
+        (WebInspector.ObjectPropertyTreeElement.prototype.update):
+        (WebInspector.ObjectPropertyTreeElement.prototype._contextMenuFired):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype.appendApplicableItems):
+        (WebInspector.ScriptsPanel.prototype._appendUISourceCodeItems):
+        (WebInspector.ScriptsPanel.prototype._appendFunctionItems.didGetDetails):
+        (WebInspector.ScriptsPanel.prototype._appendFunctionItems.revealFunction):
+        (WebInspector.ScriptsPanel.prototype._appendFunctionItems):
+        * inspector/front-end/ScriptsPanelDescriptor.js:
+        (WebInspector.ScriptsPanelDescriptor.prototype.appendApplicableItems):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+        * inspector/front-end/inspector.js:
+        (WebInspector._panelDescriptors):
+
 2012-08-26  Joe Mason  <[email protected]>
 
         [BlackBerry] Stop leaking a pthread_attr in CookieDatabaseBackingStore

Modified: trunk/Source/WebCore/WebCore.gypi (126705 => 126706)


--- trunk/Source/WebCore/WebCore.gypi	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/WebCore.gypi	2012-08-26 13:58:59 UTC (rev 126706)
@@ -6310,6 +6310,7 @@
             'inspector/front-end/DOMStorage.js',
             'inspector/front-end/DOMSyntaxHighlighter.js',
             'inspector/front-end/Drawer.js',
+            'inspector/front-end/ElementsPanelDescriptor.js',
             'inspector/front-end/ElementsTreeOutline.js',
             'inspector/front-end/EmptyView.js',
             'inspector/front-end/ExtensionAPI.js',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (126705 => 126706)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-08-26 13:58:59 UTC (rev 126706)
@@ -76030,6 +76030,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\ElementsPanelDescriptor.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\ElementsTreeOutline.js"
 					>
 				</File>

Modified: trunk/Source/WebCore/inspector/compile-front-end.py (126705 => 126706)


--- trunk/Source/WebCore/inspector/compile-front-end.py	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/inspector/compile-front-end.py	2012-08-26 13:58:59 UTC (rev 126706)
@@ -179,6 +179,7 @@
         "dependencies": ["components"],
         "sources": [
             "ElementsPanel.js",
+            "ElementsPanelDescriptor.js",
             "EventListenersSidebarPane.js",
             "MetricsSidebarPane.js",
             "PropertiesSidebarPane.js",

Modified: trunk/Source/WebCore/inspector/front-end/ElementsPanel.js (126705 => 126706)


--- trunk/Source/WebCore/inspector/front-end/ElementsPanel.js	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/inspector/front-end/ElementsPanel.js	2012-08-26 13:58:59 UTC (rev 126706)
@@ -1076,6 +1076,32 @@
 
         WebInspector.domAgent.highlightDOMNodeForTwoSeconds(nodeId);
         this.selectDOMNode(node, true);
+    },
+
+    /** 
+     * @param {WebInspector.ContextMenu} contextMenu
+     * @param {Object} target
+     */
+    appendApplicableItems: function(contextMenu, target)
+    {
+        if (!(target instanceof WebInspector.RemoteObject))
+            return;
+        var remoteObject = /** @type {WebInspector.RemoteObject} */ target;
+        if (remoteObject.subtype !== "node")
+            return;
+
+        function selectNode(nodeId)
+        {
+            if (nodeId)
+                WebInspector.domAgent.inspectElement(nodeId);
+        }
+  
+        function revealElement()
+        {
+            remoteObject.pushNodeToFrontend(selectNode);
+        }
+
+        contextMenu.appendItem(WebInspector.UIString("Reveal in Elements Panel"), revealElement.bind(this));
     }
 }
 

Copied: trunk/Source/WebCore/inspector/front-end/ElementsPanelDescriptor.js (from rev 126705, trunk/Source/WebCore/inspector/front-end/ScriptsPanelDescriptor.js) (0 => 126706)


--- trunk/Source/WebCore/inspector/front-end/ElementsPanelDescriptor.js	                        (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/ElementsPanelDescriptor.js	2012-08-26 13:58:59 UTC (rev 126706)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
+ * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @constructor
+ * @extends {WebInspector.PanelDescriptor}
+ * @implements {WebInspector.ContextMenu.Provider}
+ */
+WebInspector.ElementsPanelDescriptor = function()
+{
+    WebInspector.PanelDescriptor.call(this, "elements", WebInspector.UIString("Elements"), "ElementsPanel", "ElementsPanel.js");
+    WebInspector.ContextMenu.registerProvider(this);
+}
+
+WebInspector.ElementsPanelDescriptor.prototype = {
+    /** 
+     * @param {WebInspector.ContextMenu} contextMenu
+     * @param {Object} target
+     */
+    appendApplicableItems: function(contextMenu, target)
+    {
+        if (!(target instanceof WebInspector.RemoteObject))
+            return;
+        var remoteObject = /** @type {WebInspector.RemoteObject} */ target;
+        if (remoteObject.subtype !== "node")
+            return;
+        this.panel().appendApplicableItems(contextMenu, target);
+    }
+}
+
+WebInspector.ElementsPanelDescriptor.prototype.__proto__ = WebInspector.PanelDescriptor.prototype;

Modified: trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js (126705 => 126706)


--- trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js	2012-08-26 13:58:59 UTC (rev 126706)
@@ -60,8 +60,7 @@
     {
         var contextMenu = new WebInspector.ContextMenu();
         contextMenu.appendApplicableItems(this.object);
-        if (!contextMenu.isEmpty())
-            contextMenu.show(event);
+        contextMenu.show(event);
     },
 
     onpopulate: function()
@@ -234,18 +233,14 @@
         } 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)
             this.valueElement.addStyleClass("console-formatted-" + this.property.value.subtype);
         else if (this.property.value.type)
             this.valueElement.addStyleClass("console-formatted-" + this.property.value.type);
-        if (this.property.value.subtype === "node")
-            this.valueElement.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), false);
 
+        this.valueElement.addEventListener("contextmenu", this._contextMenuFired.bind(this, this.property.value), false);
         this.valueElement.title = description || "";
 
         this.listItemElement.removeChildren();
@@ -256,45 +251,13 @@
         this.hasChildren = this.property.value.hasChildren && !this.property.wasThrown;
     },
 
-    _contextMenuEventFired: function(event)
+    _contextMenuFired: function(value, event)
     {
-        function selectNode(nodeId)
-        {
-            if (nodeId)
-                WebInspector.domAgent.inspectElement(nodeId);
-        }
-
-        function revealElement()
-        {
-            this.property.value.pushNodeToFrontend(selectNode);
-        }
-
         var contextMenu = new WebInspector.ContextMenu();
-        contextMenu.appendItem(WebInspector.UIString("Reveal in Elements Panel"), revealElement.bind(this));
+        contextMenu.appendApplicableItems(value);
         contextMenu.show(event);
     },
 
-    _functionContextMenuEventFired: function(event)
-    {
-        function didGetDetails(error, response)
-        {
-            if (error) {
-                console.error(error);
-                return;
-            }
-            WebInspector.panel("scripts").showFunctionDefinition(response.location);
-        }
-
-        function revealFunction()
-        {
-            DebuggerAgent.getFunctionDetails(this.property.value.objectId, didGetDetails.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 (126705 => 126706)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-08-26 13:58:59 UTC (rev 126706)
@@ -389,13 +389,6 @@
         this._showSourceLine(anchor.uiSourceCode, anchor.lineNumber);
     },
 
-    showFunctionDefinition: function(functionLocation)
-    {
-        WebInspector.inspectorView.showPanelForAnchorNavigation(this);
-        var uiLocation = WebInspector.debuggerModel.rawLocationToUILocation(functionLocation);
-        this._showSourceLine(uiLocation.uiSourceCode, uiLocation.lineNumber);
-    },
-
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
      * @param {number} lineNumber
@@ -1086,6 +1079,16 @@
      */
     appendApplicableItems: function(contextMenu, target)
     {
+        this._appendUISourceCodeItems(contextMenu, target);
+        this._appendFunctionItems(contextMenu, target);
+    },
+
+    /** 
+     * @param {WebInspector.ContextMenu} contextMenu
+     * @param {Object} target
+     */
+    _appendUISourceCodeItems: function(contextMenu, target)
+    {
         if (!(target instanceof WebInspector.UISourceCode))
             return;
 
@@ -1095,6 +1098,37 @@
             contextMenu.appendApplicableItems(uiSourceCode.resource().request);
     },
 
+    /** 
+     * @param {WebInspector.ContextMenu} contextMenu
+     * @param {Object} target
+     */
+    _appendFunctionItems: function(contextMenu, target)
+    {
+        if (!(target instanceof WebInspector.RemoteObject))
+            return;
+        var remoteObject = /** @type {WebInspector.RemoteObject} */ target;
+        if (remoteObject.type !== "function")
+            return;
+
+        function didGetDetails(error, response)
+        {
+            if (error) {
+                console.error(error);
+                return;
+            }
+            WebInspector.inspectorView.showPanelForAnchorNavigation(this);
+            var uiLocation = WebInspector.debuggerModel.rawLocationToUILocation(response.location);
+            this._showSourceLine(uiLocation.uiSourceCode, uiLocation.lineNumber);
+        }
+
+        function revealFunction()
+        {
+            DebuggerAgent.getFunctionDetails(remoteObject.objectId, didGetDetails.bind(this));
+        }
+
+        contextMenu.appendItem(WebInspector.UIString("Show function definition"), revealFunction.bind(this));
+    },
+
     showGoToSourceDialog: function()
     {
         WebInspector.OpenResourceDialog.show(this, this._workspace, this.editorView.mainElement);

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanelDescriptor.js (126705 => 126706)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanelDescriptor.js	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanelDescriptor.js	2012-08-26 13:58:59 UTC (rev 126706)
@@ -44,8 +44,14 @@
      */
     appendApplicableItems: function(contextMenu, target)
     {
-        if (!(target instanceof WebInspector.UISourceCode))
-            return;
+        var hasApplicableItems = target instanceof WebInspector.UISourceCode;
+
+        if (!hasApplicableItems && target instanceof WebInspector.RemoteObject) {
+            var remoteObject = /** @type {WebInspector.RemoteObject} */ target;
+            if (remoteObject.type !== "function")
+                return;
+        }
+
         this.panel().appendApplicableItems(contextMenu, target);
     }
 }

Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (126705 => 126706)


--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2012-08-26 13:58:59 UTC (rev 126706)
@@ -57,6 +57,7 @@
     <file>DOMSyntaxHighlighter.js</file>
     <file>Drawer.js</file>
     <file>ElementsPanel.js</file>
+    <file>ElementsPanelDescriptor.js</file>
     <file>ElementsTreeOutline.js</file>
     <file>EmptyView.js</file>
     <file>EventListenersSidebarPane.js</file>

Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (126705 => 126706)


--- trunk/Source/WebCore/inspector/front-end/inspector.html	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html	2012-08-26 13:58:59 UTC (rev 126706)
@@ -162,6 +162,7 @@
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
+    <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
 </head>

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (126705 => 126706)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2012-08-26 13:48:14 UTC (rev 126705)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2012-08-26 13:58:59 UTC (rev 126706)
@@ -37,7 +37,7 @@
         WebInspector.inspectorView.show(parentElement);
         WebInspector.inspectorView.addEventListener(WebInspector.InspectorView.Events.PanelSelected, this._panelSelected, this);
 
-        var elements = new WebInspector.PanelDescriptor("elements", WebInspector.UIString("Elements"), "ElementsPanel", "ElementsPanel.js");
+        var elements = new WebInspector.ElementsPanelDescriptor();
         var resources = new WebInspector.PanelDescriptor("resources", WebInspector.UIString("Resources"), "ResourcesPanel", "ResourcesPanel.js");
         var network = new WebInspector.NetworkPanelDescriptor();
         var scripts = new WebInspector.ScriptsPanelDescriptor();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to