diff -r 020a0670ef30 accessible/src/html/nsHyperTextAccessible.cpp
--- a/accessible/src/html/nsHyperTextAccessible.cpp Thu Apr 22 16:11:24 2010 +0200
+++ b/accessible/src/html/nsHyperTextAccessible.cpp Fri Apr 23 15:11:11 2010 -0400
@@ -64,6 +64,7 @@
#include "nsIScrollableFrame.h"
#include "nsISelection2.h"
#include "nsISelectionPrivate.h"
+#include "nsFocusManager.h"
#include "nsIServiceManager.h"
#include "nsTextFragment.h"
#include "gfxSkipChars.h"
@@ -1547,11 +1548,8 @@
nsresult
nsHyperTextAccessible::SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos)
{
- nsresult rv = TakeFocus();
- NS_ENSURE_SUCCESS(rv, rv);
-
// Set the selection
- SetSelectionBounds(0, aStartPos, aEndPos);
+ nsresult rv = SetSelectionBounds(0, aStartPos, aEndPos);
NS_ENSURE_SUCCESS(rv, rv);
// If range 0 was successfully set, clear any additional selection
@@ -1578,6 +1576,16 @@
nsISelectionController::SELECTION_FOCUS_REGION, PR_FALSE);
}
+ /* Now that selection is done, move the focus to the selection. */
+ nsCOMPtr fm = do_GetService(FOCUSMANAGER_CONTRACTID);
+ if (fm) {
+ nsCOMPtr shell = GetPresShell();
+ nsCOMPtr doc = shell->GetDocument();
+ nsCOMPtr window = doc->GetWindow();
+ nsIDOMElement* aElement;
+ fm->MoveFocus(window, /* element */ nsnull, nsIFocusManager::MOVEFOCUS_CARET, 0, &aElement);
+ }
+
return NS_OK;
}