Bug 855975 part.15 Use widget::NativeKey::mCommittedCharsAndModifiers directly in the methods of widget::NativeKey r=jimm
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 29 May 2013 15:34:48 +0900
changeset 133242 0ed82af5475f4de390a9d5c9dad982a296bd36e3
parent 133241 91ba04b50639072addaaa5882251cf5ae976c650
child 133243 1f923c894ca46e2b9f500065dd6a4072d2f842c7
push id28671
push usermasayuki@d-toybox.com
push dateWed, 29 May 2013 06:35:17 +0000
treeherdermozilla-inbound@57461a161f93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs855975
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 855975 part.15 Use widget::NativeKey::mCommittedCharsAndModifiers directly in the methods of widget::NativeKey r=jimm
widget/windows/KeyboardLayout.cpp
widget/windows/KeyboardLayout.h
widget/windows/nsWindow.cpp
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -995,17 +995,16 @@ NativeKey::RemoveMessageAndDispatchPlugi
   } else {
     WinUtils::GetMessage(&msg, mMsg.hwnd, aFirstMsg, aLastMsg);
   }
   mWidget->DispatchPluginEvent(msg);
 }
 
 bool
 NativeKey::DispatchKeyPressEventsAndDiscardsCharMessages(
-                        const UniCharsAndModifiers& aInputtingChars,
                         const EventFlags& aExtraFlags) const
 {
   MOZ_ASSERT(mMsg.message == WM_KEYDOWN || mMsg.message == WM_SYSKEYDOWN);
 
   // Remove a possible WM_CHAR or WM_SYSCHAR messages from the message queue.
   // They can be more than one because of:
   //  * Dead-keys not pairing with base character
   //  * Some keyboard layouts may map up to 4 characters to the single key
@@ -1028,30 +1027,29 @@ NativeKey::DispatchKeyPressEventsAndDisc
   }
 
   if (!anyCharMessagesRemoved &&
       mDOMKeyCode == NS_VK_BACK && IsIMEDoingKakuteiUndo()) {
     MOZ_ASSERT(!mIsFakeCharMsg);
     RemoveMessageAndDispatchPluginEvent(WM_CHAR, WM_CHAR);
   }
 
