Bug 159258

Summary: [css-grid] Height percentages are not properly resolved for item's children
Product: WebKit Reporter: Manuel Rego Casasnovas <rego>
Component: Layout and RenderingAssignee: Manuel Rego Casasnovas <rego>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, esprehn+autocc, glenn, jfernandez, kondapallykalyan, rego, simon.fraser, svillar
Priority: P2 Keywords: BlinkMergeCandidate
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.chromium.org/p/chromium/issues/detail?id=612755
Bug Depends on:    
Bug Blocks: 60731    
Attachments:
Description Flags
Patch none

Description Manuel Rego Casasnovas 2016-06-29 03:49:59 PDT
This is very easy to reproduce, in a grid with just one cell (200px x 100px).
The item will be stretching by default, so it takes the whole size of the cell.
However if you've a child of the item with width and height 100%.
The child doesn't take the whole height, only the whole width.

See the attached example or check it live at:
http://jsbin.com/cinili/1/edit?html,css,output

This has been already fixed on Blink:
https://codereview.chromium.org/2039223002
Comment 1 Manuel Rego Casasnovas 2016-06-29 03:58:30 PDT
Created attachment 282339 [details]
Patch
Comment 2 Sergio Villar Senin 2016-07-06 02:54:56 PDT
Comment on attachment 282339 [details]
Patch

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

> Source/WebCore/rendering/RenderBox.cpp:2993
> +        availableHeight = cb->overrideLogicalContentHeight();

Hmm it looks to me that this is only valid for direct children of a grid item, what happens if we have a child of a child of a grid item?
Comment 3 Manuel Rego Casasnovas 2016-07-06 03:35:20 PDT
Comment on attachment 282339 [details]
Patch

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

>> Source/WebCore/rendering/RenderBox.cpp:2993
>> +        availableHeight = cb->overrideLogicalContentHeight();
> 
> Hmm it looks to me that this is only valid for direct children of a grid item, what happens if we have a child of a child of a grid item?

Mmmm, I'm not sure if I follow you. It'd work like in any regular element.
The child of a child of a grid item, has to resolve its percentage against the height of the child of the grid item.
So we don't need anything special here.

Example:
  <div style="display: grid; grid: 100px / 100px;>
    <div id="item">
      <div id="subitem">
        <div id="subsubitem"></div>
      </div>
    </div>
  </div>

A percentage height in the "subitem" needs to be resolved against the "item" height.
If the "item" is stretched (that's when we have hasOverrideLogicalContentHeight()),
then we should use that height to resolve the "subitem" percentage.
Imagine that the "subitem" has a 30% in the previous example,
it should resolve against the 100px height of the stretched "item".

A percentage height in the "subsubitem" has to be resolved against the "subitem" height.
If the "subitem" height is "auto", it cannot be resolved, that's all.
Comment 4 WebKit Commit Bot 2016-07-06 06:03:19 PDT
Comment on attachment 282339 [details]
Patch

Clearing flags on attachment: 282339

Committed r202856: <http://trac.webkit.org/changeset/202856>
Comment 5 WebKit Commit Bot 2016-07-06 06:03:23 PDT
All reviewed patches have been landed.  Closing bug.