diff --git a/accessible/src/base/nsCaretAccessible.cpp b/accessible/src/base/nsCaretAccessible.cpp index 7d20365af48..8ce7cd8d36c 100644 --- a/accessible/src/base/nsCaretAccessible.cpp +++ b/accessible/src/base/nsCaretAccessible.cpp @@ -90,6 +90,8 @@ nsresult nsCaretAccessible::SetControlSelectionListener(nsIDOMNode *aCurrentNode { NS_ENSURE_TRUE(mRootAccessible, NS_ERROR_FAILURE); + ClearControlSelectionListener(); + mCurrentControl = aCurrentNode; mLastTextAccessible = nsnull; @@ -123,7 +125,6 @@ nsresult nsCaretAccessible::SetControlSelectionListener(nsIDOMNode *aCurrentNode nsCOMPtr domSel; selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel)); - ClearControlSelectionListener(); nsCOMPtr selPrivate(do_QueryInterface(domSel)); NS_ENSURE_TRUE(selPrivate, NS_ERROR_FAILURE); @@ -133,6 +134,8 @@ nsresult nsCaretAccessible::SetControlSelectionListener(nsIDOMNode *aCurrentNode nsresult nsCaretAccessible::AddDocSelectionListener(nsIDOMDocument *aDoc) { + NS_ENSURE_TRUE(mRootAccessible, NS_ERROR_FAILURE); + nsCOMPtr doc = do_QueryInterface(aDoc); NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); nsCOMPtr selCon = do_QueryInterface(doc->GetPrimaryShell());