Title: [204511] trunk/Source/WebInspectorUI
Revision
204511
Author
[email protected]
Date
2016-08-16 10:05:54 -0700 (Tue, 16 Aug 2016)

Log Message

Web Inspector: add "Copy Selected" context menu item to Console
https://bugs.webkit.org/show_bug.cgi?id=151836

Patch by Devin Rousso <[email protected]> on 2016-08-16
Reviewed by Timothy Hatcher.

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Views/LogContentView.js:
(WebInspector.LogContentView.prototype._previousMessageRepeatCountUpdated):
(WebInspector.LogContentView.prototype._handleContextMenuEvent):
(WebInspector.LogContentView.prototype._mousedown):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (204510 => 204511)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-08-16 16:57:27 UTC (rev 204510)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-08-16 17:05:54 UTC (rev 204511)
@@ -1,5 +1,18 @@
 2016-08-16  Devin Rousso  <[email protected]>
 
+        Web Inspector: add "Copy Selected" context menu item to Console
+        https://bugs.webkit.org/show_bug.cgi?id=151836
+
+        Reviewed by Timothy Hatcher.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        * UserInterface/Views/LogContentView.js:
+        (WebInspector.LogContentView.prototype._previousMessageRepeatCountUpdated):
+        (WebInspector.LogContentView.prototype._handleContextMenuEvent):
+        (WebInspector.LogContentView.prototype._mousedown):
+
+2016-08-16  Devin Rousso  <[email protected]>
+
         Web Inspector: Visual Styles: "Text -> Content" isn't escaped
         https://bugs.webkit.org/show_bug.cgi?id=158271
 

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


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2016-08-16 16:57:27 UTC (rev 204510)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2016-08-16 17:05:54 UTC (rev 204511)
@@ -193,6 +193,7 @@
 localizedStrings["Copy Path to Property"] = "Copy Path to Property";
 localizedStrings["Copy Row"] = "Copy Row";
 localizedStrings["Copy Rule"] = "Copy Rule";
+localizedStrings["Copy Selected"] = "Copy Selected";
 localizedStrings["Copy Table"] = "Copy Table";
 localizedStrings["Copy as HTML"] = "Copy as HTML";
 localizedStrings["Copy as cURL"] = "Copy as cURL";

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js (204510 => 204511)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js	2016-08-16 16:57:27 UTC (rev 204510)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js	2016-08-16 17:05:54 UTC (rev 204511)
@@ -333,7 +333,7 @@
     }
 
     _previousMessageRepeatCountUpdated(event)
-    {        
+    {
         if (this._logViewController.updatePreviousMessageRepeatCount(event.data.count) && this._lastMessageView)
             this._markScopeBarItemUnread(this._lastMessageView.message.level);
     }
@@ -346,11 +346,32 @@
             return;
         }
 
+        // In the case that there are selected messages, only clear that selection if the right-click
+        // is not on the element or descendants of the selected messages.
+        if (this._selectedMessages.length && !this._selectedMessages.some(element => event.target.isSelfOrDescendant(element))) {
+            this._clearMessagesSelection();
+            this._mousedown(event);
+        }
+
+        // If there are no selected messages, right-clicking will not reset the current mouse state
+        // meaning that when the context menu is dismissed, console messages will be selected when
+        // the user moves the mouse even though no buttons are pressed.
+        if (!this._selectedMessages.length)
+            this._mouseup(event);
+
         // We don't want to show the custom menu for links in the console.
         if (event.target.enclosingNodeOrSelfWithNodeName("a"))
             return;
 
         let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
+
+        if (this._selectedMessages.length) {
+            contextMenu.appendItem(WebInspector.UIString("Copy Selected"), () => {
+                InspectorFrontendHost.copyText(this._formatMessagesAsData(true));
+            });
+            contextMenu.appendSeparator();
+        }
+
         contextMenu.appendItem(WebInspector.UIString("Clear Log"), this._clearLog.bind(this));
         contextMenu.appendSeparator();
 
@@ -360,7 +381,7 @@
 
     _mousedown(event)
     {
-        if (event.button !== 0 || event.ctrlKey)
+        if (this._selectedMessages.length && (event.button !== 0 || event.ctrlKey))
             return;
 
         if (event.defaultPrevented) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to