- Revision
- 276835
- Author
- [email protected]
- Date
- 2021-04-30 04:46:09 -0700 (Fri, 30 Apr 2021)
Log Message
Nullopt in RenderFlexibleBox::layoutFlexItems in RenderFlexibleBox::layoutBlock via RenderMultiColumnFlow::layout
https://bugs.webkit.org/show_bug.cgi?id=223369
Reviewed by Alan Bujtas.
LayoutTests/imported/w3c:
Imported a test from WPT covering this issue.
* web-platform-tests/css/css-flexbox/percentage-padding-002-expected.html: Added.
* web-platform-tests/css/css-flexbox/percentage-padding-002.html: Added.
* web-platform-tests/css/css-flexbox/w3c-import.log:
Source/WebCore:
When computing the main axis extent of a flex item being the main axis also the child's inline axis and the
inline size of the child is auto, we can directly use the min/maxPreferredLogicalWidths instead of having
to call computeLogicalWidthInFragmentUsing(). However we cannot use it straigth away without checking
needsPreferredWidthsRecalculation() first, otherwise the cached preferred width might be no longer valid.
The cached preferred width includes both border and padding. If any of those are percentages, and thus
depend on the size of the containing block, we could end up using obsolete values.
This was making us hit an assertion because the content size suggestion was negative. That's because in order
to compute the content size we were substracting the current borderAndPadding() to the value returned by
minPreferredLogicalWidth(). But the current borderAndPadding() might be larger than the one used to compute the
preferred width before (they must be the same to properly extract the content size) so the content size ended
up being negative.
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::computeMainAxisExtentForChild):
(WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax): Constness adjustments.
(WebCore::RenderFlexibleBox::resolveFlexibleLengths): Ditto.
* rendering/RenderFlexibleBox.h:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (276834 => 276835)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-04-30 07:18:28 UTC (rev 276834)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-04-30 11:46:09 UTC (rev 276835)
@@ -1,3 +1,16 @@
+2021-04-30 Sergio Villar Senin <[email protected]>
+
+ Nullopt in RenderFlexibleBox::layoutFlexItems in RenderFlexibleBox::layoutBlock via RenderMultiColumnFlow::layout
+ https://bugs.webkit.org/show_bug.cgi?id=223369
+
+ Reviewed by Alan Bujtas.
+
+ Imported a test from WPT covering this issue.
+
+ * web-platform-tests/css/css-flexbox/percentage-padding-002-expected.html: Added.
+ * web-platform-tests/css/css-flexbox/percentage-padding-002.html: Added.
+ * web-platform-tests/css/css-flexbox/w3c-import.log:
+
2021-04-29 Sam Weinig <[email protected]>
Add support for CanvasRenderingContext2DSettings
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-002-expected.html (0 => 276835)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-002-expected.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-002-expected.html 2021-04-30 11:46:09 UTC (rev 276835)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<link rel="author" title="Sergio Villar Senin" href=""
+<style>
+div {
+ width: 50px;
+ height: 50px;
+}
+span {
+ display: block;
+ border: 5px solid black;
+}
+</style>
+<p>Test passes if there is a white square inside a 10x30 white box.</p>
+<div>
+ <span style="width: 10px; height: 30px;">
+ <span style="padding: 10px;"></span>
+ </span>
+<div>
Property changes on: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-002-expected.html
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: svn:mime-type
+text/html
\ No newline at end of property
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-002.html (0 => 276835)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-002.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-002.html 2021-04-30 11:46:09 UTC (rev 276835)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<title>This test checks that percentage paddings do not lead to flex items with negative sizes.</title>
+<link rel="author" title="Sergio Villar Senin" href=""
+<link rel="help" href="" title="Percentages line">
+<link rel="match" href=""
+<style>
+div {
+ width: 50px;
+ height: 50px;
+}
+span {
+ display: inline-flex;
+ border: 5px solid black;
+}
+</style>
+<p>Test passes if there is a white square inside a 10x30 white box.</p>
+<div>
+ <span>
+ <span style="padding: 100%;"></span>
+ </span>
+<div>
Property changes on: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-002.html
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: svn:mime-type
+text/html
\ No newline at end of property
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/w3c-import.log (276834 => 276835)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/w3c-import.log 2021-04-30 07:18:28 UTC (rev 276834)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/w3c-import.log 2021-04-30 11:46:09 UTC (rev 276835)
@@ -1560,6 +1560,8 @@
/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-max-height-004.html
/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-max-width-cross-axis.html
/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-001.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-002-expected.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-padding-002.html
/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-size-quirks-002.html
/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-size-quirks.html
/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/percentage-size-subitems-001-expected.html
Modified: trunk/Source/WebCore/ChangeLog (276834 => 276835)
--- trunk/Source/WebCore/ChangeLog 2021-04-30 07:18:28 UTC (rev 276834)
+++ trunk/Source/WebCore/ChangeLog 2021-04-30 11:46:09 UTC (rev 276835)
@@ -1,3 +1,29 @@
+2021-04-30 Sergio Villar Senin <[email protected]>
+
+ Nullopt in RenderFlexibleBox::layoutFlexItems in RenderFlexibleBox::layoutBlock via RenderMultiColumnFlow::layout
+ https://bugs.webkit.org/show_bug.cgi?id=223369
+
+ Reviewed by Alan Bujtas.
+
+ When computing the main axis extent of a flex item being the main axis also the child's inline axis and the
+ inline size of the child is auto, we can directly use the min/maxPreferredLogicalWidths instead of having
+ to call computeLogicalWidthInFragmentUsing(). However we cannot use it straigth away without checking
+ needsPreferredWidthsRecalculation() first, otherwise the cached preferred width might be no longer valid.
+ The cached preferred width includes both border and padding. If any of those are percentages, and thus
+ depend on the size of the containing block, we could end up using obsolete values.
+
+ This was making us hit an assertion because the content size suggestion was negative. That's because in order
+ to compute the content size we were substracting the current borderAndPadding() to the value returned by
+ minPreferredLogicalWidth(). But the current borderAndPadding() might be larger than the one used to compute the
+ preferred width before (they must be the same to properly extract the content size) so the content size ended
+ up being negative.
+
+ * rendering/RenderFlexibleBox.cpp:
+ (WebCore::RenderFlexibleBox::computeMainAxisExtentForChild):
+ (WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax): Constness adjustments.
+ (WebCore::RenderFlexibleBox::resolveFlexibleLengths): Ditto.
+ * rendering/RenderFlexibleBox.h:
+
2021-04-30 Youenn Fablet <[email protected]>
MediaPlayerPrivateMediaStreamAVFObjC::ensureLayers lambda should check its player is alive
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (276834 => 276835)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2021-04-30 07:18:28 UTC (rev 276834)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2021-04-30 11:46:09 UTC (rev 276835)
@@ -547,7 +547,7 @@
return child.hasIntrinsicAspectRatio() || child.style().hasAspectRatio();
}
-Optional<LayoutUnit> RenderFlexibleBox::computeMainAxisExtentForChild(const RenderBox& child, SizeType sizeType, const Length& size)
+Optional<LayoutUnit> RenderFlexibleBox::computeMainAxisExtentForChild(RenderBox& child, SizeType sizeType, const Length& size)
{
// If we have a horizontal flow, that means the main size is the width.
// That's the logical width for horizontal writing modes, and the logical
@@ -571,18 +571,23 @@
// computeLogicalWidth always re-computes the intrinsic widths. However, when
// our logical width is auto, we can just use our cached value. So let's do
- // that here. (Compare code in LayoutBlock::computePreferredLogicalWidths)
- LayoutUnit borderAndPadding = child.borderAndPaddingLogicalWidth();
+ // that here. (Compare code in RenderBlock::computePreferredLogicalWidths)
if (child.style().logicalWidth().isAuto() && !childHasAspectRatio(child)) {
- if (size.isMinContent())
- return child.minPreferredLogicalWidth() - borderAndPadding;
- if (size.isMaxContent())
- return child.maxPreferredLogicalWidth() - borderAndPadding;
+ if (size.isMinContent()) {
+ if (child.needsPreferredWidthsRecalculation())
+ child.setPreferredLogicalWidthsDirty(true, MarkOnlyThis);
+ return child.minPreferredLogicalWidth() - child.borderAndPaddingLogicalWidth();
+ }
+ if (size.isMaxContent()) {
+ if (child.needsPreferredWidthsRecalculation())
+ child.setPreferredLogicalWidthsDirty(true, MarkOnlyThis);
+ return child.maxPreferredLogicalWidth() - child.borderAndPaddingLogicalWidth();
+ }
}
// FIXME: Figure out how this should work for regions and pass in the appropriate values.
RenderFragmentContainer* fragment = nullptr;
- return child.computeLogicalWidthInFragmentUsing(sizeType, size, contentLogicalWidth(), *this, fragment) - borderAndPadding;
+ return child.computeLogicalWidthInFragmentUsing(sizeType, size, contentLogicalWidth(), *this, fragment) - child.borderAndPaddingLogicalWidth();
}
WritingMode RenderFlexibleBox::transformedWritingMode() const
@@ -1184,7 +1189,7 @@
}
}
-LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(const RenderBox& child, LayoutUnit childSize)
+LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox& child, LayoutUnit childSize)
{
Length max = mainSizeLengthForChild(MaxSize, child);
Optional<LayoutUnit> maxExtent = WTF::nullopt;
@@ -1378,7 +1383,7 @@
for (size_t i = 0; i < children.size(); ++i) {
FlexItem& flexItem = children[i];
- const auto& child = flexItem.box;
+ auto& child = flexItem.box;
// This check also covers out-of-flow children.
if (flexItem.frozen)
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (276834 => 276835)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h 2021-04-30 07:18:28 UTC (rev 276834)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h 2021-04-30 11:46:09 UTC (rev 276835)
@@ -125,7 +125,7 @@
LayoutUnit mainAxisExtent() const;
LayoutUnit crossAxisContentExtent() const;
LayoutUnit mainAxisContentExtent(LayoutUnit contentLogicalHeight);
- Optional<LayoutUnit> computeMainAxisExtentForChild(const RenderBox& child, SizeType, const Length& size);
+ Optional<LayoutUnit> computeMainAxisExtentForChild(RenderBox& child, SizeType, const Length& size);
WritingMode transformedWritingMode() const;
LayoutUnit flowAwareBorderStart() const;
LayoutUnit flowAwareBorderEnd() const;
@@ -173,7 +173,7 @@
LayoutUnit computeChildMarginValue(Length margin);
void prepareOrderIteratorAndMargins();
- LayoutUnit adjustChildSizeForMinAndMax(const RenderBox& child, LayoutUnit childSize);
+ LayoutUnit adjustChildSizeForMinAndMax(RenderBox& child, LayoutUnit childSize);
LayoutUnit adjustChildSizeForAspectRatioCrossAxisMinAndMax(const RenderBox& child, LayoutUnit childSize);
FlexItem constructFlexItem(RenderBox&, bool relayoutChildren);