Diff
Modified: trunk/Source/WebCore/ChangeLog (241263 => 241264)
--- trunk/Source/WebCore/ChangeLog 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/ChangeLog 2019-02-11 16:23:03 UTC (rev 241264)
@@ -1,5 +1,45 @@
2019-02-11 Zalan Bujtas <[email protected]>
+ [LFC] FormattingContext::Geometry::floatingHeightAndMargin should take UsedHorizontalValues
+ https://bugs.webkit.org/show_bug.cgi?id=194490
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for adding floating preferred width computation support. It requires height computaiton
+ which uses containing block width to resolve vertical margins.
+
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::computeBorderAndPadding const):
+ * layout/FormattingContext.h:
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry):
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry):
+ (WebCore::Layout::FormattingContext::Geometry::complicatedCases):
+ (WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::computedVerticalMargin):
+ * layout/FormattingContextQuirks.cpp:
+ (WebCore::Layout::FormattingContext::Quirks::heightValueOfNearestContainingBlockWithFixedHeight):
+ * layout/LayoutUnits.h:
+ (WebCore::Layout::UsedHorizontalValues::UsedHorizontalValues):
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
+ * layout/blockformatting/BlockFormattingContextQuirks.cpp:
+ (WebCore::Layout::BlockFormattingContext::Quirks::stretchedInFlowHeight):
+ * layout/blockformatting/BlockMarginCollapse.cpp:
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeValues):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::estimatedMarginBefore):
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::layout const):
+ (WebCore::Layout::InlineFormattingContext::computeHeightAndMargin const):
+ * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+ (WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockHeightAndMargin):
+
+2019-02-11 Zalan Bujtas <[email protected]>
+
[LFC] FormattingContext::intrinsicWidthConstraints should compute and save the intrinsic widths consistently.
https://bugs.webkit.org/show_bug.cgi?id=194483
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (241263 => 241264)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2019-02-11 16:23:03 UTC (rev 241264)
@@ -129,7 +129,7 @@
auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
displayBox.setBorder(Geometry::computedBorder(layoutBox));
- displayBox.setPadding(Geometry::computedPadding(layoutBox, UsedHorizontalValues { containingBlockWidth, { }, { } }));
+ displayBox.setPadding(Geometry::computedPadding(layoutBox, UsedHorizontalValues { containingBlockWidth }));
}
void FormattingContext::layoutOutOfFlowDescendants(const Box& layoutBox) const
Modified: trunk/Source/WebCore/layout/FormattingContext.h (241263 => 241264)
--- trunk/Source/WebCore/layout/FormattingContext.h 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2019-02-11 16:23:03 UTC (rev 241264)
@@ -81,7 +81,7 @@
static VerticalGeometry outOfFlowVerticalGeometry(const LayoutState&, const Box&, UsedVerticalValues);
static HorizontalGeometry outOfFlowHorizontalGeometry(LayoutState&, const Box&, UsedHorizontalValues);
- static HeightAndMargin floatingHeightAndMargin(const LayoutState&, const Box&, UsedVerticalValues);
+ static HeightAndMargin floatingHeightAndMargin(const LayoutState&, const Box&, UsedVerticalValues, UsedHorizontalValues);
static WidthAndMargin floatingWidthAndMargin(LayoutState&, const Box&, UsedHorizontalValues);
static HeightAndMargin inlineReplacedHeightAndMargin(const LayoutState&, const Box&, UsedVerticalValues);
@@ -89,7 +89,7 @@
static LayoutSize inFlowPositionedPositionOffset(const LayoutState&, const Box&);
- static HeightAndMargin complicatedCases(const LayoutState&, const Box&, UsedVerticalValues);
+ static HeightAndMargin complicatedCases(const LayoutState&, const Box&, UsedVerticalValues, UsedHorizontalValues);
static LayoutUnit shrinkToFitWidth(LayoutState&, const Box&, UsedHorizontalValues);
static Edges computedBorder(const Box&);
@@ -96,7 +96,7 @@
static Optional<Edges> computedPadding(const Box&, UsedHorizontalValues);
static ComputedHorizontalMargin computedHorizontalMargin(const Box&, UsedHorizontalValues);
- static ComputedVerticalMargin computedVerticalMargin(const LayoutState&, const Box&);
+ static ComputedVerticalMargin computedVerticalMargin(const Box&, UsedHorizontalValues);
static Optional<LayoutUnit> computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth);
static Optional<LayoutUnit> fixedValue(const Length& geometryProperty);
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (241263 => 241264)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-02-11 16:23:03 UTC (rev 241264)
@@ -295,7 +295,7 @@
auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth);
auto isStaticallyPositioned = !top && !bottom;
auto height = usedValues.height ? usedValues.height.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);
- auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox);
+ auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, UsedHorizontalValues { containingBlockWidth });
UsedVerticalMargin::NonCollapsedValues usedVerticalMargin;
auto paddingTop = displayBox.paddingTop().valueOr(0);
auto paddingBottom = displayBox.paddingBottom().valueOr(0);
@@ -560,7 +560,7 @@
auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth);
auto isStaticallyPositioned = !top && !bottom;
auto height = inlineReplacedHeightAndMargin(layoutState, layoutBox, usedValues).height;
- auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox);
+ auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, UsedHorizontalValues { containingBlockWidth });
Optional<LayoutUnit> usedMarginBefore = computedVerticalMargin.before;
Optional<LayoutUnit> usedMarginAfter = computedVerticalMargin.after;
auto paddingTop = displayBox.paddingTop().valueOr(0);
@@ -727,7 +727,7 @@
return { *left, *right, { width, { *usedMarginStart, *usedMarginEnd }, computedHorizontalMargin } };
}
-HeightAndMargin FormattingContext::Geometry::complicatedCases(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues)
+HeightAndMargin FormattingContext::Geometry::complicatedCases(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues, UsedHorizontalValues usedHorizontalValues)
{
ASSERT(!layoutBox.replaced());
// TODO: Use complicated-case for document renderer for now (see BlockFormattingContext::Geometry::inFlowHeightAndMargin).
@@ -743,7 +743,7 @@
// 2. If 'height' is 'auto', the height depends on the element's descendants per 10.6.7.
auto height = usedValues.height ? usedValues.height.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);
- auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox);
+ auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, usedHorizontalValues);
// #1
auto usedVerticalMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
// #2
@@ -823,13 +823,13 @@
return outOfFlowReplacedHorizontalGeometry(layoutState, layoutBox, usedValues);
}
-HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues)
+HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedVerticalValues, UsedHorizontalValues usedHorizontalValues)
{
ASSERT(layoutBox.isFloatingPositioned());
if (!layoutBox.replaced())
- return complicatedCases(layoutState, layoutBox, usedValues);
- return floatingReplacedHeightAndMargin(layoutState, layoutBox, usedValues);
+ return complicatedCases(layoutState, layoutBox, usedVerticalValues, usedHorizontalValues);
+ return floatingReplacedHeightAndMargin(layoutState, layoutBox, usedVerticalValues);
}
WidthAndMargin FormattingContext::Geometry::floatingWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues)
@@ -856,7 +856,8 @@
// the height of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width.
// #1
- auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox);
+ auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
+ auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, UsedHorizontalValues { containingBlockWidth });
auto usedVerticalMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
auto& style = layoutBox.style();
auto replaced = layoutBox.replaced();
@@ -1064,11 +1065,10 @@
return { computedValueIfNotAuto(style.marginStart(), containingBlockWidth), computedValueIfNotAuto(style.marginEnd(), containingBlockWidth) };
}
-ComputedVerticalMargin FormattingContext::Geometry::computedVerticalMargin(const LayoutState& layoutState, const Box& layoutBox)
+ComputedVerticalMargin FormattingContext::Geometry::computedVerticalMargin(const Box& layoutBox, UsedHorizontalValues usedValues)
{
auto& style = layoutBox.style();
- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
-
+ auto containingBlockWidth = usedValues.containingBlockWidth.valueOr(0);
return { computedValueIfNotAuto(style.marginBefore(), containingBlockWidth), computedValueIfNotAuto(style.marginAfter(), containingBlockWidth) };
}
Modified: trunk/Source/WebCore/layout/FormattingContextQuirks.cpp (241263 => 241264)
--- trunk/Source/WebCore/layout/FormattingContextQuirks.cpp 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/FormattingContextQuirks.cpp 2019-02-11 16:23:03 UTC (rev 241264)
@@ -51,7 +51,8 @@
if (containingBlock->isBodyBox() || containingBlock->isDocumentBox()) {
auto& displayBox = layoutState.displayBoxForLayoutBox(*containingBlock);
- auto verticalMargin = Geometry::computedVerticalMargin(layoutState, *containingBlock);
+ auto usedValues = UsedHorizontalValues { layoutState.displayBoxForLayoutBox(*containingBlock->containingBlock()).contentBoxWidth() };
+ auto verticalMargin = Geometry::computedVerticalMargin(*containingBlock, usedValues);
auto verticalPadding = displayBox.paddingTop().valueOr(0) + displayBox.paddingBottom().valueOr(0);
auto verticalBorder = displayBox.borderTop() + displayBox.borderBottom();
bodyAndDocumentVerticalMarginPaddingAndBorder += verticalMargin.before.valueOr(0) + verticalMargin.after.valueOr(0) + verticalPadding + verticalBorder;
Modified: trunk/Source/WebCore/layout/LayoutUnits.h (241263 => 241264)
--- trunk/Source/WebCore/layout/LayoutUnits.h 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/LayoutUnits.h 2019-02-11 16:23:03 UTC (rev 241264)
@@ -125,6 +125,15 @@
};
struct UsedHorizontalValues {
+ explicit UsedHorizontalValues()
+ {
+ }
+
+ explicit UsedHorizontalValues(LayoutUnit containingBlockWidth)
+ : containingBlockWidth(containingBlockWidth)
+ {
+ }
+
explicit UsedHorizontalValues(Optional<LayoutUnit> containingBlockWidth, Optional<LayoutUnit> width, Optional<UsedHorizontalMargin> margin)
: containingBlockWidth(containingBlockWidth)
, width(width)
@@ -132,10 +141,6 @@
{
}
- explicit UsedHorizontalValues()
- {
- }
-
Optional<LayoutUnit> containingBlockWidth;
Optional<LayoutUnit> width;
Optional<UsedHorizontalMargin> margin;
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (241263 => 241264)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2019-02-11 16:23:03 UTC (rev 241264)
@@ -341,7 +341,7 @@
return Geometry::inFlowHeightAndMargin(layoutState, layoutBox, usedValues);
if (layoutBox.isFloatingPositioned())
- return Geometry::floatingHeightAndMargin(layoutState, layoutBox, usedValues);
+ return Geometry::floatingHeightAndMargin(layoutState, layoutBox, usedValues, UsedHorizontalValues { layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth() });
ASSERT_NOT_REACHED();
return { };
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (241263 => 241264)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2019-02-11 16:23:03 UTC (rev 241264)
@@ -58,7 +58,8 @@
// and relatively positioned boxes are considered without their offset). Note that the child box may be an anonymous block box.
auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
- auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox);
+ auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
+ auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, UsedHorizontalValues { containingBlockWidth });
auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
auto borderAndPaddingTop = displayBox.borderTop() + displayBox.paddingTop().valueOr(0);
auto height = usedValues.height ? usedValues.height.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);
@@ -258,7 +259,8 @@
else {
// 10.6.6 Complicated cases
// Block-level, non-replaced elements in normal flow when 'overflow' does not compute to 'visible' (except if the 'overflow' property's value has been propagated to the viewport).
- heightAndMargin = complicatedCases(layoutState, layoutBox, usedValues);
+ auto usedHorizontalValues = UsedHorizontalValues { layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth() };
+ heightAndMargin = complicatedCases(layoutState, layoutBox, usedValues, usedHorizontalValues);
}
if (!Quirks::needsStretching(layoutState, layoutBox))
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp (241263 => 241264)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp 2019-02-11 16:23:03 UTC (rev 241264)
@@ -68,7 +68,8 @@
auto& documentBox = layoutBox.isDocumentBox() ? layoutBox : *layoutBox.parent();
auto& documentBoxDisplayBox = layoutState.displayBoxForLayoutBox(documentBox);
- auto strechedHeight = layoutState.displayBoxForLayoutBox(initialContainingBlock(layoutBox)).contentBoxHeight();
+ auto& initialContainingBlockDisplayBox = layoutState.displayBoxForLayoutBox(initialContainingBlock(layoutBox));
+ auto strechedHeight = initialContainingBlockDisplayBox.contentBoxHeight();
strechedHeight -= documentBoxDisplayBox.verticalBorder() + documentBoxDisplayBox.verticalPadding().valueOr(0);
LayoutUnit totalVerticalMargin;
@@ -80,7 +81,7 @@
// Here is the quirky part for body box:
// Stretch the body using the initial containing block's height and shrink it with document box's margin/border/padding.
// This looks extremely odd when html has non-auto height.
- auto documentBoxVerticalMargin = Geometry::computedVerticalMargin(layoutState, documentBox);
+ auto documentBoxVerticalMargin = Geometry::computedVerticalMargin(documentBox, UsedHorizontalValues { initialContainingBlockDisplayBox.contentBoxWidth() });
strechedHeight -= (documentBoxVerticalMargin.before.valueOr(0) + documentBoxVerticalMargin.after.valueOr(0));
auto& bodyBoxDisplayBox = layoutState.displayBoxForLayoutBox(layoutBox);
Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (241263 => 241264)
--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2019-02-11 16:23:03 UTC (rev 241264)
@@ -519,7 +519,8 @@
return marginType == MarginType::Before ? positiveAndNegativeVerticalMargin.before : positiveAndNegativeVerticalMargin.after;
}
// This is the estimate path. We don't yet have positive/negative margin computed.
- auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox);
+ auto usedValues = UsedHorizontalValues { layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth() };
+ auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, usedValues);
auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
if (marginType == MarginType::Before)
@@ -586,7 +587,8 @@
ASSERT(layoutBox.isInFlow() || layoutBox.isFloatingPositioned());
ASSERT(!layoutBox.replaced());
- auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox);
+ auto usedValues = UsedHorizontalValues { layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth() };
+ auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, usedValues);
auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
auto marginsCollapseThrough = MarginCollapse::marginsCollapseThrough(layoutState, layoutBox);
auto positiveNegativeMarginBefore = MarginCollapse::positiveNegativeMarginBefore(layoutState, layoutBox, nonCollapsedMargin);
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (241263 => 241264)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-02-11 16:23:03 UTC (rev 241264)
@@ -71,7 +71,7 @@
LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> inline formatting context -> formatting root(" << &root() << ")");
auto& root = downcast<Container>(this->root());
- auto usedValues = UsedHorizontalValues { layoutState().displayBoxForLayoutBox(root).contentBoxWidth(), { }, { } };
+ auto usedValues = UsedHorizontalValues { layoutState().displayBoxForLayoutBox(root).contentBoxWidth() };
auto* layoutBox = root.firstInFlowOrFloatingChild();
// Compute width/height for non-text content and margin/border/padding for inline containers.
while (layoutBox) {
@@ -204,7 +204,7 @@
HeightAndMargin heightAndMargin;
if (layoutBox.isFloatingPositioned())
- heightAndMargin = Geometry::floatingHeightAndMargin(layoutState, layoutBox, { });
+ heightAndMargin = Geometry::floatingHeightAndMargin(layoutState, layoutBox, { }, UsedHorizontalValues { layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth() });
else if (layoutBox.isInlineBlockBox())
heightAndMargin = Geometry::inlineBlockHeightAndMargin(layoutState, layoutBox);
else if (layoutBox.replaced())
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (241263 => 241264)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2019-02-11 16:19:36 UTC (rev 241263)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2019-02-11 16:23:03 UTC (rev 241264)
@@ -73,7 +73,8 @@
// 10.6.6 Complicated cases
// - 'Inline-block', non-replaced elements.
- return complicatedCases(layoutState, layoutBox, { });
+ auto usedHorizontalValues = UsedHorizontalValues { layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth() };
+ return complicatedCases(layoutState, layoutBox, { }, usedHorizontalValues);
}
}