Bug 405951. Missing content in Thunderbird window. r=surkov, a=blocking1.9
--- a/accessible/src/base/nsCaretAccessible.cpp
+++ b/accessible/src/base/nsCaretAccessible.cpp
@@ -85,16 +85,18 @@ nsresult nsCaretAccessible::ClearControl
mCurrentControl = nsnull;
return selPrivate->RemoveSelectionListener(this);
}
nsresult nsCaretAccessible::SetControlSelectionListener(nsIDOMNode *aCurrentNode)
{
NS_ENSURE_TRUE(mRootAccessible, NS_ERROR_FAILURE);
+ ClearControlSelectionListener();
+
mCurrentControl = aCurrentNode;
mLastTextAccessible = nsnull;
// When focus moves such that the caret is part of a new frame selection
// this removes the old selection listener and attaches a new one for the current focus
nsCOMPtr<nsIPresShell> presShell =
mRootAccessible->GetPresShellFor(aCurrentNode);
if (!presShell)
@@ -118,26 +120,27 @@ nsresult nsCaretAccessible::SetControlSe
nsCOMPtr<nsISelectionController> selCon;
frame->GetSelectionController(presContext, getter_AddRefs(selCon));
NS_ENSURE_TRUE(selCon, NS_ERROR_FAILURE);
nsCOMPtr<nsISelection> domSel;
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel));
- ClearControlSelectionListener();
nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(domSel));
NS_ENSURE_TRUE(selPrivate, NS_ERROR_FAILURE);
mCurrentControlSelection = do_GetWeakReference(domSel);
return selPrivate->AddSelectionListener(this);
}
nsresult nsCaretAccessible::AddDocSelectionListener(nsIDOMDocument *aDoc)
{
+ NS_ENSURE_TRUE(mRootAccessible, NS_ERROR_FAILURE);
+
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(doc->GetPrimaryShell());
NS_ENSURE_TRUE(selCon, NS_ERROR_FAILURE);
nsCOMPtr<nsISelection> domSel;
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel));
nsCOMPtr<nsISelectionPrivate> selPrivate = do_QueryInterface(domSel);