From 6392ef0331363520383b49926858d4294adaaf73 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Thu, 28 May 2015 13:51:40 +0900 Subject: [PATCH] Bug 1166323 - Remove IME sequence number. r=masayuki,nchen --- dom/ipc/PBrowser.ipdl | 26 +-------- dom/ipc/TabParent.cpp | 56 ++++++++------------ dom/ipc/TabParent.h | 8 ++- security/certverifier/ExtendedValidation.cpp | 2 +- widget/PuppetWidget.cpp | 30 +---------- widget/PuppetWidget.h | 7 --- widget/TextEvents.h | 14 +---- widget/nsGUIEventIPC.h | 4 -- 8 files changed, 32 insertions(+), 115 deletions(-) diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 29cb07c5a22..140d2312719 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -155,26 +155,6 @@ parent: CpowEntry[] aCpows, Principal aPrincipal) returns (OwningSerializedStructuredCloneBuffer[] retval); - /** - * The IME sequence number (seqno) parameter is used to make sure - * that a notification is discarded if it arrives at the chrome process - * too late. If the notification is late and we accept it, we will have - * an out-of-date view of the content process, which means events that we - * dispatch based on this out-of-date view will be wrong also. - * (see Bug 599550 and Bug 591047 comments 44, 50, and 54) - * - * Chrome increments seqno and includes it in each IME event sent to - * content, and content sends its current seqno back to chrome with each - * notification. A notification is up-to-date only if the content - * seqno is the same as the current chrome seqno, meaning no additional - * event was sent to content before the notification was received - * - * On blur, chrome returns the current seqno to content, and content - * uses it to discard subsequent events until the content seqno and - * chrome seqno-on-blur match again. These events, meant for the blurred - * textfield, are discarded to prevent events going to the wrong target - */ - /** * Notifies chrome that there is a focus change involving an editable * object (input, textarea, document, contentEditable. etc.) @@ -182,10 +162,9 @@ parent: * focus PR_TRUE if editable object is receiving focus * PR_FALSE if losing focus * preference Native widget preference for IME updates - * seqno Current seqno value on the chrome side */ prio(urgent) sync NotifyIMEFocus(bool focus) - returns (nsIMEUpdatePreference preference, uint32_t seqno); + returns (nsIMEUpdatePreference preference); /** * Notifies chrome that there has been a change in text content @@ -221,13 +200,12 @@ parent: * Notifies chrome that there has been a change in selection * Only called when NotifyIMEFocus returns PR_TRUE for mWantUpdates * - * seqno Current seqno value on the content side * anchor Offset where the selection started * focus Offset where the caret is * writingMode CSS writing-mode in effect at the focus * causedByComposition true if the change is caused by composition */ - prio(urgent) async NotifyIMESelection(uint32_t seqno, uint32_t anchor, + prio(urgent) async NotifyIMESelection(uint32_t anchor, uint32_t focus, WritingMode writingMode, bool causedByComposition); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 268255bee2f..479f41cc3aa 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -264,7 +264,6 @@ TabParent::TabParent(nsIContentParent* aManager, , mIMECompositionEnding(false) , mIMEEventCountAfterEnding(0) , mIMECompositionStart(0) - , mIMESeqno(0) , mIMECompositionRectOffset(0) , mRect(0, 0, 0, 0) , mDimensions(0, 0) @@ -1847,11 +1846,8 @@ TabParent::RecvHideTooltip() bool TabParent::RecvNotifyIMEFocus(const bool& aFocus, - nsIMEUpdatePreference* aPreference, - uint32_t* aSeqno) + nsIMEUpdatePreference* aPreference) { - *aSeqno = mIMESeqno; - nsCOMPtr widget = GetWidget(); if (!widget) { *aPreference = nsIMEUpdatePreference(); @@ -1922,8 +1918,7 @@ TabParent::RecvNotifyIMESelectedCompositionRect( } bool -TabParent::RecvNotifyIMESelection(const uint32_t& aSeqno, - const uint32_t& aAnchor, +TabParent::RecvNotifyIMESelection(const uint32_t& aAnchor, const uint32_t& aFocus, const mozilla::WritingMode& aWritingMode, const bool& aCausedByComposition) @@ -1932,29 +1927,27 @@ TabParent::RecvNotifyIMESelection(const uint32_t& aSeqno, if (!widget) return true; - if (aSeqno == mIMESeqno) { - mIMESelectionAnchor = aAnchor; - mIMESelectionFocus = aFocus; - mWritingMode = aWritingMode; - const nsIMEUpdatePreference updatePreference = - widget->GetIMEUpdatePreference(); - if (updatePreference.WantSelectionChange() && - (updatePreference.WantChangesCausedByComposition() || - !aCausedByComposition)) { - IMENotification notification(NOTIFY_IME_OF_SELECTION_CHANGE); - notification.mSelectionChangeData.mOffset = - std::min(mIMESelectionAnchor, mIMESelectionFocus); - notification.mSelectionChangeData.mLength = - mIMESelectionAnchor > mIMESelectionFocus ? - mIMESelectionAnchor - mIMESelectionFocus : - mIMESelectionFocus - mIMESelectionAnchor; - notification.mSelectionChangeData.mReversed = - mIMESelectionFocus < mIMESelectionAnchor; - notification.mSelectionChangeData.SetWritingMode(mWritingMode); - notification.mSelectionChangeData.mCausedByComposition = - aCausedByComposition; - widget->NotifyIME(notification); - } + mIMESelectionAnchor = aAnchor; + mIMESelectionFocus = aFocus; + mWritingMode = aWritingMode; + const nsIMEUpdatePreference updatePreference = + widget->GetIMEUpdatePreference(); + if (updatePreference.WantSelectionChange() && + (updatePreference.WantChangesCausedByComposition() || + !aCausedByComposition)) { + IMENotification notification(NOTIFY_IME_OF_SELECTION_CHANGE); + notification.mSelectionChangeData.mOffset = + std::min(mIMESelectionAnchor, mIMESelectionFocus); + notification.mSelectionChangeData.mLength = + mIMESelectionAnchor > mIMESelectionFocus ? + mIMESelectionAnchor - mIMESelectionFocus : + mIMESelectionFocus - mIMESelectionAnchor; + notification.mSelectionChangeData.mReversed = + mIMESelectionFocus < mIMESelectionAnchor; + notification.mSelectionChangeData.SetWritingMode(mWritingMode); + notification.mSelectionChangeData.mCausedByComposition = + aCausedByComposition; + widget->NotifyIME(notification); } return true; } @@ -2298,7 +2291,6 @@ TabParent::SendCompositionEvent(WidgetCompositionEvent& event) mIMEEventCountAfterEnding++; return true; } - event.mSeqno = ++mIMESeqno; return PBrowserParent::SendCompositionEvent(event); } @@ -2328,7 +2320,6 @@ TabParent::SendCompositionChangeEvent(WidgetCompositionEvent& event) mIMECompositionStart + event.mData.Length(); mIMEComposing = !event.CausesDOMCompositionEndEvent(); - event.mSeqno = ++mIMESeqno; return PBrowserParent::SendCompositionEvent(event); } @@ -2340,7 +2331,6 @@ TabParent::SendSelectionEvent(WidgetSelectionEvent& event) } mIMESelectionAnchor = event.mOffset + (event.mReversed ? event.mLength : 0); mIMESelectionFocus = event.mOffset + (!event.mReversed ? event.mLength : 0); - event.mSeqno = ++mIMESeqno; return PBrowserParent::SendSelectionEvent(event); } diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 81e0c7e1654..4f1667d656c 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -161,8 +161,8 @@ public: InfallibleTArray&& aCpows, const IPC::Principal& aPrincipal) override; virtual bool RecvNotifyIMEFocus(const bool& aFocus, - nsIMEUpdatePreference* aPreference, - uint32_t* aSeqno) override; + nsIMEUpdatePreference* aPreference) + override; virtual bool RecvNotifyIMETextChange(const uint32_t& aStart, const uint32_t& aEnd, const uint32_t& aNewEnd, @@ -172,8 +172,7 @@ public: InfallibleTArray&& aRects, const uint32_t& aCaretOffset, const LayoutDeviceIntRect& aCaretRect) override; - virtual bool RecvNotifyIMESelection(const uint32_t& aSeqno, - const uint32_t& aAnchor, + virtual bool RecvNotifyIMESelection(const uint32_t& aAnchor, const uint32_t& aFocus, const mozilla::WritingMode& aWritingMode, const bool& aCausedByComposition) override; @@ -482,7 +481,6 @@ protected: // Compositions in almost all cases are small enough for nsAutoString nsAutoString mIMECompositionText; uint32_t mIMECompositionStart; - uint32_t mIMESeqno; uint32_t mIMECompositionRectOffset; InfallibleTArray mIMECompositionRects; diff --git a/security/certverifier/ExtendedValidation.cpp b/security/certverifier/ExtendedValidation.cpp index e6854e64a25..fefc1fe403b 100644 --- a/security/certverifier/ExtendedValidation.cpp +++ b/security/certverifier/ExtendedValidation.cpp @@ -1243,7 +1243,7 @@ IdentityInfoInit() continue; } #endif - PR_NOT_REACHED("Could not find EV root in NSS storage"); + //PR_NOT_REACHED("Could not find EV root in NSS storage"); continue; } diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index d8c52a998f9..3d1e6f9964f 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -137,9 +137,7 @@ PuppetWidget::InitIMEState() { MOZ_ASSERT(mTabChild); if (mNeedIMEStateInit) { - uint32_t chromeSeqno; - mTabChild->SendNotifyIMEFocus(false, &mIMEPreferenceOfParent, &chromeSeqno); - mIMELastBlurSeqno = mIMELastReceivedSeqno = chromeSeqno; + mTabChild->SendNotifyIMEFocus(false, &mIMEPreferenceOfParent); mNeedIMEStateInit = false; } } @@ -313,24 +311,6 @@ PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus) aStatus = nsEventStatus_eIgnore; - uint32_t seqno = kLatestSeqno; - switch (event->mClass) { - case eCompositionEventClass: - seqno = event->AsCompositionEvent()->mSeqno; - break; - case eSelectionEventClass: - seqno = event->AsSelectionEvent()->mSeqno; - break; - default: - break; - } - if (seqno != kLatestSeqno) { - mIMELastReceivedSeqno = seqno; - if (mIMELastReceivedSeqno < mIMELastBlurSeqno) { - return NS_OK; - } - } - if (mAttachedWidgetListener) { aStatus = mAttachedWidgetListener->HandleEvent(event, mUseAttachedEvents); } @@ -582,7 +562,6 @@ PuppetWidget::IMEEndComposition(bool aCancel) return NS_OK; } - compositionCommitEvent.mSeqno = mIMELastReceivedSeqno; DispatchEvent(&compositionCommitEvent, status); return NS_OK; } @@ -699,10 +678,8 @@ PuppetWidget::NotifyIMEOfFocusChange(bool aFocus) } } - uint32_t chromeSeqno; mIMEPreferenceOfParent = nsIMEUpdatePreference(); - if (!mTabChild->SendNotifyIMEFocus(aFocus, &mIMEPreferenceOfParent, - &chromeSeqno)) { + if (!mTabChild->SendNotifyIMEFocus(aFocus, &mIMEPreferenceOfParent)) { return NS_ERROR_FAILURE; } @@ -711,8 +688,6 @@ PuppetWidget::NotifyIMEOfFocusChange(bool aFocus) notification.mSelectionChangeData.mCausedByComposition = false; NotifyIMEOfSelectionChange(notification); // Update selection NotifyIMEOfEditorRect(); - } else { - mIMELastBlurSeqno = chromeSeqno; } return NS_OK; } @@ -897,7 +872,6 @@ PuppetWidget::NotifyIMEOfSelectionChange( return NS_ERROR_FAILURE; mTabChild->SendNotifyIMESelection( - mIMELastReceivedSeqno, aIMENotification.mSelectionChangeData.StartOffset(), aIMENotification.mSelectionChangeData.EndOffset(), aIMENotification.mSelectionChangeData.GetWritingMode(), diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index f43ca252a7e..a52d36946ff 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -309,13 +309,6 @@ private: mozilla::RefPtr mDrawTarget; // IME nsIMEUpdatePreference mIMEPreferenceOfParent; - // Latest seqno received through events - uint32_t mIMELastReceivedSeqno; - // Chrome's seqno value when last blur occurred - // arriving events with seqno up to this should be discarded - // Note that if seqno overflows (~50 days at 1 ms increment rate), - // events will be discarded until new focus/blur occurs - uint32_t mIMELastBlurSeqno; bool mNeedIMEStateInit; // The DPI of the screen corresponding to this widget diff --git a/widget/TextEvents.h b/widget/TextEvents.h index 5ccee7c0218..239697c5241 100644 --- a/widget/TextEvents.h +++ b/widget/TextEvents.h @@ -37,8 +37,6 @@ enum #undef NS_DEFINE_VK -#define kLatestSeqno UINT32_MAX - namespace mozilla { namespace dom { @@ -352,13 +350,9 @@ private: friend class mozilla::dom::PBrowserChild; WidgetCompositionEvent() - : mSeqno(kLatestSeqno) { } -public: - uint32_t mSeqno; - public: virtual WidgetCompositionEvent* AsCompositionEvent() override { @@ -368,7 +362,6 @@ public: WidgetCompositionEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eCompositionEventClass) - , mSeqno(kLatestSeqno) { // XXX compositionstart is cancelable in draft of DOM3 Events. // However, it doesn't make sense for us, we cannot cancel composition @@ -619,8 +612,7 @@ private: friend class mozilla::dom::PBrowserChild; WidgetSelectionEvent() - : mSeqno(kLatestSeqno) - , mOffset(0) + : mOffset(0) , mLength(0) , mReversed(false) , mExpandToClusterBoundary(true) @@ -628,9 +620,6 @@ private: { } -public: - uint32_t mSeqno; - public: virtual WidgetSelectionEvent* AsSelectionEvent() override { @@ -639,7 +628,6 @@ public: WidgetSelectionEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eSelectionEventClass) - , mSeqno(kLatestSeqno) , mOffset(0) , mLength(0) , mReversed(false) diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index 58320bf729e..9083d933961 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -521,7 +521,6 @@ struct ParamTraits static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mSeqno); WriteParam(aMsg, aParam.mData); bool hasRanges = !!aParam.mRanges; WriteParam(aMsg, hasRanges); @@ -535,7 +534,6 @@ struct ParamTraits bool hasRanges; if (!ReadParam(aMsg, aIter, static_cast(aResult)) || - !ReadParam(aMsg, aIter, &aResult->mSeqno) || !ReadParam(aMsg, aIter, &aResult->mData) || !ReadParam(aMsg, aIter, &hasRanges)) { return false; @@ -625,7 +623,6 @@ struct ParamTraits static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, static_cast(aParam)); - WriteParam(aMsg, aParam.mSeqno); WriteParam(aMsg, aParam.mOffset); WriteParam(aMsg, aParam.mLength); WriteParam(aMsg, aParam.mReversed); @@ -638,7 +635,6 @@ struct ParamTraits { return ReadParam(aMsg, aIter, static_cast(aResult)) && - ReadParam(aMsg, aIter, &aResult->mSeqno) && ReadParam(aMsg, aIter, &aResult->mOffset) && ReadParam(aMsg, aIter, &aResult->mLength) && ReadParam(aMsg, aIter, &aResult->mReversed) &&