Diff
Modified: trunk/LayoutTests/ChangeLog (263259 => 263260)
--- trunk/LayoutTests/ChangeLog 2020-06-19 12:27:23 UTC (rev 263259)
+++ trunk/LayoutTests/ChangeLog 2020-06-19 12:43:03 UTC (rev 263260)
@@ -1,3 +1,13 @@
+2020-06-19 Zalan Bujtas <za...@apple.com>
+
+ [LFC][BFC] Min/max-width should always be resolved against the containing block width
+ https://bugs.webkit.org/show_bug.cgi?id=213365
+
+ Reviewed by Antti Koivisto.
+
+ * fast/layoutformattingcontext/float-avoider-available-horizontal-space2-expected.html: Added.
+ * fast/layoutformattingcontext/float-avoider-available-horizontal-space2.html: Added.
+
2020-06-19 Myles C. Maxfield <mmaxfi...@apple.com>
[Cocoa] Unify "font:" CSS shorthand values between macOS and iOS family
Added: trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space2-expected.html (0 => 263260)
--- trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space2-expected.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space2-expected.html 2020-06-19 12:43:03 UTC (rev 263260)
@@ -0,0 +1,19 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+.first {
+ height: 100px;
+ width: 40px;
+ background-color: green;
+}
+
+.second {
+ height: 100px;
+ width: 10px;
+ position: relative;
+ top: -100px;
+ left: 40px;
+ background-color: blue;
+}
+</style>
+<div class=first></div>
+<div class=second></div>
Added: trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space2.html (0 => 263260)
--- trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space2.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/float-avoider-available-horizontal-space2.html 2020-06-19 12:43:03 UTC (rev 263260)
@@ -0,0 +1,25 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+.container {
+ width: 100px;
+ height: 100px;
+}
+
+.floatBox {
+ float: left;
+ width: 40px;
+ height: 100px;
+ background-color: green;
+}
+
+.floatAvoider {
+ overflow: hidden;
+ height: 100%;
+ background-color: blue;
+ max-width: 10%;
+}
+</style>
+<div class=container>
+ <div class=floatBox></div>
+ <div class=floatAvoider></div>
+</div>
Modified: trunk/Source/WebCore/ChangeLog (263259 => 263260)
--- trunk/Source/WebCore/ChangeLog 2020-06-19 12:27:23 UTC (rev 263259)
+++ trunk/Source/WebCore/ChangeLog 2020-06-19 12:43:03 UTC (rev 263260)
@@ -1,3 +1,23 @@
+2020-06-19 Zalan Bujtas <za...@apple.com>
+
+ [LFC][BFC] Min/max-width should always be resolved against the containing block width
+ https://bugs.webkit.org/show_bug.cgi?id=213365
+
+ Reviewed by Antti Koivisto.
+
+ Even when neighboring floats shrink the available horizontal space, the min/max(normal) widths should
+ be resolved against the containing block's logical width.
+
+ Test: fast/layoutformattingcontext/float-avoider-available-horizontal-space2.html
+
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin):
+ * layout/blockformatting/BlockFormattingContext.h:
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::computedWidthAndMargin):
+ * layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:
+ (WebCore::Layout::TableWrapperBlockFormattingContext::computeWidthAndMarginForTableBox):
+
2020-06-10 Sergio Villar Senin <svil...@igalia.com>
[WebXR] unsigned long in IDL should be translated as unsigned in C++ code
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (263259 => 263260)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-06-19 12:27:23 UTC (rev 263259)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-06-19 12:43:03 UTC (rev 263260)
@@ -314,14 +314,12 @@
void BlockFormattingContext::computeWidthAndMargin(const FloatingContext& floatingContext, const Box& layoutBox, const ConstraintsPair& constraintsPair)
{
- auto adjustedConstraints = constraintsPair;
- if (layoutBox.isFloatAvoider() && layoutBox.style().logicalWidth().isAuto()) {
+ auto availableWidthFloatAvoider = Optional<LayoutUnit> { };
+ if (layoutBox.isFloatAvoider()) {
// Float avoiders' available width might be shrunk by existing floats in the context.
- if (auto availableWidthForFloatAvoider = usedAvailableWidthForFloatAvoider(floatingContext, layoutBox, constraintsPair))
- adjustedConstraints.containingBlock.horizontal.logicalWidth = *availableWidthForFloatAvoider;
+ availableWidthFloatAvoider = usedAvailableWidthForFloatAvoider(floatingContext, layoutBox, constraintsPair);
}
-
- auto contentWidthAndMargin = geometry().computedWidthAndMargin(layoutBox, adjustedConstraints);
+ auto contentWidthAndMargin = geometry().computedWidthAndMargin(layoutBox, constraintsPair.containingBlock.horizontal, availableWidthFloatAvoider);
auto& displayBox = formattingState().displayBox(layoutBox);
displayBox.setContentBoxWidth(contentWidthAndMargin.contentWidth);
displayBox.setHorizontalMargin(contentWidthAndMargin.usedMargin);
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (263259 => 263260)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2020-06-19 12:27:23 UTC (rev 263259)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2020-06-19 12:43:03 UTC (rev 263260)
@@ -85,7 +85,7 @@
IntrinsicWidthConstraints intrinsicWidthConstraints(const Box&);
- ContentWidthAndMargin computedWidthAndMargin(const Box&, const ConstraintsPair&);
+ ContentWidthAndMargin computedWidthAndMargin(const Box&, const HorizontalConstraints&, Optional<LayoutUnit> availableWidthFloatAvoider);
private:
ContentHeightAndMargin inFlowNonReplacedHeightAndMargin(const Box&, const HorizontalConstraints&, const OverrideVerticalValues&);
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (263259 => 263260)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2020-06-19 12:27:23 UTC (rev 263259)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2020-06-19 12:43:03 UTC (rev 263260)
@@ -283,31 +283,35 @@
return inFlowReplacedWidthAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, overrideHorizontalValues);
}
-ContentWidthAndMargin BlockFormattingContext::Geometry::computedWidthAndMargin(const Box& layoutBox, const ConstraintsPair& constraintsPair)
+ContentWidthAndMargin BlockFormattingContext::Geometry::computedWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, Optional<LayoutUnit> availableWidthFloatAvoider)
{
- auto& horizontalConstraints = constraintsPair.containingBlock.horizontal;
- auto compute = [&](Optional<LayoutUnit> usedWidth) {
+ auto compute = [&] (auto constraintsForWidth, Optional<LayoutUnit> usedWidth) {
if (layoutBox.isFloatingPositioned())
- return floatingWidthAndMargin(layoutBox, horizontalConstraints, { usedWidth, { } });
+ return floatingWidthAndMargin(layoutBox, constraintsForWidth, { usedWidth, { } });
if (layoutBox.isInFlow())
- return inFlowWidthAndMargin(layoutBox, horizontalConstraints, { usedWidth, { } });
+ return inFlowWidthAndMargin(layoutBox, constraintsForWidth, { usedWidth, { } });
ASSERT_NOT_REACHED();
return ContentWidthAndMargin { };
};
- auto contentWidthAndMargin = compute({ });
-
+ auto horizontalConstraintsForWidth = horizontalConstraints;
+ if (layoutBox.style().logicalWidth().isAuto() && availableWidthFloatAvoider) {
+ // While the non-auto width values should all be resolved against the containing block's width, when
+ // the width is auto the available horizontal space is shrunk by neighboring floats.
+ horizontalConstraintsForWidth.logicalWidth = *availableWidthFloatAvoider;
+ }
+ auto contentWidthAndMargin = compute(horizontalConstraintsForWidth, { });
auto availableWidth = horizontalConstraints.logicalWidth;
if (auto maxWidth = computedMaxWidth(layoutBox, availableWidth)) {
- auto maxWidthAndMargin = compute(maxWidth);
+ auto maxWidthAndMargin = compute(horizontalConstraints, maxWidth);
if (contentWidthAndMargin.contentWidth > maxWidthAndMargin.contentWidth)
contentWidthAndMargin = maxWidthAndMargin;
}
auto minWidth = computedMinWidth(layoutBox, availableWidth).valueOr(0);
- auto minWidthAndMargin = compute(minWidth);
+ auto minWidthAndMargin = compute(horizontalConstraints, minWidth);
if (contentWidthAndMargin.contentWidth < minWidthAndMargin.contentWidth)
contentWidthAndMargin = minWidthAndMargin;
return contentWidthAndMargin;
Modified: trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp (263259 => 263260)
--- trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp 2020-06-19 12:27:23 UTC (rev 263259)
+++ trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp 2020-06-19 12:43:03 UTC (rev 263260)
@@ -145,8 +145,7 @@
{
ASSERT(tableBox.isTableBox());
if (!tableBox.hasChild()) {
- auto constraintsPair = ConstraintsPair { { horizontalConstraints, { } }, { horizontalConstraints, { } } };
- auto computedWidthAndMargin = geometry().computedWidthAndMargin(tableBox, constraintsPair);
+ auto computedWidthAndMargin = geometry().computedWidthAndMargin(tableBox, horizontalConstraints, { });
auto& displayBox = formattingState().displayBox(tableBox);
displayBox.setContentBoxWidth(computedWidthAndMargin.contentWidth);
displayBox.setHorizontalMargin(computedWidthAndMargin.usedMargin);