Bug 1732674 - Assert on tree mutations. r=jfkthame

This should hopefully help catch misuse. Fix an iterator that was living
for too long in ScrollIntoView.

Differential Revision: https://phabricator.services.mozilla.com/D128855
This commit is contained in:
Emilio Cobos Álvarez
2021-11-09 15:55:55 +00:00
parent 2aefad4cba
commit b9099538c1
2 changed files with 19 additions and 12 deletions

View File

@@ -3618,17 +3618,19 @@ void PresShell::DoScrollContentIntoView() {
bool haveRect = false;
bool useWholeLineHeightForInlines = data->mContentScrollVAxis.mWhenToScroll !=
WhenToScroll::IfNotFullyVisible;
// Reuse the same line iterator across calls to AccumulateFrameBounds. We set
// it every time we detect a new block (stored in prevBlock).
nsIFrame* prevBlock = nullptr;
nsAutoLineIterator lines;
// The last line we found a continuation on in |lines|. We assume that later
// continuations cannot come on earlier lines.
int32_t curLine = 0;
do {
AccumulateFrameBounds(container, frame, useWholeLineHeightForInlines,
frameBounds, haveRect, prevBlock, lines, curLine);
} while ((frame = frame->GetNextContinuation()));
{
nsIFrame* prevBlock = nullptr;
// Reuse the same line iterator across calls to AccumulateFrameBounds.
// We set it every time we detect a new block (stored in prevBlock).
nsAutoLineIterator lines;
// The last line we found a continuation on in |lines|. We assume that later
// continuations cannot come on earlier lines.
int32_t curLine = 0;
do {
AccumulateFrameBounds(container, frame, useWholeLineHeightForInlines,
frameBounds, haveRect, prevBlock, lines, curLine);
} while ((frame = frame->GetNextContinuation()));
}
ScrollFrameRectIntoView(container, frameBounds, scrollMargin,
data->mContentScrollVAxis, data->mContentScrollHAxis,