From 95d7aefeeeb2672c736c4d0a6493a3b9aee6a7d1 Mon Sep 17 00:00:00 2001 From: Nigel Babu Date: Tue, 17 Feb 2015 10:15:44 +0530 Subject: [PATCH] Backed out changeset 456038b0bdb5 (bug 1121313) for M1,M2 bustage --- dom/ipc/PBrowser.ipdl | 11 ++++------- dom/ipc/TabParent.cpp | 9 +-------- dom/ipc/TabParent.h | 2 -- widget/PuppetWidget.cpp | 15 +++++++++++---- widget/PuppetWidget.h | 1 + 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 1309d03a804..94fccb87f59 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -267,18 +267,15 @@ parent: /** * Instructs chrome to end any pending composition * - * cancel true if composition should be cancelled - * noCompositionEvent true if no composition event is fired by commit or - * cancel + * cancel PR_TRUE if composition should be cancelled * composition Text to commit before ending the composition * - * if cancel is true, + * if cancel is PR_TRUE, * widget should return empty string for composition - * if cancel is false, + * if cancel is PR_FALSE, * widget should return the current composition text */ - prio(urgent) sync EndIMEComposition(bool cancel) - returns (bool noCompositionEvent, nsString composition); + prio(urgent) sync EndIMEComposition(bool cancel) returns (nsString composition); /** * Request that the parent process move focus to the browser's frame. If diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index f11e72f32db..4c20cfc6ae8 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -259,7 +259,6 @@ TabParent::TabParent(nsIContentParent* aManager, , mWritingMode() , mIMEComposing(false) , mIMECompositionEnding(false) - , mIMEEventCountAfterEnding(0) , mIMECompositionStart(0) , mIMESeqno(0) , mIMECompositionRectOffset(0) @@ -2001,10 +2000,8 @@ TabParent::SendCompositionEvent(WidgetCompositionEvent& event) mIMEComposing = !event.CausesDOMCompositionEndEvent(); mIMECompositionStart = std::min(mIMESelectionAnchor, mIMESelectionFocus); - if (mIMECompositionEnding) { - mIMEEventCountAfterEnding++; + if (mIMECompositionEnding) return true; - } event.mSeqno = ++mIMESeqno; return PBrowserParent::SendCompositionEvent(event); } @@ -2022,7 +2019,6 @@ TabParent::SendCompositionChangeEvent(WidgetCompositionEvent& event) { if (mIMECompositionEnding) { mIMECompositionText = event.mData; - mIMEEventCountAfterEnding++; return true; } @@ -2113,7 +2109,6 @@ TabParent::GetRenderFrame() bool TabParent::RecvEndIMEComposition(const bool& aCancel, - bool* aNoCompositionEvent, nsString* aComposition) { nsCOMPtr widget = GetWidget(); @@ -2121,13 +2116,11 @@ TabParent::RecvEndIMEComposition(const bool& aCancel, return true; mIMECompositionEnding = true; - mIMEEventCountAfterEnding = 0; widget->NotifyIME(IMENotification(aCancel ? REQUEST_TO_CANCEL_COMPOSITION : REQUEST_TO_COMMIT_COMPOSITION)); mIMECompositionEnding = false; - *aNoCompositionEvent = !mIMEEventCountAfterEnding; *aComposition = mIMECompositionText; mIMECompositionText.Truncate(0); return true; diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index cec65e95ed8..3f565bfe8d9 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -195,7 +195,6 @@ public: InfallibleTArray&& aCompositionRects, const LayoutDeviceIntRect& aCaretRect) MOZ_OVERRIDE; virtual bool RecvEndIMEComposition(const bool& aCancel, - bool* aNoCompositionEvent, nsString* aComposition) MOZ_OVERRIDE; virtual bool RecvGetInputContext(int32_t* aIMEEnabled, int32_t* aIMEOpen, @@ -420,7 +419,6 @@ protected: mozilla::WritingMode mWritingMode; bool mIMEComposing; bool mIMECompositionEnding; - uint32_t mIMEEventCountAfterEnding; // Buffer to store composition text during ResetInputState // Compositions in almost all cases are small enough for nsAutoString nsAutoString mIMECompositionText; diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 9cbf8ca85de..63fb29790e9 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -109,6 +109,7 @@ PuppetWidget::Create(nsIWidget *aParent, mDrawTarget = gfxPlatform::GetPlatform()-> CreateOffscreenContentDrawTarget(IntSize(1, 1), SurfaceFormat::B8G8R8A8); + mIMEComposing = false; mNeedIMEStateInit = MightNeedIMEFocus(aInitData); PuppetWidget* parent = static_cast(aParent); @@ -304,6 +305,9 @@ PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus) aStatus = nsEventStatus_eIgnore; + if (event->message == NS_COMPOSITION_START) { + mIMEComposing = true; + } uint32_t seqno = kLatestSeqno; switch (event->mClass) { case eCompositionEventClass: @@ -326,6 +330,11 @@ PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus) aStatus = mAttachedWidgetListener->HandleEvent(event, mUseAttachedEvents); } + if (event->mClass == eCompositionEventClass && + event->AsCompositionEvent()->CausesDOMCompositionEndEvent()) { + mIMEComposing = false; + } + return NS_OK; } @@ -393,21 +402,19 @@ PuppetWidget::IMEEndComposition(bool aCancel) #endif nsEventStatus status; - bool noCompositionEvent = false; WidgetCompositionEvent compositionCommitEvent(true, NS_COMPOSITION_COMMIT, this); InitEvent(compositionCommitEvent, nullptr); // SendEndIMEComposition is always called since ResetInputState // should always be called even if we aren't composing something. if (!mTabChild || - !mTabChild->SendEndIMEComposition(aCancel, &noCompositionEvent, + !mTabChild->SendEndIMEComposition(aCancel, &compositionCommitEvent.mData)) { return NS_ERROR_FAILURE; } - if (noCompositionEvent) { + if (!mIMEComposing) return NS_OK; - } compositionCommitEvent.mSeqno = mIMELastReceivedSeqno; DispatchEvent(&compositionCommitEvent, status); diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index e505fac171a..302f816245c 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -259,6 +259,7 @@ private: mozilla::RefPtr mDrawTarget; // IME nsIMEUpdatePreference mIMEPreferenceOfParent; + bool mIMEComposing; // Latest seqno received through events uint32_t mIMELastReceivedSeqno; // Chrome's seqno value when last blur occurred