Diff
Modified: trunk/Source/WebCore/ChangeLog (250050 => 250051)
--- trunk/Source/WebCore/ChangeLog 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/ChangeLog 2019-09-18 21:12:06 UTC (rev 250051)
@@ -1,5 +1,43 @@
2019-09-18 Zalan Bujtas <[email protected]>
+ [LFC] Add contentbox left constraint to UsedHorizontalValues::Constraints
+ https://bugs.webkit.org/show_bug.cgi?id=201923
+ <rdar://problem/55485796>
+
+ Reviewed by Antti Koivisto.
+
+ Pass in the contentbox left constraint value to the FormattingContext::compute*() functions so that they don't need to read the containg block's geometry.
+ This is in preparation for using constraint values instead of querying the display tree for containing block geometry information.
+ See webkit.org/b/201795
+
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::outOfFlowConstraints):
+ (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry):
+ (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry):
+ * layout/FormattingContext.h:
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::FormattingContext::Geometry::staticHorizontalPositionForOutOfFlowPositioned const):
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry const):
+ * layout/LayoutUnits.cpp:
+ (WebCore::Layout::UsedHorizontalValues::Constraints::Constraints):
+ * layout/LayoutUnits.h:
+ (WebCore::Layout::UsedHorizontalValues::Constraints::Constraints):
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::computeStaticHorizontalPosition):
+ (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin):
+ * layout/blockformatting/BlockFormattingContext.h:
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::staticHorizontalPosition const):
+ (WebCore::Layout::BlockFormattingContext::Geometry::staticPosition const):
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::computedIntrinsicWidthConstraints):
+ (WebCore::Layout::InlineFormattingContext::computeIntrinsicWidthForFormattingRoot):
+ * layout/tableformatting/TableFormattingContext.cpp:
+ (WebCore::Layout::TableFormattingContext::computePreferredWidthForColumns):
+
+2019-09-18 Zalan Bujtas <[email protected]>
+
[LFC] Introduce UsedHorizontalValues::Constraints
https://bugs.webkit.org/show_bug.cgi?id=201919
<rdar://problem/55481927>
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (250050 => 250051)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2019-09-18 21:12:06 UTC (rev 250051)
@@ -43,6 +43,11 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingContext);
+static UsedHorizontalValues::Constraints outOfFlowConstraints(const Display::Box& containingBlockGeometry)
+{
+ return UsedHorizontalValues::Constraints { containingBlockGeometry.paddingBoxLeft(), containingBlockGeometry.paddingBoxWidth() };
+}
+
FormattingContext::FormattingContext(const Container& formattingContextRoot, FormattingState& formattingState)
: m_root(makeWeakPtr(formattingContextRoot))
, m_formattingState(formattingState)
@@ -66,11 +71,12 @@
void FormattingContext::computeOutOfFlowHorizontalGeometry(const Box& layoutBox)
{
- auto containingBlockWidth = geometryForBox(*layoutBox.containingBlock()).paddingBoxWidth();
- auto containingBlockHeight = geometryForBox(*layoutBox.containingBlock()).paddingBoxHeight();
+ auto& containingBlockGeometry = geometryForBox(*layoutBox.containingBlock());
+ auto containingBlockWidth = containingBlockGeometry.paddingBoxWidth();
+ auto containingBlockHeight = containingBlockGeometry.paddingBoxHeight();
auto compute = [&](Optional<LayoutUnit> usedWidth) {
- auto usedHorizontalValues = UsedHorizontalValues { UsedHorizontalValues::Constraints { containingBlockWidth }, usedWidth, { } };
+ auto usedHorizontalValues = UsedHorizontalValues { outOfFlowConstraints(containingBlockGeometry), usedWidth, { } };
auto usedVerticalValues = UsedVerticalValues { containingBlockHeight, { } };
return geometry().outOfFlowHorizontalGeometry(layoutBox, usedHorizontalValues, usedVerticalValues);
};
@@ -102,10 +108,9 @@
};
auto& containingBlockGeometry = geometryForBox(*layoutBox.containingBlock());
auto containingBlockHeight = containingBlockGeometry.paddingBoxHeight();
- auto containingBlockWidth = containingBlockGeometry.paddingBoxHeight();
auto usedVerticalValuesForHeight = UsedVerticalValues { containingBlockHeight, { } };
- auto usedHorizontalValues = UsedHorizontalValues { UsedHorizontalValues::Constraints { containingBlockWidth } };
+ auto usedHorizontalValues = UsedHorizontalValues { outOfFlowConstraints(containingBlockGeometry) };
auto verticalGeometry = compute(usedHorizontalValues, usedVerticalValuesForHeight);
if (auto maxHeight = geometry().computedMaxHeight(layoutBox, containingBlockHeight)) {
Modified: trunk/Source/WebCore/layout/FormattingContext.h (250050 => 250051)
--- trunk/Source/WebCore/layout/FormattingContext.h 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2019-09-18 21:12:06 UTC (rev 250051)
@@ -147,7 +147,7 @@
WidthAndMargin floatingNonReplacedWidthAndMargin(const Box&, UsedHorizontalValues);
LayoutUnit staticVerticalPositionForOutOfFlowPositioned(const Box&) const;
- LayoutUnit staticHorizontalPositionForOutOfFlowPositioned(const Box&) const;
+ LayoutUnit staticHorizontalPositionForOutOfFlowPositioned(const Box&, UsedHorizontalValues) const;
const FormattingContext& m_formattingContext;
};
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (250050 => 250051)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-09-18 21:12:06 UTC (rev 250051)
@@ -218,7 +218,7 @@
return top - paddingBoxTop;
}
-LayoutUnit FormattingContext::Geometry::staticHorizontalPositionForOutOfFlowPositioned(const Box& layoutBox) const
+LayoutUnit FormattingContext::Geometry::staticHorizontalPositionForOutOfFlowPositioned(const Box& layoutBox, UsedHorizontalValues usedHorizontalValues) const
{
ASSERT(layoutBox.isOutOfFlowPositioned());
// See staticVerticalPositionForOutOfFlowPositioned for the definition of the static position.
@@ -238,8 +238,7 @@
ASSERT(!container->isPositioned() || layoutBox.isFixedPositioned());
}
// Move the static position relative to the padding box. This is very specific to abolutely positioned boxes.
- auto paddingBoxLeft = formattingContext.geometryForBox(containingBlock, FormattingContext::EscapeType::AccessChildFormattingContext).paddingBoxLeft();
- return left - paddingBoxLeft;
+ return left - usedHorizontalValues.constraints.contentBoxLeft;
}
LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(const Box& formattingRoot, LayoutUnit availableWidth)
@@ -446,7 +445,7 @@
// position and apply rule number three below; otherwise, set 'right' to the static position and apply rule number one below.
usedHorizontalMargin = { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) };
- auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutBox);
+ auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutBox, usedHorizontalValues);
if (isLeftToRightDirection)
left = staticHorizontalPosition;
else
@@ -498,7 +497,7 @@
left = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end + *right);
} else if (!left && !right && width) {
// #2
- auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutBox);
+ auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutBox, usedHorizontalValues);
if (isLeftToRightDirection) {
left = staticHorizontalPosition;
right = containingBlockWidth - (*left + usedHorizontalMargin.start + borderLeft + paddingLeft + contentWidth() + paddingRight + borderRight + usedHorizontalMargin.end);
@@ -530,7 +529,7 @@
// For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
// At this point the positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
- auto containingBlockPaddingVerticalEdge = formattingContext.geometryForBox(*layoutBox.containingBlock()).paddingBoxLeft();
+ auto containingBlockPaddingVerticalEdge = usedHorizontalValues.constraints.contentBoxLeft;
*left += containingBlockPaddingVerticalEdge;
*right += containingBlockPaddingVerticalEdge;
@@ -657,7 +656,7 @@
if (!left && !right) {
// #1
- auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutBox);
+ auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutBox, usedHorizontalValues);
if (isLeftToRightDirection)
left = staticHorizontalPosition;
else
@@ -716,7 +715,7 @@
// For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
// At this point the positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
- auto containingBlockPaddingVerticalEdge = formattingContext.geometryForBox(*layoutBox.containingBlock()).paddingBoxLeft();
+ auto containingBlockPaddingVerticalEdge = usedHorizontalValues.constraints.contentBoxLeft;
*left += containingBlockPaddingVerticalEdge;
*right += containingBlockPaddingVerticalEdge;
Modified: trunk/Source/WebCore/layout/LayoutUnits.cpp (250050 => 250051)
--- trunk/Source/WebCore/layout/LayoutUnits.cpp 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/layout/LayoutUnits.cpp 2019-09-18 21:12:06 UTC (rev 250051)
@@ -34,7 +34,8 @@
namespace Layout {
UsedHorizontalValues::Constraints::Constraints(const Display::Box& containingBlockGeometry)
- : width(containingBlockGeometry.contentBoxWidth())
+ : contentBoxLeft(containingBlockGeometry.contentBoxLeft())
+ , width(containingBlockGeometry.contentBoxWidth())
{
}
Modified: trunk/Source/WebCore/layout/LayoutUnits.h (250050 => 250051)
--- trunk/Source/WebCore/layout/LayoutUnits.h 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/layout/LayoutUnits.h 2019-09-18 21:12:06 UTC (rev 250051)
@@ -145,11 +145,13 @@
struct UsedHorizontalValues {
struct Constraints {
explicit Constraints(const Display::Box& containingBlockGeometry);
- explicit Constraints(LayoutUnit horizontalConstraint)
- : width(horizontalConstraint)
+ explicit Constraints(LayoutUnit contentBoxLeft, LayoutUnit horizontalConstraint)
+ : contentBoxLeft(contentBoxLeft)
+ , width(horizontalConstraint)
{
}
+ LayoutUnit contentBoxLeft;
LayoutUnit width;
};
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (250050 => 250051)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2019-09-18 21:12:06 UTC (rev 250051)
@@ -221,7 +221,8 @@
void BlockFormattingContext::computeStaticHorizontalPosition(const Box& layoutBox)
{
- formattingState().displayBox(layoutBox).setLeft(geometry().staticHorizontalPosition(layoutBox));
+ auto usedHorizontalValues = UsedHorizontalValues { UsedHorizontalValues::Constraints { geometryForBox(*layoutBox.containingBlock()) } };
+ formattingState().displayBox(layoutBox).setLeft(geometry().staticHorizontalPosition(layoutBox, usedHorizontalValues));
}
void BlockFormattingContext::computeStaticPosition(const FloatingContext& floatingContext, const Box& layoutBox)
@@ -351,13 +352,15 @@
void BlockFormattingContext::computeWidthAndMargin(const Box& layoutBox, Optional<LayoutUnit> usedAvailableWidth)
{
LayoutUnit availableWidth;
+ auto containingBlockGeometry = geometryForBox(*layoutBox.containingBlock());
if (usedAvailableWidth)
availableWidth = *usedAvailableWidth;
else
- availableWidth = geometryForBox(*layoutBox.containingBlock()).contentBoxWidth();
+ availableWidth = containingBlockGeometry.contentBoxWidth();
+ auto constraints = UsedHorizontalValues::Constraints { containingBlockGeometry.contentBoxLeft(), availableWidth };
auto compute = [&](Optional<LayoutUnit> usedWidth) -> WidthAndMargin {
- auto usedValues = UsedHorizontalValues { UsedHorizontalValues::Constraints { availableWidth }, usedWidth, { } };
+ auto usedValues = UsedHorizontalValues { constraints, usedWidth, { } };
if (layoutBox.isInFlow())
return geometry().inFlowWidthAndMargin(layoutBox, usedValues);
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (250050 => 250051)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2019-09-18 21:12:06 UTC (rev 250051)
@@ -78,9 +78,9 @@
HeightAndMargin inFlowHeightAndMargin(const Box&, UsedHorizontalValues, UsedVerticalValues);
WidthAndMargin inFlowWidthAndMargin(const Box&, UsedHorizontalValues);
- Point staticPosition(const Box&) const;
+ Point staticPosition(const Box&, UsedHorizontalValues) const;
LayoutUnit staticVerticalPosition(const Box&) const;
- LayoutUnit staticHorizontalPosition(const Box&) const;
+ LayoutUnit staticHorizontalPosition(const Box&, UsedHorizontalValues) const;
IntrinsicWidthConstraints intrinsicWidthConstraints(const Box&);
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (250050 => 250051)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2019-09-18 21:12:06 UTC (rev 250051)
@@ -234,16 +234,16 @@
return formattingContext().geometryForBox(*layoutBox.containingBlock()).contentBoxTop();
}
-LayoutUnit BlockFormattingContext::Geometry::staticHorizontalPosition(const Box& layoutBox) const
+LayoutUnit BlockFormattingContext::Geometry::staticHorizontalPosition(const Box& layoutBox, UsedHorizontalValues usedHorizontalValues) const
{
// https://www.w3.org/TR/CSS22/visuren.html#block-formatting
// In a block formatting context, each box's left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch).
- return formattingContext().geometryForBox(*layoutBox.containingBlock()).contentBoxLeft() + formattingContext().geometryForBox(layoutBox).marginStart();
+ return usedHorizontalValues.constraints.contentBoxLeft + formattingContext().geometryForBox(layoutBox).marginStart();
}
-Point BlockFormattingContext::Geometry::staticPosition(const Box& layoutBox) const
+Point BlockFormattingContext::Geometry::staticPosition(const Box& layoutBox, UsedHorizontalValues usedHorizontalValues) const
{
- return { staticHorizontalPosition(layoutBox), staticVerticalPosition(layoutBox) };
+ return { staticHorizontalPosition(layoutBox, usedHorizontalValues), staticVerticalPosition(layoutBox) };
}
HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(const Box& layoutBox, UsedHorizontalValues usedHorizontalValues, UsedVerticalValues usedVerticalValues)
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (250050 => 250051)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-09-18 21:12:06 UTC (rev 250051)
@@ -106,7 +106,7 @@
}
Vector<const Box*> formattingContextRootList;
- auto usedValues = UsedHorizontalValues { UsedHorizontalValues::Constraints { LayoutUnit { } } };
+ auto usedValues = UsedHorizontalValues { UsedHorizontalValues::Constraints { { }, { } } };
auto* layoutBox = root().firstInFlowOrFloatingChild();
while (layoutBox) {
if (layoutBox->establishesFormattingContext()) {
@@ -167,7 +167,7 @@
{
ASSERT(formattingRoot.establishesFormattingContext());
- auto usedValues = UsedHorizontalValues { UsedHorizontalValues::Constraints { LayoutUnit { } } };
+ auto usedValues = UsedHorizontalValues { UsedHorizontalValues::Constraints { { }, { } } };
computeBorderAndPadding(formattingRoot, usedValues);
computeHorizontalMargin(formattingRoot, usedValues);
Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (250050 => 250051)
--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp 2019-09-18 19:56:14 UTC (rev 250050)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp 2019-09-18 21:12:06 UTC (rev 250051)
@@ -199,7 +199,7 @@
intrinsicWidth = layoutState().createFormattingContext(downcast<Container>(tableCellBox))->computedIntrinsicWidthConstraints();
intrinsicWidth = geometry().constrainByMinMaxWidth(tableCellBox, *intrinsicWidth);
auto border = geometry().computedBorder(tableCellBox);
- auto padding = *geometry().computedPadding(tableCellBox, UsedHorizontalValues { UsedHorizontalValues::Constraints { LayoutUnit { } } });
+ auto padding = *geometry().computedPadding(tableCellBox, UsedHorizontalValues { UsedHorizontalValues::Constraints { { }, { } } });
intrinsicWidth->expand(border.horizontal.width() + padding.horizontal.width());
formattingState.setIntrinsicWidthConstraintsForBox(tableCellBox, *intrinsicWidth);