Title: [184974] trunk/Source/WebInspectorUI
Revision
184974
Author
[email protected]
Date
2015-05-28 19:06:10 -0700 (Thu, 28 May 2015)

Log Message

Web Inspector: Should have a keyboard shortcut to switch between inspector tabs
https://bugs.webkit.org/show_bug.cgi?id=144207

Patch by Joseph Pecoraro <[email protected]> on 2015-05-28
Reviewed by Timothy Hatcher.

These keyboard shortcuts work well in an undocked inspector window.
Be careful that some keyboard shortcuts, when used inside a text
editor / text field are just text actions. However, some keyboard
shortcuts will work no matter where you trigger them.

* UserInterface/Models/KeyboardShortcut.js:
* UserInterface/Views/TabBar.js:
(WebInspector.TabBar.prototype.selectPreviousTab):
(WebInspector.TabBar.prototype.selectNextTab):
* UserInterface/Views/TabBrowser.js:
(WebInspector.TabBrowser):
(WebInspector.TabBrowser.prototype._showPreviousTab):
(WebInspector.TabBrowser.prototype._showNextTab):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (184973 => 184974)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-05-29 01:56:28 UTC (rev 184973)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-05-29 02:06:10 UTC (rev 184974)
@@ -1,5 +1,26 @@
 2015-05-28  Joseph Pecoraro  <[email protected]>
 
+        Web Inspector: Should have a keyboard shortcut to switch between inspector tabs
+        https://bugs.webkit.org/show_bug.cgi?id=144207
+
+        Reviewed by Timothy Hatcher.
+
+        These keyboard shortcuts work well in an undocked inspector window.
+        Be careful that some keyboard shortcuts, when used inside a text
+        editor / text field are just text actions. However, some keyboard
+        shortcuts will work no matter where you trigger them.
+
+        * UserInterface/Models/KeyboardShortcut.js:
+        * UserInterface/Views/TabBar.js:
+        (WebInspector.TabBar.prototype.selectPreviousTab):
+        (WebInspector.TabBar.prototype.selectNextTab):
+        * UserInterface/Views/TabBrowser.js:
+        (WebInspector.TabBrowser):
+        (WebInspector.TabBrowser.prototype._showPreviousTab):
+        (WebInspector.TabBrowser.prototype._showNextTab):
+
+2015-05-28  Joseph Pecoraro  <[email protected]>
+
         Web Inspector: NewTabContentView should update button disabled state as other tabs are added/removed
         https://bugs.webkit.org/show_bug.cgi?id=145448
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/KeyboardShortcut.js (184973 => 184974)


--- trunk/Source/WebInspectorUI/UserInterface/Models/KeyboardShortcut.js	2015-05-29 01:56:28 UTC (rev 184973)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/KeyboardShortcut.js	2015-05-29 02:06:10 UTC (rev 184974)
@@ -261,7 +261,9 @@
     Minus: new WebInspector.Key(189, "-"),
     Period: new WebInspector.Key(190, "."),
     Slash: new WebInspector.Key(191, "/"),
+    Apostrophe: new WebInspector.Key(192, "`"),
+    LeftCurlyBrace: new WebInspector.Key(219, "{"),
     Backslash: new WebInspector.Key(220, "\\"),
-    Apostrophe: new WebInspector.Key(192, "`"),
+    RightCurlyBrace: new WebInspector.Key(221, "}"),
     SingleQuote: new WebInspector.Key(222, "\'")
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js (184973 => 184974)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js	2015-05-29 01:56:28 UTC (rev 184973)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js	2015-05-29 02:06:10 UTC (rev 184974)
@@ -288,6 +288,52 @@
         return tabBarItem;
     }
 
+    selectPreviousTab()
+    {
+        if (this._tabBarItems.length <= 1)
+            return;
+
+        var startIndex = this._tabBarItems.indexOf(this._selectedTabBarItem);
+        var newIndex = startIndex;
+        do {
+            if (newIndex === 0)
+                newIndex = this._tabBarItems.length - 1;
+            else
+                newIndex--;
+
+            if (!this._tabBarItems[newIndex].pinned)
+                break;
+        } while (newIndex !== startIndex);
+
+        if (newIndex === startIndex)
+            return;
+
+        this.selectedTabBarItem = this._tabBarItems[newIndex];
+    }
+
+    selectNextTab()
+    {
+        if (this._tabBarItems.length <= 1)
+            return;
+
+        var startIndex = this._tabBarItems.indexOf(this._selectedTabBarItem);
+        var newIndex = startIndex;
+        do {
+            if (newIndex === this._tabBarItems.length - 1)
+                newIndex = 0;
+            else
+                newIndex++;
+
+            if (!this._tabBarItems[newIndex].pinned)
+                break;
+        } while (newIndex !== startIndex);
+
+        if (newIndex === startIndex)
+            return;
+
+        this.selectedTabBarItem = this._tabBarItems[newIndex];
+    }
+
     updateLayoutSoon()
     {
         if (this._updateLayoutIdentifier)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TabBrowser.js (184973 => 184974)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TabBrowser.js	2015-05-29 01:56:28 UTC (rev 184973)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TabBrowser.js	2015-05-29 02:06:10 UTC (rev 184974)
@@ -50,6 +50,16 @@
         this._contentViewContainer = new WebInspector.ContentViewContainer;
         this._element.appendChild(this._contentViewContainer.element);
 
+        var showNextTab = this._showNextTab.bind(this);
+        var showPreviousTab = this._showPreviousTab.bind(this);
+
+        this._showNextTabKeyboardShortcut1 = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Shift, WebInspector.KeyboardShortcut.Key.RightCurlyBrace, showNextTab);
+        this._showPreviousTabKeyboardShortcut1 = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Shift, WebInspector.KeyboardShortcut.Key.LeftCurlyBrace, showPreviousTab);
+        this._showNextTabKeyboardShortcut2 = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Control, WebInspector.KeyboardShortcut.Key.Tab, showNextTab);
+        this._showPreviousTabKeyboardShortcut2 = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Control | WebInspector.KeyboardShortcut.Modifier.Shift, WebInspector.KeyboardShortcut.Key.Tab, showPreviousTab);
+        this._showNextTabKeyboardShortcut3 = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Shift, WebInspector.KeyboardShortcut.Key.Right, showNextTab);
+        this._showPreviousTabKeyboardShortcut3 = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Shift, WebInspector.KeyboardShortcut.Key.Left, showPreviousTab);
+
         this._tabBar.newTabItem = new WebInspector.TabBarItem("Images/NewTabPlus.svg", WebInspector.UIString("Create a new tab"), true);
 
         this._tabBar.addEventListener(WebInspector.TabBar.Event.TabBarItemSelected, this._tabBarItemSelected, this);
@@ -331,6 +341,16 @@
 
         this._ignoreSidebarEvents = false;
     }
+
+    _showPreviousTab(event)
+    {
+        this._tabBar.selectPreviousTab();
+    }
+
+    _showNextTab(event)
+    {
+        this._tabBar.selectNextTab();
+    }
 };
 
 WebInspector.TabBrowser.Event = {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to