From a2828099bf89a95cffaca6fa29f078b459961dd6 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Sat, 18 Jan 2014 12:27:14 +0900 Subject: [PATCH] Bug 835262 Add an option making nsTextStateManager keep alive even while our process is deactive r=smaug+emk --- dom/events/nsIMEStateManager.cpp | 5 +++++ widget/nsIWidget.h | 11 +++++++---- widget/windows/nsTextStore.cpp | 6 ++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/dom/events/nsIMEStateManager.cpp b/dom/events/nsIMEStateManager.cpp index 24cac5849f6..89733fcc84b 100644 --- a/dom/events/nsIMEStateManager.cpp +++ b/dom/events/nsIMEStateManager.cpp @@ -68,6 +68,10 @@ public: nsIContent* aContent); void Destroy(void); bool IsManaging(nsPresContext* aPresContext, nsIContent* aContent); + bool KeepAliveDuringDeactive() const + { + return !!(mObserving & nsIMEUpdatePreference::NOTIFY_DURING_DEACTIVE); + } nsCOMPtr mWidget; nsCOMPtr mSel; @@ -226,6 +230,7 @@ nsIMEStateManager::OnChangeFocusInternal(nsPresContext* aPresContext, } if (sTextStateObserver && + (aPresContext || !sTextStateObserver->KeepAliveDuringDeactive()) && !sTextStateObserver->IsManaging(aPresContext, aContent)) { DestroyTextStateManager(); } diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 3a90d334275..12b34d79ae4 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -214,6 +214,8 @@ enum nsTopLevelWidgetZPlacement { // for PlaceBehind() * If the IME implementation on a particular platform doesn't care about * NotifyIMEOfTextChange() and/or NotifyIME(NOTIFY_IME_OF_SELECTION_CHANGE), * they should set mWantUpdates to NOTIFY_NOTHING to avoid the cost. + * If the IME implementation needs notifications even while our process is + * deactive, it should also set NOTIFY_DURING_DEACTIVE. * * If mWantHints is true, PuppetWidget will forward the content of text fields * to the chrome process to be cached. This way we return the cached content @@ -224,13 +226,14 @@ enum nsTopLevelWidgetZPlacement { // for PlaceBehind() */ struct nsIMEUpdatePreference { - typedef int8_t Notifications; + typedef uint8_t Notifications; enum { - NOTIFY_NOTHING = 0x0000, - NOTIFY_SELECTION_CHANGE = 0x0001, - NOTIFY_TEXT_CHANGE = 0x0002 + NOTIFY_NOTHING = 0x00, + NOTIFY_SELECTION_CHANGE = 0x01, + NOTIFY_TEXT_CHANGE = 0x02, + NOTIFY_DURING_DEACTIVE = 0x80 }; nsIMEUpdatePreference() diff --git a/widget/windows/nsTextStore.cpp b/widget/windows/nsTextStore.cpp index 232e0d1244a..66c5a32a4d6 100644 --- a/widget/windows/nsTextStore.cpp +++ b/widget/windows/nsTextStore.cpp @@ -3046,13 +3046,15 @@ nsTextStore::OnFocusChange(bool aGotFocus, nsIMEUpdatePreference nsTextStore::GetIMEUpdatePreference() { - int8_t notifications = nsIMEUpdatePreference::NOTIFY_NOTHING; + nsIMEUpdatePreference::Notifications notifications = + nsIMEUpdatePreference::NOTIFY_NOTHING; if (sTsfThreadMgr && sTsfTextStore && sTsfTextStore->mDocumentMgr) { nsRefPtr docMgr; sTsfThreadMgr->GetFocus(getter_AddRefs(docMgr)); if (docMgr == sTsfTextStore->mDocumentMgr) { notifications = (nsIMEUpdatePreference::NOTIFY_SELECTION_CHANGE | - nsIMEUpdatePreference::NOTIFY_TEXT_CHANGE); + nsIMEUpdatePreference::NOTIFY_TEXT_CHANGE | + nsIMEUpdatePreference::NOTIFY_DURING_DEACTIVE); } } return nsIMEUpdatePreference(notifications, false);