mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 855975 part.20 Sort out the scope of the methods of widget::NativKey r=jimm
This commit is contained in:
parent
3a5490f2b4
commit
a077030500
@ -871,14 +871,14 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
|
||||
}
|
||||
|
||||
if (!mModKeyState.IsControl() && !mModKeyState.IsAlt() &&
|
||||
!mModKeyState.IsWin() && IsPrintableKey()) {
|
||||
!mModKeyState.IsWin() && mIsPrintableKey) {
|
||||
// If this is simple KeyDown event but next message is not WM_CHAR,
|
||||
// this event may not input text, so we should ignore this event.
|
||||
// See bug 314130.
|
||||
return mWidget->PluginHasFocus() && defaultPrevented;
|
||||
}
|
||||
|
||||
if (IsDeadKey()) {
|
||||
if (mIsDeadKey) {
|
||||
return mWidget->PluginHasFocus() && defaultPrevented;
|
||||
}
|
||||
|
||||
@ -1054,7 +1054,7 @@ NativeKey::NeedsToHandleWithoutFollowingCharMessages() const
|
||||
|
||||
// Even if the key is a printable key, it might cause non-printable character
|
||||
// input with modifier key(s).
|
||||
return IsPrintableKey();
|
||||
return mIsPrintableKey;
|
||||
}
|
||||
|
||||
const MSG&
|
||||
@ -1309,7 +1309,7 @@ NativeKey::DispatchKeyPressEventForFollowingCharMessage(
|
||||
return aExtraFlags.mDefaultPrevented;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (IsPrintableKey()) {
|
||||
if (mIsPrintableKey) {
|
||||
nsPrintfCString log(
|
||||
"mOriginalVirtualKeyCode=0x%02X, mCommittedCharsAndModifiers={ "
|
||||
"mChars=[ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X ], mLength=%d }, "
|
||||
@ -1439,7 +1439,7 @@ KeyboardLayout::InitNativeKey(NativeKey& aNativeKey,
|
||||
LoadLayout(::GetKeyboardLayout(0));
|
||||
}
|
||||
|
||||
uint8_t virtualKey = aNativeKey.GetOriginalVirtualKeyCode();
|
||||
uint8_t virtualKey = aNativeKey.mOriginalVirtualKeyCode;
|
||||
int32_t virtualKeyIndex = GetKeyIndex(virtualKey);
|
||||
|
||||
if (virtualKeyIndex < 0) {
|
||||
|
@ -286,10 +286,87 @@ public:
|
||||
const ModifierKeyState& aModKeyState,
|
||||
const nsFakeCharMessage* aFakeCharMessage = nullptr);
|
||||
|
||||
uint32_t GetDOMKeyCode() const { return mDOMKeyCode; }
|
||||
KeyNameIndex GetKeyNameIndex() const { return mKeyNameIndex; }
|
||||
/**
|
||||
* Handle WM_KEYDOWN message or WM_SYSKEYDOWN message. The instance must be
|
||||
* initialized with WM_KEYDOWN or WM_SYSKEYDOWN.
|
||||
* Returns true if dispatched keydown event or keypress event is consumed.
|
||||
* Otherwise, false.
|
||||
*/
|
||||
bool HandleKeyDownMessage(bool* aEventDispatched = nullptr) const;
|
||||
|
||||
/**
|
||||
* Handles WM_CHAR message or WM_SYSCHAR message. The instance must be
|
||||
* initialized with WM_KEYDOWN, WM_SYSKEYDOWN or them.
|
||||
* Returns true if dispatched keypress event is consumed. Otherwise, false.
|
||||
*/
|
||||
bool HandleCharMessage(const MSG& aCharMsg,
|
||||
bool* aEventDispatched = nullptr,
|
||||
const EventFlags* aExtraFlags = nullptr) const;
|
||||
|
||||
/**
|
||||
* Handles keyup message. Returns true if the event is consumed.
|
||||
* Otherwise, false.
|
||||
*/
|
||||
bool HandleKeyUpMessage(bool* aEventDispatched = nullptr) const;
|
||||
|
||||
private:
|
||||
nsRefPtr<nsWindowBase> mWidget;
|
||||
HKL mKeyboardLayout;
|
||||
MSG mMsg;
|
||||
// mCharMsg stores WM_*CHAR message following WM_*KEYDOWN message.
|
||||
// If mMsg isn't WM_*KEYDOWN message or WM_*KEYDOWN but there is no following
|
||||
// WM_*CHAR message, the message member is 0.
|
||||
MSG mCharMsg;
|
||||
|
||||
uint32_t mDOMKeyCode;
|
||||
KeyNameIndex mKeyNameIndex;
|
||||
|
||||
ModifierKeyState mModKeyState;
|
||||
|
||||
// mVirtualKeyCode distinguishes left key or right key of modifier key.
|
||||
uint8_t mVirtualKeyCode;
|
||||
// mOriginalVirtualKeyCode doesn't distinguish left key or right key of
|
||||
// modifier key. However, if the given keycode is VK_PROCESS, it's resolved
|
||||
// to a keycode before it's handled by IME.
|
||||
uint8_t mOriginalVirtualKeyCode;
|
||||
|
||||
// mCommittedChars indicates the inputted characters which is committed by
|
||||
// the key. If dead key fail to composite a character, mCommittedChars
|
||||
// indicates both the dead characters and the base characters.
|
||||
UniCharsAndModifiers mCommittedCharsAndModifiers;
|
||||
|
||||
WORD mScanCode;
|
||||
bool mIsExtended;
|
||||
bool mIsDeadKey;
|
||||
// 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;
|
||||
bool mIsFakeCharMsg;
|
||||
|
||||
NativeKey()
|
||||
{
|
||||
MOZ_NOT_REACHED("The default constructor of NativeKey isn't available");
|
||||
}
|
||||
|
||||
UINT GetScanCodeWithExtendedFlag() const;
|
||||
|
||||
// The result is one of nsIDOMKeyEvent::DOM_KEY_LOCATION_*.
|
||||
uint32_t GetKeyLocation() const;
|
||||
|
||||
/**
|
||||
* "Kakutei-Undo" of ATOK or WXG (both of them are Japanese IME) causes
|
||||
* strange WM_KEYDOWN/WM_KEYUP/WM_CHAR message pattern. So, when this
|
||||
* returns true, the caller needs to be careful for processing the messages.
|
||||
*/
|
||||
bool IsIMEDoingKakuteiUndo() const;
|
||||
|
||||
/*
|
||||
* Dispatches a plugin event after the specified message is removed.
|
||||
*/
|
||||
void RemoveMessageAndDispatchPluginEvent(UINT aFirstMsg, UINT aLastMsg) const;
|
||||
|
||||
UINT GetMessage() const { return mMsg.message; }
|
||||
bool IsKeyDownMessage() const
|
||||
{
|
||||
return (mMsg.message == WM_KEYDOWN || mMsg.message == WM_SYSKEYDOWN);
|
||||
@ -300,17 +377,6 @@ public:
|
||||
return (mCharMsg.message != 0);
|
||||
}
|
||||
const MSG& RemoveFollowingCharMessage() const;
|
||||
bool IsDeadKey() const { return mIsDeadKey; }
|
||||
/**
|
||||
* IsPrintableKey() returns 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
|
||||
* returns true. E.g., it might be dead key state or Ctrl key may be pressed.
|
||||
*/
|
||||
inline bool IsPrintableKey() const { return mIsPrintableKey; }
|
||||
WORD GetScanCode() const { return mScanCode; }
|
||||
uint8_t GetVirtualKeyCode() const { return mVirtualKeyCode; }
|
||||
uint8_t GetOriginalVirtualKeyCode() const { return mOriginalVirtualKeyCode; }
|
||||
|
||||
/**
|
||||
* Wraps MapVirtualKeyEx() with MAPVK_VSC_TO_VK.
|
||||
@ -376,83 +442,6 @@ public:
|
||||
* or Backspace.
|
||||
*/
|
||||
bool NeedsToHandleWithoutFollowingCharMessages() const;
|
||||
|
||||
/**
|
||||
* Handle WM_KEYDOWN message or WM_SYSKEYDOWN message. The instance must be
|
||||
* initialized with WM_KEYDOWN or WM_SYSKEYDOWN.
|
||||
* Returns true if dispatched keydown event or keypress event is consumed.
|
||||
* Otherwise, false.
|
||||
*/
|
||||
bool HandleKeyDownMessage(bool* aEventDispatched = nullptr) const;
|
||||
|
||||
/**
|
||||
* Handles WM_CHAR message or WM_SYSCHAR message. The instance must be
|
||||
* initialized with WM_KEYDOWN, WM_SYSKEYDOWN or them.
|
||||
* Returns true if dispatched keypress event is consumed. Otherwise, false.
|
||||
*/
|
||||
bool HandleCharMessage(const MSG& aCharMsg,
|
||||
bool* aEventDispatched = nullptr,
|
||||
const EventFlags* aExtraFlags = nullptr) const;
|
||||
|
||||
/**
|
||||
* Handles keyup message. Returns true if the event is consumed.
|
||||
* Otherwise, false.
|
||||
*/
|
||||
bool HandleKeyUpMessage(bool* aEventDispatched = nullptr) const;
|
||||
|
||||
private:
|
||||
nsRefPtr<nsWindowBase> mWidget;
|
||||
HKL mKeyboardLayout;
|
||||
MSG mMsg;
|
||||
// mCharMsg stores WM_*CHAR message following WM_*KEYDOWN message.
|
||||
// If mMsg isn't WM_*KEYDOWN message or WM_*KEYDOWN but there is no following
|
||||
// WM_*CHAR message, the message member is 0.
|
||||
MSG mCharMsg;
|
||||
|
||||
uint32_t mDOMKeyCode;
|
||||
KeyNameIndex mKeyNameIndex;
|
||||
|
||||
ModifierKeyState mModKeyState;
|
||||
|
||||
// mVirtualKeyCode distinguishes left key or right key of modifier key.
|
||||
uint8_t mVirtualKeyCode;
|
||||
// mOriginalVirtualKeyCode doesn't distinguish left key or right key of
|
||||
// modifier key. However, if the given keycode is VK_PROCESS, it's resolved
|
||||
// to a keycode before it's handled by IME.
|
||||
uint8_t mOriginalVirtualKeyCode;
|
||||
|
||||
// mCommittedChars indicates the inputted characters which is committed by
|
||||
// the key. If dead key fail to composite a character, mCommittedChars
|
||||
// indicates both the dead characters and the base characters.
|
||||
UniCharsAndModifiers mCommittedCharsAndModifiers;
|
||||
|
||||
WORD mScanCode;
|
||||
bool mIsExtended;
|
||||
bool mIsDeadKey;
|
||||
bool mIsPrintableKey;
|
||||
bool mIsFakeCharMsg;
|
||||
|
||||
NativeKey()
|
||||
{
|
||||
MOZ_NOT_REACHED("The default constructor of NativeKey isn't available");
|
||||
}
|
||||
|
||||
UINT GetScanCodeWithExtendedFlag() const;
|
||||
|
||||
// The result is one of nsIDOMKeyEvent::DOM_KEY_LOCATION_*.
|
||||
uint32_t GetKeyLocation() const;
|
||||
|
||||
/**
|
||||
* "Kakutei-Undo" of ATOK or WXG (both of them are Japanese IME) causes
|
||||
* strange WM_KEYDOWN/WM_KEYUP/WM_CHAR message pattern. So, when this
|
||||
* returns true, the caller needs to be careful for processing the messages.
|
||||
*/
|
||||
bool IsIMEDoingKakuteiUndo() const;
|
||||
|
||||
/*
|
||||
* Dispatches a plugin event after the specified message is removed.
|
||||
*/
|
||||
void RemoveMessageAndDispatchPluginEvent(UINT aFirstMsg, UINT aLastMsg) const;
|
||||
};
|
||||
|
||||
class KeyboardLayout
|
||||
|
Loading…
Reference in New Issue
Block a user