Bug 543789 part.6 Implement DOM3 composition event on Android r=dougt+smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 22 Sep 2011 18:17:40 +0900
changeset 78626 54fbf5eda91483e9770ed039b7378a82335d9a4a
parent 78625 8d48a0f50b4c2c92de5320e97f48b69e7ebfba11
child 78627 df8272331d537e4c3577eae41e5c5bc3c506f42f
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
bugs543789
milestone9.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 543789 part.6 Implement DOM3 composition event on Android r=dougt+smaug
widget/src/android/nsWindow.cpp
widget/src/android/nsWindow.h
--- a/widget/src/android/nsWindow.cpp
+++ b/widget/src/android/nsWindow.cpp
@@ -1627,22 +1627,25 @@ void
 nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
 {
     switch (ae->Action()) {
     case AndroidGeckoEvent::IME_COMPOSITION_END:
         {
             ALOGIME("IME: IME_COMPOSITION_END");
             nsCompositionEvent event(PR_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");
+            mIMELastDispatchedComposingText.Truncate();
             nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_START, this);
             InitEvent(event, nsnull);
             DispatchEvent(&event);
         }
         return;
     case AndroidGeckoEvent::IME_ADD_RANGE:
         {
             OnIMEAddRange(ae);
@@ -1654,16 +1657,30 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
 
             nsTextEvent event(PR_TRUE, NS_TEXT_TEXT, this);
             InitEvent(event, nsnull);
 
             event.theText.Assign(ae->Characters());
             event.rangeArray = mIMERanges.Elements();
             event.rangeCount = mIMERanges.Length();
 
+            if (mIMEComposing &&
+                event.theText != mIMELastDispatchedComposingText) {
+                nsCompositionEvent compositionUpdate(PR_TRUE,
+                                                     NS_COMPOSITION_UPDATE,
+                                                     this);
+                InitEvent(compositionUpdate, nsnull);
+                compositionUpdate.data = event.theText;
+                mIMELastDispatchedComposingText = event.theText;
+                DispatchEvent(&compositionUpdate);
+                // XXX We must check whether this widget is destroyed or not
+                //     before dispatching next event.  However, Android's
+                //     nsWindow has never checked it...
+            }
+
             ALOGIME("IME: IME_SET_TEXT: l=%u, r=%u",
                 event.theText.Length(), mIMERanges.Length());
 
             DispatchEvent(&event);
             mIMERanges.Clear();
         }
         return;
     case AndroidGeckoEvent::IME_GET_TEXT:
--- a/widget/src/android/nsWindow.h
+++ b/widget/src/android/nsWindow.h
@@ -194,16 +194,17 @@ protected:
     // Multitouch swipe thresholds in screen pixels
     double mSwipeMaxPinchDelta;
     double mSwipeMinDistance;
 
     nsCOMPtr<nsIdleService> mIdleService;
 
     PRBool mIMEComposing;
     nsString mIMEComposingText;
+    nsString mIMELastDispatchedComposingText;
     nsAutoTArray<nsTextRange, 4> mIMERanges;
 
     IMEContext mIMEContext;
 
     static void DumpWindows();
     static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0);
     static void LogWindow(nsWindow *win, int index, int indent);