Title: [182902] trunk/Source/WebInspectorUI
Revision
182902
Author
joep...@webkit.org
Date
2015-04-16 12:47:41 -0700 (Thu, 16 Apr 2015)

Log Message

Web Inspector: Give DOM Nodes a Context Menu to Log Element to the console
https://bugs.webkit.org/show_bug.cgi?id=143813

Reviewed by Brian Burg.

Always give DOM Nodes a "Log Element" context menu to log it to the console.
This will give a $n reference, and is a convenient alternative to $0 or
the now removed $1-$9.

* Localizations/en.lproj/localizedStrings.js:
New "Log Element" and "Selected Element" strings.

* UserInterface/Views/DOMTreeOutline.js:
(WebInspector.DOMTreeOutline):
(WebInspector.DOMTreeOutline.prototype._contextMenuEventFired):
(WebInspector.DOMTreeOutline.prototype._updateModifiedNodes):
(WebInspector.DOMTreeOutline.prototype._populateContextMenu.revealElement):
(WebInspector.DOMTreeOutline.prototype._populateContextMenu.logElement):
(WebInspector.DOMTreeOutline.prototype._populateContextMenu):
Always include the "Log Element" context menu/

* UserInterface/Views/FormattedValue.js:
(WebInspector.FormattedValue.createElementForNode):
This uses all the defaults.

* UserInterface/Views/DOMTreeContentView.js:
(WebInspector.DOMTreeContentView):
This enables all the extra behavior.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (182901 => 182902)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-04-16 19:39:50 UTC (rev 182901)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-04-16 19:47:41 UTC (rev 182902)
@@ -1,5 +1,36 @@
 2015-04-16  Joseph Pecoraro  <pecor...@apple.com>
 
+        Web Inspector: Give DOM Nodes a Context Menu to Log Element to the console
+        https://bugs.webkit.org/show_bug.cgi?id=143813
+
+        Reviewed by Brian Burg.
+
+        Always give DOM Nodes a "Log Element" context menu to log it to the console.
+        This will give a $n reference, and is a convenient alternative to $0 or
+        the now removed $1-$9.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        New "Log Element" and "Selected Element" strings.
+
+        * UserInterface/Views/DOMTreeOutline.js:
+        (WebInspector.DOMTreeOutline):
+        (WebInspector.DOMTreeOutline.prototype._contextMenuEventFired):
+        (WebInspector.DOMTreeOutline.prototype._updateModifiedNodes):
+        (WebInspector.DOMTreeOutline.prototype._populateContextMenu.revealElement):
+        (WebInspector.DOMTreeOutline.prototype._populateContextMenu.logElement):
+        (WebInspector.DOMTreeOutline.prototype._populateContextMenu):
+        Always include the "Log Element" context menu/
+
+        * UserInterface/Views/FormattedValue.js:
+        (WebInspector.FormattedValue.createElementForNode):
+        This uses all the defaults.
+
+        * UserInterface/Views/DOMTreeContentView.js:
+        (WebInspector.DOMTreeContentView):
+        This enables all the extra behavior.
+
+2015-04-16  Joseph Pecoraro  <pecor...@apple.com>
+
         Web Inspector: Remove unnecessary intermediate object from DOMTreeOutline
         https://bugs.webkit.org/show_bug.cgi?id=143811
 

Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (182901 => 182902)


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2015-04-16 19:39:50 UTC (rev 182901)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2015-04-16 19:47:41 UTC (rev 182902)
@@ -295,6 +295,7 @@
 localizedStrings["Local Variables"] = "Local Variables";
 localizedStrings["Located at %s"] = "Located at %s";
 localizedStrings["Location"] = "Location";
+localizedStrings["Log Element"] = "Log Element";
 localizedStrings["Log Message"] = "Log Message";
 localizedStrings["Log Symbol"] = "Log Symbol";
 localizedStrings["Log Value"] = "Log Value";
