Title: [183324] trunk/Source/WebInspectorUI
Revision
183324
Author
[email protected]
Date
2015-04-25 18:16:50 -0700 (Sat, 25 Apr 2015)

Log Message

Web Inspector: Disable global keyboard shortcuts for background tabs
https://bugs.webkit.org/show_bug.cgi?id=143918

Reviewed by Joseph Pecoraro.

* UserInterface/Views/ContentBrowser.js:
(WebInspector.ContentBrowser):
(WebInspector.ContentBrowser.prototype.shown): Added.
(WebInspector.ContentBrowser.prototype.hidden): Added.
Disable shortcuts on the browser and find banner.

* UserInterface/Views/ContentBrowserTabContentView.js:
(WebInspector.ContentBrowserTabContentView.prototype.shown): Added.
(WebInspector.ContentBrowserTabContentView.prototype.hidden): Added.
Tell the content browser we were shown or hidden.

* UserInterface/Views/FindBanner.js:
(WebInspector.FindBanner):
(WebInspector.FindBanner.prototype.show):
(WebInspector.FindBanner.prototype.enableKeyboardShortcuts): Added.
(WebInspector.FindBanner.prototype.disableKeyboardShortcuts): Added.
Support disabling or enabling the keyboard shortcuts.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (183323 => 183324)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-04-26 01:16:22 UTC (rev 183323)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-04-26 01:16:50 UTC (rev 183324)
@@ -1,3 +1,28 @@
+2015-04-18  Timothy Hatcher  <[email protected]>
+
+        Web Inspector: Disable global keyboard shortcuts for background tabs
+        https://bugs.webkit.org/show_bug.cgi?id=143918
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/ContentBrowser.js:
+        (WebInspector.ContentBrowser):
+        (WebInspector.ContentBrowser.prototype.shown): Added.
+        (WebInspector.ContentBrowser.prototype.hidden): Added.
+        Disable shortcuts on the browser and find banner.
+
+        * UserInterface/Views/ContentBrowserTabContentView.js:
+        (WebInspector.ContentBrowserTabContentView.prototype.shown): Added.
+        (WebInspector.ContentBrowserTabContentView.prototype.hidden): Added.
+        Tell the content browser we were shown or hidden.
+
+        * UserInterface/Views/FindBanner.js:
+        (WebInspector.FindBanner):
+        (WebInspector.FindBanner.prototype.show):
+        (WebInspector.FindBanner.prototype.enableKeyboardShortcuts): Added.
+        (WebInspector.FindBanner.prototype.disableKeyboardShortcuts): Added.
+        Support disabling or enabling the keyboard shortcuts.
+
 2015-04-17  Timothy Hatcher  <[email protected]>
 
         Web Inspector: Add TabBrowser and TabContentView

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js (183323 => 183324)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js	2015-04-26 01:16:22 UTC (rev 183323)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js	2015-04-26 01:16:50 UTC (rev 183324)
@@ -39,17 +39,24 @@
     this._element.appendChild(this._contentViewContainer.element);
 
     this._findBanner = new WebInspector.FindBanner(this);
-    this._findKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "F", this._showFindBanner.bind(this));
     this._findBanner.addEventListener(WebInspector.FindBanner.Event.DidShow, this._findBannerDidShow, this);
     this._findBanner.addEventListener(WebInspector.FindBanner.Event.DidHide, this._findBannerDidHide, this);
 
+    this._findKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "F", this._showFindBanner.bind(this));
     this._saveKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "S", this._save.bind(this));
     this._saveAsKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Shift | WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "S", this._saveAs.bind(this));
 
+    this._findKeyboardShortcut.disabled = true;
+    this._saveKeyboardShortcut.disabled = true;
+    this._saveAsKeyboardShortcut.disabled = true;
+
     if (!disableBackForward) {
         this._backKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Control, WebInspector.KeyboardShortcut.Key.Left, this._backButtonClicked.bind(this));
         this._forwardKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Control, WebInspector.KeyboardShortcut.Key.Right, this._forwardButtonClicked.bind(this));
 
