Closed Bug 1794456 Opened 2 years ago Closed 2 years ago

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

Categories

(Core :: Layout, task)

task

Tracking

()

RESOLVED FIXED
107 Branch
Tracking Status
firefox107 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

References

Details

Attachments

(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
reverse_iterator.

Assignee: nobody → aethanyc
Status: NEW → ASSIGNED

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
nsFrameList::Enumerator.

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.
https://searchfox.org/mozilla-central/rev/ffa4d00965c5281def6d3ddcbcdf6259d38c9b9a/layout/generic/nsFrameList.h#402-407

Depends on D158985

Pushed by aethanyc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/7f0b494afb59
Part 1 - Reimplement reverse iterator for nsFrameList. r=emilio
https://hg.mozilla.org/integration/autoland/rev/58733fee05e0
Part 2 - Remove DEBUG members in nsFrameList::Slice and nsFrameList::Enumerator. r=emilio
https://hg.mozilla.org/integration/autoland/rev/dd14514b9e99
Part 3 - Support range-based for loop for nsFrameList::Slice. r=emilio
https://hg.mozilla.org/integration/autoland/rev/99069a63ec27
Part 4 - Remove unused nsFrameList::Enumerator. r=emilio
Regressions: 1795030
Regressions: 1795051
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: