Closed Bug 1794456 Opened 4 months ago Closed 4 months ago

Support range-based for loop for nsFrameList::Slice, and remove nsFrameList::Enumerator


(Core :: Layout, task)




107 Branch
Tracking Status
firefox107 --- fixed


(Reporter: TYLin, Assigned: TYLin)




(4 files)

This bug concludes the trilogy of my nsFrameList clean up (previous in bug 1793826 and bug 1794035).

If we traverse a frame list via Iterator::operator--() repeatedly, when it
reaches the beginning of the list (mCurrent's previous sibiling is null), it
will start over from the end of the list. This behavior can be surprising, so it
is removed. Also, remove Iterator::mList since it's no longer needed.

We don't really need to rely on mozilla::ReverseIterator to implement
nsFrameList::reverse_iterator. We can abstract frame traversal operations as a
template parameter, and implement reverse_iterator directly. This is more
performant since mozilla::ReverseIterator makes a copy of the original iterator
when dereferencing the reverse iterator.

Iterator(nullptr) is now served as a end iterator for both the iterator and

Assignee: nobody → aethanyc

Since Slice::mEnd is the first frame that is NOT in the slice, so we only
support forward iteration, and it's sufficient to replace existing usages of

For those for loops iterating TableColFrame and TableColGroupFrame, we need to
explicitly check the validity of the iterator because they modify the frame list
while iterating. nsFrameList::Enumerator::End() has a hack for this.

Depends on D158985

Pushed by
Part 1 - Reimplement reverse iterator for nsFrameList. r=emilio
Part 2 - Remove DEBUG members in nsFrameList::Slice and nsFrameList::Enumerator. r=emilio
Part 3 - Support range-based for loop for nsFrameList::Slice. r=emilio
Part 4 - Remove unused nsFrameList::Enumerator. r=emilio
Regressions: 1795051
You need to log in before you can comment on or make changes to this bug.