Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (250034 => 250035)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2019-09-18 15:41:09 UTC (rev 250034)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2019-09-18 15:53:06 UTC (rev 250035)
@@ -67,10 +67,12 @@
void FormattingContext::computeOutOfFlowHorizontalGeometry(const Box& layoutBox)
{
auto containingBlockWidth = geometryForBox(*layoutBox.containingBlock()).paddingBoxWidth();
+ auto containingBlockHeight = geometryForBox(*layoutBox.containingBlock()).paddingBoxHeight();
auto compute = [&](Optional<LayoutUnit> usedWidth) {
- auto usedValues = UsedHorizontalValues { containingBlockWidth, usedWidth, { } };
- return geometry().outOfFlowHorizontalGeometry(layoutBox, usedValues);
+ auto usedHorizontalValues = UsedHorizontalValues { containingBlockWidth, usedWidth, { } };
+ auto usedVerticalValues = UsedVerticalValues { containingBlockHeight, { } };
+ return geometry().outOfFlowHorizontalGeometry(layoutBox, usedHorizontalValues, usedVerticalValues);
};
auto horizontalGeometry = compute({ });
@@ -106,7 +108,7 @@
auto usedHorizontalValues = UsedHorizontalValues { containingBlockWidth };
auto verticalGeometry = compute(usedHorizontalValues, usedVerticalValuesForHeight);
- if (auto maxHeight = geometry().computedMaxHeight(layoutBox, usedVerticalValuesForHeight)) {
+ if (auto maxHeight = geometry().computedMaxHeight(layoutBox, containingBlockHeight)) {
auto usedValuesForMaxHeight = UsedVerticalValues { containingBlockHeight, maxHeight };
auto maxVerticalGeometry = compute(usedHorizontalValues, usedValuesForMaxHeight);
if (verticalGeometry.heightAndMargin.height > maxVerticalGeometry.heightAndMargin.height)
@@ -113,7 +115,7 @@
verticalGeometry = maxVerticalGeometry;
}
- if (auto minHeight = geometry().computedMinHeight(layoutBox, usedVerticalValuesForHeight)) {
+ if (auto minHeight = geometry().computedMinHeight(layoutBox, containingBlockHeight)) {
auto usedValuesForMinHeight = UsedVerticalValues { containingBlockHeight, minHeight };
auto minVerticalGeometry = compute(usedHorizontalValues, usedValuesForMinHeight);
if (verticalGeometry.heightAndMargin.height < minVerticalGeometry.heightAndMargin.height)
Modified: trunk/Source/WebCore/layout/FormattingContext.h (250034 => 250035)
--- trunk/Source/WebCore/layout/FormattingContext.h 2019-09-18 15:41:09 UTC (rev 250034)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2019-09-18 15:53:06 UTC (rev 250035)
@@ -94,13 +94,13 @@
class Geometry {
public:
VerticalGeometry outOfFlowVerticalGeometry(const Box&, UsedHorizontalValues, UsedVerticalValues) const;
- HorizontalGeometry outOfFlowHorizontalGeometry(const Box&, UsedHorizontalValues);
+ HorizontalGeometry outOfFlowHorizontalGeometry(const Box&, UsedHorizontalValues, UsedVerticalValues);
HeightAndMargin floatingHeightAndMargin(const Box&, UsedHorizontalValues, UsedVerticalValues) const;
WidthAndMargin floatingWidthAndMargin(const Box&, UsedHorizontalValues);
HeightAndMargin inlineReplacedHeightAndMargin(const Box&, UsedHorizontalValues, UsedVerticalValues) const;
- WidthAndMargin inlineReplacedWidthAndMargin(const Box&, UsedHorizontalValues) const;
+ WidthAndMargin inlineReplacedWidthAndMargin(const Box&, UsedHorizontalValues, Optional<UsedVerticalValues> = WTF::nullopt) const;
LayoutSize inFlowPositionedPositionOffset(const Box&, UsedHorizontalValues) const;
@@ -116,8 +116,8 @@
Optional<LayoutUnit> computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth) const;
Optional<LayoutUnit> fixedValue(const Length& geometryProperty) const;
- Optional<LayoutUnit> computedMinHeight(const Box&, Optional<UsedVerticalValues> = WTF::nullopt) const;
- Optional<LayoutUnit> computedMaxHeight(const Box&, Optional<UsedVerticalValues> = WTF::nullopt) const;
+ Optional<LayoutUnit> computedMinHeight(const Box&, Optional<LayoutUnit> containingBlockHeight = WTF::nullopt) const;
+ Optional<LayoutUnit> computedMaxHeight(const Box&, Optional<LayoutUnit> containingBlockHeight = WTF::nullopt) const;
FormattingContext::IntrinsicWidthConstraints constrainByMinMaxWidth(const Box&, IntrinsicWidthConstraints) const;
@@ -128,7 +128,7 @@
Geometry(const FormattingContext&);
enum class HeightType { Min, Max, Normal };
- Optional<LayoutUnit> computedHeightValue(const Box&, HeightType, Optional<UsedVerticalValues> = WTF::nullopt) const;
+ Optional<LayoutUnit> computedHeightValue(const Box&, HeightType, Optional<LayoutUnit> containingBlockHeight = WTF::nullopt) const;
const LayoutState& layoutState() const { return m_formattingContext.layoutState(); }
LayoutState& layoutState() { return m_formattingContext.layoutState(); }
@@ -136,7 +136,7 @@
private:
VerticalGeometry outOfFlowReplacedVerticalGeometry(const Box&, UsedHorizontalValues, UsedVerticalValues) const;
- HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const Box&, UsedHorizontalValues) const;
+ HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const Box&, UsedHorizontalValues, UsedVerticalValues) const;
VerticalGeometry outOfFlowNonReplacedVerticalGeometry(const Box&, UsedHorizontalValues, UsedVerticalValues) const;
HorizontalGeometry outOfFlowNonReplacedHorizontalGeometry(const Box&, UsedHorizontalValues);
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (250034 => 250035)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-09-18 15:41:09 UTC (rev 250034)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-09-18 15:53:06 UTC (rev 250035)
@@ -59,7 +59,7 @@
return false;
}
-Optional<LayoutUnit> FormattingContext::Geometry::computedHeightValue(const Box& layoutBox, HeightType heightType, Optional<UsedVerticalValues> usedVerticalValues) const
+Optional<LayoutUnit> FormattingContext::Geometry::computedHeightValue(const Box& layoutBox, HeightType heightType, Optional<LayoutUnit> containingBlockHeight) const
{
auto& style = layoutBox.style();
auto height = heightType == HeightType::Normal ? style.logicalHeight() : heightType == HeightType::Min ? style.logicalMinHeight() : style.logicalMaxHeight();
@@ -69,25 +69,22 @@
if (height.isFixed())
return LayoutUnit { height.value() };
- Optional<LayoutUnit> containingBlockHeightValue;
- if (usedVerticalValues && usedVerticalValues->containingBlockHeight) {
- ASSERT(layoutBox.isOutOfFlowPositioned());
+ if (!containingBlockHeight) {
// Containing block's height is already computed since we layout the out-of-flow boxes as the last step.
- containingBlockHeightValue = *usedVerticalValues->containingBlockHeight;
- } else {
+ ASSERT(!layoutBox.isOutOfFlowPositioned());
if (layoutState().inQuirksMode())
- containingBlockHeightValue = formattingContext().quirks().heightValueOfNearestContainingBlockWithFixedHeight(layoutBox);
+ containingBlockHeight = formattingContext().quirks().heightValueOfNearestContainingBlockWithFixedHeight(layoutBox);
else {
- auto containingBlockHeight = layoutBox.containingBlock()->style().logicalHeight();
- if (containingBlockHeight.isFixed())
- containingBlockHeightValue = LayoutUnit(containingBlockHeight.value());
+ auto containingBlockHeightFromStyle = layoutBox.containingBlock()->style().logicalHeight();
+ if (containingBlockHeightFromStyle.isFixed())
+ containingBlockHeight = LayoutUnit { containingBlockHeightFromStyle.value() };
}
}
- if (!containingBlockHeightValue)
+ if (!containingBlockHeight)
return { };
- return valueForLength(height, *containingBlockHeightValue);
+ return valueForLength(height, *containingBlockHeight);
}
LayoutUnit FormattingContext::Geometry::contentHeightForFormattingContextRoot(const Box& layoutBox) const
@@ -172,14 +169,14 @@
// Specifies a percentage for determining the used value. The percentage is calculated with respect to the height of the generated box's containing block.
// If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned,
// the percentage value is treated as '0' (for 'min-height') or 'none' (for 'max-height').
-Optional<LayoutUnit> FormattingContext::Geometry::computedMaxHeight(const Box& layoutBox, Optional<UsedVerticalValues> usedVerticalValues) const
+Optional<LayoutUnit> FormattingContext::Geometry::computedMaxHeight(const Box& layoutBox, Optional<LayoutUnit> containingBlockHeight) const
{
- return computedHeightValue(layoutBox, HeightType::Max, usedVerticalValues);
+ return computedHeightValue(layoutBox, HeightType::Max, containingBlockHeight);
}
-Optional<LayoutUnit> FormattingContext::Geometry::computedMinHeight(const Box& layoutBox, Optional<UsedVerticalValues> usedVerticalValues) const
+Optional<LayoutUnit> FormattingContext::Geometry::computedMinHeight(const Box& layoutBox, Optional<LayoutUnit> containingBlockHeight) const
{
- if (auto minHeightValue = computedHeightValue(layoutBox, HeightType::Min, usedVerticalValues))
+ if (auto minHeightValue = computedHeightValue(layoutBox, HeightType::Min, containingBlockHeight))
return minHeightValue;
return { LayoutUnit { } };
@@ -307,7 +304,7 @@
auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth);
auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth);
- auto height = usedVerticalValues.height ? usedVerticalValues.height.value() : computedHeightValue(layoutBox, HeightType::Normal, usedVerticalValues);
+ auto height = usedVerticalValues.height ? usedVerticalValues.height.value() : computedHeightValue(layoutBox, HeightType::Normal, containingBlockHeight);
auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, usedHorizontalValues);
UsedVerticalMargin::NonCollapsedValues usedVerticalMargin;
auto paddingTop = boxGeometry.paddingTop().valueOr(0);
@@ -623,7 +620,7 @@
return { *top, *bottom, { height, { *usedMarginBefore, *usedMarginAfter } } };
}
-HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(const Box& layoutBox, UsedHorizontalValues usedHorizontalValues) const
+HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(const Box& layoutBox, UsedHorizontalValues usedHorizontalValues, UsedVerticalValues usedVerticalValues) const
{
ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced());
@@ -652,7 +649,7 @@
auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedHorizontalValues);
Optional<LayoutUnit> usedMarginStart = computedHorizontalMargin.start;
Optional<LayoutUnit> usedMarginEnd = computedHorizontalMargin.end;
- auto width = inlineReplacedWidthAndMargin(layoutBox, usedHorizontalValues).width;
+ auto width = inlineReplacedWidthAndMargin(layoutBox, usedHorizontalValues, usedVerticalValues).width;
auto paddingLeft = boxGeometry.paddingLeft().valueOr(0);
auto paddingRight = boxGeometry.paddingRight().valueOr(0);
auto borderLeft = boxGeometry.borderLeft();
@@ -814,13 +811,13 @@
return outOfFlowReplacedVerticalGeometry(layoutBox, usedHorizontalValues, usedVerticalValues);
}
-HorizontalGeometry FormattingContext::Geometry::outOfFlowHorizontalGeometry(const Box& layoutBox, UsedHorizontalValues usedValues)
+HorizontalGeometry FormattingContext::Geometry::outOfFlowHorizontalGeometry(const Box& layoutBox, UsedHorizontalValues usedHorizontalValues, UsedVerticalValues usedVerticalValues)
{
ASSERT(layoutBox.isOutOfFlowPositioned());
if (!layoutBox.replaced())
- return outOfFlowNonReplacedHorizontalGeometry(layoutBox, usedValues);
- return outOfFlowReplacedHorizontalGeometry(layoutBox, usedValues);
+ return outOfFlowNonReplacedHorizontalGeometry(layoutBox, usedHorizontalValues);
+ return outOfFlowReplacedHorizontalGeometry(layoutBox, usedHorizontalValues, usedVerticalValues);
}
HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(const Box& layoutBox, UsedHorizontalValues usedHorizontalValues, UsedVerticalValues usedVerticalValues) const
@@ -862,7 +859,7 @@
auto& style = layoutBox.style();
auto replaced = layoutBox.replaced();
- auto height = usedVerticalValues.height ? usedVerticalValues.height.value() : computedHeightValue(layoutBox, HeightType::Normal, usedVerticalValues);
+ auto height = usedVerticalValues.height ? usedVerticalValues.height.value() : computedHeightValue(layoutBox, HeightType::Normal, usedVerticalValues.containingBlockHeight);
auto heightIsAuto = !usedVerticalValues.height && isHeightAuto(layoutBox);
auto widthIsAuto = style.logicalWidth().isAuto();
@@ -887,7 +884,7 @@
return { *height, usedVerticalMargin };
}
-WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(const Box& layoutBox, UsedHorizontalValues usedHorizontalValues) const
+WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(const Box& layoutBox, UsedHorizontalValues usedHorizontalValues, Optional<UsedVerticalValues> usedVerticalValues) const
{
ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced());
@@ -931,7 +928,7 @@
auto width = computedValueIfNotAuto(usedHorizontalValues.width ? Length { usedHorizontalValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth);
auto heightIsAuto = isHeightAuto(layoutBox);
- auto height = computedHeightValue(layoutBox, HeightType::Normal);
+ auto height = computedHeightValue(layoutBox, HeightType::Normal, usedVerticalValues ? usedVerticalValues->containingBlockHeight : WTF::nullopt);
if (!width && heightIsAuto && replaced->hasIntrinsicWidth()) {
// #1