Closed Bug 1909761 Opened 7 months ago Closed 6 months ago

Pass percentage basis when computing intrinsic sizes

Categories

(Core :: Layout, task)

task

Tracking

()

RESOLVED FIXED
132 Branch
Tracking Status
firefox132 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

References

(Blocks 3 open bugs)

Details

Attachments

(6 files)

This tracks my work to refactor GetMinISize() and GetPrefISize() to accept a parameter of current frame's size so that it can be used as a percentage basis when computing child frame's intrinsic contribution.

I think this bug can at least fixes bug 1800991 and some tests on wpt.

Assignee: nobody → aethanyc
Depends on: 1909995
Depends on: 1910428
Depends on: 1911027
Blocks: 1910290
Blocks: 1911472
Blocks: 1748339
Blocks: 1912743
Blocks: 1231059

The main entry point for computing the intrinsic inline size of a frame is nsIFrame::IntrinsicISize(), which is called when computing the computed inline size of ReflowInput.

nsLayoutUtils::IntrinsicForAxis() is an underlying helper method used for calculating children's intrinsic inline size contributions. GetPercentBSize() is a helper used in nsLayoutUtils::IntrinsicForAxis() to compute the percentage basis when there is a percentage size in the block axis. GetPercentBSize() traverses up the containing block chain to find the first ancestor containing block with a definite block size. However, it does not find a definite block size if the containing block's definite block size is established via inline size and aspect-ratio (see bug 1800991).

The main idea of the patch is to pass the frame's definite block size (with min block size and max block size constraints considered) into IntrinsicISize(). This bug also enables potential future improvements allowing flex or grid items to use stretched block size as a percentage basis for the content inside the items (e.g. bug 1742042).

The patch stack doesn't handle all the edge cases where IntrinsicISize(), GetPrefISize, and GetMinISize() need a percentage basis. For example, AddIntrinsicSizeOffset() requires more refactor to construct percentage basis easily. After that, we can fix bug 1231059 by removing GetPercentBSize().

Capitalize the name of lambda expressions to make them look like functions
rather than variables.

Rename and improve GetContentEdgeToBoxSizing since I feel the indentation
makes it difficult to read. Also, rename the local Maybe<LogicalSize> storing
the result of the lambda.

This patch doesn't change behavior.

This patch changes the signature to GetMinISize(), GetPrefISize(),
IntrinsicISize by adding a helper struct as a preparation. Then we can just
add more data such as a percentage basis to the struct without altering the
signature in the future.

When passing IntrinsicSizeInput struct down to another helper method, we
generally just pass the original one if the method is computing the intrinsic
size of our own or our anonymous children. If the method is computing our
children's intrinsic contribution, we'll need to create a brand new
IntrinsicSizeInput for our children.

Another preparation patch in order to pass down a percentage basis when
computing intrinsic size.

A percentage basis is needed to resolve percentage block size when computing
children's intrinsic inline size contributions. This is necessary for a child or
descendants with a preferred aspect-ratio so that the block size can transfer
through the aspect-ratio to become an intrinsic inline size.

The change in nsFlexContainerFrame::ComputeIntrinsicISize() is necessary to
keep us passing
testing/web-platform/tests/css/css-flexbox/image-nested-within-definite-column-flexbox.html.

The change in nsPlaceholderFrame::AddFloatToIntrinsicISizeData() is necessary
to keep us passing
testing/web-platform/tests/css/css-sizing/intrinsic-percent-replaced-dynamic-010.html.

GetISizeInfo() in BasicTableLayoutStrategy.cpp is modified to pass table cell
frame's bsize as percentage basis. Otherwise,
layout/reftests/bugs/522632-1.html fails. This is our current behavior, but it
is bug 1542098.

All the tests pass in Google Chrome. They fail in the current Firefox Nightly
but will pass with the patches in this bug.

intrinsic-percent-replaced-{012,013,014}.html are adapted from the second
testcase in bug 1231059 comment 0.

intrinsic-percent-replaced-{015,016}.html are adapted from the testcase in bug
1800991 comment 2.

intrinsic-percent-replaced-017.html is adapted from bug 1910290 comment 7.

Blocks: 1822065
Pushed by aethanyc@gmail.com: https://hg.mozilla.org/integration/autoland/rev/4e7f22f43bb4 Part 1 - Improve lambda expressions in nsLayoutUtils::IntrinsicForAxis(). r=dholbert https://hg.mozilla.org/integration/autoland/rev/8de556490289 Part 2 - Create a helper struct IntrinsicSizeInput to aggregate needed data when computing intrinsic inline size. r=dholbert https://hg.mozilla.org/integration/autoland/rev/38d1e5eda09d Part 3 - Use IntrinsicSizeInput for AddInlineMinISize() and AddInlinePrefISize(). r=dholbert https://hg.mozilla.org/integration/autoland/rev/3f48c106bff9 Part 4 - Construct a percentage basis when computing children's intrinsic inline size contributions. r=dholbert https://hg.mozilla.org/integration/autoland/rev/d2dcf159185b Part 5 - Add web-platform reftests for percentage resolution during intrinsic size computation. r=dholbert https://hg.mozilla.org/integration/autoland/rev/1e9f47784a54 Part 6 - Delete or improve obsolete comments in layout. r=layout-reviewers,emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/47832 for changes under testing/web-platform/tests
Upstream PR was closed without merging
Pushed by aethanyc@gmail.com: https://hg.mozilla.org/integration/autoland/rev/d0f7ac5c6dc9 Part 1 - Improve lambda expressions in nsLayoutUtils::IntrinsicForAxis(). r=dholbert https://hg.mozilla.org/integration/autoland/rev/9c9289d5bffc Part 2 - Create a helper struct IntrinsicSizeInput to aggregate needed data when computing intrinsic inline size. r=dholbert https://hg.mozilla.org/integration/autoland/rev/f531438e13a4 Part 3 - Use IntrinsicSizeInput for AddInlineMinISize() and AddInlinePrefISize(). r=dholbert https://hg.mozilla.org/integration/autoland/rev/b509d1a77c27 Part 4 - Construct a percentage basis when computing children's intrinsic inline size contributions. r=dholbert https://hg.mozilla.org/integration/autoland/rev/4646bfebde8f Part 5 - Add web-platform reftests for percentage resolution during intrinsic size computation. r=dholbert https://hg.mozilla.org/integration/autoland/rev/d0336fee53a3 Part 6 - Delete or improve obsolete comments in layout. r=layout-reviewers,emilio
Flags: needinfo?(aethanyc)
Upstream PR merged by moz-wptsync-bot
No longer blocks: 1822065
Duplicate of this bug: 1822065
No longer blocks: 1910290
Duplicate of this bug: 1910290
No longer blocks: 1800991
Duplicate of this bug: 1800991
Blocks: 1917144
Regressions: 1918576
Regressions: 1919220
No longer duplicate of this bug: 1910290
Regressions: 1926015
Blocks: 1910290
Regressions: 1931491
Regressions: 1931838
Regressions: 1934532
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: