Bug 180632 - [css-grid] Implement alignment for absolute positioned grid items
Summary: [css-grid] Implement alignment for absolute positioned grid items
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: 2017-12-10 08:18 PST by Javier Fernandez
Modified: 2017-12-12 14:20 PST (History)
6 users (show)

See Also:


Attachments
Patch (195.33 KB, patch)
2017-12-11 01:46 PST, Javier Fernandez
no flags Details | Formatted Diff | Diff
Patch (195.18 KB, patch)
2017-12-12 12:46 PST, Javier Fernandez
no flags Details | Formatted Diff | Diff
Patch (195.18 KB, patch)
2017-12-12 12:54 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 2017-12-10 08:18:13 PST
According to the css-align spec (https://drafts.csswg.org/css-align/#justify-abspos),
it should be possible to align positioned items too:
"Alignment Container
 The box’s containing block, as modified by the offset properties (top/right/bottom/left)."
Comment 1 Javier Fernandez 2017-12-11 01:46:57 PST
Created attachment 328955 [details]
Patch
Comment 2 Manuel Rego Casasnovas 2017-12-12 06:06:36 PST
Comment on attachment 328955 [details]
Patch

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

The patch looks good, just some minor comments and a question about the result of some tests.

> Source/WebCore/ChangeLog:25
> +        Updated web-platform-tests so that all test cases pass now.

Nit: I'd say "Updated web-platform-tests results" or "expected results".
Also not all the tests pass now as stated in the previous paragraph, so I'd reword this.

> Source/WebCore/rendering/RenderGrid.cpp:1423
> +    return (position.isAuto() || (position.isNamedGridArea() && !NamedLineCollection::isValidNamedLineOrArea(position.namedGridLine(), style(), GridPositionsResolver::initialPositionSide(direction))));

Nit: I guess the external parenthesis are not needed.

> Source/WebCore/rendering/RenderGrid.cpp:1493
> +        // These vectors store line positions including gaps, but we shouldn't
> +        // consider them for the edges of the grid.

Nit: Don't need to wrap this comment line in WebKit.

> Source/WebCore/rendering/RenderGrid.cpp:1502
> +    // TODO (lajava): Is expectable that in some cases 'end' is smaller than
> +    // 'start' ?

I believe this is expected in some situations, so we can remove the TODO.

> Source/WebCore/rendering/RenderGrid.cpp:1532
> +    if (std::optional<size_t> line = lineOfPositionedItem.get(&child)) {

Nit: You can use "auto" here.

> Source/WebCore/rendering/RenderGrid.h:185
> +    OutOfFlowPositionsMap m_columnOfPositionedItem;

Nit: I don't like a lot the name "OutOfFlow..." when the variable is "...PositionedItem".

> LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-009-expected.txt:41
> +offsetLeft expected 80 but got 110

This is a RTL case, not a vertical one. Why is this failing?
Comment 3 Javier Fernandez 2017-12-12 09:57:02 PST
Comment on attachment 328955 [details]
Patch

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

>> Source/WebCore/ChangeLog:25
>> +        Updated web-platform-tests so that all test cases pass now.
> 
> Nit: I'd say "Updated web-platform-tests results" or "expected results".
> Also not all the tests pass now as stated in the previous paragraph, so I'd reword this.

Done.

>> Source/WebCore/rendering/RenderGrid.cpp:1423
>> +    return (position.isAuto() || (position.isNamedGridArea() && !NamedLineCollection::isValidNamedLineOrArea(position.namedGridLine(), style(), GridPositionsResolver::initialPositionSide(direction))));
> 
> Nit: I guess the external parenthesis are not needed.

Done

>> Source/WebCore/rendering/RenderGrid.cpp:1493
>> +        // consider them for the edges of the grid.
> 
> Nit: Don't need to wrap this comment line in WebKit.

Done

>> Source/WebCore/rendering/RenderGrid.cpp:1502
>> +    // 'start' ?
> 
> I believe this is expected in some situations, so we can remove the TODO.

Done

>> Source/WebCore/rendering/RenderGrid.cpp:1532
>> +    if (std::optional<size_t> line = lineOfPositionedItem.get(&child)) {
> 
> Nit: You can use "auto" here.

Done

>> Source/WebCore/rendering/RenderGrid.h:185
>> +    OutOfFlowPositionsMap m_columnOfPositionedItem;
> 
> Nit: I don't like a lot the name "OutOfFlow..." when the variable is "...PositionedItem".

Well, positioned items are indeed out-of-flow elements, according to this statement:

https://www.w3.org/TR/CSS22/visuren.html#positioning-scheme

Do you mean that we should rename, either the variable or the type, to use the same term ?

>> LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-009-expected.txt:41
>> +offsetLeft expected 80 but got 110
> 
> This is a RTL case, not a vertical one. Why is this failing?

The item is also verticalRL
Comment 4 Manuel Rego Casasnovas 2017-12-12 12:20:26 PST
Comment on attachment 328955 [details]
Patch

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

>>> Source/WebCore/ChangeLog:25
>>> +        Updated web-platform-tests so that all test cases pass now.
>> 
>> Nit: I'd say "Updated web-platform-tests results" or "expected results".
>> Also not all the tests pass now as stated in the previous paragraph, so I'd reword this.
> 
> Done.

Mmmm, I don't see the new patch yet. :-)

>>> Source/WebCore/rendering/RenderGrid.h:185
>>> +    OutOfFlowPositionsMap m_columnOfPositionedItem;
>> 
>> Nit: I don't like a lot the name "OutOfFlow..." when the variable is "...PositionedItem".
> 
> Well, positioned items are indeed out-of-flow elements, according to this statement:
> 
> https://www.w3.org/TR/CSS22/visuren.html#positioning-scheme
> 
> Do you mean that we should rename, either the variable or the type, to use the same term ?

Yeah I know, I meant that is strange to use one term in the type and another in the variable.
I won't modify the variable name, so I'd use a different name for the type.
Anyway it's not really important, it's just a nit.

>>> LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-009-expected.txt:41
>>> +offsetLeft expected 80 but got 110
>> 
>> This is a RTL case, not a vertical one. Why is this failing?
> 
> The item is also verticalRL

Oops I didn't realize.
Comment 5 Javier Fernandez 2017-12-12 12:46:40 PST
Created attachment 329139 [details]
Patch

Applied suggested changed.
Comment 6 Javier Fernandez 2017-12-12 12:54:49 PST
Created attachment 329141 [details]
Patch
Comment 7 Manuel Rego Casasnovas 2017-12-12 13:02:06 PST
Comment on attachment 329141 [details]
Patch

Thanks for the changes. LGTM!
Comment 8 WebKit Commit Bot 2017-12-12 14:19:25 PST
Comment on attachment 329141 [details]
Patch

Clearing flags on attachment: 329141

Committed r225805: <https://trac.webkit.org/changeset/225805>
Comment 9 WebKit Commit Bot 2017-12-12 14:19:26 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2017-12-12 14:20:40 PST
<rdar://problem/36004392>