зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1635709: part 11) Factor removing generated ranges out from `AutoPrepareFocusRange`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D74857
This commit is contained in:
Родитель
cb2a7735a3
Коммит
3310444867
|
@ -277,23 +277,28 @@ struct MOZ_RAII AutoPrepareFocusRange {
|
|||
range->SetIsGenerated(false);
|
||||
aSelection->mAnchorFocusRange = range;
|
||||
|
||||
// Remove all generated ranges (including the old mAnchorFocusRange).
|
||||
RefPtr<nsPresContext> presContext = aSelection->GetPresContext();
|
||||
size_t i = len;
|
||||
while (i--) {
|
||||
range = aSelection->mStyledRanges.mRanges[i].mRange;
|
||||
if (range->IsGenerated()) {
|
||||
range->UnregisterSelection();
|
||||
aSelection->SelectFrames(presContext, range, false);
|
||||
aSelection->mStyledRanges.mRanges.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
RemoveGeneratedRanges(*aSelection);
|
||||
|
||||
if (aSelection->mFrameSelection) {
|
||||
aSelection->mFrameSelection->InvalidateDesiredCaretPos();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static void RemoveGeneratedRanges(Selection& aSelection) {
|
||||
RefPtr<nsPresContext> presContext = aSelection.GetPresContext();
|
||||
nsTArray<StyledRange>& ranges = aSelection.mStyledRanges.mRanges;
|
||||
size_t i = ranges.Length();
|
||||
while (i--) {
|
||||
nsRange* range = ranges[i].mRange;
|
||||
if (range->IsGenerated()) {
|
||||
range->UnregisterSelection();
|
||||
aSelection.SelectFrames(presContext, range, false);
|
||||
ranges.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @aParam aSelectionChangeReasons can be multiple of the reasons defined in
|
||||
nsISelectionListener.idl.
|
||||
|
|
Загрузка…
Ссылка в новой задаче