Title: [264267] trunk
- Revision
- 264267
- Author
- [email protected]
- Date
- 2020-07-11 08:45:14 -0700 (Sat, 11 Jul 2020)
Log Message
[LFC][BFC][Min-Max width] Add support for float avoiders
https://bugs.webkit.org/show_bug.cgi?id=214220
Reviewed by Antti Koivisto.
Source/WebCore:
Test: fast/layoutformattingcontext/min-max-content-width-with-floats-simple.html
Float avoiders (including the float boxes) with infinite constraint form a horizontal float stack.
(This does not yet support clear property/non-direct children.)
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computedIntrinsicWidthConstraints):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::intrinsicWidthConstraints):
LayoutTests:
* fast/layoutformattingcontext/min-max-content-width-with-floats-simple-expected.html: Added.
* fast/layoutformattingcontext/min-max-content-width-with-floats-simple.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (264266 => 264267)
--- trunk/LayoutTests/ChangeLog 2020-07-11 06:30:24 UTC (rev 264266)
+++ trunk/LayoutTests/ChangeLog 2020-07-11 15:45:14 UTC (rev 264267)
@@ -1,3 +1,13 @@
+2020-07-11 Zalan Bujtas <[email protected]>
+
+ [LFC][BFC][Min-Max width] Add support for float avoiders
+ https://bugs.webkit.org/show_bug.cgi?id=214220
+
+ Reviewed by Antti Koivisto.
+
+ * fast/layoutformattingcontext/min-max-content-width-with-floats-simple-expected.html: Added.
+ * fast/layoutformattingcontext/min-max-content-width-with-floats-simple.html: Added.
+
2020-07-10 Chris Dumez <[email protected]>
Unreviewed, mark a couple of user-timing WPT tests as flaky since their import in r264255.
Added: trunk/LayoutTests/fast/layoutformattingcontext/min-max-content-width-with-floats-simple-expected.html (0 => 264267)
--- trunk/LayoutTests/fast/layoutformattingcontext/min-max-content-width-with-floats-simple-expected.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/min-max-content-width-with-floats-simple-expected.html 2020-07-11 15:45:14 UTC (rev 264267)
@@ -0,0 +1,9 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+ width: 300px;
+ height: 100px;
+ background-color: green;
+}
+</style>
+<div></div>
Added: trunk/LayoutTests/fast/layoutformattingcontext/min-max-content-width-with-floats-simple.html (0 => 264267)
--- trunk/LayoutTests/fast/layoutformattingcontext/min-max-content-width-with-floats-simple.html (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/min-max-content-width-with-floats-simple.html 2020-07-11 15:45:14 UTC (rev 264267)
@@ -0,0 +1,19 @@
+<!DOCTYPE html><!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+.container {
+ float: left;
+ background-color: red;
+}
+
+.child_floating {
+ float:left;
+ width: 100px;
+ height: 100px;
+ background-color: green;
+}
+</style>
+<div class=container>
+<div class=child_floating></div>
+<div class=child_floating></div>
+<div class=child_floating></div>
+</div>
Modified: trunk/Source/WebCore/ChangeLog (264266 => 264267)
--- trunk/Source/WebCore/ChangeLog 2020-07-11 06:30:24 UTC (rev 264266)
+++ trunk/Source/WebCore/ChangeLog 2020-07-11 15:45:14 UTC (rev 264267)
@@ -1,3 +1,20 @@
+2020-07-11 Zalan Bujtas <[email protected]>
+
+ [LFC][BFC][Min-Max width] Add support for float avoiders
+ https://bugs.webkit.org/show_bug.cgi?id=214220
+
+ Reviewed by Antti Koivisto.
+
+ Test: fast/layoutformattingcontext/min-max-content-width-with-floats-simple.html
+
+ Float avoiders (including the float boxes) with infinite constraint form a horizontal float stack.
+ (This does not yet support clear property/non-direct children.)
+
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::computedIntrinsicWidthConstraints):
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::intrinsicWidthConstraints):
+
2020-07-10 Chris Dumez <[email protected]>
Unreviewed, reverting r264242.
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (264266 => 264267)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-07-11 06:30:24 UTC (rev 264266)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-07-11 15:45:14 UTC (rev 264267)
@@ -398,7 +398,6 @@
{
auto& formattingState = this->formattingState();
ASSERT(!formattingState.intrinsicWidthConstraints());
-
// Visit the in-flow descendants and compute their min/max intrinsic width if needed.
// 1. Go all the way down to the leaf node
// 2. Check if actually need to visit all the boxes as we traverse down (already computed, container's min/max does not depend on descendants etc)
@@ -409,25 +408,45 @@
queue.append(root().firstInFlowOrFloatingChild());
IntrinsicWidthConstraints constraints;
+ auto floatAvoidersMaximumIntrinsicWidth = LayoutUnit { };
while (!queue.isEmpty()) {
while (true) {
+ // Check if we have to deal with descendant content.
auto& layoutBox = *queue.last();
- auto hasInFlowOrFloatingChild = is<ContainerBox>(layoutBox) && downcast<ContainerBox>(layoutBox).hasInFlowOrFloatingChild();
- auto skipDescendants = formattingState.intrinsicWidthConstraintsForBox(layoutBox) || !hasInFlowOrFloatingChild || layoutBox.establishesFormattingContext() || layoutBox.style().width().isFixed();
- if (skipDescendants)
+ // Already has computed intrinsic constraints.
+ if (formattingState.intrinsicWidthConstraintsForBox(layoutBox))
break;
+ // Box with fixed width defines their descendant content intrinsic width.
+ if (layoutBox.style().width().isFixed())
+ break;
+ // Float avoiders are all establish a new formatting context. No need to look inside them.
+ if (layoutBox.isFloatAvoider())
+ break;
+ // Non-float avoider formatting context roots are opaque to intrinsic width computation.
+ if (layoutBox.establishesFormattingContext())
+ break;
+ // No relevant child content.
+ if (!is<ContainerBox>(layoutBox) || !downcast<ContainerBox>(layoutBox).hasInFlowOrFloatingChild())
+ break;
queue.append(downcast<ContainerBox>(layoutBox).firstInFlowOrFloatingChild());
}
// Compute min/max intrinsic width bottom up if needed.
while (!queue.isEmpty()) {
auto& layoutBox = *queue.takeLast();
- auto desdendantConstraints = formattingState.intrinsicWidthConstraintsForBox(layoutBox);
+ auto desdendantConstraints = formattingState.intrinsicWidthConstraintsForBox(layoutBox);
if (!desdendantConstraints) {
desdendantConstraints = geometry().intrinsicWidthConstraints(layoutBox);
formattingState.setIntrinsicWidthConstraintsForBox(layoutBox, *desdendantConstraints);
}
constraints.minimum = std::max(constraints.minimum, desdendantConstraints->minimum);
- constraints.maximum = std::max(constraints.maximum, desdendantConstraints->maximum);
+ // FIXME: This works as long as the float avoider is a direct child of the root.
+ // When the containing block of the float avoider is not the root, the containing block itself sets the constraint.
+ if (layoutBox.isFloatAvoider()) {
+ // Floats and formatting context roots that avoid floats form a horizontal stack when the constraint is infinite.
+ // FIXME: Add support for clear property.
+ floatAvoidersMaximumIntrinsicWidth += desdendantConstraints->maximum;
+ } else
+ constraints.maximum = std::max(constraints.maximum, desdendantConstraints->maximum);
// Move over to the next sibling or take the next box in the queue.
if (auto* nextSibling = layoutBox.nextInFlowOrFloatingSibling()) {
queue.append(nextSibling);
@@ -435,6 +454,7 @@
}
}
}
+ constraints.maximum = std::max(constraints.maximum, floatAvoidersMaximumIntrinsicWidth);
formattingState.setIntrinsicWidthConstraints(constraints);
return constraints;
}
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (264266 => 264267)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2020-07-11 06:30:24 UTC (rev 264266)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2020-07-11 15:45:14 UTC (rev 264267)
@@ -372,7 +372,7 @@
auto intrinsicWidthConstraints = IntrinsicWidthConstraints { };
auto& formattingState = layoutState().formattingStateForBox(layoutBox);
for (auto& child : childrenOfType<Box>(downcast<ContainerBox>(layoutBox))) {
- if (child.isOutOfFlowPositioned())
+ if (child.isOutOfFlowPositioned() || child.isFloatAvoider())
continue;
auto childIntrinsicWidthConstraints = formattingState.intrinsicWidthConstraintsForBox(child);
ASSERT(childIntrinsicWidthConstraints);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes