Changeset 207460 in webkit


Ignore:
Timestamp:
Oct 18, 2016 5:33:28 AM (8 years ago)
Author:
jfernandez@igalia.com
Message:

[css-grid] Different width of grid container between initial load and refresh
https://bugs.webkit.org/show_bug.cgi?id=163535

Reviewed by Manuel Rego Casasnovas.

Source/WebCore:

Grid's layout logic manages two different override sizes; one it's
designed to implement the grid item's stretching behavior, identified
with the concept of 'overrideContentLogicalSize'; there is another
override size, known as overrideContainingBlockContentLogicalSize,
used to implement the Grid Area abstraction, which will behave as
the actual containing block of any grid item.

During grid's layout logic these override sizes are set according
to the CSS style rules. This affects how the grid container and its
children are going to be sized during layout. Grid Tracks sizing
algorithm depends on these override sizes.

In order to ensure that the tracks sizing algorithm produces the
same results when it's run consecutively several times, we need to
clear these override sizes and perform a layout of the affected grid
items. Otherwise, the affected items will return sizing values which
depend on the override values set in the previous layout, which in
some cases, like orthogonal flows, may change through different runs
of the sizing algorithm.

Test: fast/css-grid-layout/repeating-layout-must-produce-the-same-results.html

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::layoutBlock):

LayoutTests:

