bug 804927 - fix text control frame and accessibility issues. r=ehsan,tbsaunde a=akeybl
authorJonathan Kew <jkew@mozilla.com>
Sat, 03 Nov 2012 12:08:09 +0000
changeset 109796 3118742f6ea347f5761371e5473da7e5c82674a2
parent 109795 b53dbef72a5558a304b33925dfce8a6b89048a61
child 109797 a61dc39f8fd7abef67956899f5dc7c4293ff5e92
push id1679
push userjkew@mozilla.com
push dateFri, 09 Nov 2012 18:50:54 +0000
treeherdermozilla-beta@3118742f6ea3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, tbsaunde, akeybl
bugs804927
milestone17.0
bug 804927 - fix text control frame and accessibility issues. r=ehsan,tbsaunde a=akeybl
accessible/src/generic/HyperTextAccessible.cpp
content/html/content/src/nsTextEditorState.cpp
--- a/accessible/src/generic/HyperTextAccessible.cpp
+++ b/accessible/src/generic/HyperTextAccessible.cpp
@@ -1493,16 +1493,24 @@ HyperTextAccessible::GetEditor() const
 
 /**
   * =================== Caret & Selection ======================
   */
 
 nsresult
 HyperTextAccessible::SetSelectionRange(int32_t aStartPos, int32_t aEndPos)
 {
+  // Before setting the selection range, we need to ensure that the editor
+  // is initialized. (See bug 804927.)
+  // Otherwise, it's possible that lazy editor initialization will override
+  // the selection we set here and leave the caret at the end of the text.
+  // By calling GetEditor here, we ensure that editor initialization is
+  // completed before we set the selection.
+  nsCOMPtr<nsIEditor> editor = GetEditor();
+
   bool isFocusable = InteractiveState() & states::FOCUSABLE;
 
   // If accessible is focusable then focus it before setting the selection to
   // neglect control's selection changes on focus if any (for example, inputs
   // that do select all on focus).
   // some input controls
   if (isFocusable)
     TakeFocus();
--- a/content/html/content/src/nsTextEditorState.cpp
+++ b/content/html/content/src/nsTextEditorState.cpp
@@ -1202,17 +1202,17 @@ nsTextEditorState::PrepareEditor(const n
     shouldInitializeEditor = true;
 
     // Create an editor
     newEditor = do_CreateInstance(kTextEditorCID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     preDestroyer.Init(newEditor);
 
     // Make sure we clear out the non-breaking space before we initialize the editor
-    rv = mBoundFrame->UpdateValueDisplay(false, true);
+    rv = mBoundFrame->UpdateValueDisplay(true, true);
     NS_ENSURE_SUCCESS(rv, rv);
   } else {
     if (aValue || !mEditorInitialized) {
       // Set the correct value in the root node
       rv = mBoundFrame->UpdateValueDisplay(true, !mEditorInitialized, aValue);
       NS_ENSURE_SUCCESS(rv, rv);
     }