Closed Bug 1903141 Opened 18 days ago Closed 16 days ago

Store floats list in a frame property rather than in nsBlockFrame::mFloats

Categories

(Core :: Layout: Block and Inline, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
129 Branch
Tracking Status
firefox129 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

References

Details

Attachments

(3 files)

Not every block frame contains float elements. I agree with this comment that we can save some memory by storing floats list in a frame property.

After Bug 1902542 Part 5 [1], the pushed floats list is deleted if it is empty.
Therefore, we can simplify MaybeHasFloats() as suggested in the XXX comment.

[1] https://hg.mozilla.org/mozilla-central/rev/52a9610fc9f2

Assignee: nobody → aethanyc
Status: NEW → ASSIGNED

EnsurePushedFloats() either returns the existing pushed floats list or creates
a new empty one. Therefore, it can never return nullptr.

On optimized builds for all desktop platforms, nsBlockFrame is 192 bytes, and
mFloats is 16 bytes. With this patch, we can reduce the size of nsBlockFrame
to 176 bytes, saving 8.33% memory on every nsBlockFrame and its derived
subclasses allocated.

On a real webpage like https://en.wikipedia.org/wiki/Firefox, about:memory
shows that we allocate 0.36 MB of nsBlockFrame consistently. After this patch,
we allocate 0.33 MB, saving approximately 30 KB (0.36 MB * 8.33%) of the memory.

Pushed by aethanyc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/ce65f1574c68
Part 1 - Simplify MaybeHasFloats() that checks pushed floats. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/fbd60d2007b0
Part 2 - Annotate EnsurePushedFloats() as MOZ_NONNULL_RETURN. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/ccd18b9b52fc
Part 3 - Store floats list in a frame property rather than in nsBlockFrame::mFloats. r=dholbert

Backed out for causing crashtest failures on nsSplittableFrame.cpp

Flags: needinfo?(aethanyc)
Flags: needinfo?(aethanyc)
Pushed by aethanyc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/edc66fd360d1
Part 1 - Simplify MaybeHasFloats() that checks pushed floats. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/cff1f22c9444
Part 2 - Annotate EnsurePushedFloats() as MOZ_NONNULL_RETURN. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/c2ba52894016
Part 3 - Store floats list in a frame property rather than in nsBlockFrame::mFloats. r=dholbert
Status: ASSIGNED → RESOLVED
Closed: 16 days ago
Resolution: --- → FIXED
Target Milestone: --- → 129 Branch
Regressions: 1904409
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: