Bug 1633448: part 7) Add `StyledRanges::UnregisterSelection`. r=hsivonen

One step closer towards privatizing `StyledRanges::mRanges`.

Depends on D73234

Differential Revision: https://phabricator.services.mozilla.com/D73430
This commit is contained in:
Mirko Brodesser 2020-05-04 10:11:13 +00:00
Родитель c6b90540b1
Коммит c4ed6f536e
2 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -541,10 +541,7 @@ Selection::~Selection() { Disconnect(); }
void Selection::Disconnect() {
SetAnchorFocusRange(-1);
uint32_t count = mStyledRanges.mRanges.Length();
for (uint32_t i = 0; i < count; ++i) {
mStyledRanges.mRanges[i].mRange->UnregisterSelection();
}
mStyledRanges.UnregisterSelection();
if (mAutoScrollTimer) {
mAutoScrollTimer->Stop();
@ -1109,8 +1106,8 @@ nsresult Selection::RemoveCollapsedRanges() {
nsresult Selection::Clear(nsPresContext* aPresContext) {
SetAnchorFocusRange(-1);
mStyledRanges.UnregisterSelection();
for (uint32_t i = 0; i < mStyledRanges.mRanges.Length(); ++i) {
mStyledRanges.mRanges[i].mRange->UnregisterSelection();
SelectFrames(aPresContext, mStyledRanges.mRanges[i].mRange, false);
}
mStyledRanges.mRanges.Clear();
@ -1749,6 +1746,13 @@ void Selection::SetAncestorLimiter(nsIContent* aLimiter) {
}
}
void Selection::StyledRanges::UnregisterSelection() {
uint32_t count = mRanges.Length();
for (uint32_t i = 0; i < count; ++i) {
mRanges[i].mRange->UnregisterSelection();
}
}
StyledRange* Selection::StyledRanges::FindRangeData(nsRange* aRange) {
NS_ENSURE_TRUE(aRange, nullptr);
for (uint32_t i = 0; i < mRanges.Length(); i++) {

Просмотреть файл

@ -841,6 +841,8 @@ class Selection final : public nsSupportsWeakReference,
static nsresult SubtractRange(StyledRange& aRange, nsRange& aSubtract,
nsTArray<StyledRange>* aOutput);
void UnregisterSelection();
// These are the ranges inside this selection. They are kept sorted in order
// of DOM start position.
//