Bug 1667626 [wpt PR 25805] - [css-flex] Pass a ConstraintSpace to ortho_table.Compute...
commitc504cea279c3d7ff78ed0e4f14ab9fafdf6ab2b5
authorDavid Grogan <dgrogan@chromium.org>
Wed, 30 Sep 2020 22:07:39 +0000 (30 22:07 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Fri, 2 Oct 2020 12:32:40 +0000 (2 12:32 +0000)
treec823ad07366fb3c06c60a4054b7a9c35e49e7579
parent2b0dc7a31f8af95f24671fc7ad91aa9a8091051b
Bug 1667626 [wpt PR 25805] - [css-flex] Pass a ConstraintSpace to ortho_table.ComputeMinMaxSizes(), a=testonly

Automatic update from web-platform-tests
[css-flex] Pass a ConstraintSpace to ortho_table.ComputeMinMaxSizes()

ComputeMinMaxSizes needs a ConstraintSpace when the child is not in a
parallel writing mode. Flex wasn't providing one when it retrieved a
table's intrinsic min size.

Before this bug was introduced, flex was calling
ComputeMinAndMaxContentContribution(..., table, ...) instead of
table.ComputeMinMaxSizes(...). ComputeMinAndMaxContentContribution
builds its own ConstraintSpace for ortho items, so flex didn't need to
provide one.

We originally switched from ComputeMinAndMaxContentContribution to
table.ComputeMinMaxSizes because:

* One input to the flex algorithm is the item's used min-width (for a
  row flexbox). The flex algorithm will never assign a flex item a width
  smaller than its used min-width. For most elements, we get this value
  via ResolveMinInlineLength(..., style.LogicalMinWidth(), ...).

* But table's used min-width is defined specially to be "the greater of
  the resolved min-width, CAPMIN, and GRIDMIN". So to get the
  table-as-flex-item's used min-width, we need to retrieve max(CAPMIN,
  GRIDMIN) in addition to resolving style.LogicalMinWidth from the
  above step.

* ComputeMinAndMaxContentContribution(table).min returns max(CAPMIN,
  GRIDMIN, style.LogicalWidth()). I.e. it obeys any specified width on
  the table.

* But table.ComputeMinMaxSizes().min returns only max(CAPMIN, GRIDMIN)[1],
  which is what we want.

In the example below, the flexbox will try to shrink the table's width
to 75px. Using ComputeMinAndMaxContentContribution for the table's
min-width computation would result in the table being 100px wide. Using
table.ComputeMinMaxSizes would make it 75px wide. 75px is correct.

<div style="display: flex; width: 75px;">
  <table style="width: 100px; min-width: 0px;">
    <td>
      <div style="float: left; width:50px"></div>
      <div style="float: left; width:50px"></div>
    </td>
  </table>
</div>
https://jsfiddle.net/dgrogan/gwu4ac82/3/

[1] This is actually not true today but is true for TablesNG. Switching
to table.ComputeMinMaxSizes gets us closer.

Bug: 1128262
Fixed: 1131890
Change-Id: Ie5a4eac97e4a6a2e96104397bd5c5ec483d40e78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2433594
Commit-Queue: David Grogan <dgrogan@chromium.org>
Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811216}

--

wpt-commits: 2531feaeef0530450b7a7271b2bb4cc450edb831
wpt-pr: 25805
testing/web-platform/tests/css/css-flexbox/ortho-table-item-001.html [new file with mode: 0644]