[LFC][BFC] Apply the "10.6.6 Complicated cases" when computing height and margin...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Aug 2018 04:32:05 +0000 (04:32 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Aug 2018 04:32:05 +0000 (04:32 +0000)
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

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.h
Source/WebCore/layout/FormattingContextGeometry.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
Source/WebCore/layout/layouttree/LayoutBox.cpp
Source/WebCore/layout/layouttree/LayoutBox.h

index b6cf833..aa50efa 100644 (file)
@@ -1,5 +1,27 @@
 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
 
index ce201cf..57139a5 100644 (file)
@@ -97,6 +97,8 @@ protected:
         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 @@ protected:
         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&);
index 7313388..a7a8c27 100644 (file)
@@ -574,9 +574,11 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeome
     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 @@ HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(LayoutConte
     ASSERT(layoutBox.isFloatingPositioned());
 
     if (!layoutBox.replaced())
-        return floatingNonReplacedHeightAndMargin(layoutContext, layoutBox);
+        return complicatedCases(layoutContext, layoutBox);
     return floatingReplacedHeightAndMargin(layoutContext, layoutBox);
 }
 
index 8b5265a..a6d7f09 100644 (file)
@@ -60,6 +60,7 @@ static const Container& initialContainingBlock(const Box& layoutBox)
 HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isInFlow() && !layoutBox.replaced());
+    ASSERT(layoutBox.isOverflowVisible());
 
     auto compute = [&]() -> HeightAndMargin {
 
@@ -364,11 +365,18 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(LayoutCo
 {
     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)
index 13a89d4..5fd5829 100644 (file)
@@ -57,16 +57,23 @@ bool Box::establishesBlockFormattingContext() const
     // 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;
 }
 
index f83a73a..f544515 100644 (file)
@@ -95,6 +95,7 @@ public:
     bool isInlineContainer() const { return m_baseTypeFlags & InlineContainerFlag; }
 
     bool isPaddingApplicable() const;
+    bool isOverflowVisible() const;
 
     const RenderStyle& style() const { return m_style; }
 
@@ -125,8 +126,6 @@ protected:
     };
     Box(std::optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags);
 
-    bool isOverflowVisible() const;
-
 private:
     void setParent(Container& parent) { m_parent = &parent; }
     void setNextSibling(Box& nextSibling) { m_nextSibling = &nextSibling; }