@@ -414,6 +415,7 @@
 localizedStrings["Secure"] = "Secure";
 localizedStrings["Security Issue"] = "Security Issue";
 localizedStrings["Selected"] = "Selected";
+localizedStrings["Selected Element"] = "Selected Element";
 localizedStrings["Selected Item"] = "Selected Item";
 localizedStrings["Selected Items"] = "Selected Items";
 localizedStrings["Selected Range"] = "Selected Range";

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js (182901 => 182902)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js	2015-04-16 19:39:50 UTC (rev 182901)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js	2015-04-16 19:47:41 UTC (rev 182902)
@@ -56,7 +56,7 @@
     this.element.classList.add(WebInspector.DOMTreeContentView.StyleClassName);
     this.element.addEventListener("click", this._mouseWasClicked.bind(this), false);
 
-    this._domTreeOutline = new WebInspector.DOMTreeOutline(true, true, false);
+    this._domTreeOutline = new WebInspector.DOMTreeOutline(true, true, true);
     this._domTreeOutline.addEventListener(WebInspector.DOMTreeOutline.Event.SelectedNodeChanged, this._selectedNodeDidChange, this);
     this._domTreeOutline.wireToDomAgent();
     this.element.appendChild(this._domTreeOutline.element);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js (182901 => 182902)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js	2015-04-16 19:39:50 UTC (rev 182901)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js	2015-04-16 19:47:41 UTC (rev 182902)
@@ -30,7 +30,7 @@
 
 WebInspector.DOMTreeOutline = class DOMTreeOutline extends WebInspector.TreeOutline
 {
-    constructor(omitRootDOMNode, selectEnabled, showInElementsPanelEnabled)
+    constructor(omitRootDOMNode, selectEnabled, excludeRevealElementContextMenu)
     {
         var element = document.createElement("ol");
 
@@ -50,7 +50,7 @@
 
         this._includeRootDOMNode = !omitRootDOMNode;
         this._selectEnabled = selectEnabled;
-        this._showInElementsPanelEnabled = showInElementsPanelEnabled;
+        this._excludeRevealElementContextMenu = excludeRevealElementContextMenu;
         this._rootDOMNode = null;
         this._selectedDOMNode = null;
 
@@ -483,16 +483,27 @@
 
     _populateContextMenu(contextMenu, domNode)
     {
-        if (!this._showInElementsPanelEnabled)
-            return;
-
         function revealElement()
         {
             WebInspector.domTreeManager.inspectElement(domNode.id);
         }
 
+        function logElement()
+        {
+            WebInspector.RemoteObject.resolveNode(domNode, "console", function(remoteObject) {
+                if (!remoteObject)
+                    return;
+                var text = WebInspector.UIString("Selected Element");
+                WebInspector.consoleLogViewController.appendImmediateExecutionWithResult(text, remoteObject);
+            });
+        }
+
         contextMenu.appendSeparator();
-        contextMenu.appendItem(WebInspector.UIString("Reveal in DOM Tree"), revealElement);
+
+        if (!this._excludeRevealElementContextMenu)
+            contextMenu.appendItem(WebInspector.UIString("Reveal in DOM Tree"), revealElement);
+
+        contextMenu.appendItem(WebInspector.UIString("Log Element"), logElement);
     }
 
     _showShadowDOMSettingChanged(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js (182901 => 182902)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js	2015-04-16 19:39:50 UTC (rev 182901)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FormattedValue.js	2015-04-16 19:47:41 UTC (rev 182902)
@@ -56,7 +56,7 @@
             return;
         }
 
-        var treeOutline = new WebInspector.DOMTreeOutline(false, false, true);
+        var treeOutline = new WebInspector.DOMTreeOutline;
         treeOutline.setVisible(true);
         treeOutline.rootDOMNode = WebInspector.domTreeManager.nodeForId(nodeId);
         if (!treeOutline.children[0].hasChildren)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to