Closed Bug 189077 Opened 22 years ago Closed 22 years ago

Make nsImageFrame smaller

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.4alpha

People

(Reporter: hjtoi-bugzilla, Assigned: hjtoi-bugzilla)

Details

(Keywords: memory-footprint)

Attachments

(1 file, 2 obsolete files)

nsImageFrame has 6 PRPackedBool member variables. We can save a little space by
concerting them into a single variable and using its bits as truth values instead.
Attachment #111536 - Flags: superreview?(bzbarsky)
Attachment #111536 - Flags: review?(dbaron)
Status: NEW → ASSIGNED
Whiteboard: [fixinhand]
Target Milestone: --- → mozilla1.3beta
If you're going to use bits, why not use the 12 high frame state bits (of
mState) that are already there, reserved for implementations of nsIFrame?  See
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/layout/base/public/nsIFrame.h&rev=3.213&mark=226-228#216
Attached patch Use mState (obsolete) — Splinter Review
I have some concerns about this, and I have not yet fully investigated what is
happening. Maybe you who have more experience with layout can answer these...

1. nsImageFrame needs to set one bit in the constructor. But it was not
previously doing anything with mState in the constructor, so somebody else does
that. How can I ensure that the bit I set remains? I tested setting the value
of mState to my bit, and that apparently worked but I don't know if there are
subtle errors. If I just tried to |= my bit, mozilla.org did not lay out
correctly and I got assertions.

2. Is my usage of the high bits safe (I am not stomping on anyone's bits and
nobody is stomping on my bits)?
> If I just tried to |= my bit, mozilla.org did not lay out
> correctly and I got assertions.

Weird. Because frames are created with a zeroing |new| and so using "=" and "|="
right at initialization should be the same (unelss frames don't use a zeroing
|new| anymore?).

> How can I ensure that the bit I set remains?
[...]
> 2. Is my usage of the high bits safe (I am not stomping on anyone's bits and
> nobody is stomping on my bits)?

Both questions are the same. If you are inheriting from somebody or somebody is
inheriting from you, then the contract is that you honour the bits owned by
others below you. So, repeating, this means that the inheritance chain is
therefore safe.
Attached patch Final (?) fixSplinter Review
It seems the broken layout was a fluke, I have not been able to reproduce. This
patch seems to work, and I am just flipping a bit in mState and not stomping
the whole value in the constructor.
Attachment #111536 - Attachment is obsolete: true
Attachment #111991 - Attachment is obsolete: true
Attachment #112424 - Flags: superreview?(roc+moz)
Attachment #112424 - Flags: review?(dbaron)
Attachment #111536 - Flags: superreview?(bzbarsky)
Attachment #111536 - Flags: review?(dbaron)
Comment on attachment 112424 [details] [diff] [review]
Final (?) fix

sr=roc+moz
looks good

You could get Paper (aaronm) to review this if dbaron's too busy.
Attachment #112424 - Flags: superreview?(roc+moz) → superreview+
Comment on attachment 112424 [details] [diff] [review]
Final (?) fix

nothing but smaller goodness here :)
Attachment #112424 - Flags: review?(dbaron) → review+
Comment on attachment 112424 [details] [diff] [review]
Final (?) fix

Made nsImageFrame use the frame state bits for its state, which allowed me to
get rid of members that were needlessly bloating the class.

I have run the precheckin tests and have had this change in my tree for a while
and I haven't noticed any problems.

Risks: typo nobody has noticed, or somebody else uses these exact bits in the
frame state that I din't notice. I think the risks are very low.
Attachment #112424 - Flags: approval1.3b?
Comment on attachment 112424 [details] [diff] [review]
Final (?) fix

Please hold this cleanup until we open for 1.4alpha. Thanks.
Attachment #112424 - Flags: approval1.3b? → approval1.3b-
Target Milestone: mozilla1.3beta → mozilla1.4alpha
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Whiteboard: [fixinhand]
eep. See bug 83774 (nsImageFrame is down to _3_ PRPackedBools there.....)
But now we have zero (0) PRPackedBools, so this is smaller. Or am I missing
something?
Hm.... it is indeed 4 bytes smaller.

I'd missed the fact that you moved all that stuff into the frame state instead
of adding another bitfield.  OK.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: