Web Inspector: Network Tab's "Clear Network Items" button should have keyboard shortcuts
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2017 18:31:08 +0000 (18:31 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2017 18:31:08 +0000 (18:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166943

Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2017-01-19
Reviewed by Timothy Hatcher.

* Localizations/en.lproj/localizedStrings.js:

* UserInterface/Base/Main.js:
(WebInspector.contentLoaded):
(WebInspector._clear):
Move clear keyboard shortcut to main object and call _handleClearShortcut on the visible
content view if able.

* UserInterface/Controllers/JavaScriptLogViewController.js:
(WebInspector.JavaScriptLogViewController):
(WebInspector.JavaScriptLogViewController.prototype.requestClearMessages):
(WebInspector.JavaScriptLogViewController.prototype._handleClearShortcut): Deleted.
* UserInterface/Views/LogContentView.js:
(WebInspector.LogContentView):
(WebInspector.LogContentView.prototype.handleClearShortcut):
Move logic for requesting to clear messages from the LogManager to a better named function.

* UserInterface/Views/NetworkGridContentView.js:
(WebInspector.NetworkGridContentView):
(WebInspector.NetworkGridContentView.prototype.handleClearShortcut):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210930 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js
Source/WebInspectorUI/UserInterface/Views/LogContentView.js
Source/WebInspectorUI/UserInterface/Views/NetworkGridContentView.js

index 636000b..681084c 100644 (file)
@@ -1,5 +1,33 @@
 2017-01-19  Devin Rousso  <dcrousso+webkit@gmail.com>
 
+        Web Inspector: Network Tab's "Clear Network Items" button should have keyboard shortcuts
+        https://bugs.webkit.org/show_bug.cgi?id=166943
+
+        Reviewed by Timothy Hatcher.
+
+        * Localizations/en.lproj/localizedStrings.js:
+
+        * UserInterface/Base/Main.js:
+        (WebInspector.contentLoaded):
+        (WebInspector._clear):
+        Move clear keyboard shortcut to main object and call _handleClearShortcut on the visible
+        content view if able.
+
+        * UserInterface/Controllers/JavaScriptLogViewController.js:
+        (WebInspector.JavaScriptLogViewController):
+        (WebInspector.JavaScriptLogViewController.prototype.requestClearMessages):
+        (WebInspector.JavaScriptLogViewController.prototype._handleClearShortcut): Deleted.
+        * UserInterface/Views/LogContentView.js:
+        (WebInspector.LogContentView):
+        (WebInspector.LogContentView.prototype.handleClearShortcut):
+        Move logic for requesting to clear messages from the LogManager to a better named function.
+
+        * UserInterface/Views/NetworkGridContentView.js:
+        (WebInspector.NetworkGridContentView):
+        (WebInspector.NetworkGridContentView.prototype.handleClearShortcut):
+
+2017-01-19  Devin Rousso  <dcrousso+webkit@gmail.com>
+
         Web Inspector: Dashboard's log/error/warning help tag says "click to show the Console" even when clicking does nothing
         https://bugs.webkit.org/show_bug.cgi?id=167102
 
index 18abb5c..1855436 100644 (file)
@@ -145,7 +145,7 @@ localizedStrings["Children"] = "Children";
 localizedStrings["Classes"] = "Classes";
 localizedStrings["Clear"] = "Clear";
 localizedStrings["Clear Log"] = "Clear Log";
-localizedStrings["Clear Network Items"] = "Clear Network Items";
+localizedStrings["Clear Network Items (%s)"] = "Clear Network Items (%s)";
 localizedStrings["Clear Timeline"] = "Clear Timeline";
 localizedStrings["Clear focus"] = "Clear focus";
 localizedStrings["Clear log (%s or %s)"] = "Clear log (%s or %s)";
index 6827d06..540082f 100644 (file)
@@ -276,6 +276,8 @@ WebInspector.contentLoaded = function()
     this.splitContentBrowser = new WebInspector.ContentBrowser(document.getElementById("split-content-browser"), this, disableBackForward, disableFindBanner);
     this.splitContentBrowser.navigationBar.element.addEventListener("mousedown", this._consoleResizerMouseDown.bind(this));
 
+    this.clearKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "K", this._clear.bind(this));
+
     this.quickConsole = new WebInspector.QuickConsole(document.getElementById("quick-console"));
     this.quickConsole.addEventListener(WebInspector.QuickConsole.Event.DidResize, this._quickConsoleDidResize, this);
 
@@ -2018,6 +2020,19 @@ WebInspector._saveAs = function(event)
     WebInspector.saveDataToFile(contentView.saveData, true);
 };
 
