[css-grid] Make the grid sizing data persistent through layouts
authorjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jan 2017 18:41:28 +0000 (18:41 +0000)
committerjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jan 2017 18:41:28 +0000 (18:41 +0000)
commit249127d8d736188ddc657ce867cd89425a9e6737
tree27a6c8275d9054ddef74ce39e11e7b7b32777b4a
parent6971b34826e8053a45ccc31580b470b3952eb988
[css-grid] Make the grid sizing data persistent through layouts
https://bugs.webkit.org/show_bug.cgi?id=166883

Reviewed by Darin Adler and Manuel Rego Casasnovas.

Source/WebCore:

We want to keep the grid sizing data structures through different
layouts. This will allow to optimize some operations, reusing
these data while still valid. Additionally, operations like
determining the baseline position when the grid container is under
an inline formatting context need these data once the grid has
been laid out.

This patch controls the sizing data validity and make the data
structures persistent after layout.

Tests: fast/css-grid-layout/grid-add-item-with-positioned-items.html
       fast/css-grid-layout/grid-add-positioned-block-item-after-inline-item.html
       fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child.html
       fast/css-grid-layout/grid-item-change-order-auto-flow.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::styleDidChange): Evaluate if the style change made the grid data invalid.
(WebCore::RenderBox::updateGridPositionAfterStyleChange): Evaluate if the style change made the grid data invalid.
* rendering/RenderBox.h:
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::Grid::setNeedsItemsPlacement): The grid must execute the items placement logic before continue processing the layout.
(WebCore::RenderGrid::addChild): Mark the grid data as dirty.
(WebCore::RenderGrid::removeChild): Mark the grid data as dirty.
(WebCore::RenderGrid::styleDidChange): Evaluate grid data validity.
(WebCore::RenderGrid::explicitGridDidResize): Mark the grid data as dirty.
(WebCore::RenderGrid::namedGridLinesDefinitionDidChange): Mark the grid data as dirty.
(WebCore::RenderGrid::layoutBlock): We don't need to clear the grid data anymore.
(WebCore::RenderGrid::dirtyGrid): Clearing the grid data and mark is as needing to execute the items placement logic.
(WebCore::RenderGrid::trackSizesForComputedStyle): Assert we don't need to perform the items placement logic.
(WebCore::RenderGrid::paintChildren): Assert we don't need to perform the items placement logic.
* rendering/RenderGrid.h:
(WebCore::RenderGrid::clear): Deleted.

LayoutTests:

The tests added are now needed to verify we perform correctly the
data validation after certain style changes.

* fast/css-grid-layout/grid-add-item-with-positioned-items-expected.txt: Added.
* fast/css-grid-layout/grid-add-item-with-positioned-items.html: Added.
* fast/css-grid-layout/grid-add-positioned-block-item-after-inline-item-expected.txt: Added.
* fast/css-grid-layout/grid-add-positioned-block-item-after-inline-item.html: Added.
* fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child-expected.txt: Added.
* fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child.html: Added.
* fast/css-grid-layout/grid-item-change-order-auto-flow-expected.txt: Added.
* fast/css-grid-layout/grid-item-change-order-auto-flow.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-add-item-with-positioned-items-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-add-item-with-positioned-items.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-add-positioned-block-item-after-inline-item-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-add-positioned-block-item-after-inline-item.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-container-change-explicit-grid-recompute-child.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-change-order-auto-flow-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-change-order-auto-flow.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h