Tests to ensure repeated layouts on grid elements produce the same results when using
orthogonal grid items.

  • fast/css-grid-layout/repeating-layout-must-produce-the-same-results-expected.txt: Added.
  • fast/css-grid-layout/repeating-layout-must-produce-the-same-results.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207457 r207460  
     12016-10-18  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        [css-grid] Different width of grid container between initial load and refresh
     4        https://bugs.webkit.org/show_bug.cgi?id=163535
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        Tests to ensure repeated layouts on grid elements produce the same results when using
     9        orthogonal grid items.
     10
     11        * fast/css-grid-layout/repeating-layout-must-produce-the-same-results-expected.txt: Added.
     12        * fast/css-grid-layout/repeating-layout-must-produce-the-same-results.html: Added.
     13
    1142016-10-17  Sergio Villar Senin  <svillar@igalia.com>
    215
  • trunk/LayoutTests/fast/css-grid-layout/grid-track-sizing-with-orthogonal-flows.html

    r203501 r207460  
    4747<div class="container">
    4848    <p>Grid width under <b>min-content</b> constrain and <b>fixed</b> height.<br> All grid items sized with <b>min-{width, height} auto</b>.<br> Orthogonal green row track assumed as infinity, hence 10px for the column track. Actual row tracks size is different, hence overflowing. </p>
    49     <div class="grid itemsStart contentStart min-content height200" data-expected-width="30" data-expected-height="200">
     49    <div class="grid itemsStart contentStart min-content height200" data-expected-width="50" data-expected-height="200">
    5050        <div class="firstRowFirstColumn"             data-offset-x="0"  data-offset-y="0"   data-expected-width="30" data-expected-height="50">XX XXX X XXX XX</div>
    5151        <div class="verticalLR firstRowSecondColumn" data-offset-x="30" data-offset-y="0"   data-expected-width="40" data-expected-height="105">X XXX XX XXXXX XX XXX X XXXX X XX</div>
     
    5656<div class="container">
    5757    <p>Grid width under <b>max-content</b> constrain and <b>fixed</b> height.<br> All grid items sized with <b>min-{width, height} auto</b>.<br> Parallel blue column track sized as its max of 150x, while Orthogonal green row, assumed as infinity, sized as 10px. Since actual row tracks size is different, green column track will occupy some space initally assigned to the blue one.</p>
    58     <div class="grid itemsStart contentStart max-content height200" data-expected-width="150" data-expected-height="200">
    59         <div class="firstRowFirstColumn"             data-offset-x="0"   data-offset-y="0"   data-expected-width="110" data-expected-height="20">XX XXX X XXX XX</div>
    60         <div class="verticalLR firstRowSecondColumn" data-offset-x="110" data-offset-y="0"   data-expected-width="40"  data-expected-height="105">X XXX XX XXXXX XX XXX X XXXX X XX</div>
     58    <div class="grid itemsStart contentStart max-content height200" data-expected-width="170" data-expected-height="200">
     59        <div class="firstRowFirstColumn"             data-offset-x="0"   data-offset-y="0"   data-expected-width="130" data-expected-height="20">XX XXX X XXX XX</div>
     60        <div class="verticalLR firstRowSecondColumn" data-offset-x="130" data-offset-y="0"   data-expected-width="40"  data-expected-height="105">X XXX XX XXXXX XX XXX X XXXX X XX</div>
    6161        <div class="verticalLR secondRowFirstColumn" data-offset-x="0"   data-offset-y="105" data-expected-width="20"  data-expected-height="95">XXXX XX X XX XXX</div>
    6262    </div>
     
    6565<div class="container">
    6666    <p>Grid width under <b>fit-content</b> constrain and <b>fixed</b> height.<br >All grid items sized with <b>min-{width, height} auto</b>.<br> Since we use assumed row tracks sizes, minimum and maximum will be the same, hence fit-content will produce the same result than max-content.</p>
    67     <div class="grid itemsStart contentStart fit-content height200" data-expected-width="150" data-expected-height="200">
    68         <div class="firstRowFirstColumn"             data-offset-x="0"   data-offset-y="0"   data-expected-width="110" data-expected-height="20">XX XXX X XXX XX</div>
    69         <div class="verticalLR firstRowSecondColumn" data-offset-x="110" data-offset-y="0"   data-expected-width="40"  data-expected-height="105">X XXX XX XXXXX XX XXX X XXXX X XX</div>
     67    <div class="grid itemsStart contentStart fit-content height200" data-expected-width="170" data-expected-height="200">
     68        <div class="firstRowFirstColumn"             data-offset-x="0"   data-offset-y="0"   data-expected-width="130" data-expected-height="20">XX XXX X XXX XX</div>
     69        <div class="verticalLR firstRowSecondColumn" data-offset-x="130" data-offset-y="0"   data-expected-width="40"  data-expected-height="105">X XXX XX XXXXX XX XXX X XXXX X XX</div>
    7070        <div class="verticalLR secondRowFirstColumn" data-offset-x="0"   data-offset-y="105" data-expected-width="20"  data-expected-height="95">XXXX XX X XX XXX</div>
    7171    </div>
     
    121121<div class="container">
    122122    <p>Grid width under <b>max-content</b> constrain and <b>fixed</b> height.<br> All grid items sized with <b>min-width: 0px, min-height: auto</b>.<br> Since container is sized under max-content, tracks will use its maximum size.</p>
    123     <div class="grid itemsStart contentStart max-content height200" data-expected-width="160" data-expected-height="200">
    124         <div class="minWidthZero firstRowFirstColumn"               data-offset-x="0"   data-offset-y="0"   data-expected-width="120" data-expected-height="20">XX XXX X XXX XX</div>
    125         <div class="minWidthZero verticalLR firstRowSecondColumn"   data-offset-x="120" data-offset-y="0"   data-expected-width="40"  data-expected-height="105">X XXX XX XXXXX XX XXX X XXXX X XX</div>
     123    <div class="grid itemsStart contentStart max-content height200" data-expected-width="170" data-expected-height="200">
     124        <div class="minWidthZero firstRowFirstColumn"               data-offset-x="0"   data-offset-y="0"   data-expected-width="130" data-expected-height="20">XX XXX X XXX XX</div>
     125        <div class="minWidthZero verticalLR firstRowSecondColumn"   data-offset-x="130" data-offset-y="0"   data-expected-width="40"  data-expected-height="105">X XXX XX XXXXX XX XXX X XXXX X XX</div>
    126126        <div class="minWidthZero verticalLR secondRowFirstColumn"   data-offset-x="0"   data-offset-y="105" data-expected-width="20"  data-expected-height="95">XXXX XX X XX XXX</div>
    127127    </div>
  • trunk/LayoutTests/fast/css-grid-layout/grid-track-sizing-with-percentages-and-orthogonal-flows.html

    r203501 r207460  
    2525<p>HORIZONTAL-TB container with VERTICAL-LR items.</p>
    2626<div class="container">
    27     <div class="grid itemsStart contentStart fit-content" data-expected-width="100" data-expected-height="260">
     27    <div class="grid itemsStart contentStart fit-content" data-expected-width="110" data-expected-height="260">
    2828        <div class="firstRowFirstColumn   verticalLR" data-offset-x="0"  data-offset-y="0"  data-expected-width="10" data-expected-height="50">X X X</div>
    2929        <div class="firstRowSecondColumn  verticalLR" data-offset-x="100" data-offset-y="0"  data-expected-width="10" data-expected-height="110">X X X X X X</div>
     
    3535<p>HORIZONTAL-TB container with VERTICAL-RL items.</p>
    3636<div class="container">
    37     <div class="grid itemsStart contentStart fit-content" data-expected-width="100" data-expected-height="260">
     37    <div class="grid itemsStart contentStart fit-content" data-expected-width="110" data-expected-height="260">
    3838        <div class="firstRowFirstColumn   verticalRL" data-offset-x="0"  data-offset-y="0"  data-expected-width="10" data-expected-height="50">X X X</div>
    3939        <div class="firstRowSecondColumn  verticalRL" data-offset-x="100" data-offset-y="0"  data-expected-width="10" data-expected-height="110">X X X X X X</div>
     
    4545<p>VERTICAL-LR container with HORIZONTAL-TB items.</p>
    4646<div class="container">
    47     <div class="grid itemsStart contentStart verticalLR fit-content" data-expected-width="260" data-expected-height="120">
     47    <div class="grid itemsStart contentStart verticalLR fit-content" data-expected-width="260" data-expected-height="110">
    4848        <div class="firstRowFirstColumn   horizontalTB" data-offset-x="0"   data-offset-y="0"  data-expected-width="50" data-expected-height="10">X X X</div>
    4949        <div class="firstRowSecondColumn  horizontalTB" data-offset-x="0" data-offset-y="100" data-expected-width="110" data-expected-height="10">X X X X X X</div>
     
    5555<p>VERTICAL-RL container with HORIZONTAL-TB items.</p>
    5656<div class="container">
    57     <div class="grid itemsStart contentStart verticalRL fit-content" data-expected-width="260" data-expected-height="100">
     57    <div class="grid itemsStart contentStart verticalRL fit-content" data-expected-width="260" data-expected-height="110">
    5858        <div class="firstRowFirstColumn   horizontalTB" data-offset-x="210"   data-offset-y="0"  data-expected-width="50" data-expected-height="10">X X X</div>
    5959        <div class="firstRowSecondColumn  horizontalTB" data-offset-x="150" data-offset-y="100" data-expected-width="110" data-expected-height="10">X X X X X X</div>
  • trunk/Source/WebCore/ChangeLog

    r207459 r207460  
     12016-10-18  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        [css-grid] Different width of grid container between initial load and refresh
     4        https://bugs.webkit.org/show_bug.cgi?id=163535
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        Grid's layout logic manages two different override sizes; one it's
     9        designed to implement the grid item's stretching behavior, identified
     10        with the concept of 'overrideContentLogicalSize'; there is another
     11        override size, known as overrideContainingBlockContentLogicalSize,
     12        used to implement the Grid Area abstraction, which will behave as
     13        the actual containing block of any grid item.
     14
     15        During grid's layout logic these override sizes are set according
     16        to the CSS style rules. This affects how the grid container and its
     17        children are going to be sized during layout. Grid Tracks sizing
     18        algorithm depends on these override sizes.
     19
     20        In order to ensure that the tracks sizing algorithm produces the
     21        same results when it's run consecutively several times, we need to
     22        clear these override sizes and perform a layout of the affected grid
     23        items. Otherwise, the affected items will return sizing values which
     24        depend on the override values set in the previous layout, which in
     25        some cases, like orthogonal flows, may change through different runs
     26        of the sizing algorithm.
     27
     28        Test: fast/css-grid-layout/repeating-layout-must-produce-the-same-results.html
     29
     30        * rendering/RenderGrid.cpp:
     31        (WebCore::RenderGrid::layoutBlock):
     32
    1332016-10-18  Youenn Fablet  <youenn@apple.com>
    234
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r207457 r207460  
    460460
    461461    LayoutSize previousSize = size();
     462
     463    // We need to clear both own and containingBlock override sizes of orthogonal items to ensure we get the
     464    // same result when grid's intrinsic size is computed again in the updateLogicalWidth call bellow.
     465    if (sizesLogicalWidthToFitContent(MaxSize) || style().logicalWidth().isIntrinsicOrAuto()) {
     466        for (auto* child = firstChildBox(); child; child = child->nextSiblingBox()) {
     467            if (child->isOutOfFlowPositioned() || !isOrthogonalChild(*child))
     468                continue;
     469            child->clearOverrideSize();
     470            child->clearContainingBlockOverrideSize();
     471            child->setNeedsLayout();
     472            child->layoutIfNeeded();
     473        }
     474    }
    462475
    463476    setLogicalHeight(0);
Note: See TracChangeset for help on using the changeset viewer.