Bug 1254629 - Ensure content root is in document when flushing IME changes; r=esawin
authorJim Chen <nchen@mozilla.com>
Fri, 11 Mar 2016 13:47:22 -0500
changeset 288331 ef38f6f97d2f1cdad49149d48bf9989432f1f7c5
parent 288330 a21940e738361589daeeef7368e02a0a291fff4e
child 288332 fd7564bd9998e88960bcdaca6df3dff2160e459f
push id30079
push userryanvm@gmail.com
push dateSat, 12 Mar 2016 20:24:19 +0000
treeherdermozilla-central@d1d47ba19ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1254629
milestone48.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 1254629 - Ensure content root is in document when flushing IME changes; r=esawin One work-around for the bug is to ensure that our content root is in a document when flushing IME changes, because when an input becomes hidden, the previous content root is removed from the document.
widget/android/nsWindow.cpp
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -2686,16 +2686,20 @@ nsWindow::GeckoViewSupport::FlushIMEChan
 
     nsCOMPtr<nsISelection> imeSelection;
     nsCOMPtr<nsIContent> imeRoot;
 
     // If we are receiving notifications, we must have selection/root content.
     MOZ_ALWAYS_TRUE(NS_SUCCEEDED(IMEStateManager::GetFocusSelectionAndRoot(
             getter_AddRefs(imeSelection), getter_AddRefs(imeRoot))));
 
+    // Make sure we still have a valid selection/root. We can potentially get
+    // a stale selection/root if the editor becomes hidden, for example.
+    NS_ENSURE_TRUE_VOID(imeRoot->IsInComposedDoc());
+
     RefPtr<nsWindow> kungFuDeathGrip(&window);
     window.UserActivity();
 
     struct TextRecord {
         nsString text;
         int32_t start;
         int32_t oldEnd;
         int32_t newEnd;