mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 892539 modifier flag database should be reset if we detect mismatch between the stored data and the latest information via key event r=smichaud
This commit is contained in:
parent
dc4eed8ded
commit
e79ad519c7
@ -1211,14 +1211,14 @@ protected:
|
|||||||
* GetModifierKeyForNativeKeyCode() returns the stored ModifierKey for
|
* GetModifierKeyForNativeKeyCode() returns the stored ModifierKey for
|
||||||
* the key.
|
* the key.
|
||||||
*/
|
*/
|
||||||
ModifierKey*
|
const ModifierKey*
|
||||||
GetModifierKeyForNativeKeyCode(unsigned short aKeyCode) const;
|
GetModifierKeyForNativeKeyCode(unsigned short aKeyCode) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetModifierKeyForDeviceDependentFlags() returns the stored ModifierKey for
|
* GetModifierKeyForDeviceDependentFlags() returns the stored ModifierKey for
|
||||||
* the device dependent flags.
|
* the device dependent flags.
|
||||||
*/
|
*/
|
||||||
ModifierKey*
|
const ModifierKey*
|
||||||
GetModifierKeyForDeviceDependentFlags(NSUInteger aFlags) const;
|
GetModifierKeyForDeviceDependentFlags(NSUInteger aFlags) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1665,10 +1665,20 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
// dependent flags.
|
// dependent flags.
|
||||||
if (isKeyDown && ((diff & ~NSDeviceIndependentModifierFlagsMask) != 0)) {
|
if (isKeyDown && ((diff & ~NSDeviceIndependentModifierFlagsMask) != 0)) {
|
||||||
unsigned short keyCode = [aNativeEvent keyCode];
|
unsigned short keyCode = [aNativeEvent keyCode];
|
||||||
ModifierKey* modifierKey = GetModifierKeyForDeviceDependentFlags(diff);
|
const ModifierKey* modifierKey =
|
||||||
if (modifierKey) {
|
GetModifierKeyForDeviceDependentFlags(diff);
|
||||||
MOZ_ASSERT(modifierKey->keyCode == keyCode);
|
if (modifierKey && modifierKey->keyCode != keyCode) {
|
||||||
} else {
|
// Although, we're not sure the actual cause of this case, the stored
|
||||||
|
// modifier information and the latest key event information may be
|
||||||
|
// mismatched. Then, let's reset the stored information.
|
||||||
|
// NOTE: If this happens, it may fail to handle NSFlagsChanged event
|
||||||
|
// in the default case (below). However, it's the rare case handler
|
||||||
|
// and this case occurs rarely. So, we can ignore the edge case bug.
|
||||||
|
NS_WARNING("Resetting stored modifier key information");
|
||||||
|
mModifierKeys.Clear();
|
||||||
|
modifierKey = nullptr;
|
||||||
|
}
|
||||||
|
if (!modifierKey) {
|
||||||
mModifierKeys.AppendElement(ModifierKey(diff, keyCode));
|
mModifierKeys.AppendElement(ModifierKey(diff, keyCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1749,7 +1759,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ModifierKey* modifierKey =
|
const ModifierKey* modifierKey =
|
||||||
GetModifierKeyForDeviceDependentFlags(flag);
|
GetModifierKeyForDeviceDependentFlags(flag);
|
||||||
if (!modifierKey) {
|
if (!modifierKey) {
|
||||||
// See the note above (in the other branch of the if statement)
|
// See the note above (in the other branch of the if statement)
|
||||||
@ -1764,7 +1774,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
modifiers &= ~flag;
|
modifiers &= ~flag;
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case kVK_Shift: {
|
case kVK_Shift: {
|
||||||
ModifierKey* modifierKey =
|
const ModifierKey* modifierKey =
|
||||||
GetModifierKeyForNativeKeyCode(kVK_RightShift);
|
GetModifierKeyForNativeKeyCode(kVK_RightShift);
|
||||||
if (!modifierKey ||
|
if (!modifierKey ||
|
||||||
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
||||||
@ -1773,7 +1783,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kVK_RightShift: {
|
case kVK_RightShift: {
|
||||||
ModifierKey* modifierKey =
|
const ModifierKey* modifierKey =
|
||||||
GetModifierKeyForNativeKeyCode(kVK_Shift);
|
GetModifierKeyForNativeKeyCode(kVK_Shift);
|
||||||
if (!modifierKey ||
|
if (!modifierKey ||
|
||||||
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
||||||
@ -1782,7 +1792,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kVK_Command: {
|
case kVK_Command: {
|
||||||
ModifierKey* modifierKey =
|
const ModifierKey* modifierKey =
|
||||||
GetModifierKeyForNativeKeyCode(kVK_RightCommand);
|
GetModifierKeyForNativeKeyCode(kVK_RightCommand);
|
||||||
if (!modifierKey ||
|
if (!modifierKey ||
|
||||||
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
||||||
@ -1791,7 +1801,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kVK_RightCommand: {
|
case kVK_RightCommand: {
|
||||||
ModifierKey* modifierKey =
|
const ModifierKey* modifierKey =
|
||||||
GetModifierKeyForNativeKeyCode(kVK_Command);
|
GetModifierKeyForNativeKeyCode(kVK_Command);
|
||||||
if (!modifierKey ||
|
if (!modifierKey ||
|
||||||
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
||||||
@ -1800,7 +1810,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kVK_Control: {
|
case kVK_Control: {
|
||||||
ModifierKey* modifierKey =
|
const ModifierKey* modifierKey =
|
||||||
GetModifierKeyForNativeKeyCode(kVK_RightControl);
|
GetModifierKeyForNativeKeyCode(kVK_RightControl);
|
||||||
if (!modifierKey ||
|
if (!modifierKey ||
|
||||||
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
||||||
@ -1809,7 +1819,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kVK_RightControl: {
|
case kVK_RightControl: {
|
||||||
ModifierKey* modifierKey =
|
const ModifierKey* modifierKey =
|
||||||
GetModifierKeyForNativeKeyCode(kVK_Control);
|
GetModifierKeyForNativeKeyCode(kVK_Control);
|
||||||
if (!modifierKey ||
|
if (!modifierKey ||
|
||||||
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
||||||
@ -1818,7 +1828,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kVK_Option: {
|
case kVK_Option: {
|
||||||
ModifierKey* modifierKey =
|
const ModifierKey* modifierKey =
|
||||||
GetModifierKeyForNativeKeyCode(kVK_RightOption);
|
GetModifierKeyForNativeKeyCode(kVK_RightOption);
|
||||||
if (!modifierKey ||
|
if (!modifierKey ||
|
||||||
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
||||||
@ -1827,7 +1837,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kVK_RightOption: {
|
case kVK_RightOption: {
|
||||||
ModifierKey* modifierKey =
|
const ModifierKey* modifierKey =
|
||||||
GetModifierKeyForNativeKeyCode(kVK_Option);
|
GetModifierKeyForNativeKeyCode(kVK_Option);
|
||||||
if (!modifierKey ||
|
if (!modifierKey ||
|
||||||
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
!(modifiers & modifierKey->GetDeviceDependentFlags())) {
|
||||||
@ -1875,7 +1885,7 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
|
|||||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextInputHandler::ModifierKey*
|
const TextInputHandler::ModifierKey*
|
||||||
TextInputHandler::GetModifierKeyForNativeKeyCode(unsigned short aKeyCode) const
|
TextInputHandler::GetModifierKeyForNativeKeyCode(unsigned short aKeyCode) const
|
||||||
{
|
{
|
||||||
for (ModifierKeyArray::index_type i = 0; i < mModifierKeys.Length(); ++i) {
|
for (ModifierKeyArray::index_type i = 0; i < mModifierKeys.Length(); ++i) {
|
||||||
@ -1886,7 +1896,7 @@ TextInputHandler::GetModifierKeyForNativeKeyCode(unsigned short aKeyCode) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextInputHandler::ModifierKey*
|
const TextInputHandler::ModifierKey*
|
||||||
TextInputHandler::GetModifierKeyForDeviceDependentFlags(NSUInteger aFlags) const
|
TextInputHandler::GetModifierKeyForDeviceDependentFlags(NSUInteger aFlags) const
|
||||||
{
|
{
|
||||||
for (ModifierKeyArray::index_type i = 0; i < mModifierKeys.Length(); ++i) {
|
for (ModifierKeyArray::index_type i = 0; i < mModifierKeys.Length(); ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user