From 48e08820414b952a99719731e164b61a2a9d7769 Mon Sep 17 00:00:00 2001 From: "jfernandez@igalia.com" Date: Wed, 7 Oct 2015 13:14:11 +0000 Subject: [PATCH] [CSS Grid Layout] Modify grid item height doesn't work https://bugs.webkit.org/show_bug.cgi?id=149840 Reviewed by Sergio Villar Senin. Source/WebCore: When computing the logical height of content-sized grid tracks we need to clear grid item's override height if it needs to be laid out again. Currently we are doing so only in the case of percentage heights or when the grid track's width has changed; these situations would obviously mark grid items as needing layout. However, there are other situations, like the one defined in this bug, which would imply a new layout of the grid items; hence we need to clear its override value if we want the layout logic to be computed correctly. * rendering/RenderGrid.cpp: (WebCore::RenderGrid::logicalContentHeightForChild): LayoutTests: Added new tests cases to verify content-sized grid tracks are resized appropriately whenever grid item's height is changed. * fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change-expected.txt: Added new test cases. * fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change.html: Added new test cases. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190665 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 13 ++++++++ ...n-height-or-width-or-margin-change-expected.txt | 3 ++ ...ched-when-height-or-width-or-margin-change.html | 39 +++++++++++++++++++--- Source/WebCore/ChangeLog | 23 +++++++++++++ Source/WebCore/rendering/RenderGrid.cpp | 7 ++-- 5 files changed, 78 insertions(+), 7 deletions(-) diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 64dcf66..f36d2a8 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,16 @@ +2015-10-07 Javier Fernandez + + [CSS Grid Layout] Modify grid item height doesn't work + https://bugs.webkit.org/show_bug.cgi?id=149840 + + Reviewed by Sergio Villar Senin. + + Added new tests cases to verify content-sized grid tracks are resized + appropriately whenever grid item's height is changed. + + * fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change-expected.txt: Added new test cases. + * fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change.html: Added new test cases. + 2015-10-05 Sergio Villar Senin [css-grid] Implement grid gutters diff --git a/LayoutTests/fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change-expected.txt b/LayoutTests/fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change-expected.txt index 65f4411..32ca00c 100644 --- a/LayoutTests/fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change-expected.txt +++ b/LayoutTests/fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change-expected.txt @@ -3,3 +3,6 @@ The grids below had initially 'stretched' items, but we have changed 'height', ' PASS PASS PASS +PASS +PASS +PASS diff --git a/LayoutTests/fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change.html b/LayoutTests/fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change.html index 52b82eb..c9124bb 100644 --- a/LayoutTests/fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change.html +++ b/LayoutTests/fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-width-or-margin-change.html @@ -3,28 +3,31 @@

The grids below had initially 'stretched' items, but we have changed 'height', 'width' and 'margin' to values which don't allow stretch. This test verifies that the layout algorithm properly detects such changes and clear the override height and width accordingly.

-
+
-
+
-
+
@@ -34,6 +37,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 853dd1b..621eb70 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,26 @@ +2015-10-07 Javier Fernandez + + [CSS Grid Layout] Modify grid item height doesn't work + https://bugs.webkit.org/show_bug.cgi?id=149840 + + Reviewed by Sergio Villar Senin. + + When computing the logical height of content-sized grid tracks we + need to clear grid item's override height if it needs to be laid + out again. + + Currently we are doing so only in the case of percentage heights + or when the grid track's width has changed; these situations would + obviously mark grid items as needing layout. + + However, there are other situations, like the one defined in this + bug, which would imply a new layout of the grid items; hence we + need to clear its override value if we want the layout logic to be + computed correctly. + + * rendering/RenderGrid.cpp: + (WebCore::RenderGrid::logicalContentHeightForChild): + 2015-10-07 Xabier Rodriguez Calvar and Youenn Fablet Automate WebCore JS builtins generation and build system diff --git a/Source/WebCore/rendering/RenderGrid.cpp b/Source/WebCore/rendering/RenderGrid.cpp index 6b7c606..31c0d00 100644 --- a/Source/WebCore/rendering/RenderGrid.cpp +++ b/Source/WebCore/rendering/RenderGrid.cpp @@ -590,11 +590,12 @@ LayoutUnit RenderGrid::logicalContentHeightForChild(RenderBox& child, Vector oldOverrideContainingBlockContentLogicalWidth = child.hasOverrideContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth() : LayoutUnit(); LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForChild(child, ForColumns, columnTracks); - if (child.hasRelativeLogicalHeight() || !oldOverrideContainingBlockContentLogicalWidth || oldOverrideContainingBlockContentLogicalWidth.value() != overrideContainingBlockContentLogicalWidth) { + if (child.hasRelativeLogicalHeight() || !oldOverrideContainingBlockContentLogicalWidth || oldOverrideContainingBlockContentLogicalWidth.value() != overrideContainingBlockContentLogicalWidth) child.setNeedsLayout(MarkOnlyThis); - // We need to clear the stretched height to properly compute logical height during layout. + + // We need to clear the stretched height to properly compute logical height during layout. + if (child.needsLayout()) child.clearOverrideLogicalContentHeight(); - } child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockContentLogicalWidth); // If |child| has a relative logical height, we shouldn't let it override its intrinsic height, which is -- 1.8.3.1