- Revision
- 253266
- Author
- [email protected]
- Date
- 2019-12-07 19:00:24 -0800 (Sat, 07 Dec 2019)
Log Message
[LFC][IFC] Convert InlineLayoutUnit/Point/Rect to LayoutUnit/Point/Rect when crossing inline/block boundary
https://bugs.webkit.org/show_bug.cgi?id=204991
<rdar://problem/57730383>
Reviewed by Sam Weinig.
Float -> LayoutUnit requires explicit conversion due to precision loss. Use these functions when
feeding inline box geometry information back to block layout.
Implicit floor will do for now (might need to call round though).
This is in preparation for using float based types in IFC. See webkit.org/b/204986 for more info.
* layout/LayoutUnits.h:
(WebCore::Layout::toLayoutUnit):
(WebCore::Layout::toLayoutPoint):
(WebCore::Layout::toLayoutRect):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
* layout/displaytree/DisplayInlineContent.cpp:
(WebCore::Display:: const):
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computedIntrinsicWidthConstraints):
(WebCore::Layout::InlineFormattingContext::constraintsForLine):
(WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::paint):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (253265 => 253266)
--- trunk/Source/WebCore/ChangeLog 2019-12-08 00:41:03 UTC (rev 253265)
+++ trunk/Source/WebCore/ChangeLog 2019-12-08 03:00:24 UTC (rev 253266)
@@ -1,3 +1,33 @@
+2019-12-07 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Convert InlineLayoutUnit/Point/Rect to LayoutUnit/Point/Rect when crossing inline/block boundary
+ https://bugs.webkit.org/show_bug.cgi?id=204991
+ <rdar://problem/57730383>
+
+ Reviewed by Sam Weinig.
+
+ Float -> LayoutUnit requires explicit conversion due to precision loss. Use these functions when
+ feeding inline box geometry information back to block layout.
+
+ Implicit floor will do for now (might need to call round though).
+
+ This is in preparation for using float based types in IFC. See webkit.org/b/204986 for more info.
+
+ * layout/LayoutUnits.h:
+ (WebCore::Layout::toLayoutUnit):
+ (WebCore::Layout::toLayoutPoint):
+ (WebCore::Layout::toLayoutRect):
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+ * layout/displaytree/DisplayInlineContent.cpp:
+ (WebCore::Display:: const):
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::computedIntrinsicWidthConstraints):
+ (WebCore::Layout::InlineFormattingContext::constraintsForLine):
+ (WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::LineLayout::paint):
+
2019-12-07 Ryosuke Niwa <[email protected]>
Unique origin's window must get its own event loop
Modified: trunk/Source/WebCore/layout/LayoutUnits.h (253265 => 253266)
--- trunk/Source/WebCore/layout/LayoutUnits.h 2019-12-08 00:41:03 UTC (rev 253265)
+++ trunk/Source/WebCore/layout/LayoutUnits.h 2019-12-08 03:00:24 UTC (rev 253266)
@@ -199,6 +199,21 @@
Optional<LayoutUnit> height;
};
+inline LayoutUnit toLayoutUnit(InlineLayoutUnit value)
+{
+ return LayoutUnit { value };
}
+
+inline LayoutPoint toLayoutPoint(const InlineLayoutPoint& point)
+{
+ return LayoutPoint { point };
}
+
+inline LayoutRect toLayoutRect(const InlineLayoutRect& rect)
+{
+ return LayoutRect { rect };
+}
+
+}
+}
#endif
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (253265 => 253266)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2019-12-08 00:41:03 UTC (rev 253265)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2019-12-08 03:00:24 UTC (rev 253266)
@@ -75,7 +75,7 @@
auto& lineBoxes = downcast<InlineFormattingState>(layoutState().establishedFormattingState(layoutContainer)).displayInlineContent()->lineBoxes;
// Even empty containers generate one line.
ASSERT(!lineBoxes.isEmpty());
- return { lineBoxes.last().logicalBottom() - borderAndPaddingTop, nonCollapsedMargin };
+ return { toLayoutUnit(lineBoxes.last().logicalBottom()) - borderAndPaddingTop, nonCollapsedMargin };
}
// 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin...
Modified: trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.cpp (253265 => 253266)
--- trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.cpp 2019-12-08 00:41:03 UTC (rev 253265)
+++ trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.cpp 2019-12-08 03:00:24 UTC (rev 253266)
@@ -36,7 +36,7 @@
// FIXME: Do something efficient.
const Run* first = nullptr;
for (auto& run : runs) {
- LayoutRect runRect = run.logicalRect();
+ auto runRect = Layout::toLayoutRect(run.logicalRect());
if (runRect.intersects(rect)) {
first = &run;
break;
@@ -47,7 +47,7 @@
const Run* last = nullptr;
for (auto& run : WTF::makeReversedRange(runs)) {
- LayoutRect runRect = run.logicalRect();
+ auto runRect = Layout::toLayoutRect(run.logicalRect());
if (runRect.intersects(rect)) {
last = &run;
break;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (253265 => 253266)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-12-08 00:41:03 UTC (rev 253265)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-12-08 03:00:24 UTC (rev 253266)
@@ -219,11 +219,11 @@
auto contentWidth = (availableWidth ? intrinsicWidths->maximum : intrinsicWidths->minimum) - displayBox.horizontalMarginBorderAndPadding();
displayBox.setContentBoxWidth(contentWidth);
}
- auto usedHorizontalValues = UsedHorizontalValues { UsedHorizontalValues::Constraints { 0_lu, availableWidth } };
+ auto usedHorizontalValues = UsedHorizontalValues { UsedHorizontalValues::Constraints { 0_lu, toLayoutUnit(availableWidth) } };
return computedIntrinsicWidthForConstraint(usedHorizontalValues);
};
- auto constraints = geometry().constrainByMinMaxWidth(root(), { maximumLineWidth(0), maximumLineWidth(InlineLayoutUnit::max()) });
+ auto constraints = geometry().constrainByMinMaxWidth(root(), { toLayoutUnit(maximumLineWidth(0)), toLayoutUnit(maximumLineWidth(InlineLayoutUnit::max())) });
formattingState().setIntrinsicWidthConstraints(constraints);
return constraints;
}
@@ -380,7 +380,7 @@
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({ lineLogicalTop });
+ auto floatConstraints = floatingContext.constraints({ toLayoutUnit(lineLogicalTop) });
// Check if these constraints actually put limitation on the line.
if (floatConstraints.left && floatConstraints.left->x <= lineLogicalLeft)
floatConstraints.left = { };
@@ -445,9 +445,9 @@
inlineContent.runs.append({ lineIndex, lineRun.layoutBox(), lineRun.logicalRect(), lineRun.textContext() });
if (lineRun.isLineBreak()) {
- displayBox.setTopLeft(logicalRect.topLeft());
- displayBox.setContentBoxWidth(logicalRect.width());
- displayBox.setContentBoxHeight(logicalRect.height());
+ displayBox.setTopLeft(toLayoutPoint(logicalRect.topLeft()));
+ displayBox.setContentBoxWidth(toLayoutUnit(logicalRect.width()));
+ displayBox.setContentBoxHeight(toLayoutUnit(logicalRect.height()));
continue;
}
@@ -456,13 +456,13 @@
auto topLeft = logicalRect.topLeft();
if (layoutBox.isInFlowPositioned())
topLeft += geometry().inFlowPositionedPositionOffset(layoutBox, usedHorizontalValues);
- displayBox.setTopLeft(topLeft);
+ displayBox.setTopLeft(toLayoutPoint(topLeft));
continue;
}
// Inline level container start (<span>)
if (lineRun.isContainerStart()) {
- displayBox.setTopLeft(logicalRect.topLeft());
+ displayBox.setTopLeft(toLayoutPoint(logicalRect.topLeft()));
continue;
}
@@ -476,8 +476,8 @@
auto marginBoxWidth = logicalRect.left() - displayBox.left();
auto contentBoxWidth = marginBoxWidth - (displayBox.marginStart() + displayBox.borderLeft() + displayBox.paddingLeft().valueOr(0));
// FIXME fix it for multiline.
- displayBox.setContentBoxWidth(contentBoxWidth);
- displayBox.setContentBoxHeight(logicalRect.height());
+ displayBox.setContentBoxWidth(toLayoutUnit(contentBoxWidth));
+ displayBox.setContentBoxHeight(toLayoutUnit(logicalRect.height()));
continue;
}
@@ -486,12 +486,12 @@
auto firstRunForLayoutBox = !index || &lineRuns[index - 1].layoutBox() != &layoutBox;
if (firstRunForLayoutBox) {
// Setup display box for the associated layout box.
- displayBox.setTopLeft(logicalRect.topLeft());
- displayBox.setContentBoxWidth(logicalRect.width());
- displayBox.setContentBoxHeight(logicalRect.height());
+ displayBox.setTopLeft(toLayoutPoint(logicalRect.topLeft()));
+ displayBox.setContentBoxWidth(toLayoutUnit(logicalRect.width()));
+ displayBox.setContentBoxHeight(toLayoutUnit(logicalRect.height()));
} else {
// FIXME fix it for multirun/multiline.
- displayBox.setContentBoxWidth(displayBox.contentBoxWidth() + logicalRect.width());
+ displayBox.setContentBoxWidth(toLayoutUnit(displayBox.contentBoxWidth() + logicalRect.width()));
}
continue;
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (253265 => 253266)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2019-12-08 00:41:03 UTC (rev 253265)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2019-12-08 03:00:24 UTC (rev 253266)
@@ -226,7 +226,7 @@
if (style.visibility() != Visibility::Visible)
return;
- LayoutRect rect = run.logicalRect();
+ auto rect = Layout::toLayoutRect(run.logicalRect());
auto visualOverflowRect = computeOverflow(style, rect, viewportSize);
if (paintRect.y() > visualOverflowRect.maxY() || paintRect.maxY() < visualOverflowRect.y())
continue;