Bug 1300003 part.4 Remove NativeKey::mIsFollowedByNonControlCharMessage because calling NativeKey::IsFollowedByNonControlCharMessage() is enough fast r?m_kato
NativeKey is now removing and storing following char messages when it's created for a keydown message. Therefore, IsFollowedByNonControlCharMessage() just refers the stored messages and it's enough fast. So, we can get rid of mIsFollowedByNonControlCharMessage.
MozReview-Commit-ID: 542A2sHNXeC
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -856,17 +856,16 @@ NativeKey::NativeKey(nsWindowBase* aWidg
, mModKeyState(aModKeyState)
, mVirtualKeyCode(0)
, mOriginalVirtualKeyCode(0)
, mShiftedLatinChar(0)
, mUnshiftedLatinChar(0)
, mScanCode(0)
, mIsExtended(false)
, mIsDeadKey(false)
- , mIsFollowedByNonControlCharMessage(false)
, mFakeCharMsgs(aFakeCharMsgs && aFakeCharMsgs->Length() ?
aFakeCharMsgs : nullptr)
{
MOZ_ASSERT(aWidget);
MOZ_ASSERT(mDispatcher);
KeyboardLayout* keyboardLayout = KeyboardLayout::GetInstance();
mKeyboardLayout = keyboardLayout->GetLayout();
if (aOverrideKeyboardLayout && mKeyboardLayout != aOverrideKeyboardLayout) {
@@ -1056,19 +1055,19 @@ NativeKey::NativeKey(nsWindowBase* aWidg
if (!mVirtualKeyCode) {
mVirtualKeyCode = mOriginalVirtualKeyCode;
}
mDOMKeyCode =
keyboardLayout->ConvertNativeKeyCodeToDOMKeyCode(mOriginalVirtualKeyCode);
// Be aware, keyboard utilities can change non-printable keys to printable
// keys. In such case, we should make the key value as a printable key.
- mIsFollowedByNonControlCharMessage =
- IsKeyDownMessage() && IsFollowedByNonControlCharMessage();
- mKeyNameIndex = mIsFollowedByNonControlCharMessage ?
+ // FYI: IsFollowedByNonControlCharMessage() returns true only when it's
+ // handling a keydown message.
+ mKeyNameIndex = IsFollowedByNonControlCharMessage() ?
KEY_NAME_INDEX_USE_STRING :
keyboardLayout->ConvertNativeKeyCodeToKeyNameIndex(mOriginalVirtualKeyCode);
mCodeNameIndex =
KeyboardLayout::ConvertScanCodeToCodeNameIndex(
GetScanCodeWithExtendedFlag());
keyboardLayout->InitNativeKey(*this, mModKeyState);
@@ -2033,17 +2032,17 @@ NativeKey::NeedsToHandleWithoutFollowing
// whole following char messages.
if (mCommittedCharsAndModifiers.mLength > 1) {
return true;
}
// If keydown message is followed by WM_CHAR whose wParam isn't a control
// character, we should dispatch keypress event with the char message
// even with any modifier state.
- if (mIsFollowedByNonControlCharMessage) {
+ if (IsFollowedByNonControlCharMessage()) {
return false;
}
// If any modifier keys which may cause printable keys becoming non-printable
// are not pressed, we don't need special handling for the key.
if (!mModKeyState.IsControl() && !mModKeyState.IsAlt() &&
!mModKeyState.IsWin()) {
return false;
--- a/widget/windows/KeyboardLayout.h
+++ b/widget/windows/KeyboardLayout.h
@@ -316,20 +316,16 @@ private:
// mIsPrintableKey is true if the key may be a printable key without
// any modifier keys. Otherwise, false.
// Please note that the event may not cause any text input even if this
// is true. E.g., it might be dead key state or Ctrl key may be pressed.
bool mIsPrintableKey;
// mIsOverridingKeyboardLayout is true if the instance temporarily overriding
// keyboard layout with specified by the constructor.
bool mIsOverridingKeyboardLayout;
- // mIsFollowedByNonControlCharMessage may be true when mMsg is a keydown
- // message. When the keydown message is followed by a char message, this
- // is true.
- bool mIsFollowedByNonControlCharMessage;
nsTArray<FakeCharMsg>* mFakeCharMsgs;
// When a keydown event is dispatched at handling WM_APPCOMMAND, the computed
// virtual keycode is set to this. Even if we consume WM_APPCOMMAND message,
// Windows may send WM_KEYDOWN and WM_KEYUP message for them.
// At that time, we should not dispatch key events for them.
static uint8_t sDispatchedKeyOfAppCommand;