Title: [118520] trunk/Source/WebCore
Revision
118520
Author
[email protected]
Date
2012-05-25 06:10:58 -0700 (Fri, 25 May 2012)

Log Message

Web Inspector: cmd-[ shortcut navigates page and is fr-keyboard incompatible
https://bugs.webkit.org/show_bug.cgi?id=85312

Reviewed by Vsevolod Vlasov.

Suppress the handling of panel history navigation events if the corresponding keyboard activities produce
the "keypress" event (which is the case on French keyboards, where AltGr+[ is translated into Ctrl+Alt+[ on Windows).
The event is also told to preventDefault() to avoid browser history navigation on Mac while traversing the Inspector panel history.

* inspector/front-end/InspectorView.js:
(WebInspector.InspectorView):
(WebInspector.InspectorView.prototype._keyPress):
(WebInspector.InspectorView.prototype._keyDown):
(WebInspector.InspectorView.prototype._keyDownInternal):
* inspector/front-end/UIUtils.js:
(WebInspector.isWin):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (118519 => 118520)


--- trunk/Source/WebCore/ChangeLog	2012-05-25 13:08:24 UTC (rev 118519)
+++ trunk/Source/WebCore/ChangeLog	2012-05-25 13:10:58 UTC (rev 118520)
@@ -1,3 +1,22 @@
+2012-05-25  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: cmd-[ shortcut navigates page and is fr-keyboard incompatible
+        https://bugs.webkit.org/show_bug.cgi?id=85312
+
+        Reviewed by Vsevolod Vlasov.
+
+        Suppress the handling of panel history navigation events if the corresponding keyboard activities produce
+        the "keypress" event (which is the case on French keyboards, where AltGr+[ is translated into Ctrl+Alt+[ on Windows).
+        The event is also told to preventDefault() to avoid browser history navigation on Mac while traversing the Inspector panel history.
+
+        * inspector/front-end/InspectorView.js:
+        (WebInspector.InspectorView):
+        (WebInspector.InspectorView.prototype._keyPress):
+        (WebInspector.InspectorView.prototype._keyDown):
+        (WebInspector.InspectorView.prototype._keyDownInternal):
+        * inspector/front-end/UIUtils.js:
+        (WebInspector.isWin):
+
 2012-05-25  Yury Semikhatsky  <[email protected]>
 
         Unreviewed. Fixed closure compiler warnings.

Modified: trunk/Source/WebCore/inspector/front-end/InspectorView.js (118519 => 118520)


--- trunk/Source/WebCore/inspector/front-end/InspectorView.js	2012-05-25 13:08:24 UTC (rev 118519)
+++ trunk/Source/WebCore/inspector/front-end/InspectorView.js	2012-05-25 13:10:58 UTC (rev 118520)
@@ -41,7 +41,16 @@
     this._history = [];
     this._historyIterator = -1;
     document.addEventListener("keydown", this._keyDown.bind(this), false);
+    document.addEventListener("keypress", this._keyPress.bind(this), false);
     this._panelOrder = [];
+
+    // Windows and Mac have two different definitions of '[', so accept both.
+    this._openBracketIdentifiers = ["U+005B", "U+00DB"].keySet();
+    this._openBracketCharCode = "[".charCodeAt(0);
+
+    // Windows and Mac have two different definitions of ']', so accept both.
+    this._closeBracketIdentifiers = ["U+005D", "U+00DD"].keySet();
+    this._closeBracketCharCode = "]".charCodeAt(0);
 }
 
 WebInspector.InspectorView.Events = {
@@ -85,47 +94,67 @@
         }
     },
 
+    _keyPress: function(event)
+    {
+        if (!this._keyDownTimer)
+            return;
+
+        if (event.charCode === this._openBracketCharCode || event.charCode === this._closeBracketCharCode) {
+            clearTimeout(this._keyDownTimer);
+            delete this._keyDownTimer;
+        }
+    },
+
     _keyDown: function(event)
     {
-        switch (event.keyIdentifier) {
-            // Windows and Mac have two different definitions of [, so accept both.
-            case "U+005B":
-            case "U+00DB": // [ key
-                var isRotateLeft = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !event.shiftKey && !event.altKey;
-                if (isRotateLeft) {
-                    var index = this._panelOrder.indexOf(this.currentPanel());
-                    index = (index === 0) ? this._panelOrder.length - 1 : index - 1;
-                    this._panelOrder[index].toolbarItem.click();
-                    event.consume();
-                    return;
-                }
+        // BUG85312: On French AZERTY keyboards, AltGr-]/[ combinations (synonymous to Ctrl-Alt-]/[ on Windows) are used to enter ]/[,
+        // so for a ]/[-related keydown we delay the panel switch using a timer, to see if there is a keypress event following this one.
+        // If there is, we cancel the timer and do not consider this a panel switch.
+        if (!WebInspector.isWin() || (!this._openBracketIdentifiers.hasOwnProperty(event.keyIdentifier) && !this._closeBracketIdentifiers.hasOwnProperty(event.keyIdentifier))) {
+            this._keyDownInternal(event);
+            return;
+        }
 
-                var isGoBack = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && event.altKey;
-                if (isGoBack && this._canGoBackInHistory()) {
-                    this._goBackInHistory();
-                    event.consume();
-                }
-                break;
+        this._keyDownTimer = setTimeout(this._keyDownInternal.bind(this, event), 0);
+    },
 
-            // Windows and Mac have two different definitions of ], so accept both.
-            case "U+005D":
-            case "U+00DD":  // ] key
-                var isRotateRight = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !event.shiftKey && !event.altKey;
-                if (isRotateRight) {
-                    var index = this._panelOrder.indexOf(this.currentPanel());
-                    index = (index + 1) % this._panelOrder.length;
-                    this._panelOrder[index].toolbarItem.click();
-                    event.consume();
-                    return;
-                }
+    _keyDownInternal: function(event)
+    {
+        if (this._openBracketIdentifiers.hasOwnProperty(event.keyIdentifier)) {
+            var isRotateLeft = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !event.shiftKey && !event.altKey;
+            if (isRotateLeft) {
+                var index = this._panelOrder.indexOf(this.currentPanel());
+                index = (index === 0) ? this._panelOrder.length - 1 : index - 1;
+                this._panelOrder[index].toolbarItem.click();
+                event.consume(true);
+                return;
+            }
 
-                var isGoForward = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && event.altKey;
-                if (isGoForward && this._canGoForwardInHistory()) {
-                    this._goForwardInHistory();
-                    event.consume();
-                }
-                break;
+            var isGoBack = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && event.altKey;
+            if (isGoBack && this._canGoBackInHistory()) {
+                this._goBackInHistory();
+                event.consume(true);
+            }
+            return;
         }
+
+        if (this._closeBracketIdentifiers.hasOwnProperty(event.keyIdentifier)) {
+            var isRotateRight = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && !event.shiftKey && !event.altKey;
+            if (isRotateRight) {
+                var index = this._panelOrder.indexOf(this.currentPanel());
+                index = (index + 1) % this._panelOrder.length;
+                this._panelOrder[index].toolbarItem.click();
+                event.consume(true);
+                return;
+            }
+
+            var isGoForward = WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event) && event.altKey;
+            if (isGoForward && this._canGoForwardInHistory()) {
+                this._goForwardInHistory();
+                event.consume(true);
+            }
+            return;
+        }
     },
 
     _canGoBackInHistory: function()

Modified: trunk/Source/WebCore/inspector/front-end/UIUtils.js (118519 => 118520)


--- trunk/Source/WebCore/inspector/front-end/UIUtils.js	2012-05-25 13:08:24 UTC (rev 118519)
+++ trunk/Source/WebCore/inspector/front-end/UIUtils.js	2012-05-25 13:10:58 UTC (rev 118520)
@@ -512,6 +512,14 @@
     return WebInspector._isMac;
 }
 
+WebInspector.isWin = function()
+{
+    if (typeof WebInspector._isWin === "undefined")
+        WebInspector._isWin = WebInspector.platform() === "windows";
+
+    return WebInspector._isWin;
+}
+
 WebInspector.PlatformFlavor = {
     WindowsVista: "windows-vista",
     MacTiger: "mac-tiger",
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to