- Revision
- 234537
- Author
- [email protected]
- Date
- 2018-08-02 21:32:05 -0700 (Thu, 02 Aug 2018)
Log Message
[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:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (234536 => 234537)
--- trunk/Source/WebCore/ChangeLog 2018-08-03 02:32:24 UTC (rev 234536)
+++ trunk/Source/WebCore/ChangeLog 2018-08-03 04:32:05 UTC (rev 234537)
@@ -1,5 +1,27 @@
2018-08-02 Zalan Bujtas <[email protected]>
+ [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 <[email protected]>
+
[LFC][Floating] Add FloatingState::bottom() to enable content height computation for formatting roots.
https://bugs.webkit.org/show_bug.cgi?id=188294
Modified: trunk/Source/WebCore/layout/FormattingContext.h (234536 => 234537)
--- trunk/Source/WebCore/layout/FormattingContext.h 2018-08-03 02:32:24 UTC (rev 234536)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2018-08-03 04:32:05 UTC (rev 234537)
@@ -97,6 +97,8 @@
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&);
@@ -116,7 +118,6 @@
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&);
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (234536 => 234537)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2018-08-03 02:32:24 UTC (rev 234536)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2018-08-03 04:32:05 UTC (rev 234537)
@@ -574,9 +574,11 @@
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
//
@@ -685,7 +687,7 @@
ASSERT(layoutBox.isFloatingPositioned());
if (!layoutBox.replaced())
- return floatingNonReplacedHeightAndMargin(layoutContext, layoutBox);
+ return complicatedCases(layoutContext, layoutBox);
return floatingReplacedHeightAndMargin(layoutContext, layoutBox);
}
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (234536 => 234537)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2018-08-03 02:32:24 UTC (rev 234536)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2018-08-03 04:32:05 UTC (rev 234537)
@@ -60,6 +60,7 @@
HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
{
ASSERT(layoutBox.isInFlow() && !layoutBox.replaced());
+ ASSERT(layoutBox.isOverflowVisible());
auto compute = [&]() -> HeightAndMargin {
@@ -364,11 +365,18 @@
{
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)
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (234536 => 234537)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2018-08-03 02:32:24 UTC (rev 234536)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2018-08-03 04:32:05 UTC (rev 234537)
@@ -57,6 +57,7 @@
// 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)
@@ -63,10 +64,16 @@
// 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;
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (234536 => 234537)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2018-08-03 02:32:24 UTC (rev 234536)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2018-08-03 04:32:05 UTC (rev 234537)
@@ -95,6 +95,7 @@
bool isInlineContainer() const { return m_baseTypeFlags & InlineContainerFlag; }
bool isPaddingApplicable() const;
+ bool isOverflowVisible() const;
const RenderStyle& style() const { return m_style; }
@@ -125,8 +126,6 @@
};
Box(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
- bool isOverflowVisible() const;
-
private:
void setParent(Container& parent) { m_parent = &parent; }
void setNextSibling(Box& nextSibling) { m_nextSibling = &nextSibling; }