https://bugs.webkit.org/show_bug.cgi?id=186394
Reviewed by Antti Koivisto.
To match the spec (and the width/horizontal margin computation). -currently with default values.
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeFloatingHeightAndMargin const):
(WebCore::Layout::FormattingContext::computeOutOfFlowHeight const):
(WebCore::Layout::FormattingContext::computeFloatingHeight const): Deleted.
* layout/FormattingContext.h:
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin):
(WebCore::Layout::outOfFlowNonReplacedHeight): Deleted.
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHeight): Deleted.
(WebCore::Layout::floatingNonReplacedHeight): Deleted.
(WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeight): Deleted.
(WebCore::Layout::FormattingContext::Geometry::outOfFlowHeight): Deleted.
(WebCore::Layout::FormattingContext::Geometry::floatingHeight): Deleted.
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeight): Deleted.
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layout const):
(WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
(WebCore::Layout::BlockFormattingContext::computeInFlowHeightAndMargin const):
(WebCore::Layout::BlockFormattingContext::computeHeight const): Deleted.
(WebCore::Layout::BlockFormattingContext::computeInFlowHeight const): Deleted.
* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeight): Deleted.
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeight): Deleted.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232581
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2018-06-07 Zalan Bujtas <zalan@apple.com>
+
+ [LFC] Merge height and vertical margin computation
+ https://bugs.webkit.org/show_bug.cgi?id=186394
+
+ Reviewed by Antti Koivisto.
+
+ To match the spec (and the width/horizontal margin computation). -currently with default values.
+
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::computeFloatingHeightAndMargin const):
+ (WebCore::Layout::FormattingContext::computeOutOfFlowHeight const):
+ (WebCore::Layout::FormattingContext::computeFloatingHeight const): Deleted.
+ * layout/FormattingContext.h:
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHeightAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHeightAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedHeightAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowHeightAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin):
+ (WebCore::Layout::outOfFlowNonReplacedHeight): Deleted.
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHeight): Deleted.
+ (WebCore::Layout::floatingNonReplacedHeight): Deleted.
+ (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeight): Deleted.
+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowHeight): Deleted.
+ (WebCore::Layout::FormattingContext::Geometry::floatingHeight): Deleted.
+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeight): Deleted.
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::layout const):
+ (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
+ (WebCore::Layout::BlockFormattingContext::computeInFlowHeightAndMargin const):
+ (WebCore::Layout::BlockFormattingContext::computeHeight const): Deleted.
+ (WebCore::Layout::BlockFormattingContext::computeInFlowHeight const): Deleted.
+ * layout/blockformatting/BlockFormattingContext.h:
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeight): Deleted.
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeight): Deleted.
+
2018-06-07 Antti Koivisto <antti@apple.com>
Don't start service worker fetch when there is substitute data
displayBox.setTopLeft(Geometry::outOfFlowPosition(layoutContext, layoutBox));
}
-void FormattingContext::computeFloatingHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void FormattingContext::computeFloatingHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
- displayBox.setHeight(Geometry::floatingHeight(layoutContext, layoutBox));
+ auto heightAndMargin = Geometry::floatingHeightAndMargin(layoutContext, layoutBox);
+ displayBox.setHeight(heightAndMargin.height);
+ displayBox.setVerticalMargin(heightAndMargin.margin);
}
void FormattingContext::computeFloatingWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
void FormattingContext::computeOutOfFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
- displayBox.setHeight(Geometry::outOfFlowHeight(layoutContext, layoutBox));
+ auto heightAndMargin = Geometry::outOfFlowHeightAndMargin(layoutContext, layoutBox);
+ displayBox.setHeight(heightAndMargin.height);
+ displayBox.setVerticalMargin(heightAndMargin.margin);
}
void FormattingContext::computeBorderAndPadding(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
virtual void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const = 0;
virtual void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const = 0;
- void computeFloatingHeight(LayoutContext&, const Box&, Display::Box&) const;
+ void computeFloatingHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
void computeFloatingWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
void computeBorderAndPadding(LayoutContext&, const Box&, Display::Box&) const;
Display::Box::HorizontalEdges margin;
};
- static LayoutUnit outOfFlowHeight(LayoutContext&, const Box&);
+ struct HeightAndMargin {
+ LayoutUnit height;
+ Display::Box::VerticalEdges margin;
+ };
+
+ static HeightAndMargin outOfFlowHeightAndMargin(LayoutContext&, const Box&);
static WidthAndMargin outOfFlowWidthAndMargin(LayoutContext&, const Box&);
- static LayoutUnit floatingHeight(LayoutContext&, const Box&);
+ static HeightAndMargin floatingHeightAndMargin(LayoutContext&, const Box&);
static WidthAndMargin floatingWidthAndMargin(LayoutContext&, const Box&);
static LayoutPoint outOfFlowPosition(LayoutContext&, const Box&);
- static LayoutUnit inlineReplacedHeight(LayoutContext&, const Box&);
+ static HeightAndMargin inlineReplacedHeightAndMargin(LayoutContext&, const Box&);
static WidthAndMargin inlineReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedMarginLeft = { },
std::optional<LayoutUnit> precomputedMarginRight = { });
static std::optional<Display::Box::Edges> computedPadding(LayoutContext&, const Box&);
private:
- static LayoutUnit outOfFlowReplacedHeight(LayoutContext&, const Box&);
+ static HeightAndMargin outOfFlowReplacedHeightAndMargin(LayoutContext&, const Box&);
static WidthAndMargin outOfFlowReplacedWidthAndMargin(LayoutContext&, const Box&);
+ static HeightAndMargin outOfFlowNonReplacedHeightAndMargin(LayoutContext&, const Box&);
static WidthAndMargin outOfFlowNonReplacedWidthAndMargin(LayoutContext&, const Box&);
- static LayoutUnit floatingReplacedHeight(LayoutContext&, const Box&);
+ static HeightAndMargin floatingReplacedHeightAndMargin(LayoutContext&, const Box&);
static WidthAndMargin floatingReplacedWidthAndMargin(LayoutContext&, const Box&);
+ static HeightAndMargin floatingNonReplacedHeightAndMargin(LayoutContext&, const Box&);
static WidthAndMargin floatingNonReplacedWidthAndMargin(LayoutContext&, const Box&);
};
return { };
}
-static LayoutUnit outOfFlowNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::outOfFlowNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
{
ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced());
ASSERT_NOT_REACHED();
}
- return computedHeightValue;
+ return { computedHeightValue, { } };
}
FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::outOfFlowNonReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
return WidthAndMargin { computedWidthValue, { } };
}
-LayoutUnit FormattingContext::Geometry::outOfFlowReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::outOfFlowReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
{
ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced());
// 10.6.5 Absolutely positioned, replaced elements
//
// The used value of 'height' is determined as for inline replaced elements.
- return inlineReplacedHeight(layoutContext, layoutBox);
+ return inlineReplacedHeightAndMargin(layoutContext, layoutBox);
}
FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::outOfFlowReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
return inlineReplacedWidthAndMargin(layoutContext, layoutBox);
}
-static LayoutUnit floatingNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floatingNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
{
ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced());
// 10.6.6 Complicated cases
//
// If 'height' is 'auto', the height depends on the element's descendants per 10.6.7.
auto height = layoutBox.style().logicalHeight();
- return height.isAuto() ? contentHeightForFormattingContextRoot(layoutContext, layoutBox) : LayoutUnit(height.value());
+ auto computedHeightValue = height.isAuto() ? contentHeightForFormattingContextRoot(layoutContext, layoutBox) : LayoutUnit { height.value() };
+ return FormattingContext::Geometry::HeightAndMargin { computedHeightValue, { } };
}
FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
return FormattingContext::Geometry::WidthAndMargin { computedWidthValue, { computedMarginLeftValue, computedMarginRightValue } };
}
-LayoutUnit FormattingContext::Geometry::floatingReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floatingReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
{
ASSERT(layoutBox.isFloatingPositioned() && layoutBox.replaced());
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block'
// replaced elements in normal flow and floating replaced elements
- return inlineReplacedHeight(layoutContext, layoutBox);
+ return inlineReplacedHeightAndMargin(layoutContext, layoutBox);
}
FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatingReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
return { computedLeftValue, computedTopValue };
}
-LayoutUnit FormattingContext::Geometry::outOfFlowHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::outOfFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
{
ASSERT(layoutBox.isOutOfFlowPositioned());
if (!layoutBox.replaced())
- return outOfFlowNonReplacedHeight(layoutContext, layoutBox);
- return outOfFlowReplacedHeight(layoutContext, layoutBox);
+ return outOfFlowNonReplacedHeightAndMargin(layoutContext, layoutBox);
+ return outOfFlowReplacedHeightAndMargin(layoutContext, layoutBox);
}
FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::outOfFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
return outOfFlowReplacedWidthAndMargin(layoutContext, layoutBox);
}
-LayoutUnit FormattingContext::Geometry::floatingHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
{
ASSERT(layoutBox.isFloatingPositioned());
if (!layoutBox.replaced())
- return floatingNonReplacedHeight(layoutContext, layoutBox);
- return floatingReplacedHeight(layoutContext, layoutBox);
+ return floatingNonReplacedHeightAndMargin(layoutContext, layoutBox);
+ return floatingReplacedHeightAndMargin(layoutContext, layoutBox);
}
FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::floatingWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
return outOfFlowReplacedPosition(layoutContext, layoutBox);
}
-LayoutUnit FormattingContext::Geometry::inlineReplacedHeight(LayoutContext&, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(LayoutContext&, const Box& layoutBox)
{
ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced());
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements
} else
computedHeightValue = height.value();
- return computedHeightValue;
+ return { computedHeightValue, { } };
}
FormattingContext::Geometry::WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox,
auto& layoutBox = layoutPair->layoutBox;
auto& displayBox = layoutPair->displayBox;
- computeHeight(layoutContext, layoutBox, displayBox);
+ computeHeightAndMargin(layoutContext, layoutBox, displayBox);
// Adjust position now that we have all the previous floats placed in this context -if needed.
floatingContext.computePosition(layoutBox, displayBox);
if (!is<Container>(layoutBox))
ASSERT_NOT_REACHED();
}
-void BlockFormattingContext::computeHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
if (layoutBox.isInFlow())
- return computeInFlowHeight(layoutContext, layoutBox, displayBox);
+ return computeInFlowHeightAndMargin(layoutContext, layoutBox, displayBox);
if (layoutBox.isFloatingPositioned())
- return computeFloatingHeight(layoutContext, layoutBox, displayBox);
+ return computeFloatingHeightAndMargin(layoutContext, layoutBox, displayBox);
ASSERT_NOT_REACHED();
}
-void BlockFormattingContext::computeInFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+void BlockFormattingContext::computeInFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
- displayBox.setHeight(Geometry::inFlowHeight(layoutContext, layoutBox));
+ auto heightAndMargin = Geometry::inFlowHeightAndMargin(layoutContext, layoutBox);
+ displayBox.setHeight(heightAndMargin.height);
+ displayBox.setVerticalMargin(heightAndMargin.margin);
}
void BlockFormattingContext::computeInFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
private:
void computeWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
- void computeHeight(LayoutContext&, const Box&, Display::Box&) const;
+ void computeHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const override;
void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const override;
void computeInFlowWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
- void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const;
+ void computeInFlowHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
// This class implements positioning and sizing for boxes participating in a block formatting context.
class Geometry {
public:
- static LayoutUnit inFlowHeight(LayoutContext&, const Box&);
+ static FormattingContext::Geometry::HeightAndMargin inFlowHeightAndMargin(LayoutContext&, const Box&);
static FormattingContext::Geometry::WidthAndMargin inFlowWidthAndMargin(LayoutContext&, const Box&);
static LayoutPoint staticPosition(LayoutContext&, const Box&);
static LayoutPoint inFlowPositionedPosition(LayoutContext&, const Box&);
private:
- static LayoutUnit inFlowNonReplacedHeight(LayoutContext&, const Box&);
+ static FormattingContext::Geometry::HeightAndMargin inFlowNonReplacedHeightAndMargin(LayoutContext&, const Box&);
static FormattingContext::Geometry::WidthAndMargin inFlowNonReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedWidth = std::nullopt);
static FormattingContext::Geometry::WidthAndMargin inFlowReplacedWidthAndMargin(LayoutContext&, const Box&);
};
return *containingBlock;
}
-LayoutUnit BlockFormattingContext::Geometry::inFlowNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
{
ASSERT(layoutBox.isInFlow() && !layoutBox.replaced());
auto computedHeight = compute();
if (!isStretchedToViewport(layoutContext, layoutBox))
- return computedHeight;
+ return { computedHeight, { } };
auto initialContainingBlockHeight = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBox().height();
- return std::max(computedHeight, initialContainingBlockHeight);
+ return { std::max(computedHeight, initialContainingBlockHeight), { } };
}
FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox,
return { displayBox.left() + leftDelta, displayBox.top() + topDelta };
}
-LayoutUnit BlockFormattingContext::Geometry::inFlowHeight(LayoutContext& layoutContext, const Box& layoutBox)
+FormattingContext::Geometry::HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
{
ASSERT(layoutBox.isInFlow());
if (!layoutBox.replaced())
- return inFlowNonReplacedHeight(layoutContext, layoutBox);
+ return inFlowNonReplacedHeightAndMargin(layoutContext, layoutBox);
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block'
// replaced elements in normal flow and floating replaced elements
- return FormattingContext::Geometry::inlineReplacedHeight(layoutContext, layoutBox);
+ return FormattingContext::Geometry::inlineReplacedHeightAndMargin(layoutContext, layoutBox);
}
FormattingContext::Geometry::WidthAndMargin BlockFormattingContext::Geometry::inFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)