Bug 756429 - Part 2: Assert sanity of composition string's state changes. r=blassey
authorChris Peterson <cpeterson@mozilla.com>
Fri, 01 Jun 2012 09:48:13 -0700
changeset 95547 180b78b6cec4aad931e2ee9fc53d61ffce081cdf
parent 95546 9a6a5cc5a4a586533b4307492bbd6c4548e1ebdc
child 95548 22a080ac092e66118cebcea3abf4ddc279855216
push id10156
push usercpeterson@mozilla.com
push dateFri, 01 Jun 2012 19:02:03 +0000
treeherdermozilla-inbound@180b78b6cec4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs756429
milestone15.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 756429 - Part 2: Assert sanity of composition string's state changes. r=blassey
widget/android/nsWindow.cpp
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1877,39 +1877,50 @@ nsWindow::OnIMEAddRange(AndroidGeckoEven
 void
 nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
 {
     nsRefPtr<nsWindow> kungFuDeathGrip(this);
     switch (ae->Action()) {
     case AndroidGeckoEvent::IME_COMPOSITION_END:
         {
             ALOGIME("IME: IME_COMPOSITION_END");
+            MOZ_ASSERT(mIMEComposing,
+                       "IME_COMPOSITION_END when we are not composing?!");
+
             nsCompositionEvent event(true, NS_COMPOSITION_END, this);
             InitEvent(event, nsnull);
             event.data = mIMELastDispatchedComposingText;
             mIMELastDispatchedComposingText.Truncate();
             DispatchEvent(&event);
         }
         return;
     case AndroidGeckoEvent::IME_COMPOSITION_BEGIN:
         {
             ALOGIME("IME: IME_COMPOSITION_BEGIN");
+            MOZ_ASSERT(!mIMEComposing,
+                       "IME_COMPOSITION_BEGIN when we are already composing?!");
+
             mIMELastDispatchedComposingText.Truncate();
             nsCompositionEvent event(true, NS_COMPOSITION_START, this);
             InitEvent(event, nsnull);
             DispatchEvent(&event);
         }
         return;
     case AndroidGeckoEvent::IME_ADD_RANGE:
         {
+            NS_ASSERTION(mIMEComposing,
+                         "IME_ADD_RANGE when we are not composing?!");
             OnIMEAddRange(ae);
         }
         return;
     case AndroidGeckoEvent::IME_SET_TEXT:
         {
+            NS_ASSERTION(mIMEComposing,
+                         "IME_SET_TEXT when we are not composing?!");
+
             OnIMEAddRange(ae);
 
             nsTextEvent event(true, NS_TEXT_TEXT, this);
             InitEvent(event, nsnull);
 
             event.theText.Assign(ae->Characters());
             event.rangeArray = mIMERanges.Elements();
             event.rangeCount = mIMERanges.Length();
@@ -1922,18 +1933,22 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
                 InitEvent(compositionUpdate, nsnull);
                 compositionUpdate.data = event.theText;
                 mIMELastDispatchedComposingText = event.theText;
                 DispatchEvent(&compositionUpdate);
                 if (Destroyed())
                     return;
             }
 
-            ALOGIME("IME: IME_SET_TEXT: l=%u, r=%u",
-                event.theText.Length(), mIMERanges.Length());
+#ifdef DEBUG_ANDROID_IME
+            const NS_ConvertUTF16toUTF8 theText8(event.theText);
+            const char* text = theText8.get();
+            ALOGIME("IME: IME_SET_TEXT: text=\"%s\", length=%u, range=%u",
+                    text, event.theText.Length(), mIMERanges.Length());
+#endif // DEBUG_ANDROID_IME
 
             DispatchEvent(&event);
             mIMERanges.Clear();
         }
         return;
     case AndroidGeckoEvent::IME_GET_TEXT:
         {
             ALOGIME("IME: IME_GET_TEXT: o=%u, l=%u", ae->Offset(), ae->Count());
@@ -1950,22 +1965,24 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
                 AndroidBridge::Bridge()->ReturnIMEQueryResult(
                     nsnull, 0, 0, 0);
                 return;
             } else if (!event.mWasAsync) {
                 AndroidBridge::Bridge()->ReturnIMEQueryResult(
                     event.mReply.mString.get(), 
                     event.mReply.mString.Length(), 0, 0);
             }
-            //ALOGIME("IME:     -> l=%u", event.mReply.mString.Length());
         }
         return;
     case AndroidGeckoEvent::IME_DELETE_TEXT:
         {
             ALOGIME("IME: IME_DELETE_TEXT");
+            NS_ASSERTION(mIMEComposing,
+                         "IME_DELETE_TEXT when we are not composing?!");
+
             nsKeyEvent event(true, NS_KEY_PRESS, this);
             ANPEvent pluginEvent;
             InitKeyEvent(event, *ae, &pluginEvent);
             event.keyCode = NS_VK_BACK;
             DispatchEvent(&event);
         }
         return;
     case AndroidGeckoEvent::IME_SET_SELECTION: