mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 09:49:14 +00:00
Bug 429219 Ctrl+1, Ctrl+2, etc, regression (on fr(-FR) keyboard), after bug 359638 r=karl+gavin, sr=roc, a=dsicore
This commit is contained in:
parent
9b6caac281
commit
bccb64fe9e
@ -312,6 +312,23 @@
|
||||
#endif
|
||||
|
||||
<key id="key_undoCloseTab" command="History:UndoCloseTab" key="&tabCmd.commandkey;" modifiers="accel,shift"/>
|
||||
|
||||
#ifdef XP_GNOME
|
||||
#define NUM_SELECT_TAB_MODIFIER alt
|
||||
#else
|
||||
#define NUM_SELECT_TAB_MODIFIER accel
|
||||
#endif
|
||||
|
||||
#expand <key id="key_selectTab1" oncommand="BrowserNumberTabSelection(event, 0);" key="1" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
|
||||
#expand <key id="key_selectTab2" oncommand="BrowserNumberTabSelection(event, 1);" key="2" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
|
||||
#expand <key id="key_selectTab3" oncommand="BrowserNumberTabSelection(event, 2);" key="3" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
|
||||
#expand <key id="key_selectTab4" oncommand="BrowserNumberTabSelection(event, 3);" key="4" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
|
||||
#expand <key id="key_selectTab5" oncommand="BrowserNumberTabSelection(event, 4);" key="5" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
|
||||
#expand <key id="key_selectTab6" oncommand="BrowserNumberTabSelection(event, 5);" key="6" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
|
||||
#expand <key id="key_selectTab7" oncommand="BrowserNumberTabSelection(event, 6);" key="7" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
|
||||
#expand <key id="key_selectTab8" oncommand="BrowserNumberTabSelection(event, 7);" key="8" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
|
||||
#expand <key id="key_selectTab9" oncommand="BrowserNumberTabSelection(event, 8);" key="9" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
|
||||
|
||||
</keyset>
|
||||
|
||||
# Used by baseMenuOverlay
|
||||
|
@ -911,7 +911,7 @@ function delayedStartup()
|
||||
|
||||
gBrowser.addEventListener("pageshow", function(evt) { setTimeout(pageShowEventHandlers, 0, evt); }, true);
|
||||
|
||||
window.addEventListener("keypress", ctrlNumberTabSelection, false);
|
||||
window.addEventListener("keypress", onBrowserKeyPress, false);
|
||||
|
||||
// Ensure login manager is up and running.
|
||||
Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
|
||||
@ -1299,7 +1299,7 @@ SanitizeListener.prototype =
|
||||
}
|
||||
}
|
||||
|
||||
function ctrlNumberTabSelection(event)
|
||||
function onBrowserKeyPress(event)
|
||||
{
|
||||
if (event.altKey && event.keyCode == KeyEvent.DOM_VK_RETURN) {
|
||||
// XXXblake Proper fix is to just check whether focus is in the urlbar. However, focus with the autocomplete widget is all
|
||||
@ -1311,38 +1311,10 @@ function ctrlNumberTabSelection(event)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Mac: Cmd+number
|
||||
if (!event.metaKey || event.ctrlKey || event.altKey || event.shiftKey)
|
||||
#else
|
||||
#ifdef XP_UNIX
|
||||
// Linux: Alt+number
|
||||
if (!event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
||||
#else
|
||||
// Windows: Ctrl+number
|
||||
if (!event.ctrlKey || event.metaKey || event.altKey || event.shiftKey)
|
||||
#endif
|
||||
#endif
|
||||
return;
|
||||
|
||||
// \d in a RegExp will find any Unicode character with the "decimal digit"
|
||||
// property (Nd)
|
||||
var regExp = /\d/;
|
||||
if (!regExp.test(String.fromCharCode(event.charCode)))
|
||||
return;
|
||||
|
||||
// Some Unicode decimal digits are in the range U+xxx0 - U+xxx9 and some are
|
||||
// in the range U+xxx6 - U+xxxF. Find the digit 1 corresponding to our
|
||||
// character.
|
||||
var digit1 = (event.charCode & 0xFFF0) | 1;
|
||||
if (!regExp.test(String.fromCharCode(digit1)))
|
||||
digit1 += 6;
|
||||
|
||||
var index = event.charCode - digit1;
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
function BrowserNumberTabSelection(event, index)
|
||||
{
|
||||
// [Ctrl]+[9] always selects the last tab
|
||||
if (index == 8)
|
||||
index = gBrowser.tabContainer.childNodes.length - 1;
|
||||
|
@ -4022,6 +4022,17 @@ nsContentUtils::DOMEventToNativeKeyEvent(nsIDOMEvent* aDOMEvent,
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
HasASCIIDigit(const nsTArray<nsShortcutCandidate>& aCandidates)
|
||||
{
|
||||
for (PRUint32 i = 0; i < aCandidates.Length(); ++i) {
|
||||
PRUint32 ch = aCandidates[i].mCharCode;
|
||||
if (ch >= '0' && ch <= '9')
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
nsContentUtils::GetAccelKeyCandidates(nsIDOMEvent* aDOMEvent,
|
||||
@ -4054,9 +4065,9 @@ nsContentUtils::GetAccelKeyCandidates(nsIDOMEvent* aDOMEvent,
|
||||
aCandidates.AppendElement(key);
|
||||
}
|
||||
|
||||
PRUint32 len = nativeKeyEvent->alternativeCharCodes.Length();
|
||||
if (!nativeKeyEvent->isShift) {
|
||||
for (PRUint32 i = 0;
|
||||
i < nativeKeyEvent->alternativeCharCodes.Length(); ++i) {
|
||||
for (PRUint32 i = 0; i < len; ++i) {
|
||||
PRUint32 ch =
|
||||
nativeKeyEvent->alternativeCharCodes[i].mUnshiftedCharCode;
|
||||
if (!ch || ch == nativeKeyEvent->charCode)
|
||||
@ -4065,9 +4076,23 @@ nsContentUtils::GetAccelKeyCandidates(nsIDOMEvent* aDOMEvent,
|
||||
nsShortcutCandidate key(ch, PR_FALSE);
|
||||
aCandidates.AppendElement(key);
|
||||
}
|
||||
// If unshiftedCharCodes doesn't have numeric but shiftedCharCode has it,
|
||||
// this keyboard layout is AZERTY or similar layout, probably.
|
||||
// In this case, Accel+[0-9] should be accessible without shift key.
|
||||
// However, the priority should be lowest.
|
||||
if (!HasASCIIDigit(aCandidates)) {
|
||||
for (PRUint32 i = 0; i < len; ++i) {
|
||||
PRUint32 ch =
|
||||
nativeKeyEvent->alternativeCharCodes[i].mShiftedCharCode;
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
nsShortcutCandidate key(ch, PR_FALSE);
|
||||
aCandidates.AppendElement(key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (PRUint32 i = 0;
|
||||
i < nativeKeyEvent->alternativeCharCodes.Length(); ++i) {
|
||||
for (PRUint32 i = 0; i < len; ++i) {
|
||||
PRUint32 ch = nativeKeyEvent->alternativeCharCodes[i].mShiftedCharCode;
|
||||
if (!ch)
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user