applied bug1400399_pm.diff

This commit is contained in:
2018-07-12 13:46:09 +08:00
parent da64af5f36
commit 0f872f7503
2 changed files with 22 additions and 26 deletions
+19 -24
View File
@@ -48,26 +48,21 @@ 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 +73,24 @@ 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 =
frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL);
normalSel->AddSelectionListener(this);
nsCOMPtr<nsISelection> normalSel = frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL);
normalSel->AsSelection()->AddSelectionListener(this);
mCurrCtrlNormalSel = do_GetWeakReference(normalSel);
// Register 'this' as selection listener for the spell check selection.
Selection* spellSel =
frameSel->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
spellSel->AddSelectionListener(this);
nsCOMPtr<nsISelection> spellSel = frameSel->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
spellSel->AsSelection()->AddSelectionListener(this);
mCurrCtrlSpellSel = do_GetWeakReference(spellSel);
}
void
+3 -2
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