https://bugs.webkit.org/show_bug.cgi?id=188296
Reviewed by Simon Fraser.
The spec is not clear about what to do with the document renderer. It behaves as if it was a formatting context root when
it comes to computing the content height. Let's apply "10.6.6 Complicated cases" for now.
* layout/FormattingContext.h:
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::complicatedCases):
(WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedHeightAndMargin): Deleted.
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
* layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::establishesBlockFormattingContext const):
* layout/layouttree/LayoutBox.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234537
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2018-08-02 Zalan Bujtas <zalan@apple.com>
+ [LFC][BFC] Apply the "10.6.6 Complicated cases" when computing height and margin for the document renderer
+ https://bugs.webkit.org/show_bug.cgi?id=188296
+
+ Reviewed by Simon Fraser.
+
+ The spec is not clear about what to do with the document renderer. It behaves as if it was a formatting context root when
+ it comes to computing the content height. Let's apply "10.6.6 Complicated cases" for now.
+
+ * layout/FormattingContext.h:
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::FormattingContext::Geometry::complicatedCases):
+ (WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin):
+ (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedHeightAndMargin): Deleted.
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
+ * layout/layouttree/LayoutBox.cpp:
+ (WebCore::Layout::Box::establishesBlockFormattingContext const):
+ * layout/layouttree/LayoutBox.h:
+
+2018-08-02 Zalan Bujtas <zalan@apple.com>
+
[LFC][Floating] Add FloatingState::bottom() to enable content height computation for formatting roots.
https://bugs.webkit.org/show_bug.cgi?id=188294
static WidthAndMargin inlineReplacedWidthAndMargin(LayoutContext&, const Box&, std::optional<LayoutUnit> precomputedMarginLeft = { },
std::optional<LayoutUnit> precomputedMarginRight = { });
+ static HeightAndMargin complicatedCases(LayoutContext&, const Box&);
+
static Edges computedBorder(LayoutContext&, const Box&);
static std::optional<Edges> computedPadding(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 FormattingContext&, const Box&);
static LayoutUnit shrinkToFitWidth(LayoutContext&, const FormattingContext&, const Box&);
return { *left, *right, { width, { *marginLeft, *marginRight } } };
}
-HeightAndMargin FormattingContext::Geometry::floatingNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
+HeightAndMargin FormattingContext::Geometry::complicatedCases(LayoutContext& layoutContext, const Box& layoutBox)
{
- ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced());
+ ASSERT(!layoutBox.replaced());
+ // TODO: Use complicated-case for document renderer for now (see BlockFormattingContext::Geometry::inFlowHeightAndMargin).
+ ASSERT((layoutBox.isBlockLevelBox() && layoutBox.isInFlow() && !layoutBox.isOverflowVisible()) || layoutBox.isInlineBlockBox() || layoutBox.isFloatingPositioned() || layoutBox.isDocumentBox());
// 10.6.6 Complicated cases
//
ASSERT(layoutBox.isFloatingPositioned());
if (!layoutBox.replaced())
- return floatingNonReplacedHeightAndMargin(layoutContext, layoutBox);
+ return complicatedCases(layoutContext, layoutBox);
return floatingReplacedHeightAndMargin(layoutContext, layoutBox);
}
HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
{
ASSERT(layoutBox.isInFlow() && !layoutBox.replaced());
+ ASSERT(layoutBox.isOverflowVisible());
auto compute = [&]() -> HeightAndMargin {
{
ASSERT(layoutBox.isInFlow());
- if (!layoutBox.replaced())
- 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::inlineReplacedHeightAndMargin(layoutContext, layoutBox);
+ if (layoutBox.replaced())
+ return FormattingContext::Geometry::inlineReplacedHeightAndMargin(layoutContext, layoutBox);
+
+ // TODO: Figure out the case for the document element. Let's just complicated-case it for now.
+ if (layoutBox.isOverflowVisible() && !layoutBox.isDocumentBox())
+ return inFlowNonReplacedHeightAndMargin(layoutContext, layoutBox);
+
+ // 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).
+ return FormattingContext::Geometry::complicatedCases(layoutContext, layoutBox);
}
WidthAndMargin BlockFormattingContext::Geometry::inFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
// Initial Containing Block always creates a new (inital) block formatting context.
if (!parent())
return true;
+
// 9.4.1 Block formatting contexts
// Floats, absolutely positioned elements, block containers (such as inline-blocks, table-cells, and table-captions)
// that are not block boxes, and block boxes with 'overflow' other than 'visible' (except when that value has been propagated to the viewport)
// establish new block formatting contexts for their contents.
if (isFloatingPositioned() || isAbsolutelyPositioned())
return true;
+
if (isBlockContainerBox() && !isBlockLevelBox())
return true;
+
if (isBlockLevelBox() && !isOverflowVisible())
return true;
+
+ if (isDocumentBox())
+ return true;
+
return false;
}
bool isInlineContainer() const { return m_baseTypeFlags & InlineContainerFlag; }
bool isPaddingApplicable() const;
+ bool isOverflowVisible() const;
const RenderStyle& style() const { return m_style; }
};
Box(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
- bool isOverflowVisible() const;
-
private:
void setParent(Container& parent) { m_parent = &parent; }
void setNextSibling(Box& nextSibling) { m_nextSibling = &nextSibling; }