-  return DispatchKeyPressEventsWithKeyboardLayout(aInputtingChars, aExtraFlags);
+  return DispatchKeyPressEventsWithKeyboardLayout(aExtraFlags);
 }
 
 bool
 NativeKey::DispatchKeyPressEventsWithKeyboardLayout(
-                        const UniCharsAndModifiers& aInputtingChars,
                         const EventFlags& aExtraFlags) const
 {
   MOZ_ASSERT(mMsg.message == WM_KEYDOWN || mMsg.message == WM_SYSKEYDOWN);
   MOZ_ASSERT(!mIsDeadKey);
 
   KeyboardLayout* keyboardLayout = KeyboardLayout::GetInstance();
 
-  UniCharsAndModifiers inputtingChars(aInputtingChars);
+  UniCharsAndModifiers inputtingChars(mCommittedCharsAndModifiers);
   UniCharsAndModifiers shiftedChars;
   UniCharsAndModifiers unshiftedChars;
   uint32_t shiftedLatinChar = 0;
   uint32_t unshiftedLatinChar = 0;
 
   if (!KeyboardLayout::IsPrintableCharKey(mVirtualKeyCode)) {
     inputtingChars.Clear();
   }
@@ -1198,40 +1196,42 @@ NativeKey::DispatchKeyPressEventsWithKey
     defaultPrevented = (DispatchKeyEvent(keypressEvent) || defaultPrevented);
   }
 
   return defaultPrevented;
 }
 
 bool
 NativeKey::DispatchKeyPressEventForFollowingCharMessage(
-                        const UniCharsAndModifiers& aInputtingChars,
                         const EventFlags& aExtraFlags) const
 {
   MOZ_ASSERT(mMsg.message == WM_KEYDOWN || mMsg.message == WM_SYSKEYDOWN);
 
   const MSG& msg = RemoveFollowingCharMessage();
   if (mIsFakeCharMsg) {
     if (msg.message == WM_DEADCHAR) {
       return aExtraFlags.mDefaultPrevented;
     }
 #ifdef DEBUG
     if (IsPrintableKey()) {
       nsPrintfCString log(
-        "mOriginalVirtualKeyCode=0x%02X, aInputtingChars={ mChars=[ 0x%04X, "
-        "0x%04X, 0x%04X, 0x%04X, 0x%04X ], mLength=%d }, wParam=0x%04X",
-        mOriginalVirtualKeyCode, aInputtingChars.mChars[0],
-        aInputtingChars.mChars[1], aInputtingChars.mChars[2],
-        aInputtingChars.mChars[3], aInputtingChars.mChars[4],
-        aInputtingChars.mLength, msg.wParam);
-      if (aInputtingChars.IsEmpty()) {
+        "mOriginalVirtualKeyCode=0x%02X, mCommittedCharsAndModifiers={ "
+        "mChars=[ 0x%04X, 0x%04X, 0x%04X, 0x%04X, 0x%04X ], mLength=%d }, "
+        "wParam=0x%04X",
+        mOriginalVirtualKeyCode, mCommittedCharsAndModifiers.mChars[0],
+        mCommittedCharsAndModifiers.mChars[1],
+        mCommittedCharsAndModifiers.mChars[2],
+        mCommittedCharsAndModifiers.mChars[3],
+        mCommittedCharsAndModifiers.mChars[4],
+        mCommittedCharsAndModifiers.mLength, msg.wParam);
+      if (mCommittedCharsAndModifiers.IsEmpty()) {
         log.Insert("length is zero: ", 0);
         NS_ERROR(log.get());
         NS_ABORT();
-      } else if (aInputtingChars.mChars[0] != msg.wParam) {
+      } else if (mCommittedCharsAndModifiers.mChars[0] != msg.wParam) {
         log.Insert("character mismatch: ", 0);
         NS_ERROR(log.get());
         NS_ABORT();
       }
     }
 #endif // #ifdef DEBUG
     return HandleCharMessage(msg, nullptr, &aExtraFlags);
   }
--- a/widget/windows/KeyboardLayout.h
+++ b/widget/windows/KeyboardLayout.h
@@ -283,20 +283,16 @@ class MOZ_STACK_CLASS NativeKey
 public:
   NativeKey(nsWindowBase* aWidget,
             const MSG& aKeyOrCharMessage,
             const ModifierKeyState& aModKeyState,
             const nsFakeCharMessage* aFakeCharMessage = nullptr);
 
   uint32_t GetDOMKeyCode() const { return mDOMKeyCode; }
   KeyNameIndex GetKeyNameIndex() const { return mKeyNameIndex; }
-  const UniCharsAndModifiers& GetCommittedCharsAndModifiers() const
-  {
-    return mCommittedCharsAndModifiers;
-  }
 
   UINT GetMessage() const { return mMsg.message; }
   bool IsKeyDownMessage() const
   {
     return (mMsg.message == WM_KEYDOWN || mMsg.message == WM_SYSKEYDOWN);
   }
   bool IsFollowedByCharMessage() const
   {
@@ -348,36 +344,33 @@ public:
   bool DispatchKeyEvent(nsKeyEvent& aKeyEvent,
                         const MSG* aMsgSentToPlugin = nullptr) const;
 
   /**
    * DispatchKeyPressEventsWithKeyboardLayout() dispatches keypress event(s)
    * with the information provided by KeyboardLayout class.
    */
   bool DispatchKeyPressEventsWithKeyboardLayout(
-                        const UniCharsAndModifiers& aInputtingChars,
                         const EventFlags& aExtraFlags) const;
 
   /**
    * Dispatches keypress events after removing WM_*CHAR messages for the
    * WM_*KEYDOWN message.
    * Returns true if the dispatched keypress event is consumed.  Otherwise,
    * false.
    */
   bool DispatchKeyPressEventsAndDiscardsCharMessages(
-                        const UniCharsAndModifiers& aInputtingChars,
                         const EventFlags& aExtraFlags) const;
 
   /**
    * DispatchKeyPressEventForFollowingCharMessage() dispatches keypress event
    * for following WM_*CHAR message.
    * Returns true if the event is consumed.  Otherwise, false.
    */
   bool DispatchKeyPressEventForFollowingCharMessage(
-                        const UniCharsAndModifiers& aInputtingChars,
                         const EventFlags& aExtraFlags) const;
 
   /**
    * Checkes whether the key event down message is handled without following
    * WM_CHAR messages.  For example, if following WM_CHAR message indicates
    * control character input, the WM_CHAR message is unclear whether it's
    * caused by a printable key with Ctrl or just a function key such as Enter
    * or Backspace.
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6354,18 +6354,16 @@ bool nsWindow::IsRedirectedKeyDownMessag
  */
 LRESULT nsWindow::OnKeyDown(const MSG &aMsg,
                             const ModifierKeyState &aModKeyState,
                             bool *aEventDispatched,
                             nsFakeCharMessage* aFakeCharMessage)
 {
   KeyboardLayout* keyboardLayout = KeyboardLayout::GetInstance();
   NativeKey nativeKey(this, aMsg, aModKeyState, aFakeCharMessage);
-  UniCharsAndModifiers inputtingChars =
-    nativeKey.GetCommittedCharsAndModifiers();
   uint32_t DOMKeyCode = nativeKey.GetDOMKeyCode();
 
   static bool sRedirectedKeyDownEventPreventedDefault = false;
   bool noDefault;
   if (aFakeCharMessage || !IsRedirectedKeyDownMessage(aMsg)) {
     bool isIMEEnabled = IMEHandler::IsIMEEnabled(mInputContext);
     bool eventDispatched;
     noDefault = nativeKey.DispatchKeyDownEvent(&eventDispatched);
@@ -6447,41 +6445,38 @@ LRESULT nsWindow::OnKeyDown(const MSG &a
     case NS_VK_WIN:
       return noDefault;
   }
 
   EventFlags extraFlags;
   extraFlags.mDefaultPrevented = noDefault;
 
   if (nativeKey.NeedsToHandleWithoutFollowingCharMessages()) {
-    return nativeKey.DispatchKeyPressEventsAndDiscardsCharMessages(
-                       inputtingChars, extraFlags);
+    return nativeKey.DispatchKeyPressEventsAndDiscardsCharMessages(extraFlags);
   }
 
   if (nativeKey.IsFollowedByCharMessage()) {
     return static_cast<LRESULT>(
-      nativeKey.DispatchKeyPressEventForFollowingCharMessage(inputtingChars,
-                                                             extraFlags));
+      nativeKey.DispatchKeyPressEventForFollowingCharMessage(extraFlags));
   }
 
   if (!aModKeyState.IsControl() && !aModKeyState.IsAlt() &&
       !aModKeyState.IsWin() && nativeKey.IsPrintableKey()) {
     // 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 PluginHasFocus() && noDefault;
   }
 
   if (nativeKey.IsDeadKey()) {
     return PluginHasFocus() && noDefault;
   }
 
   return static_cast<LRESULT>(
-    nativeKey.DispatchKeyPressEventsWithKeyboardLayout(inputtingChars,
-                                                       extraFlags));
+    nativeKey.DispatchKeyPressEventsWithKeyboardLayout(extraFlags));
 }
 
 void
 nsWindow::SetupKeyModifiersSequence(nsTArray<KeyPair>* aArray, uint32_t aModifiers)
 {
   for (uint32_t i = 0; i < ArrayLength(sModifierKeyMap); ++i) {
     const uint32_t* map = sModifierKeyMap[i];
     if (aModifiers & map[0]) {