FlexItem mainDeltaSize is not well-documented

RESOLVED FIXED in Firefox 64

Status

()

defect
RESOLVED FIXED
7 months ago
7 months ago

People

(Reporter: pbro, Assigned: bradwerth)

Tracking

unspecified
mozilla64
Points:
---

Firefox Tracking Flags

(firefox64 fixed)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

7 months ago
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
(Reporter)

Comment 1

7 months ago
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)

Updated

7 months ago
Assignee: nobody → bwerth
Flags: needinfo?(bwerth)
(Assignee)

Comment 2

7 months ago
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.
(Assignee)

Updated

7 months ago
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+

Comment 5

7 months ago
Pushed by bwerth@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/72d5f7a7f6ec
Improve a comment in the ComputedFlexItemInfo structure header. r=dholbert

Comment 6

7 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/72d5f7a7f6ec
Status: NEW → RESOLVED
Last Resolved: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.