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 339592 ef38f6f97d2f1cdad49149d48bf9989432f1f7c5
parent 339591 a21940e738361589daeeef7368e02a0a291fff4e
child 339593 fd7564bd9998e88960bcdaca6df3dff2160e459f
push id12762
push userbmo:rail@mozilla.com
push dateFri, 11 Mar 2016 19:47:45 +0000
reviewersesawin
bugs1254629
milestone48.0a1
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;