Diff
Modified: trunk/Source/WebCore/ChangeLog (241193 => 241194)
--- trunk/Source/WebCore/ChangeLog 2019-02-08 09:54:50 UTC (rev 241193)
+++ trunk/Source/WebCore/ChangeLog 2019-02-08 13:57:09 UTC (rev 241194)
@@ -1,3 +1,39 @@
+2019-02-08 Zalan Bujtas <[email protected]>
+
+ [LFC] Horizontal geometry compute functions should take the containing block's width as a used value
+ https://bugs.webkit.org/show_bug.cgi?id=194424
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for passing optional containing block width for the preferred with codepath.
+
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
+ (WebCore::Layout::FormattingContext::computeBorderAndPadding const):
+ * layout/FormattingContext.h:
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry):
+ (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::computedBorder):
+ (WebCore::Layout::FormattingContext::Geometry::computedPadding):
+ (WebCore::Layout::FormattingContext::Geometry::computedHorizontalMargin):
+ * layout/LayoutUnits.h:
+ (WebCore::Layout::UsedHorizontalValues::UsedHorizontalValues):
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin):
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::computeMarginBorderAndPadding const):
+ (WebCore::Layout::InlineFormattingContext::computeWidthAndMargin const):
+ * layout/inlineformatting/InlineFormattingContext.h:
+ * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+ (WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockWidthAndMargin):
+
2019-02-08 Benjamin Poulain <[email protected]>
clampTo(): do not convert the input to double when dealing with integers
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (241193 => 241194)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2019-02-08 09:54:50 UTC (rev 241193)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2019-02-08 13:57:09 UTC (rev 241194)
@@ -67,22 +67,22 @@
void FormattingContext::computeOutOfFlowHorizontalGeometry(const Box& layoutBox) const
{
auto& layoutState = this->layoutState();
+ auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).paddingBoxWidth();
- auto compute = [&](UsedHorizontalValues usedValues) {
+ auto compute = [&](Optional<LayoutUnit> usedWidth) {
+ auto usedValues = UsedHorizontalValues { containingBlockWidth, usedWidth, { } };
return Geometry::outOfFlowHorizontalGeometry(layoutState, layoutBox, usedValues);
};
auto horizontalGeometry = compute({ });
- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).paddingBoxWidth();
-
if (auto maxWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMaxWidth(), containingBlockWidth)) {
- auto maxHorizontalGeometry = compute({ *maxWidth, { } });
+ auto maxHorizontalGeometry = compute(maxWidth);
if (horizontalGeometry.widthAndMargin.width > maxHorizontalGeometry.widthAndMargin.width)
horizontalGeometry = maxHorizontalGeometry;
}
if (auto minWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMinWidth(), containingBlockWidth)) {
- auto minHorizontalGeometry = compute({ *minWidth, { } });
+ auto minHorizontalGeometry = compute(minWidth);
if (horizontalGeometry.widthAndMargin.width < minHorizontalGeometry.widthAndMargin.width)
horizontalGeometry = minHorizontalGeometry;
}
@@ -127,8 +127,9 @@
{
auto& layoutState = this->layoutState();
auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
- displayBox.setBorder(Geometry::computedBorder(layoutState, layoutBox));
- displayBox.setPadding(Geometry::computedPadding(layoutState, layoutBox));
+ auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
+ displayBox.setBorder(Geometry::computedBorder(layoutBox));
+ displayBox.setPadding(Geometry::computedPadding(layoutBox, UsedHorizontalValues { containingBlockWidth, { }, { } }));
}
void FormattingContext::layoutOutOfFlowDescendants(const Box& layoutBox) const
Modified: trunk/Source/WebCore/layout/FormattingContext.h (241193 => 241194)
--- trunk/Source/WebCore/layout/FormattingContext.h 2019-02-08 09:54:50 UTC (rev 241193)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2019-02-08 13:57:09 UTC (rev 241194)
@@ -90,12 +90,12 @@
static LayoutSize inFlowPositionedPositionOffset(const LayoutState&, const Box&);
static HeightAndMargin complicatedCases(const LayoutState&, const Box&, UsedVerticalValues);
- static LayoutUnit shrinkToFitWidth(LayoutState&, const Box&);
+ static LayoutUnit shrinkToFitWidth(LayoutState&, const Box&, UsedHorizontalValues);
- static Edges computedBorder(const LayoutState&, const Box&);
- static Optional<Edges> computedPadding(const LayoutState&, const Box&);
+ static Edges computedBorder(const Box&);
+ static Optional<Edges> computedPadding(const Box&, UsedHorizontalValues);
- static ComputedHorizontalMargin computedHorizontalMargin(const LayoutState&, const Box&);
+ static ComputedHorizontalMargin computedHorizontalMargin(const Box&, UsedHorizontalValues);
static ComputedVerticalMargin computedVerticalMargin(const LayoutState&, const Box&);
static Optional<LayoutUnit> computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth);
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (241193 => 241194)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-02-08 09:54:50 UTC (rev 241193)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-02-08 13:57:09 UTC (rev 241194)
@@ -234,7 +234,7 @@
return left;
}
-LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(LayoutState& layoutState, const Box& formattingRoot)
+LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(LayoutState& layoutState, const Box& formattingRoot, UsedHorizontalValues usedValues)
{
LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width] -> shrink to fit -> unsupported -> width(" << LayoutUnit { } << "px) layoutBox: " << &formattingRoot << ")");
ASSERT(formattingRoot.establishesFormattingContext());
@@ -246,7 +246,7 @@
// 'padding-left', 'padding-right', 'border-right-width', 'margin-right', and the widths of any relevant scroll bars.
// Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width).
- auto availableWidth = layoutState.displayBoxForLayoutBox(*formattingRoot.containingBlock()).width();
+ auto availableWidth = usedValues.containingBlockWidth;
auto instrinsicWidthConstraints = layoutState.createFormattingContext(formattingRoot)->instrinsicWidthConstraints();
return std::min(std::max(instrinsicWidthConstraints.minimum, availableWidth), instrinsicWidthConstraints.maximum);
}
@@ -410,7 +410,7 @@
auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
auto& containingBlock = *layoutBox.containingBlock();
auto& containingBlockDisplayBox = layoutState.displayBoxForLayoutBox(containingBlock);
- auto containingBlockWidth = containingBlockDisplayBox.paddingBoxWidth();
+ auto containingBlockWidth = usedValues.containingBlockWidth;
auto isLeftToRightDirection = containingBlock.style().isLeftToRightDirection();
auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
@@ -417,7 +417,7 @@
auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth);
auto isStaticallyPositioned = !left && !right;
auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth);
- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox);
+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
UsedHorizontalMargin usedHorizontalMargin;
auto paddingLeft = displayBox.paddingLeft().valueOr(0);
auto paddingRight = displayBox.paddingRight().valueOr(0);
@@ -487,7 +487,7 @@
if (!left && !width && right) {
// #1
- width = shrinkToFitWidth(layoutState, layoutBox);
+ width = shrinkToFitWidth(layoutState, layoutBox, usedValues);
left = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end + *right);
} else if (!left && !right && width) {
// #2
@@ -501,7 +501,7 @@
}
} else if (!width && !right && left) {
// #3
- width = shrinkToFitWidth(layoutState, layoutBox);
+ width = shrinkToFitWidth(layoutState, layoutBox, usedValues);
right = containingBlockWidth - (*left + usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end);
} else if (!left && width && right) {
// #4
@@ -635,14 +635,13 @@
auto& style = layoutBox.style();
auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
auto& containingBlock = *layoutBox.containingBlock();
- auto& containingBlockDisplayBox = layoutState.displayBoxForLayoutBox(containingBlock);
- auto containingBlockWidth = containingBlockDisplayBox.paddingBoxWidth();
+ auto containingBlockWidth = usedValues.containingBlockWidth;
auto isLeftToRightDirection = containingBlock.style().isLeftToRightDirection();
auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth);
auto isStaticallyPositioned = !left && !right;
- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox);
+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
Optional<LayoutUnit> usedMarginStart = computedHorizontalMargin.start;
Optional<LayoutUnit> usedMarginEnd = computedHorizontalMargin.end;
auto width = inlineReplacedWidthAndMargin(layoutState, layoutBox, usedValues).width;
@@ -713,7 +712,7 @@
// For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
// At this point the non-statically positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
if (!isStaticallyPositioned) {
- auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxLeft();
+ auto containingBlockPaddingVerticalEdge = layoutState.displayBoxForLayoutBox(containingBlock).paddingBoxLeft();
*left += containingBlockPaddingVerticalEdge;
*right += containingBlockPaddingVerticalEdge;
}
@@ -762,16 +761,14 @@
// 1. If 'margin-left', or 'margin-right' are computed as 'auto', their used value is '0'.
// 2. If 'width' is computed as 'auto', the used value is the "shrink-to-fit" width.
- auto& containingBlock = *layoutBox.containingBlock();
- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(containingBlock).contentBoxWidth();
- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox);
+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
// #1
auto usedHorizontallMargin = UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) };
// #2
- auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : layoutBox.style().logicalWidth(), containingBlockWidth);
+ auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : layoutBox.style().logicalWidth(), usedValues.containingBlockWidth);
if (!width)
- width = shrinkToFitWidth(layoutState, layoutBox);
+ width = shrinkToFitWidth(layoutState, layoutBox, usedValues);
LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> floating non-replaced -> width(" << *width << "px) margin(" << usedHorizontallMargin.start << "px, " << usedHorizontallMargin.end << "px) -> layoutBox(" << &layoutBox << ")");
return WidthAndMargin { *width, usedHorizontallMargin, computedHorizontalMargin };
@@ -795,10 +792,10 @@
//
// 1. If 'margin-left' or 'margin-right' are computed as 'auto', their used value is '0'.
// 2. The used value of 'width' is determined as for inline replaced elements.
- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox);
+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating replaced -> redirected to inline replaced");
- return inlineReplacedWidthAndMargin(layoutState, layoutBox, { usedValues.width, UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) } });
+ return inlineReplacedWidthAndMargin(layoutState, layoutBox, UsedHorizontalValues { usedValues.containingBlockWidth, usedValues.width, UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) } });
}
VerticalGeometry FormattingContext::Geometry::outOfFlowVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues)
@@ -906,9 +903,8 @@
// If 300px is too wide to fit the device, UAs should use the width of the largest rectangle that has a 2:1 ratio and fits the device instead.
auto& style = layoutBox.style();
- auto& containingBlock = *layoutBox.containingBlock();
- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(containingBlock).contentBoxWidth();
- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox);
+ auto containingBlockWidth = usedValues.containingBlockWidth;
+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
auto usedMarginStart = [&] {
if (usedValues.margin)
@@ -1030,7 +1026,7 @@
return { leftPositionOffset, topPositionOffset };
}
-Edges FormattingContext::Geometry::computedBorder(const LayoutState&, const Box& layoutBox)
+Edges FormattingContext::Geometry::computedBorder(const Box& layoutBox)
{
auto& style = layoutBox.style();
LOG_WITH_STREAM(FormattingContextLayout, stream << "[Border] -> layoutBox: " << &layoutBox);
@@ -1040,25 +1036,23 @@
};
}
-Optional<Edges> FormattingContext::Geometry::computedPadding(const LayoutState& layoutState, const Box& layoutBox)
+Optional<Edges> FormattingContext::Geometry::computedPadding(const Box& layoutBox, UsedHorizontalValues usedValues)
{
if (!layoutBox.isPaddingApplicable())
return WTF::nullopt;
auto& style = layoutBox.style();
- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
LOG_WITH_STREAM(FormattingContextLayout, stream << "[Padding] -> layoutBox: " << &layoutBox);
return Edges {
- { valueForLength(style.paddingLeft(), containingBlockWidth), valueForLength(style.paddingRight(), containingBlockWidth) },
- { valueForLength(style.paddingTop(), containingBlockWidth), valueForLength(style.paddingBottom(), containingBlockWidth) }
+ { valueForLength(style.paddingLeft(), usedValues.containingBlockWidth), valueForLength(style.paddingRight(), usedValues.containingBlockWidth) },
+ { valueForLength(style.paddingTop(), usedValues.containingBlockWidth), valueForLength(style.paddingBottom(), usedValues.containingBlockWidth) }
};
}
-ComputedHorizontalMargin FormattingContext::Geometry::computedHorizontalMargin(const LayoutState& layoutState, const Box& layoutBox)
+ComputedHorizontalMargin FormattingContext::Geometry::computedHorizontalMargin(const Box& layoutBox, UsedHorizontalValues usedValues)
{
auto& style = layoutBox.style();
- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
- return { computedValueIfNotAuto(style.marginStart(), containingBlockWidth), computedValueIfNotAuto(style.marginEnd(), containingBlockWidth) };
+ return { computedValueIfNotAuto(style.marginStart(), usedValues.containingBlockWidth), computedValueIfNotAuto(style.marginEnd(), usedValues.containingBlockWidth) };
}
ComputedVerticalMargin FormattingContext::Geometry::computedVerticalMargin(const LayoutState& layoutState, const Box& layoutBox)
Modified: trunk/Source/WebCore/layout/LayoutUnits.h (241193 => 241194)
--- trunk/Source/WebCore/layout/LayoutUnits.h 2019-02-08 09:54:50 UTC (rev 241193)
+++ trunk/Source/WebCore/layout/LayoutUnits.h 2019-02-08 13:57:09 UTC (rev 241194)
@@ -125,6 +125,14 @@
};
struct UsedHorizontalValues {
+ explicit UsedHorizontalValues(LayoutUnit containingBlockWidth, Optional<LayoutUnit> width, Optional<UsedHorizontalMargin> margin)
+ : containingBlockWidth(containingBlockWidth)
+ , width(width)
+ , margin(margin)
+ {
+ }
+
+ LayoutUnit containingBlockWidth;
Optional<LayoutUnit> width;
Optional<UsedHorizontalMargin> margin;
};
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (241193 => 241194)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2019-02-08 09:54:50 UTC (rev 241193)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2019-02-08 13:57:09 UTC (rev 241194)
@@ -298,9 +298,10 @@
void BlockFormattingContext::computeWidthAndMargin(const Box& layoutBox) const
{
auto& layoutState = this->layoutState();
+ auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
- auto compute = [&](UsedHorizontalValues usedValues) -> WidthAndMargin {
-
+ auto compute = [&](Optional<LayoutUnit> usedWidth) -> WidthAndMargin {
+ auto usedValues = UsedHorizontalValues { containingBlockWidth, usedWidth, { } };
if (layoutBox.isInFlow())
return Geometry::inFlowWidthAndMargin(layoutState, layoutBox, usedValues);
@@ -312,16 +313,15 @@
};
auto widthAndMargin = compute({ });
- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
if (auto maxWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMaxWidth(), containingBlockWidth)) {
- auto maxWidthAndMargin = compute({ *maxWidth, { } });
+ auto maxWidthAndMargin = compute(maxWidth);
if (widthAndMargin.width > maxWidthAndMargin.width)
widthAndMargin = maxWidthAndMargin;
}
auto minWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMinWidth(), containingBlockWidth).valueOr(0);
- auto minWidthAndMargin = compute({ minWidth, { } });
+ auto minWidthAndMargin = compute(minWidth);
if (widthAndMargin.width < minWidthAndMargin.width)
widthAndMargin = minWidthAndMargin;
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (241193 => 241194)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2019-02-08 09:54:50 UTC (rev 241193)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2019-02-08 13:57:09 UTC (rev 241194)
@@ -136,11 +136,11 @@
auto& style = layoutBox.style();
auto* containingBlock = layoutBox.containingBlock();
- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*containingBlock).contentBoxWidth();
+ auto containingBlockWidth = usedValues.containingBlockWidth;
auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth);
- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox);
+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
UsedHorizontalMargin usedHorizontalMargin;
auto borderLeft = displayBox.borderLeft();
auto borderRight = displayBox.borderRight();
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (241193 => 241194)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-02-08 09:54:50 UTC (rev 241193)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2019-02-08 13:57:09 UTC (rev 241194)
@@ -97,7 +97,8 @@
computeBorderAndPadding(inlineContainer);
auto& displayBox = layoutState().displayBoxForLayoutBox(inlineContainer);
- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState(), inlineContainer);
+ auto containingBlockWidth = layoutState().displayBoxForLayoutBox(*inlineContainer.containingBlock()).contentBoxWidth();
+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(inlineContainer, UsedHorizontalValues { containingBlockWidth, { }, { } });
displayBox.setHorizontalComputedMargin(computedHorizontalMargin);
displayBox.setHorizontalMargin({ computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) });
}
@@ -105,14 +106,16 @@
void InlineFormattingContext::computeWidthAndMargin(const Box& layoutBox) const
{
auto& layoutState = this->layoutState();
+ auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
WidthAndMargin widthAndMargin;
+ auto usedValues = UsedHorizontalValues { containingBlockWidth, { }, { } };
if (layoutBox.isFloatingPositioned())
- widthAndMargin = Geometry::floatingWidthAndMargin(layoutState, layoutBox, { });
+ widthAndMargin = Geometry::floatingWidthAndMargin(layoutState, layoutBox, usedValues);
else if (layoutBox.isInlineBlockBox())
- widthAndMargin = Geometry::inlineBlockWidthAndMargin(layoutState, layoutBox);
+ widthAndMargin = Geometry::inlineBlockWidthAndMargin(layoutState, layoutBox, usedValues);
else if (layoutBox.replaced())
- widthAndMargin = Geometry::inlineReplacedWidthAndMargin(layoutState, layoutBox, { });
+ widthAndMargin = Geometry::inlineReplacedWidthAndMargin(layoutState, layoutBox, usedValues);
else
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (241193 => 241194)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2019-02-08 09:54:50 UTC (rev 241193)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2019-02-08 13:57:09 UTC (rev 241194)
@@ -82,7 +82,7 @@
class Geometry : public FormattingContext::Geometry {
public:
static HeightAndMargin inlineBlockHeightAndMargin(const LayoutState&, const Box&);
- static WidthAndMargin inlineBlockWidthAndMargin(LayoutState&, const Box&);
+ static WidthAndMargin inlineBlockWidthAndMargin(LayoutState&, const Box&, UsedHorizontalValues);
};
void layoutFormattingContextRoot(const Box&) const;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (241193 => 241194)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2019-02-08 09:54:50 UTC (rev 241193)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2019-02-08 13:57:09 UTC (rev 241194)
@@ -38,7 +38,7 @@
namespace WebCore {
namespace Layout {
-WidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(LayoutState& layoutState, const Box& formattingContextRoot)
+WidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(LayoutState& layoutState, const Box& formattingContextRoot, UsedHorizontalValues usedValues)
{
ASSERT(formattingContextRoot.isInFlow());
@@ -46,21 +46,19 @@
// Exactly as inline replaced elements.
if (formattingContextRoot.replaced())
- return inlineReplacedWidthAndMargin(layoutState, formattingContextRoot, { });
+ return inlineReplacedWidthAndMargin(layoutState, formattingContextRoot, usedValues);
// 10.3.9 'Inline-block', non-replaced elements in normal flow
// If 'width' is 'auto', the used value is the shrink-to-fit width as for floating elements.
// A computed value of 'auto' for 'margin-left' or 'margin-right' becomes a used value of '0'.
- auto& containingBlock = *formattingContextRoot.containingBlock();
- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(containingBlock).contentBoxWidth();
// #1
- auto width = computedValueIfNotAuto(formattingContextRoot.style().logicalWidth(), containingBlockWidth);
+ auto width = computedValueIfNotAuto(formattingContextRoot.style().logicalWidth(), usedValues.containingBlockWidth);
if (!width)
- width = shrinkToFitWidth(layoutState, formattingContextRoot);
+ width = shrinkToFitWidth(layoutState, formattingContextRoot, usedValues);
// #2
- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, formattingContextRoot);
+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(formattingContextRoot, usedValues);
return WidthAndMargin { *width, { computedHorizontalMargin.start.valueOr(0_lu), computedHorizontalMargin.end.valueOr(0_lu) }, computedHorizontalMargin };
}