Skip to content

[css-grid] Inconsitence of the "intrinsically-sized track" concept when using flexible tracks #3046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
javifernandez opened this issue Aug 23, 2018 · 13 comments
Assignees
Labels
Closed Accepted as Editorial Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-grid-1 Tracked in DoC

Comments

@javifernandez
Copy link
Contributor

javifernandez commented Aug 23, 2018

Lets consider the following example:

<div style="display: grid; font-family: Ahem; border: solid; width: 200px; grid: minmax(0px, 1fr) / 100px 100px; align-items: baseline">
  <div style="grid-column: 1; background: blue; font-size: 50px;  padding-bottom: 25px">É</div>
  <div style="grid-column: 2; background: green; grid-row: 1; writing-mode: vertical-lr">ÉÉ É ÉÉ ÉÉÉÉ É</div>
</div>

My doubt is whether or not the orthogonal item in column 2 can participate in baseline alignment along the column-axis, honoring the align-items property.

Assuming that a flexible track on a indefinite sized container should be considered as a content-sized track (this should be clarified in issues #3042 and #3044), in this case we have a situation where we can't determine this condition consistently during the different steps of the track sizing algorithm.

https://drafts.csswg.org/css-grid/#algo-overview

  1. Next, the track sizing algorithm resolves the sizes of the grid rows, using the grid column sizes calculated in the previous step and the effective column gap sizes after applying justify-content.

During step 2 we have to use the baseline shims so that they contribute to the size of the track; hence, we have to compute the baseline shims just before computing the tracks intrinsic sizes.

https://drafts.csswg.org/css-grid/#algo-baseline-shims

Shim baseline-aligned items so their intrinsic size contributions reflect their baseline alignment. For the items in each baseline-sharing group, add a “shim” (effectively, additional margin) on the start/end side (for first/last-baseline alignment) of each item so that, when start/end-aligned together their baselines align as specified.

It's important to notice that we implement this shim computation as part of the track sizing algorithm, so that we can run it again in step 3, if necessary (eg. orthogonal items). This is an implementation decision, since the spec doesn't specify when the baseline shims must be computed; it just state when they should be applied.

So, at this point, since we are under indefinite height, we should consider the flexible track as content-sized; hence, since the orthogonal item has 'auto' inline-size, there is a cyclic dependency that implies the item should not participate in baseline alignment along the column-axis.

https://drafts.csswg.org/css-grid/#column-align

If baseline alignment is specified on a grid item whose size in that axis depends on the size of an intrinsically-sized track (whose size is therefore dependent on both the item’s size and baseline alignment, creating a cyclic dependency), that item does not participate in baseline alignment, and instead uses its fallback alignment.

Then, we enter it step 3 of the grid sizing algorithm:

  1. Then, if the min-content contribution of any grid item has changed based on the row sizes and alignment calculated in step 2, re-resolve the sizes of the grid columns with the new min-content and max-content contributions (once only), using the grid row sizes calculated in the previous step along with the effective row gap sizes calculated by applying align-content.

We are indeed in this scenario, so we have to repeat steps 1 and 2. This will include (that's what we should clarify in this issue) the computation of the baseline shims. Although these shims shouldn't change because of the different sizes resolved in this step, it's possible that items that didn't participate in baseline before are now allowed to do so.

The key is that for this step 3, the height is not indefinite anymore, so theoretically, we shouldn't consider the flexible tracks as content sized. The result is that the orthogonal item participates now in the baseline alignment.

is this the behavior we want ? The following pictures shows how the example above would be rendered:

baseline-and-flex-tracks

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Aug 24, 2018
The new Baseline Alignment algorithm states that items with sizing
cyclic dependencies must be excluded from any baseline context they
participate in. One of these cyclic dependencies can happen with
intrinsic sized grid areas and relative items.

The grid spec states [1] that flex-sized tracks should be considered as
content-sized when the grid container has an indefinite size. We were
using the AvailableSize(direction) function to determine whether the
grid container is indefinite or not. However, this function doesn't
provide consistent results during the different phases of the grid
layout  logic.

The new Baseline Alignment logic is now integrated in the Grid Track
sizing algorithm. Hence, we need to ensure that an item that
participates in any baseline alignment context during the track sizing
also does during the alignment phase, at the end of the grid layout
logic.

However, the AvailableSize(direction) could indicate that the grid has
an indefinite size during the track sizing, but it returns a definite
size during alignment. This issue leads to inconsistencies regarding
the participation of an item in baseline alignment, so it may raises
the assertion of having a context, like it happens in the bugs this CL
tries to fix.

For inline-axis, we'll assume indefinite constraints only during
intrinsic size computation; afterwards, we'll always assume definite
size. This issue could imply that baseline shims are not considered to
compute the grid's intrinsic size, but are then used to calculate the
actual size of the grid tacks, which may lead to such tracks
overflowing the grid container.

In the case of block-axis sizing, we determine the indefinite or
definite size constraints during layout. However, the presence of
orthogonal grid items imply the execution of the 3rd step of the grid
sizing, repeating the execution of track sizing algorithm in both
directions. During this phase, we can't assume indefinite size
constraints anymore because block-axis has been determined already in
the previous 2 steps. While baseline shims computed in the previous
steps shouldn't vary even if the tracks' size change during this phase,
it's possible that items not participating in baseline alignment before
may do participate in this phase. The inclusion of new items in the
baseline context may indeed change the baseline shims, which will be
used to determine the tracks' size during this step.

This CL removes the early return that prevented he Baseline offsets to
be computed again during the step 3. This change assumes the already
mentioned inconsistencies, which I hope we can clarify in the issue [2]
I filed for the CSS WG.

[1] https://drafts.csswg.org/css-grid/#fr-unit
[2] w3c/csswg-drafts#3046

Bug: 867833, 874861, 876593
Change-Id: I668d399b920c9280a8e20b3e8362f562eded4770
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Aug 30, 2018
The new Baseline Alignment algorithm states that items with sizing
cyclic dependencies must be excluded from any baseline context they
participate in. One of these cyclic dependencies can happen with
intrinsic sized grid areas and relative items.

The grid spec states [1] that flex-sized tracks should be considered
as content-sized when the grid container has an indefinite size. We
were using the AvailableSize(direction) function to determine whether
the grid container is indefinite or not. However, this function may
provide different results during the different phases of the grid
layout logic. This issue causes assert violations like the one
described in the bugs listed below.

The new Baseline Alignment logic is now integrated in the Grid Track
sizing algorithm. Hence, we need to ensure that an item that
participates in any baseline alignment context during the track sizing
also does during the alignment phase, at the end of the grid layout
logic. In order to achieve that, this CL forces a new computation of
the Baseline offsets during the step 3 of the Grid sizing algorith,
since during this step the available space is not indefinite anymore.

It's worth mentioning that this change assumes the issue grid items
being excluded and included of Baseline Context during the different
phases of the Grid sizing algorithm, which I hope we can clarify in
the issue [2] I filed for the CSS WG.

[1] https://drafts.csswg.org/css-grid/#fr-unit
[2] w3c/csswg-drafts#3046

Bug: 867833, 874861, 876593
Change-Id: I668d399b920c9280a8e20b3e8362f562eded4770
aarongable pushed a commit to chromium/chromium that referenced this issue Aug 30, 2018
The new Baseline Alignment algorithm states that items with sizing
cyclic dependencies must be excluded from any baseline context they
participate in. One of these cyclic dependencies can happen with
intrinsic sized grid areas and relative items.

The grid spec states [1] that flex-sized tracks should be considered
as content-sized when the grid container has an indefinite size. We
were using the AvailableSize(direction) function to determine whether
the grid container is indefinite or not. However, this function may
provide different results during the different phases of the grid
layout logic. This issue causes assert violations like the one
described in the bugs listed below.

The new Baseline Alignment logic is now integrated in the Grid Track
sizing algorithm. Hence, we need to ensure that an item that
participates in any baseline alignment context during the track sizing
also does during the alignment phase, at the end of the grid layout
logic. In order to achieve that, this CL forces a new computation of
the Baseline offsets during the step 3 of the Grid sizing algorith,
since during this step the available space is not indefinite anymore.

It's worth mentioning that this change assumes the issue grid items
being excluded and included of Baseline Context during the different
phases of the Grid sizing algorithm, which I hope we can clarify in
the issue [2] I filed for the CSS WG.

[1] https://drafts.csswg.org/css-grid/#fr-unit
[2] w3c/csswg-drafts#3046

Bug: 867833, 874861, 876593
Change-Id: I668d399b920c9280a8e20b3e8362f562eded4770
Reviewed-on: https://chromium-review.googlesource.com/1177757
Reviewed-by: Sergio Villar <svillar@igalia.com>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Commit-Queue: Javier Fernandez <jfernandez@igalia.com>
Cr-Commit-Position: refs/heads/master@{#587799}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Aug 30, 2018
The new Baseline Alignment algorithm states that items with sizing
cyclic dependencies must be excluded from any baseline context they
participate in. One of these cyclic dependencies can happen with
intrinsic sized grid areas and relative items.

The grid spec states [1] that flex-sized tracks should be considered
as content-sized when the grid container has an indefinite size. We
were using the AvailableSize(direction) function to determine whether
the grid container is indefinite or not. However, this function may
provide different results during the different phases of the grid
layout logic. This issue causes assert violations like the one
described in the bugs listed below.

The new Baseline Alignment logic is now integrated in the Grid Track
sizing algorithm. Hence, we need to ensure that an item that
participates in any baseline alignment context during the track sizing
also does during the alignment phase, at the end of the grid layout
logic. In order to achieve that, this CL forces a new computation of
the Baseline offsets during the step 3 of the Grid sizing algorith,
since during this step the available space is not indefinite anymore.

It's worth mentioning that this change assumes the issue grid items
being excluded and included of Baseline Context during the different
phases of the Grid sizing algorithm, which I hope we can clarify in
the issue [2] I filed for the CSS WG.

[1] https://drafts.csswg.org/css-grid/#fr-unit
[2] w3c/csswg-drafts#3046

Bug: 867833, 874861, 876593
Change-Id: I668d399b920c9280a8e20b3e8362f562eded4770
Reviewed-on: https://chromium-review.googlesource.com/1177757
Reviewed-by: Sergio Villar <svillar@igalia.com>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Commit-Queue: Javier Fernandez <jfernandez@igalia.com>
Cr-Commit-Position: refs/heads/master@{#587799}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Aug 30, 2018
The new Baseline Alignment algorithm states that items with sizing
cyclic dependencies must be excluded from any baseline context they
participate in. One of these cyclic dependencies can happen with
intrinsic sized grid areas and relative items.

The grid spec states [1] that flex-sized tracks should be considered
as content-sized when the grid container has an indefinite size. We
were using the AvailableSize(direction) function to determine whether
the grid container is indefinite or not. However, this function may
provide different results during the different phases of the grid
layout logic. This issue causes assert violations like the one
described in the bugs listed below.

The new Baseline Alignment logic is now integrated in the Grid Track
sizing algorithm. Hence, we need to ensure that an item that
participates in any baseline alignment context during the track sizing
also does during the alignment phase, at the end of the grid layout
logic. In order to achieve that, this CL forces a new computation of
the Baseline offsets during the step 3 of the Grid sizing algorith,
since during this step the available space is not indefinite anymore.

It's worth mentioning that this change assumes the issue grid items
being excluded and included of Baseline Context during the different
phases of the Grid sizing algorithm, which I hope we can clarify in
the issue [2] I filed for the CSS WG.

[1] https://drafts.csswg.org/css-grid/#fr-unit
[2] w3c/csswg-drafts#3046

Bug: 867833, 874861, 876593
Change-Id: I668d399b920c9280a8e20b3e8362f562eded4770
Reviewed-on: https://chromium-review.googlesource.com/1177757
Reviewed-by: Sergio Villar <svillar@igalia.com>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Commit-Queue: Javier Fernandez <jfernandez@igalia.com>
Cr-Commit-Position: refs/heads/master@{#587799}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Sep 5, 2018
…fsets during step 3, a=testonly

Automatic update from web-platform-tests[css-grid] Compute again the baseline offsets during step 3

The new Baseline Alignment algorithm states that items with sizing
cyclic dependencies must be excluded from any baseline context they
participate in. One of these cyclic dependencies can happen with
intrinsic sized grid areas and relative items.

The grid spec states [1] that flex-sized tracks should be considered
as content-sized when the grid container has an indefinite size. We
were using the AvailableSize(direction) function to determine whether
the grid container is indefinite or not. However, this function may
provide different results during the different phases of the grid
layout logic. This issue causes assert violations like the one
described in the bugs listed below.

The new Baseline Alignment logic is now integrated in the Grid Track
sizing algorithm. Hence, we need to ensure that an item that
participates in any baseline alignment context during the track sizing
also does during the alignment phase, at the end of the grid layout
logic. In order to achieve that, this CL forces a new computation of
the Baseline offsets during the step 3 of the Grid sizing algorith,
since during this step the available space is not indefinite anymore.

It's worth mentioning that this change assumes the issue grid items
being excluded and included of Baseline Context during the different
phases of the Grid sizing algorithm, which I hope we can clarify in
the issue [2] I filed for the CSS WG.

[1] https://drafts.csswg.org/css-grid/#fr-unit
[2] w3c/csswg-drafts#3046

Bug: 867833, 874861, 876593
Change-Id: I668d399b920c9280a8e20b3e8362f562eded4770
Reviewed-on: https://chromium-review.googlesource.com/1177757
Reviewed-by: Sergio Villar <svillar@igalia.com>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Commit-Queue: Javier Fernandez <jfernandez@igalia.com>
Cr-Commit-Position: refs/heads/master@{#587799}

--

wpt-commits: 16e4b911814b15f308f39cb06e5ac8b790608d37
wpt-pr: 12529
jankeromnes pushed a commit to jankeromnes/gecko that referenced this issue Sep 5, 2018
…fsets during step 3, a=testonly

Automatic update from web-platform-tests[css-grid] Compute again the baseline offsets during step 3

The new Baseline Alignment algorithm states that items with sizing
cyclic dependencies must be excluded from any baseline context they
participate in. One of these cyclic dependencies can happen with
intrinsic sized grid areas and relative items.

The grid spec states [1] that flex-sized tracks should be considered
as content-sized when the grid container has an indefinite size. We
were using the AvailableSize(direction) function to determine whether
the grid container is indefinite or not. However, this function may
provide different results during the different phases of the grid
layout logic. This issue causes assert violations like the one
described in the bugs listed below.

The new Baseline Alignment logic is now integrated in the Grid Track
sizing algorithm. Hence, we need to ensure that an item that
participates in any baseline alignment context during the track sizing
also does during the alignment phase, at the end of the grid layout
logic. In order to achieve that, this CL forces a new computation of
the Baseline offsets during the step 3 of the Grid sizing algorith,
since during this step the available space is not indefinite anymore.

It's worth mentioning that this change assumes the issue grid items
being excluded and included of Baseline Context during the different
phases of the Grid sizing algorithm, which I hope we can clarify in
the issue [2] I filed for the CSS WG.

[1] https://drafts.csswg.org/css-grid/#fr-unit
[2] w3c/csswg-drafts#3046

Bug: 867833, 874861, 876593
Change-Id: I668d399b920c9280a8e20b3e8362f562eded4770
Reviewed-on: https://chromium-review.googlesource.com/1177757
Reviewed-by: Sergio Villar <svillar@igalia.com>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Commit-Queue: Javier Fernandez <jfernandez@igalia.com>
Cr-Commit-Position: refs/heads/master@{#587799}

--

wpt-commits: 16e4b911814b15f308f39cb06e5ac8b790608d37
wpt-pr: 12529
@fantasai
Copy link
Collaborator

I think the point of confusion is that you're evaluating whether the item is in a cyclic layout situation within the scope of a particular step in the algorithm. Within such a narrow scope, you get different answers depending on which step you're in. But the decision of whether an item can be baseline-aligned or not due to cyclic dependencies is at the top level. If any part of the layout creates this cycle, the cycle exists, and you must use fallback alignment--and that fallback alignment applies as if it were originally specified, not only in certain steps.

@tabatkins
Copy link
Member

This implication, however (that the cyclic-baseline check is performed once at the beginning of track layout, and persists thru the later steps where the track may be treated as fixed) is not clear from the language, so we need to fix it. ^_^

@tabatkins
Copy link
Member

(@fantasai and I are arguing with each other over these comments even tho we're sitting next to each other irl.)

@fantasai
Copy link
Collaborator

It's clear because it's unconditional and unscoped. It's defined at the same level as "if you're in a vertical writing mode, an 'auto' dominant baseline is treated as 'center' and in a horizontal writing mode it is treated as 'alphabetic'. We could make it clearer by being extra explicit about this, but the only condition is “there is a cycle during layout” and the command is ”treat baseline as its fallback”, with no conditions or scoping or timing constraints.

@tabatkins
Copy link
Member

By definition it's not clear, since Javi didn't understand it, and I would have interpreted it differently five minutes ago too. ^_^

@tabatkins
Copy link
Member

tabatkins commented Sep 10, 2018

To be a bit more explicit:

Figuring out the baseline-alignment shims is a part of the track sizing algorithm, and this is run for one set of tracks at a time, either the rows or the columns.

In this case, step 2 figures out row heights, and assigns block-axis margins to baseline-align between rows. (Which, due to the vertical item not participating, means that everyone gets 0-sized shims; they're not baseline-aligning.)

Then step 3 happens - we treat the row as fixed-size, but we're working on the columns. So the baseline-shim determination is for the columns - we're adding inline-axis margins to align things across a column. The fact that the row is fixed has no relevance here; the cyclic check we're doing is for widths (and in this case, the column widths are both fixed at 100px, so everything's cool).

Then step 4 happens - the columns are fixed, rows are un-fixed (because we're calculating them again), and so the cyclic-check is made for the rows, and once again, the vertical item still depends on an intrinsically-sized track, so it still can't baseline-align.

@tabatkins
Copy link
Member

It's important to notice that we implement this shim computation as part of the track sizing algorithm, so that we can run it again in step 3, if necessary (eg. orthogonal items). This is an implementation decision, since the spec doesn't specify when the baseline shims must be computed; it just state when they should be applied.

It does say when to calculate these - it's done in step 11.5.1. That's part of the Track Sizing Algorithm, tho (and does get re-run in step 3/4), so it looks like it's consistent with what you're already doing. ^_^

fantasai added a commit that referenced this issue Sep 10, 2018
@javifernandez
Copy link
Contributor Author

It does say when to calculate these - it's done in step 11.5.1. That's part of the Track Sizing Algorithm, tho (and does get re-run in step 3/4), so it looks like it's consistent with what you're already doing. ^_^

I guess with 11.5.1 you meant the Step 1 in the 11.5 section: https://drafts.csswg.org/css-grid/#algo-baseline-shims

Then, yes, we assume that but I meant that it was not explicitly stated. I didn't want to imply that the text would need edits to clarify it, though, just that we assumed it was necessary to do it in that precise step.

Then, we are on the same page regarding this specific sub-topic of the issue, about when to compute the baseline shims. I'm happy because it's a very important point of this issue.

@javifernandez
Copy link
Contributor Author

Let's focus now on the comment bellow, which I think it's the key point to clarify here.

Then step 4 happens - the columns are fixed, rows are un-fixed (because we're calculating them again), and so the cyclic-check is made for the rows, and once again, the vertical item still depends on an intrinsically-sized track, so it still can't baseline-align.

The statement that I'm not sure about is this conclusion you made that the vertical item depends on an intrinsically-sized track. The track has a flex size and, as far as I understand, it's intrinsic nature depends on the definiteness of the available space (in this case, the grid container height).

The grid area the item we are evaluating for a sizing-cycle is not intrinsically sized because the rows are "un-fixed" as you said. Even though we are resolving the row's size, if the grid container height was definite, the fr track would have been treated as fixed size, for the purpose of this sizing cycle check.

This is the main doubt that I, and a few other devs at Igalia (we used several meetings to discuss about this and I admit we still haven't reach an agreement). Is the available space definite during the step 4 ? Can/Should assume that the rows' size determined in Step 2 can be used to set the grid container's height, hence it can/should we use it as definite available space for computing rows' size in Step 4 ?

If "yes" is the answer of both questions, I guess that, according to the spec, we should treat the fr tacks as fixed size during this Step 4, hence, the vertical item would not be under a cyclic sizing dependency and it indeed would participate in baseline alignment.

Personally, I'd be more in favor of an interpretation like the one fantasai proposed, where this definite/indefinite condition is determined once for all at the beginning of the track sizing algorithm. However, this would require, in my opinion, a more complex editing.

Maybe I'm wrong on some of my assumptions above, and we should treat the vertical item as not participating in baseline alignment even in the extra Step 4 of the track sizing algorithm; this is in my opinion what I'd would expect as rendering result. However, I'm afraid that with the current spec, we can't conclude that.

@mrego
Copy link
Member

mrego commented Sep 20, 2018

This is the main doubt that I, and a few other devs at Igalia (we used several meetings to discuss about this and I admit we still haven't reach an agreement). Is the available space definite during the step 4 ? Can/Should assume that the rows' size determined in Step 2 can be used to set the grid container's height, hence it can/should we use it as definite available space for computing rows' size in Step 4 ?

Regarding this we're currently assuming in Chromium and WebKit that grid size (width and height) is definite when we repeat the track sizing algorithm (steps 3 and 4).
And @MatsPalmgren requested to add this in a comment on a different issue:

And that the grid container's block-axis size is definite and final after the first pass (so that it works similar to the inline-axis).

About the particular problem of this issue, I agree with @fantasai that we should determine this at the beginning and then don't change the status during the whole track sizing algorithm.

@tabatkins
Copy link
Member

Is the available space definite during the step 4 ? Can/Should assume that the rows' size determined in Step 2 can be used to set the grid container's height, hence it can/should we use it as definite available space for computing rows' size in Step 4 ?

No. Step 4 tells you what information to use - it mentions using the column widths you calculated in step 3, but makes no mention of the previous attempt at row heights from step 2. So you ignore everything that happened in step 2; it has no relevance during step 4.

About the particular problem of this issue, I agree with @fantasai that we should determine this at the beginning and then don't change the status during the whole track sizing algorithm.

Are there any particular edits you need for this to be clearer?

@mrego
Copy link
Member

mrego commented Dec 11, 2018

With the edits from #3042 it seems we won't need changes:

For this purpose, track sizes count as “intrinsically-sized” when the grid container has an indefinite size in the relevant axis.

We guess that has an indefinite size is true on the first pass and also on the second pass.

Note that in order to resolve percentages rows on a grid container with indefinite size, we are setting the intrinsic height after the first pass and then use that size to resolve the percentages in the second pass. For that reason @MatsPalmgren asked for some extra changes on the spec in this comment:

And that the grid container's block-axis size is definite and final after the first pass (so that it works similar to the inline-axis).

If we do that maybe we'd need some extra clarification on the "intrinsically-sized" and flex tracks sentence. As otherwise both texts would be somehow contradictory: in one place we would say that after the first pass the height is definite, then with the current sentence the flex track would be "intrinsically-sized" on the first pass but not on the second pass.

@fantasai fantasai added this to the css-grid-1 CR 2017-12-14+ milestone Jan 23, 2019
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 7, 2019
The CSS WG resolved [1] that we should determine the existence of cyclic
sizing dependencies at the begining of layout, and this condition must
be kept during the next phases of the grid layout algorithm.

This has some interesting implications for Baseline Alignment, since we
must exclude from participating in Baseline Alignment those items that
have a cyclic sizing dependency with the grid area they are located
into.

We were using the AvailableSpace() function to determine when a grid
area may be defined under indefinite sizing constraints, which would
make tracks with a flex max-sizing function to behave like an
intrinsically sized track. However, the result of this function may
be different during the different steps of the grid layout algorithm.

The consequences of this undetermined results may cause that items
excluded from participating in Baseline Alignment during the grid's
intrinsic size computation, or even in the first steps of the layout
(orthogonal items may force an extra cycle of the layout algorithm),
could be selected to participate later in the next steps.

The CSS WG clarified that once we detect a cyclic sizing dependency
the affected items must be definitively excluded from participating
in Baseline Alignment. In order to implement this new behavior, this
patch provides a deterministic way to know whether the grid container
is sized under indefinite constraints.

[1] w3c/csswg-drafts#3046

Bug: 941987
Change-Id: I9b2ae86af9c675bf59dff639dfcbb362c2f302ba
@javifernandez
Copy link
Contributor Author

javifernandez commented May 7, 2019

I'm currently implementing the agreed new behavior in chrome (I'll do the same for Safari as soon as possible), so I think we can close this issue, unless @rego or anybody else has anything to add.

@fantasai fantasai added Closed Accepted as Editorial Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. labels May 24, 2019
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 3, 2019
…fsets during step 3, a=testonly

Automatic update from web-platform-tests[css-grid] Compute again the baseline offsets during step 3

The new Baseline Alignment algorithm states that items with sizing
cyclic dependencies must be excluded from any baseline context they
participate in. One of these cyclic dependencies can happen with
intrinsic sized grid areas and relative items.

The grid spec states [1] that flex-sized tracks should be considered
as content-sized when the grid container has an indefinite size. We
were using the AvailableSize(direction) function to determine whether
the grid container is indefinite or not. However, this function may
provide different results during the different phases of the grid
layout logic. This issue causes assert violations like the one
described in the bugs listed below.

The new Baseline Alignment logic is now integrated in the Grid Track
sizing algorithm. Hence, we need to ensure that an item that
participates in any baseline alignment context during the track sizing
also does during the alignment phase, at the end of the grid layout
logic. In order to achieve that, this CL forces a new computation of
the Baseline offsets during the step 3 of the Grid sizing algorith,
since during this step the available space is not indefinite anymore.

It's worth mentioning that this change assumes the issue grid items
being excluded and included of Baseline Context during the different
phases of the Grid sizing algorithm, which I hope we can clarify in
the issue [2] I filed for the CSS WG.

[1] https://drafts.csswg.org/css-grid/#fr-unit
[2] w3c/csswg-drafts#3046

Bug: 867833, 874861, 876593
Change-Id: I668d399b920c9280a8e20b3e8362f562eded4770
Reviewed-on: https://chromium-review.googlesource.com/1177757
Reviewed-by: Sergio Villar <svillarigalia.com>
Reviewed-by: Emil A Eklund <eaechromium.org>
Commit-Queue: Javier Fernandez <jfernandezigalia.com>
Cr-Commit-Position: refs/heads/master{#587799}

--

wpt-commits: 16e4b911814b15f308f39cb06e5ac8b790608d37
wpt-pr: 12529

UltraBlame original commit: 7a1e05b09e40b019b67ba54e64e983fcd8b30d0e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Oct 3, 2019
…fsets during step 3, a=testonly

Automatic update from web-platform-tests[css-grid] Compute again the baseline offsets during step 3

The new Baseline Alignment algorithm states that items with sizing
cyclic dependencies must be excluded from any baseline context they
participate in. One of these cyclic dependencies can happen with
intrinsic sized grid areas and relative items.

The grid spec states [1] that flex-sized tracks should be considered
as content-sized when the grid container has an indefinite size. We
were using the AvailableSize(direction) function to determine whether
the grid container is indefinite or not. However, this function may
provide different results during the different phases of the grid
layout logic. This issue causes assert violations like the one
described in the bugs listed below.

The new Baseline Alignment logic is now integrated in the Grid Track
sizing algorithm. Hence, we need to ensure that an item that
participates in any baseline alignment context during the track sizing
also does during the alignment phase, at the end of the grid layout
logic. In order to achieve that, this CL forces a new computation of
the Baseline offsets during the step 3 of the Grid sizing algorith,
since during this step the available space is not indefinite anymore.

It's worth mentioning that this change assumes the issue grid items
being excluded and included of Baseline Context during the different
phases of the Grid sizing algorithm, which I hope we can clarify in
the issue [2] I filed for the CSS WG.

[1] https://drafts.csswg.org/css-grid/#fr-unit
[2] w3c/csswg-drafts#3046

Bug: 867833, 874861, 876593
Change-Id: I668d399b920c9280a8e20b3e8362f562eded4770
Reviewed-on: https://chromium-review.googlesource.com/1177757
Reviewed-by: Sergio Villar <svillarigalia.com>
Reviewed-by: Emil A Eklund <eaechromium.org>
Commit-Queue: Javier Fernandez <jfernandezigalia.com>
Cr-Commit-Position: refs/heads/master{#587799}

--

wpt-commits: 16e4b911814b15f308f39cb06e5ac8b790608d37
wpt-pr: 12529

UltraBlame original commit: 7a1e05b09e40b019b67ba54e64e983fcd8b30d0e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 3, 2019
…fsets during step 3, a=testonly

Automatic update from web-platform-tests[css-grid] Compute again the baseline offsets during step 3

The new Baseline Alignment algorithm states that items with sizing
cyclic dependencies must be excluded from any baseline context they
participate in. One of these cyclic dependencies can happen with
intrinsic sized grid areas and relative items.

The grid spec states [1] that flex-sized tracks should be considered
as content-sized when the grid container has an indefinite size. We
were using the AvailableSize(direction) function to determine whether
the grid container is indefinite or not. However, this function may
provide different results during the different phases of the grid
layout logic. This issue causes assert violations like the one
described in the bugs listed below.

The new Baseline Alignment logic is now integrated in the Grid Track
sizing algorithm. Hence, we need to ensure that an item that
participates in any baseline alignment context during the track sizing
also does during the alignment phase, at the end of the grid layout
logic. In order to achieve that, this CL forces a new computation of
the Baseline offsets during the step 3 of the Grid sizing algorith,
since during this step the available space is not indefinite anymore.

It's worth mentioning that this change assumes the issue grid items
being excluded and included of Baseline Context during the different
phases of the Grid sizing algorithm, which I hope we can clarify in
the issue [2] I filed for the CSS WG.

[1] https://drafts.csswg.org/css-grid/#fr-unit
[2] w3c/csswg-drafts#3046

Bug: 867833, 874861, 876593
Change-Id: I668d399b920c9280a8e20b3e8362f562eded4770
Reviewed-on: https://chromium-review.googlesource.com/1177757
Reviewed-by: Sergio Villar <svillarigalia.com>
Reviewed-by: Emil A Eklund <eaechromium.org>
Commit-Queue: Javier Fernandez <jfernandezigalia.com>
Cr-Commit-Position: refs/heads/master{#587799}

--

wpt-commits: 16e4b911814b15f308f39cb06e5ac8b790608d37
wpt-pr: 12529

UltraBlame original commit: 7a1e05b09e40b019b67ba54e64e983fcd8b30d0e
webkit-commit-queue pushed a commit to WebKit/WebKit that referenced this issue Nov 24, 2021
…tion would change

https://bugs.webkit.org/show_bug.cgi?id=232617

Reviewed by Javier Fernandez.

Source/WebCore:

According to https://drafts.csswg.org/css-grid/#algo-flex-tracks, when row height is
indefinite, for each grid item that crosses a flexible track, we run the track sizing
algorithm under a max-content constraint to find the flex fraction. Then we work out
the grid container height as definite, which may cause the flex fraction change. At this
point, we need to repeat the track sizing algorithm for row and layout the grid for real.
The current implementation doesn't repeat the track sizing algorithm for row.

The complication with calling RenderGrid::repeatTracksSizingIfNeeded() for flex max-sizing
is that it might change a grid item's status of participating in Baseline Alignment for
a cyclic sizing dependncy case, which should be definitively excluded. See
w3c/csswg-drafts#3046 for more details. This issue should be handled
in a seperate bug. This CL only handle test cases that don't have baseline alignment specified.

* rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithm::initializeTrackSizes):
(WebCore::GridTrackSizingAlgorithm::setup):
(WebCore::GridTrackSizingAlgorithm::reset):
* rendering/GridTrackSizingAlgorithm.h:
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::repeatTracksSizingIfNeeded):
(WebCore::RenderGrid::layoutBlock):
* rendering/RenderGrid.h:

LayoutTests:

Unskip two tests that are passing.

* TestExpectations:



Canonical link: https://commits.webkit.org/244532@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286148 268f45cc-cd09-0410-ab3c-d52691b4dbfc
annulen pushed a commit to qtwebkit/qtwebkit that referenced this issue Nov 25, 2021
…tion would change

https://bugs.webkit.org/show_bug.cgi?id=232617

Reviewed by Javier Fernandez.

Source/WebCore:

According to https://drafts.csswg.org/css-grid/#algo-flex-tracks, when row height is
indefinite, for each grid item that crosses a flexible track, we run the track sizing
algorithm under a max-content constraint to find the flex fraction. Then we work out
the grid container height as definite, which may cause the flex fraction change. At this
point, we need to repeat the track sizing algorithm for row and layout the grid for real.
The current implementation doesn't repeat the track sizing algorithm for row.

The complication with calling RenderGrid::repeatTracksSizingIfNeeded() for flex max-sizing
is that it might change a grid item's status of participating in Baseline Alignment for
a cyclic sizing dependncy case, which should be definitively excluded. See
w3c/csswg-drafts#3046 for more details. This issue should be handled
in a seperate bug. This CL only handle test cases that don't have baseline alignment specified.

* rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithm::initializeTrackSizes):
(WebCore::GridTrackSizingAlgorithm::setup):
(WebCore::GridTrackSizingAlgorithm::reset):
* rendering/GridTrackSizingAlgorithm.h:
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::repeatTracksSizingIfNeeded):
(WebCore::RenderGrid::layoutBlock):
* rendering/RenderGrid.h:

LayoutTests:

Unskip two tests that are passing.

* TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@286148 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted as Editorial Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-grid-1 Tracked in DoC
Projects
None yet
Development

No branches or pull requests

4 participants