- Revision
- 256158
- Author
- carlo...@webkit.org
- Date
- 2020-02-10 05:26:57 -0800 (Mon, 10 Feb 2020)
Log Message
Merge r256101 - [LFC] FloatingContext::constraints should take a vertical range instead of just vertical position.
https://bugs.webkit.org/show_bug.cgi?id=207440
<rdar://problem/59295022>
Reviewed by Antti Koivisto.
In an IFC, this covers the entire line when searching for intrusive float to shrink the available horizontal space.
(This fix is limited to content with fixed line height)
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::usedAvailableWidthForFloatAvoider const):
* layout/floats/FloatingContext.cpp:
(WebCore::Layout::FloatingContext::constraints const):
* layout/floats/FloatingContext.h:
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::lineLayout):
(WebCore::Layout::InlineFormattingContext::constraintsForLine):
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog (256157 => 256158)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog 2020-02-10 13:26:52 UTC (rev 256157)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/ChangeLog 2020-02-10 13:26:57 UTC (rev 256158)
@@ -1,3 +1,23 @@
+2020-02-09 Zalan Bujtas <za...@apple.com>
+
+ [LFC] FloatingContext::constraints should take a vertical range instead of just vertical position.
+ https://bugs.webkit.org/show_bug.cgi?id=207440
+ <rdar://problem/59295022>
+
+ Reviewed by Antti Koivisto.
+
+ In an IFC, this covers the entire line when searching for intrusive float to shrink the available horizontal space.
+ (This fix is limited to content with fixed line height)
+
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::usedAvailableWidthForFloatAvoider const):
+ * layout/floats/FloatingContext.cpp:
+ (WebCore::Layout::FloatingContext::constraints const):
+ * layout/floats/FloatingContext.h:
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::lineLayout):
+ (WebCore::Layout::InlineFormattingContext::constraintsForLine):
+
2020-02-08 Zalan Bujtas <za...@apple.com>
[LFC][BFC] Replace "estimated" term with "precomputed"
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (256157 => 256158)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-02-10 13:26:52 UTC (rev 256157)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-02-10 13:26:57 UTC (rev 256158)
@@ -183,7 +183,9 @@
return { };
// Vertical static position is not computed yet, so let's just pre-compute it for now.
auto verticalPosition = mapTopToFormattingContextRoot(layoutBox);
- auto constraints = floatingContext.constraints({ verticalPosition });
+ // FIXME: Check if the non-yet-computed height affects this computation - and whether we have to resolve it
+ // at a later point or not (can't find this in the spec).
+ auto constraints = floatingContext.constraints(verticalPosition, verticalPosition);
if (!constraints.left && !constraints.right)
return { };
auto& containingBlock = *layoutBox.containingBlock();
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/floats/FloatingContext.cpp (256157 => 256158)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/floats/FloatingContext.cpp 2020-02-10 13:26:52 UTC (rev 256157)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/floats/FloatingContext.cpp 2020-02-10 13:26:57 UTC (rev 256158)
@@ -276,22 +276,23 @@
return { };
}
-FloatingContext::Constraints FloatingContext::constraints(PositionInContextRoot verticalPosition) const
+FloatingContext::Constraints FloatingContext::constraints(LayoutUnit logicalTop, LayoutUnit logicalBottom) const
{
if (isEmpty())
return { };
// 1. Convert vertical position if this floating context is inherited.
- // 2. Find the inner left/right floats at verticalPosition.
+ // 2. Find the inner left/right floats at logicalTop/logicalBottom.
// 3. Convert left/right positions back to formattingContextRoot's cooridnate system.
auto coordinateMappingIsRequired = &floatingState().root() != &root();
- auto adjustedPosition = Point { 0, verticalPosition };
+ auto adjustedLogicalTop = logicalTop;
LayoutSize adjustingDelta;
-
if (coordinateMappingIsRequired) {
- adjustedPosition = mapPointFromFormattingContextRootToFloatingStateRoot(adjustedPosition);
- adjustingDelta = { adjustedPosition.x, adjustedPosition.y - verticalPosition };
+ auto adjustedPosition = mapPointFromFormattingContextRootToFloatingStateRoot({ 0, logicalTop });
+ adjustedLogicalTop = adjustedPosition.y;
+ adjustingDelta = { adjustedPosition.x, adjustedLogicalTop - logicalTop };
}
+ auto adjustedLogicalBottom = adjustedLogicalTop + (logicalBottom - logicalTop);
Constraints constraints;
auto& floats = floatingState().floats();
@@ -305,7 +306,7 @@
continue;
auto rect = floatItem.rectWithMargin();
- if (!(rect.top() <= adjustedPosition.y && adjustedPosition.y < rect.bottom()))
+ if (rect.top() >= adjustedLogicalBottom || rect.bottom() <= adjustedLogicalTop)
continue;
if (floatItem.isLeftPositioned())
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/floats/FloatingContext.h (256157 => 256158)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/floats/FloatingContext.h 2020-02-10 13:26:52 UTC (rev 256157)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/floats/FloatingContext.h 2020-02-10 13:26:57 UTC (rev 256158)
@@ -64,7 +64,7 @@
Optional<PointInContextRoot> left;
Optional<PointInContextRoot> right;
};
- Constraints constraints(PositionInContextRoot verticalPosition) const;
+ Constraints constraints(LayoutUnit logicalTop, LayoutUnit logicalBottom) const;
void append(const Box&);
void remove(const Box&);
Modified: releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (256157 => 256158)
--- releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-02-10 13:26:52 UTC (rev 256157)
+++ releases/WebKitGTK/webkit-2.28/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-02-10 13:26:57 UTC (rev 256158)
@@ -159,7 +159,7 @@
ASSERT(lineBuilder.hasIntrusiveFloat());
// Move the next line below the intrusive float.
auto floatingContext = FloatingContext { root(), *this, formattingState().floatingState() };
- auto floatConstraints = floatingContext.constraints({ lineLogicalTop });
+ auto floatConstraints = floatingContext.constraints(lineLogicalTop, toLayoutUnit(lineContent.lineBox.logicalBottom()) );
ASSERT(floatConstraints.left || floatConstraints.right);
static auto inifitePoint = PointInContextRoot::max();
// In case of left and right constraints, we need to pick the one that's closer to the current line.
@@ -357,12 +357,14 @@
{
auto lineLogicalLeft = horizontalConstraints.logicalLeft;
auto lineLogicalRight = lineLogicalLeft + horizontalConstraints.logicalWidth;
+ auto lineHeightAndBaseline = quirks().lineHeightConstraints(root());
auto lineIsConstrainedByFloat = false;
auto floatingContext = FloatingContext { root(), *this, formattingState().floatingState() };
// Check for intruding floats and adjust logical left/available width for this line accordingly.
if (!floatingContext.isEmpty()) {
- auto floatConstraints = floatingContext.constraints({ toLayoutUnit(lineLogicalTop) });
+ // FIXME: Add support for variable line height, where the intrusive floats should be probed as the line height grows.
+ auto floatConstraints = floatingContext.constraints(toLayoutUnit(lineLogicalTop), toLayoutUnit(lineLogicalTop + lineHeightAndBaseline.height));
// Check if these constraints actually put limitation on the line.
if (floatConstraints.left && floatConstraints.left->x <= lineLogicalLeft)
floatConstraints.left = { };
@@ -418,7 +420,7 @@
return geometry().computedTextIndent(root, horizontalConstraints).valueOr(InlineLayoutUnit { });
};
lineLogicalLeft += computedTextIndent();
- return LineBuilder::Constraints { { lineLogicalLeft, lineLogicalTop }, lineLogicalRight - lineLogicalLeft, lineIsConstrainedByFloat, quirks().lineHeightConstraints(root()) };
+ return LineBuilder::Constraints { { lineLogicalLeft, lineLogicalTop }, lineLogicalRight - lineLogicalLeft, lineIsConstrainedByFloat, lineHeightAndBaseline };
}
void InlineFormattingContext::setDisplayBoxesForLine(const LineLayoutContext::LineContent& lineContent, const HorizontalConstraints& horizontalConstraints)