Closed Bug 1494694 Opened 2 years ago Closed 2 years ago

FlexItem mainDeltaSize is not well-documented

Categories

(Core :: Layout: Flexbox, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: pbro, Assigned: bradwerth)

References

()

Details

Attachments

(1 file)

STR:
- open the test URL
data:text/html,<div style="display:flex"><div style="flex-basis:400px;flex-grow:1;max-width:500px;">test item</div></div>
- run the chrome-only API getAsFlexContainer on the parent <div> element
- access the only item in there (I think getLines()[0].getItems()[0] or something like this)
- check the main sizing properties returned.

In my case it returns:

mainBaseSize: 400 --> This makes sense, because flex-basis is 400px
​​
mainMaxSize: 500 --> This makes sense too, max-width:500px is defined too

mainDeltaSize: 1024 --> This does not make sense at all, the item's final size is 500px, and that should be equal to mainBaseSize + mainDeltaSize
Brad, this is the bug we discussed just now. Do you mind taking a look at why this might be?
Blocks: 1478396
Flags: needinfo?(bwerth)
Assignee: nobody → bwerth
Flags: needinfo?(bwerth)
Okay, in my determination, this is working as intended. It's explained here in a comment that I need to improve:

https://searchfox.org/mozilla-central/source/layout/generic/nsFlexContainerFrame.h#43

The mainDeltaSize is the value applied to the mainBaseSize, which is then clamped by the mainMinSize and mainMaxSize. You can think of this as how much the flex algorithm "wants" to adjust the base size, but might not be allowed to due to the min and max constraints. So the final size is base + delta, clamped. I argue that this is what we want, because we can always calculate the difference between the final size and the base size, but we need the delta value to provide insight into what size the item would have been without clamping.

I'm going to use this bug to improve the comment.
Summary: Chrome-only getAsFlexContainer returns an odd mainDeltaSize in a specific case → FlexItem mainDeltaSize is not well-documented
Comment on attachment 9012670 [details]
Bug 1494694: Improve a comment in the ComputedFlexItemInfo structure header. r=dholbert!

Daniel Holbert [:dholbert] has approved the revision.
Attachment #9012670 - Flags: review+
Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/72d5f7a7f6ec
Improve a comment in the ComputedFlexItemInfo structure header. r=dholbert
https://hg.mozilla.org/mozilla-central/rev/72d5f7a7f6ec
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.