+WebInspector._clear = function(event)
+{
+    let contentView = this.focusedOrVisibleContentView();
+    if (!contentView || typeof contentView.handleClearShortcut !== "function") {
+        // If the current content view is unable to handle this event, clear the console to reset
+        // the dashboard counters.
+        this.logManager.requestClearMessages();
+        return;
+    }
+
+    contentView.handleClearShortcut(event);
+};
+
 WebInspector._copy = function(event)
 {
     var selection = window.getSelection();
index c6e7c2d..7262132 100644 (file)
@@ -50,13 +50,12 @@ WebInspector.JavaScriptLogViewController = class JavaScriptLogViewController ext
 
         this._sessions = [];
 
-        this.messagesClearKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "K", this._handleClearShortcut.bind(this));
-        this.messagesAlternateClearKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Control, "L", this._handleClearShortcut.bind(this), this._element);
+        this.messagesAlternateClearKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Control, "L", this.requestClearMessages.bind(this), this._element);
 
         this._messagesFindNextKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "G", this._handleFindNextShortcut.bind(this), this._element);
         this._messagesFindPreviousKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Shift, "G", this._handleFindPreviousShortcut.bind(this), this._element);
 
-        this._promptAlternateClearKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Control, "L", this._handleClearShortcut.bind(this), this._prompt.element);
+        this._promptAlternateClearKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Control, "L", this.requestClearMessages.bind(this), this._prompt.element);
         this._promptFindNextKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "G", this._handleFindNextShortcut.bind(this), this._prompt.element);
         this._promptFindPreviousKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Shift, "G", this._handleFindPreviousShortcut.bind(this), this._prompt.element);
 
@@ -192,6 +191,11 @@ WebInspector.JavaScriptLogViewController = class JavaScriptLogViewController ext
         this._scrollToBottomTimeout = setTimeout(delayedWork.bind(this), 0);
     }
 
+    requestClearMessages()
+    {
+        WebInspector.logManager.requestClearMessages();
+    }
+
     // Protected
 
     consolePromptHistoryDidChange(prompt)
@@ -251,11 +255,6 @@ WebInspector.JavaScriptLogViewController = class JavaScriptLogViewController ext
 
     // Private
 
-    _handleClearShortcut()
-    {
-        WebInspector.logManager.requestClearMessages();
-    }
-
     _handleFindNextShortcut()
     {
         this.delegate.highlightNextSearchMatch();
index 42d2156..49b662b 100644 (file)
@@ -77,7 +77,7 @@ WebInspector.LogContentView = class LogContentView extends WebInspector.ContentV
         this._scopeBar = new WebInspector.ScopeBar("log-scope-bar", scopeBarItems, scopeBarItems[0]);
         this._scopeBar.addEventListener(WebInspector.ScopeBar.Event.SelectionChanged, this._scopeBarSelectionDidChange, this);
 
-        this._clearLogNavigationItem = new WebInspector.ButtonNavigationItem("clear-log", WebInspector.UIString("Clear log (%s or %s)").format(this._logViewController.messagesClearKeyboardShortcut.displayName, this._logViewController.messagesAlternateClearKeyboardShortcut.displayName), "Images/NavigationItemTrash.svg", 15, 15);
+        this._clearLogNavigationItem = new WebInspector.ButtonNavigationItem("clear-log", WebInspector.UIString("Clear log (%s or %s)").format(WebInspector.clearKeyboardShortcut.displayName, this._logViewController.messagesAlternateClearKeyboardShortcut.displayName), "Images/NavigationItemTrash.svg", 15, 15);
         this._clearLogNavigationItem.addEventListener(WebInspector.ButtonNavigationItem.Event.Clicked, this._clearLog, this);
 
         var toolTip = WebInspector.UIString("Show console tab");
@@ -216,6 +216,11 @@ WebInspector.LogContentView = class LogContentView extends WebInspector.ContentV
         event.preventDefault();
     }
 
+    handleClearShortcut(event)
+    {
+        this._logViewController.requestClearMessages();
+    }
+
     findBannerRevealPreviousResult()
     {
         if (!this.hasPerformedSearch || isEmptyObject(this._searchMatches))
index a32b208..838aa79 100644 (file)
@@ -101,7 +101,7 @@ WebInspector.NetworkGridContentView = class NetworkGridContentView extends WebIn
         networkTimeline.addEventListener(WebInspector.Timeline.Event.RecordAdded, this._networkTimelineRecordAdded, this);
         networkTimeline.addEventListener(WebInspector.Timeline.Event.Reset, this._networkTimelineReset, this);
 
-        this._clearNetworkItemsNavigationItem = new WebInspector.ButtonNavigationItem("clear-network-items", WebInspector.UIString("Clear Network Items"), "Images/NavigationItemTrash.svg", 15, 15);
+        this._clearNetworkItemsNavigationItem = new WebInspector.ButtonNavigationItem("clear-network-items", WebInspector.UIString("Clear Network Items (%s)").format(WebInspector.clearKeyboardShortcut.displayName), "Images/NavigationItemTrash.svg", 15, 15);
         this._clearNetworkItemsNavigationItem.addEventListener(WebInspector.ButtonNavigationItem.Event.Clicked, () => this.reset());
 
         this._pendingRecords = [];
@@ -217,6 +217,11 @@ WebInspector.NetworkGridContentView = class NetworkGridContentView extends WebIn
         this._processPendingRecords();
     }
 
+    handleClearShortcut(event)
+    {
+        this.reset();
+    }
+
     // Private
 
     _processPendingRecords()