#433: M1368269 M1400399

This commit is contained in:
Cameron Kaiser 2017-09-23 15:45:05 -07:00
parent e13d43ac6a
commit ea7b13db83
4 changed files with 24 additions and 27 deletions

View File

@ -48,26 +48,20 @@ SelectionManager::SelectionManager() :
void
SelectionManager::ClearControlSelectionListener()
{
if (!mCurrCtrlFrame)
return;
const nsFrameSelection* frameSel = mCurrCtrlFrame->GetConstFrameSelection();
NS_ASSERTION(frameSel, "No frame selection for the element!");
mCurrCtrlFrame = nullptr;
if (!frameSel)
return;
// Remove 'this' registered as selection listener for the normal selection.
Selection* normalSel =
frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL);
normalSel->RemoveSelectionListener(this);
nsCOMPtr<nsISelection> normalSel = do_QueryReferent(mCurrCtrlNormalSel);
if (normalSel) {
normalSel->AsSelection()->RemoveSelectionListener(this);
mCurrCtrlNormalSel = nullptr;
}
// Remove 'this' registered as selection listener for the spellcheck
// selection.
Selection* spellSel =
frameSel->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
spellSel->RemoveSelectionListener(this);
nsCOMPtr<nsISelection> spellSel = do_QueryReferent(mCurrCtrlSpellSel);
if (spellSel) {
spellSel->AsSelection()->RemoveSelectionListener(this);
mCurrCtrlSpellSel = nullptr;
}
}
void
@ -78,24 +72,26 @@ SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm)
// the current focus.
ClearControlSelectionListener();
mCurrCtrlFrame = aFocusedElm->GetPrimaryFrame();
if (!mCurrCtrlFrame)
nsIFrame* controlFrame = aFocusedElm->GetPrimaryFrame();
if (!controlFrame)
return;
const nsFrameSelection* frameSel = mCurrCtrlFrame->GetConstFrameSelection();
const nsFrameSelection* frameSel = controlFrame->GetConstFrameSelection();
NS_ASSERTION(frameSel, "No frame selection for focused element!");
if (!frameSel)
return;
// Register 'this' as selection listener for the normal selection.
Selection* normalSel =
nsCOMPtr<nsISelection> normalSel =
frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL);
normalSel->AddSelectionListener(this);
normalSel->AsSelection()->AddSelectionListener(this);
mCurrCtrlNormalSel = do_GetWeakReference(normalSel);
// Register 'this' as selection listener for the spell check selection.
Selection* spellSel =
nsCOMPtr<nsISelection> spellSel =
frameSel->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
spellSel->AddSelectionListener(this);
spellSel->AsSelection()->AddSelectionListener(this);
mCurrCtrlSpellSel = do_GetWeakReference(spellSel);
}
void

View File

@ -120,10 +120,11 @@ protected:
void ProcessSelectionChanged(SelData* aSelData);
private:
// Currently focused control.
nsWeakFrame mCurrCtrlFrame;
int32_t mCaretOffset;
HyperTextAccessible* mAccWithCaret;
// Currently focused controls.
nsWeakPtr mCurrCtrlNormalSel;
nsWeakPtr mCurrCtrlSpellSel;
};
} // namespace a11y

View File

@ -145,7 +145,7 @@ XULTreeAccessible::Value(nsString& aValue)
void
XULTreeAccessible::Shutdown()
{
if (!mDoc->IsDefunct()) {
if (mDoc && !mDoc->IsDefunct()) {
UnbindCacheEntriesFromDocument(mAccessibleCache);
}

View File

@ -276,7 +276,7 @@ NS_IMPL_RELEASE_INHERITED(XULTreeGridRowAccessible,
void
XULTreeGridRowAccessible::Shutdown()
{
if (!mDoc->IsDefunct()) {
if (mDoc && !mDoc->IsDefunct()) {
UnbindCacheEntriesFromDocument(mAccessibleCache);
}