Bug 835262 Add an option making nsTextStateManager keep alive even while our process is deactive r=smaug+emk
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 18 Jan 2014 12:27:14 +0900
changeset 164117 3e17b97b0c9ae1ff17099d78a9e48eb157e66513
parent 164116 288705e6fd293a3c16fdc3eaf5d480b11d96b6a1
child 164118 1c63f67bbaf11247b00233f95270098458dc632b
push id26026
push userphilringnalda@gmail.com
push dateSat, 18 Jan 2014 23:17:27 +0000
treeherdermozilla-central@61fd0f987cf2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs835262
milestone29.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 835262 Add an option making nsTextStateManager keep alive even while our process is deactive r=smaug+emk
dom/events/nsIMEStateManager.cpp
widget/nsIWidget.h
widget/windows/nsTextStore.cpp
--- a/dom/events/nsIMEStateManager.cpp
+++ b/dom/events/nsIMEStateManager.cpp
@@ -63,16 +63,20 @@ public:
   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE
   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
 
   void     Init(nsIWidget* aWidget,
                 nsPresContext* aPresContext,
                 nsIContent* aContent);
   void     Destroy(void);
   bool     IsManaging(nsPresContext* aPresContext, nsIContent* aContent);
+  bool     KeepAliveDuringDeactive() const
+  {
+    return !!(mObserving & nsIMEUpdatePreference::NOTIFY_DURING_DEACTIVE);
+  }
 
   nsCOMPtr<nsIWidget>            mWidget;
   nsCOMPtr<nsISelection>         mSel;
   nsCOMPtr<nsIContent>           mRootContent;
   nsCOMPtr<nsINode>              mEditableNode;
 
 private:
   void NotifyContentAdded(nsINode* aContainer, int32_t aStart, int32_t aEnd);
@@ -221,16 +225,17 @@ nsIMEStateManager::OnChangeFocusInternal
     // If we're deactivating, we shouldn't commit composition forcibly because
     // the user may want to continue the composition.
     if (aPresContext) {
       NotifyIME(REQUEST_TO_COMMIT_COMPOSITION, oldWidget);
     }
   }
 
   if (sTextStateObserver &&
+      (aPresContext || !sTextStateObserver->KeepAliveDuringDeactive()) &&
       !sTextStateObserver->IsManaging(aPresContext, aContent)) {
     DestroyTextStateManager();
   }
 
   if (!aPresContext) {
     return NS_OK;
   }
 
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -209,33 +209,36 @@ enum nsTopLevelWidgetZPlacement { // for
  * If mWantUpdates is not NOTIFY_NOTHING, nsTextStateManager will observe text
  * change and/or selection change and call nsIWidget::NotifyIMEOfTextChange()
  * and/or nsIWidget::NotifyIME(NOTIFY_IME_OF_SELECTION_CHANGE).
  * Please note that the text change observing cost is very expensive especially
  * on an HTML editor has focus.
  * 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
  * during query events. (see comments in bug 583976). This only makes sense
  * for IME implementations that do use query events, otherwise there's a
  * significant overhead. Platforms that don't use query events should set
  * mWantHints to false.
  */
 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()
     : mWantUpdates(NOTIFY_NOTHING), mWantHints(false)
   {
   }
   nsIMEUpdatePreference(Notifications aWantUpdates, bool aWantHints)
     : mWantUpdates(aWantUpdates), mWantHints(aWantHints)
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -3041,23 +3041,25 @@ nsTextStore::OnFocusChange(bool aGotFocu
   }
   return NS_OK;
 }
 
 // static
 nsIMEUpdatePreference
 nsTextStore::GetIMEUpdatePreference()
 {
-  int8_t notifications = nsIMEUpdatePreference::NOTIFY_NOTHING;
+  nsIMEUpdatePreference::Notifications notifications =
+    nsIMEUpdatePreference::NOTIFY_NOTHING;
   if (sTsfThreadMgr && sTsfTextStore && sTsfTextStore->mDocumentMgr) {
     nsRefPtr<ITfDocumentMgr> 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);
 }
 
 nsresult
 nsTextStore::OnTextChangeInternal(uint32_t aStart,
                                   uint32_t aOldEnd,