Title: [273435] trunk
- Revision
- 273435
- Author
- commit-qu...@webkit.org
- Date
- 2021-02-24 13:35:41 -0800 (Wed, 24 Feb 2021)
Log Message
[css-grid] Fix min/max widths of grid affected by ancestor
https://bugs.webkit.org/show_bug.cgi?id=222100
Patch by Ziran Sun <z...@igalia.com> on 2021-02-24
Reviewed by Javier Fernandez.
LayoutTests/imported/w3c:
Updated test expectation files.
* web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-002-expected.txt:
* web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-lr-002-expected.txt:
* web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-rl-002-expected.txt:
Source/WebCore:
We need to recalculate min/max widths of child that depend on the ancestor.
Before update logical-width, for element that needs preferredWidth recalcution,
it is necessary to make sure that min/max widths are set dirty.
This change is an import of chromium CL at
https://chromium-review.googlesource.com/c/chromium/src/+/527640/
Only the parts that apply to this issue are imported.
Tests were already imported in WPT.
* rendering/RenderBox.cpp:
(WebCore::shouldRecalculateMinMaxWidthsAffectedByAncestor):
(WebCore::RenderBox::updateLogicalWidth):
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (273434 => 273435)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-02-24 21:24:18 UTC (rev 273434)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-02-24 21:35:41 UTC (rev 273435)
@@ -1,3 +1,16 @@
+2021-02-24 Ziran Sun <z...@igalia.com>
+
+ [css-grid] Fix min/max widths of grid affected by ancestor
+ https://bugs.webkit.org/show_bug.cgi?id=222100
+
+ Reviewed by Javier Fernandez.
+
+ Updated test expectation files.
+
+ * web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-002-expected.txt:
+ * web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-lr-002-expected.txt:
+ * web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-rl-002-expected.txt:
+
2021-02-24 Imanol Fernandez <ifernan...@igalia.com>
Implement WebXR getViewport
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-002-expected.txt (273434 => 273435)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-002-expected.txt 2021-02-24 21:24:18 UTC (rev 273434)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-002-expected.txt 2021-02-24 21:35:41 UTC (rev 273435)
@@ -1,30 +1,10 @@
-FAIL .grid 1 assert_equals:
-<div class="grid">
- <div class="paddingLeft50Percent" data-expected-padding-left="50" data-expected-width="60" data-expected-height="10">X</div>
- <div data-offset-x="0" data-offset-y="10" data-expected-width="100" data-expected-height="10"></div>
-</div>
-width expected 60 but got 50
-FAIL .grid 2 assert_equals:
-<div class="grid">
- <div class="paddingRight50Percent" data-expected-padding-right="50" data-expected-width="60" data-expected-height="10">X</div>
- <div data-offset-x="0" data-offset-y="10" data-expected-width="100" data-expected-height="10"></div>
-</div>
-width expected 60 but got 50
+PASS .grid 1
+PASS .grid 2
PASS .grid 3
PASS .grid 4
-FAIL .grid 5 assert_equals:
-<div class="grid directionRTL">
- <div class="paddingLeft50Percent" data-expected-padding-left="50" data-expected-width="60" data-expected-height="10">X</div>
- <div data-offset-x="400" data-offset-y="10" data-expected-width="100" data-expected-height="10"></div>
-</div>
-width expected 60 but got 50
-FAIL .grid 6 assert_equals:
-<div class="grid directionRTL">
- <div class="paddingRight50Percent" data-expected-padding-right="50" data-expected-width="60" data-expected-height="10">X</div>
- <div data-offset-x="400" data-offset-y="10" data-expected-width="100" data-expected-height="10"></div>
-</div>
-width expected 60 but got 50
+PASS .grid 5
+PASS .grid 6
PASS .grid 7
PASS .grid 8
Direction LTR
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-lr-002-expected.txt (273434 => 273435)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-lr-002-expected.txt 2021-02-24 21:24:18 UTC (rev 273434)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-lr-002-expected.txt 2021-02-24 21:35:41 UTC (rev 273435)
@@ -1,32 +1,12 @@
PASS .grid 1
PASS .grid 2
-FAIL .grid 3 assert_equals:
-<div class="grid">
- <div class="paddingTop50Percent" data-expected-padding-top="50" data-expected-width="10" data-expected-height="60">X</div>
- <div data-offset-x="10" data-offset-y="0" data-expected-width="10" data-expected-height="100"></div>
-</div>
-height expected 60 but got 50
-FAIL .grid 4 assert_equals:
-<div class="grid">
- <div class="paddingBottom50Percent" data-expected-padding-bottom="50" data-expected-width="10" data-expected-height="60">X</div>
- <div data-offset-x="10" data-offset-y="0" data-expected-width="10" data-expected-height="100"></div>
-</div>
-height expected 60 but got 50
+PASS .grid 3
+PASS .grid 4
PASS .grid 5
PASS .grid 6
-FAIL .grid 7 assert_equals:
-<div class="grid directionRTL">
- <div class="paddingTop50Percent" data-expected-padding-top="50" data-expected-width="10" data-expected-height="60">X</div>
- <div data-offset-x="10" data-offset-y="400" data-expected-width="10" data-expected-height="100"></div>
-</div>
-height expected 60 but got 50
-FAIL .grid 8 assert_equals:
-<div class="grid directionRTL">
- <div class="paddingBottom50Percent" data-expected-padding-bottom="50" data-expected-width="10" data-expected-height="60">X</div>
- <div data-offset-x="10" data-offset-y="400" data-expected-width="10" data-expected-height="100"></div>
-</div>
-height expected 60 but got 50
+PASS .grid 7
+PASS .grid 8
Direction LTR
Item padding-left: 50%;
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-rl-002-expected.txt (273434 => 273435)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-rl-002-expected.txt 2021-02-24 21:24:18 UTC (rev 273434)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-rl-002-expected.txt 2021-02-24 21:35:41 UTC (rev 273435)
@@ -1,32 +1,12 @@
PASS .grid 1
PASS .grid 2
-FAIL .grid 3 assert_equals:
-<div class="grid">
- <div class="paddingTop50Percent" data-expected-padding-top="50" data-expected-width="10" data-expected-height="60">X</div>
- <div data-offset-x="0" data-offset-y="0" data-expected-width="10" data-expected-height="100"></div>
-</div>
-height expected 60 but got 50
-FAIL .grid 4 assert_equals:
-<div class="grid">
- <div class="paddingBottom50Percent" data-expected-padding-bottom="50" data-expected-width="10" data-expected-height="60">X</div>
- <div data-offset-x="0" data-offset-y="0" data-expected-width="10" data-expected-height="100"></div>
-</div>
-height expected 60 but got 50
+PASS .grid 3
+PASS .grid 4
PASS .grid 5
PASS .grid 6
-FAIL .grid 7 assert_equals:
-<div class="grid directionRTL">
- <div class="paddingTop50Percent" data-expected-padding-top="50" data-expected-width="10" data-expected-height="60">X</div>
- <div data-offset-x="0" data-offset-y="400" data-expected-width="10" data-expected-height="100"></div>
-</div>
-height expected 60 but got 50
-FAIL .grid 8 assert_equals:
-<div class="grid directionRTL">
- <div class="paddingBottom50Percent" data-expected-padding-bottom="50" data-expected-width="10" data-expected-height="60">X</div>
- <div data-offset-x="0" data-offset-y="400" data-expected-width="10" data-expected-height="100"></div>
-</div>
-height expected 60 but got 50
+PASS .grid 7
+PASS .grid 8
Direction LTR
Item padding-left: 50%;
Modified: trunk/Source/WebCore/ChangeLog (273434 => 273435)
--- trunk/Source/WebCore/ChangeLog 2021-02-24 21:24:18 UTC (rev 273434)
+++ trunk/Source/WebCore/ChangeLog 2021-02-24 21:35:41 UTC (rev 273435)
@@ -1,3 +1,24 @@
+2021-02-24 Ziran Sun <z...@igalia.com>
+
+ [css-grid] Fix min/max widths of grid affected by ancestor
+ https://bugs.webkit.org/show_bug.cgi?id=222100
+
+ Reviewed by Javier Fernandez.
+
+ We need to recalculate min/max widths of child that depend on the ancestor.
+ Before update logical-width, for element that needs preferredWidth recalcution,
+ it is necessary to make sure that min/max widths are set dirty.
+
+ This change is an import of chromium CL at
+ https://chromium-review.googlesource.com/c/chromium/src/+/527640/
+ Only the parts that apply to this issue are imported.
+
+ Tests were already imported in WPT.
+
+ * rendering/RenderBox.cpp:
+ (WebCore::shouldRecalculateMinMaxWidthsAffectedByAncestor):
+ (WebCore::RenderBox::updateLogicalWidth):
+
2021-02-24 Michael Catanzaro <mcatanz...@gnome.org>
Unreviewed, silence -Wreturn-type warnings from r273127
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (273434 => 273435)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2021-02-24 21:24:18 UTC (rev 273434)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2021-02-24 21:35:41 UTC (rev 273435)
@@ -2475,8 +2475,32 @@
{
}
+static bool shouldRecalculateMinMaxWidthsAffectedByAncestor(const RenderBox* box)
+{
+ // If the preferred widths are already dirty at this point (during layout), it actually means that we never need to calculate them, since that should
+ // have been carried out by an ancestor that's sized based on preferred widths (a shrink-to-fit container, for instance). In such cases the
+ // object will be left as dirty indefinitely, and it would just be a waste of time to calculate the preferred withs when nobody needs them.
+ if (box->preferredLogicalWidthsDirty())
+ return false;
+ // If our containing block also has min/max widths that are affected by the ancestry, we have already dealt with this object as well. Avoid
+ // unnecessary work and O(n^2) time complexity.
+ if (const RenderBox* cb = box->containingBlock()) {
+ if (cb->needsPreferredWidthsRecalculation() && !cb->preferredLogicalWidthsDirty())
+ return false;
+ }
+ return true;
+}
+
void RenderBox::updateLogicalWidth()
{
+ // Laying out this object means that its containing block is also being laid out. This object is special, in that its min/max widths depend on
+ // the ancestry (min/max width calculation should ideally be strictly bottom-up, but that's not always the case), so since the containing
+ // block size may have changed, we need to recalculate the min/max widths of this object, and every child that has the same issue, recursively.
+ if (needsPreferredWidthsRecalculation() && shouldRecalculateMinMaxWidthsAffectedByAncestor(this)) {
+ setPreferredLogicalWidthsDirty(true, MarkOnlyThis);
+ const_cast<RenderBox&>(*this).computePreferredLogicalWidths();
+ }
+
LogicalExtentComputedValues computedValues;
computeLogicalWidthInFragment(computedValues);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes