Closed Bug 2089710 Opened 16 days ago Closed 15 days ago

Firefox incorrectly resolves percent heights on child of auto-sized multicol element, inside auto-sized flex or grid container

Categories

(Core :: Layout: Columns, defect)

defect

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: dholbert, Assigned: dholbert, NeedInfo)

References

Details

(Keywords: webcompat:platform-bug)

Attachments

(9 files, 1 external file, 1 obsolete file)

811 bytes, text/html
Details
36.49 KB, image/png
Details
783 bytes, text/html
Details
35.00 KB, image/png
Details
783 bytes, text/html
Details
35.38 KB, image/png
Details
786 bytes, text/html
Details
768 bytes, text/html
Details
796 bytes, text/html
Details
Attached file testcase 1 —

STR:

  1. Load attached testcase.

ACTUAL RESULTS:
The purple-bordered elements are the same height as their container (i.e. they honor their 100% height)

EXPECTED RESULTS:
The purple-bordered elements are the height of their content (cyan box).

This is the root cause of webcompat site-issue bug 2088487.

Chrome/Safari give EXPECTED RESULTS.
Firefox (release and Nightly) give ACTUAL RESULTS.

Just to illustrate that this isn't specific to column-oriented flex containers -- here's the same testcase with flex-direction:column removed. The layout ends up slightly different but the behavior-difference vs. Chrome/Safari remains.

Attached file testcase 3 (now using a grid) (obsolete) —

This also isn't specific to flexbox; it happens if the outer container is a grid, too, as shown in this testcase.

(er, adjusting a class name in testcase 3 for clarity)

Attachment #9675145 - Attachment is obsolete: true
Component: Layout: Flexbox → Layout: Columns
Summary: Firefox incorrectly resolves percent heights on child of auto-sized multicol element, inside auto-sized flex container → Firefox incorrectly resolves percent heights on child of auto-sized multicol element, inside auto-sized flex or grid container
No longer blocks: 2088487

For completeness, here's a testcase with display:block on the outer wrapper. This produces the expected rendering, with the percent size not being resolved.

Hmm, here's a variant of testcase 1 where I removed the multicol styling.

In this case, browsers agree that we do treat the percent height as resolvable.

Attachment #9675154 - Attachment description: testcase 5 (without multicol) → testcase 5 (without multicol, where browsers agree to resolve the percentages)
Attachment #9675154 - Attachment description: testcase 5 (without multicol, where browsers agree to resolve the percentages) → testcase 5 (row-oriented flex container, with child being a regular block, with percent-height children)

note:

  • testcase 6 is like testcase 1, with multicol removed.
  • testcase 5 is like testcase 2, with multicol removed.
  • Chrome, Safari, and Firefox agree with each other on how to render testcase 4, 5, and 6.
  • The fact that there's consensus to not resolve percentages in testcase 6 implies that we also shouldn't resolve percentages in testcase 1 (which confirms that we're wrong on that one). Fixing that (i.e. not-resolving-percentages in testcase 1) would fix the associated webcompat bug.
  • Having said that... the fact that browsers do resolve percentages in testcase 5 implies that Firefox is correct to resolve percentages in testcase 2 (and I think 3). Perhaps we should spin off Chrome/WebKit bugs for that. But that's followup; it just helps to properly-scope what beahvior should change here, which is perhaps just testcase 1.

hackbot: come up with a patch that makes Firefox treat the multicol container as having an indefinite height (for the purposes of resolving percent heights in its children), in testcase 1.

(The height should be treated as indefinite per css-flexbox-1 section 9.8 -- it's the main size of a flex item, and the flex item has an indefinite flex-basis, and is in a flex container with an indefinite main size.)

Flags: needinfo?(hackbot)

The percentage basis for content inside a multicol container came from the ColumnSetWrapper's ComputedBSize(), in two places:

  • nsBlockFrame::ReflowBlockFrame(): containing-block size for children of ::-moz-column-content.
  • nsColumnSetFrame::ReflowColumns(): containing-block size for the column boxes.

Neither checked ReflowInput::mFlags.mTreatBSizeAsIndefinite. nsFlexContainerFrame sets that flag on a flex item whose main size must be treated as indefinite (css-flexbox-1 §9.8: indefinite flex basis in a container with an indefinite main size). So percent heights inside a multicol flex item in an auto-height column flex container resolved against the item's flexed height instead of behaving as auto. Chrome and Safari treat them as auto, and so does Firefox when the item is a plain block.

Both places now use ComputedBSizeAsPercentageBasis(). That helper honors mTreatBSizeAsIndefinite and also mPercentageBasisInBlockAxis, the definite basis flex sets for fragmented flex items. This matches how ComputeContainingBlockRectangle() treats regular blocks.

Row flex and grid containers (testcases 2 and 3) don't change: no indefinite flag is set there, and comment 10 says Firefox's current rendering of those agrees with the non-multicol consensus.

Flags: needinfo?(hackbot)

at first glance, hackbot's patch looks reasonable. ni=me to get it finalized + landed, barring issues.

Flags: needinfo?(dholbert)
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #9675368 - Attachment description: Bug 2089710 - Honor the multicol container's percentage basis (e.g. flex's indefinite block-size) when resolving percent block-sizes inside columns. → Bug 2089710 - Treat block size as indefinite on a multicol element that is an auto-main-size flex item in an auto-sized flex container. r?#layout
Pushed by dholbert@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/13cb7320aa23 https://hg.mozilla.org/integration/autoland/rev/af92f1d5d496 Treat block size as indefinite on a multicol element that is an auto-main-size flex item in an auto-sized flex container. r=layout-reviewers,emilio
Blocks: 2088487
Status: ASSIGNED → RESOLVED
Closed: 15 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/64898 for changes under testing/web-platform/tests

Upstream PR merged by moz-wptsync-bot

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: