Bug 1385666, ensure layout is flushed when editor gets focus, r=masayuki
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 03 Aug 2017 19:36:58 +0300
changeset 372756 fc490a4565fc694307b634599fc2516aa11a6687
parent 372755 68ba6a81d15d7db42ece51ed201200f7c5789564
child 372757 c034e9ebd9e069652c8af6167406c66edda725b6
push id32283
push userkwierso@gmail.com
push dateFri, 04 Aug 2017 01:07:14 +0000
treeherdermozilla-central@32083f24a1bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1385666
milestone57.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 1385666, ensure layout is flushed when editor gets focus, r=masayuki
dom/events/EventStateManager.cpp
dom/events/IMEContentObserver.cpp
dom/events/IMEContentObserver.h
dom/events/IMEStateManager.cpp
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -485,17 +485,17 @@ EventStateManager::OnStopObservingConten
   NS_ENSURE_TRUE_VOID(mIMEContentObserver == aIMEContentObserver);
   mIMEContentObserver = nullptr;
 }
 
 void
 EventStateManager::TryToFlushPendingNotificationsToIME()
 {
   if (mIMEContentObserver) {
-    mIMEContentObserver->TryToFlushPendingNotifications();
+    mIMEContentObserver->TryToFlushPendingNotifications(true);
   }
 }
 
 static bool
 IsMessageMouseUserActivity(EventMessage aMessage)
 {
   return aMessage == eMouseMove ||
          aMessage == eMouseUp ||
--- a/dom/events/IMEContentObserver.cpp
+++ b/dom/events/IMEContentObserver.cpp
@@ -1734,20 +1734,20 @@ IMEContentObserver::FlushMergeableNotifi
   mQueuedSender = new IMENotificationSender(this);
   mQueuedSender->Dispatch(mDocShell);
   MOZ_LOG(sIMECOLog, LogLevel::Debug,
     ("0x%p IMEContentObserver::FlushMergeableNotifications(), "
      "finished", this));
 }
 
 void
-IMEContentObserver::TryToFlushPendingNotifications()
+IMEContentObserver::TryToFlushPendingNotifications(bool aAllowAsync)
 {
   if (!mQueuedSender || mSendingNotification != NOTIFY_IME_OF_NOTHING ||
-      XRE_IsContentProcess()) {
+      (XRE_IsContentProcess() && aAllowAsync)) {
     return;
   }
 
   MOZ_LOG(sIMECOLog, LogLevel::Debug,
     ("0x%p IMEContentObserver::TryToFlushPendingNotifications(), "
      "performing queued IMENotificationSender forcibly", this));
   RefPtr<IMENotificationSender> queuedSender = mQueuedSender;
   queuedSender->Run();
--- a/dom/events/IMEContentObserver.h
+++ b/dom/events/IMEContentObserver.h
@@ -150,19 +150,19 @@ public:
   nsPresContext* GetPresContext() const;
   nsresult GetSelectionAndRoot(nsISelection** aSelection,
                                nsIContent** aRoot) const;
 
   /**
    * TryToFlushPendingNotifications() should be called when pending events
    * should be flushed.  This tries to run the queued IMENotificationSender.
    * Doesn't do anything in child processes where flushing happens
-   * asynchronously.
+   * asynchronously unless aAllowAsync is false.
    */
-  void TryToFlushPendingNotifications();
+  void TryToFlushPendingNotifications(bool aAllowAsync);
 
   /**
    * MaybeNotifyCompositionEventHandled() posts composition event handled
    * notification into the pseudo queue.
    */
   void MaybeNotifyCompositionEventHandled();
 
 private:
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -647,17 +647,17 @@ IMEStateManager::OnChangeFocusInternal(n
   // editor.
   if (newState.mEnabled == IMEState::PLUGIN) {
     CreateIMEContentObserver(nullptr);
     if (sActiveIMEContentObserver) {
       MOZ_LOG(sISMLog, LogLevel::Debug,
         ("  OnChangeFocusInternal(), an "
          "IMEContentObserver instance is created for plugin and trying to "
          "flush its pending notifications..."));
-      sActiveIMEContentObserver->TryToFlushPendingNotifications();
+      sActiveIMEContentObserver->TryToFlushPendingNotifications(false);
     }
   }
 
   return NS_OK;
 }
 
 // static
 void
@@ -822,17 +822,17 @@ IMEStateManager::OnFocusInEditor(nsPresC
 
   CreateIMEContentObserver(&aEditorBase);
 
   // Let's flush the focus notification now.
   if (sActiveIMEContentObserver) {
     MOZ_LOG(sISMLog, LogLevel::Debug,
       ("  OnFocusInEditor(), new IMEContentObserver is "
        "created, trying to flush pending notifications..."));
-    sActiveIMEContentObserver->TryToFlushPendingNotifications();
+    sActiveIMEContentObserver->TryToFlushPendingNotifications(false);
   }
 }
 
 // static
 void
 IMEStateManager::OnEditorInitialized(EditorBase& aEditorBase)
 {
   if (!sActiveIMEContentObserver ||