Bug 191358 - [css-grid] Refactoring to make more explicit the orthogonal items' pre-layout logic
Summary: [css-grid] Refactoring to make more explicit the orthogonal items' pre-layout...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Javier Fernandez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-11-07 06:17 PST by Javier Fernandez
Modified: 2018-11-12 16:34 PST (History)
8 users (show)

See Also:


Attachments
Patch (29.63 KB, patch)
2018-11-07 06:25 PST, Javier Fernandez
no flags Details | Formatted Diff | Diff
Patch (29.52 KB, patch)
2018-11-11 16:11 PST, Javier Fernandez
no flags Details | Formatted Diff | Diff
Patch (29.46 KB, patch)
2018-11-12 02:15 PST, Javier Fernandez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Javier Fernandez 2018-11-07 06:17:22 PST
We need to adapt the code to integrate later the new Baseline Alignment logic, which in latest spec it was included as part of the Track Sizing algorithm. 

Orthogonal items must be laid out using a properly estimated grid area, since the result of this pre-layout may affect during the baseline offsets computation.
Comment 1 Javier Fernandez 2018-11-07 06:25:37 PST
Created attachment 354085 [details]
Patch
Comment 2 Manuel Rego Casasnovas 2018-11-09 01:53:28 PST
Comment on attachment 354085 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=354085&action=review

LGTM, but I added some minor comments inline.

> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:602
> +bool GridTrackSizingAlgorithm::isRelativeSizedTrackAsAuto(const GridTrackSize& trackSize, GridTrackSizingDirection direction) const

This method is only used in one place, do we really need it? We call it and later we recheck the percentages things, I'm not sure if it's really adding any value.

> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:626
> +    if (isRelativeSizedTrackAsAuto(trackSize, direction)) {

I'd just modify this to something like:
  if (!availableSpace(direction)) {
    if (minTrackBreadth.isPercentage())
      minTrackBreadth = Length(Auto);
    if (maxTrackBreadth.isPercentage())
      maxTrackBreadth = Length(Auto);
  }

> Source/WebCore/rendering/GridTrackSizingAlgorithm.h:172
> +    // Data

Is this comment really useful? If you want to keep it add a "." at the end. :-)

> Source/WebCore/rendering/RenderGrid.cpp:205
> +            // Grid's layout logic controls the grid item's override height, hence
> +            // we need to clear any override height set previously, so it doesn't
> +            // interfere in current layout execution.
> +            // Grid never uses the override width, that's why we don't need to clear
> +            // it.

Nit: You don't need to line wrap so hard :-)

> Source/WebCore/rendering/RenderGrid.cpp:209
> +            // We may need to repeat the track sizing in case of any grid item was
> +            // orthogonal.

Ditto about line wrapping.

> Source/WebCore/rendering/RenderGrid.cpp:648
> +    // FIXME(jfernandez): We need a way when we are calling this during intrinsic size compuation before performing

Mmm, it seems some word is missing in this sentence.
Nit: Don't remember if this FIXME(jfernandez) is common in WebKit, or just a simple FIXME.

> Source/WebCore/rendering/RenderGrid.cpp:890
> +    // Because the grid area cannot be styled, we don't need to adjust
> +    // the grid breadth to account for 'box-sizing'.

Nit: More line wrapping.
Comment 3 Javier Fernandez 2018-11-11 16:09:09 PST
Comment on attachment 354085 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=354085&action=review

>> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:602
>> +bool GridTrackSizingAlgorithm::isRelativeSizedTrackAsAuto(const GridTrackSize& trackSize, GridTrackSizingDirection direction) const
> 
> This method is only used in one place, do we really need it? We call it and later we recheck the percentages things, I'm not sure if it's really adding any value.

Well, this patch is just a refactoring needed to a follow-up patch to implement the new Baseline Alignment logic. In the next patches, I'll use this function again. 

I think it's useful to have this function, which is auto-explained and avoid the need of additional code comments.

>> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:626
>> +    if (isRelativeSizedTrackAsAuto(trackSize, direction)) {
> 
> I'd just modify this to something like:
>   if (!availableSpace(direction)) {
>     if (minTrackBreadth.isPercentage())
>       minTrackBreadth = Length(Auto);
>     if (maxTrackBreadth.isPercentage())
>       maxTrackBreadth = Length(Auto);
>   }

I don't think this code improves current logic; also, as I commented above, I'd rather keep using the new function.

>> Source/WebCore/rendering/GridTrackSizingAlgorithm.h:172
>> +    // Data
> 
> Is this comment really useful? If you want to keep it add a "." at the end. :-)

Well, we have similar comments all over this header file, so I think is, at least, consistent with current codebase.

>> Source/WebCore/rendering/RenderGrid.cpp:205
>> +            // it.
> 
> Nit: You don't need to line wrap so hard :-)

ok

>> Source/WebCore/rendering/RenderGrid.cpp:648
>> +    // FIXME(jfernandez): We need a way when we are calling this during intrinsic size compuation before performing
> 
> Mmm, it seems some word is missing in this sentence.
> Nit: Don't remember if this FIXME(jfernandez) is common in WebKit, or just a simple FIXME.

OK

>> Source/WebCore/rendering/RenderGrid.cpp:890
>> +    // the grid breadth to account for 'box-sizing'.
> 
> Nit: More line wrapping.

OK
Comment 4 Javier Fernandez 2018-11-11 16:11:57 PST
Created attachment 354514 [details]
Patch
Comment 5 Manuel Rego Casasnovas 2018-11-12 00:29:20 PST
Comment on attachment 354514 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=354514&action=review

> Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp:605
> +        return isRelativeGridLengthAsAuto(trackSize.minTrackBreadth(), direction);

I'm still not fully convinced of this. We know it's a percentage but we still check it again in isRelativeGridLengthAsAuto(), do we really need to do it twice?
Comment 6 Javier Fernandez 2018-11-12 02:15:40 PST
Created attachment 354539 [details]
Patch
Comment 7 WebKit Commit Bot 2018-11-12 16:31:58 PST
Comment on attachment 354539 [details]
Patch

Clearing flags on attachment: 354539

Committed r238114: <https://trac.webkit.org/changeset/238114>
Comment 8 WebKit Commit Bot 2018-11-12 16:31:59 PST
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2018-11-12 16:34:22 PST
<rdar://problem/46009086>