+        this._backKeyboardShortcut.disabled = true;
+        this._forwardKeyboardShortcut.disabled = true;
+
         var forwardArrow, backArrow;
         if (WebInspector.Platform.isLegacyMacOS) {
             forwardArrow = {src: "Images/Legacy/ForwardArrow.svg", width: 9, height: 9};
@@ -271,6 +278,38 @@
         currentContentView.revealNextSearchResult(!findBanner.showing);
     },
 
+    shown: function()
+    {
+        this._contentViewContainer.shown();
+
+        if (this._backKeyboardShortcut)
+            this._backKeyboardShortcut.disabled = false;
+        if (this._forwardKeyboardShortcut)
+            this._forwardKeyboardShortcut.disabled = false;
+
+        this._findKeyboardShortcut.disabled = false;
+        this._saveKeyboardShortcut.disabled = false;
+        this._saveAsKeyboardShortcut.disabled = false;
+
+        this._findBanner.enableKeyboardShortcuts();
+    },
+
+    hidden: function()
+    {
+        this._contentViewContainer.hidden();
+
+        if (this._backKeyboardShortcut)
+            this._backKeyboardShortcut.disabled = false;
+        if (this._forwardKeyboardShortcut)
+            this._forwardKeyboardShortcut.disabled = true;
+
+        this._findKeyboardShortcut.disabled = true;
+        this._saveKeyboardShortcut.disabled = true;
+        this._saveAsKeyboardShortcut.disabled = true;
+
+        this._findBanner.disableKeyboardShortcuts();
+    },
+
     // Private
 
     _backButtonClicked: function(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js (183323 => 183324)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js	2015-04-26 01:16:22 UTC (rev 183323)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js	2015-04-26 01:16:50 UTC (rev 183324)
@@ -91,10 +91,19 @@
     {
         WebInspector.TabContentView.prototype.shown.call(this);
 
+        this._contentBrowser.shown();
+
         if (this.navigationSidebarPanel && !this._contentBrowser.currentContentView)
             this.navigationSidebarPanel.showDefaultContentView();
     },
 
+    hidden: function()
+    {
+        WebInspector.TabContentView.prototype.hidden.call(this);
+
+        this._contentBrowser.hidden();
+    },
+
     closed: function()
     {
         WebInspector.TabContentView.prototype.closed.call(this);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.js (183323 => 183324)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.js	2015-04-26 01:16:22 UTC (rev 183323)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.js	2015-04-26 01:16:50 UTC (rev 183324)
@@ -86,6 +86,8 @@
         this._findNextKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "G", this._nextResultButtonClicked.bind(this));
         this._findPreviousKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Shift | WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "G", this._previousResultButtonClicked.bind(this));
 
+        this.disableKeyboardShortcuts();
+
         this._generateButtonsGlyphsIfNeeded();
     }
 
@@ -205,7 +207,7 @@
         }
 
         // Delay adding the classes in case the target element and/or the find banner were just added to
-        // the document. Adding the class right away will prevent the animation from working the firs time.
+        // the document. Adding the class right away will prevent the animation from working the first time.
         setTimeout(delayedWork.bind(this), 0);
 
         this.dispatchEventToListeners(WebInspector.FindBanner.Event.DidShow);
@@ -225,6 +227,20 @@
         this.dispatchEventToListeners(WebInspector.FindBanner.Event.DidHide);
     }
 
+    enableKeyboardShortcuts()
+    {
+        this._populateFindKeyboardShortcut.disabled = false;
+        this._findNextKeyboardShortcut.disabled = false;
+        this._findPreviousKeyboardShortcut.disabled = false;
+    }
+
+    disableKeyboardShortcuts()
+    {
+        this._populateFindKeyboardShortcut.disabled = true;
+        this._findNextKeyboardShortcut.disabled = true;
+        this._findPreviousKeyboardShortcut.disabled = true;
+    }
+
     // Private
 
     _inputFieldKeyDown(event)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to