[LFC] Implement height computation for non-replaced floating elements.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2018 16:32:14 +0000 (16:32 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2018 16:32:14 +0000 (16:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185767

Reviewed by Antti Koivisto.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeFloatingHeight const):
(WebCore::Layout::FormattingContext::computeFloatingNonReplacedHeight const):
(WebCore::Layout::FormattingContext::contentHeightForFormattingContextRoot const):
* layout/FormattingContext.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231958 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.cpp
Source/WebCore/layout/FormattingContext.h

index 11b53fe..9bf9345 100644 (file)
@@ -1,3 +1,16 @@
+2018-05-18  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Implement height computation for non-replaced floating elements.
+        https://bugs.webkit.org/show_bug.cgi?id=185767
+
+        Reviewed by Antti Koivisto.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeFloatingHeight const):
+        (WebCore::Layout::FormattingContext::computeFloatingNonReplacedHeight const):
+        (WebCore::Layout::FormattingContext::contentHeightForFormattingContextRoot const):
+        * layout/FormattingContext.h:
+
 2018-05-18  Dirk Schulze  <krit@webkit.org>
 
         Make all SVG shape interfaces inherit from SVGGeometryElement
index f73e5dc..b197ea5 100644 (file)
@@ -108,7 +108,7 @@ void FormattingContext::computeOutOfFlowHeight(LayoutContext& layoutContext, con
 void FormattingContext::computeFloatingHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
     if (!layoutBox.replaced()) {
-        ASSERT_NOT_IMPLEMENTED_YET();
+        computeFloatingNonReplacedHeight(layoutContext, layoutBox, displayBox);
         return;
     }
     computeReplacedHeight(layoutContext, layoutBox, displayBox);
@@ -217,6 +217,18 @@ void FormattingContext::computeOutOfFlowNonReplacedHeight(LayoutContext& layoutC
     displayBox.setHeight(computedHeightValue);
 }
 
+void FormattingContext::computeFloatingNonReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+{
+    ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced());
+    // 10.6.6 Complicated cases
+    //
+    // Floating, non-replaced elements.
+    //
+    // If 'height' is 'auto', the height depends on the element's descendants per 10.6.7.
+    auto height = layoutBox.style().logicalHeight();
+    displayBox.setHeight(height.isAuto() ? contentHeightForFormattingContextRoot(layoutContext, layoutBox) : LayoutUnit(height.value()));
+}
+
 void FormattingContext::computeReplacedHeight(LayoutContext&, const Box& layoutBox, Display::Box& displayBox) const
 {
     ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced());
@@ -317,12 +329,7 @@ void FormattingContext::computeReplacedWidth(LayoutContext&, const Box& layoutBo
 
 LayoutUnit FormattingContext::contentHeightForFormattingContextRoot(LayoutContext& layoutContext, const Box& layoutBox) const
 {
-    ASSERT(layoutBox.style().logicalHeight().isAuto());
-
-    if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild())
-        return 0;
-
-    auto& formattingRootContainer = downcast<Container>(layoutBox);
+    ASSERT(layoutBox.style().logicalHeight().isAuto() && layoutBox.establishesFormattingContext());
     // 10.6.7 'Auto' heights for block formatting context roots
 
     // If it only has inline-level children, the height is the distance between the top of the topmost line box and the bottom of the bottommost line box.
@@ -332,6 +339,10 @@ LayoutUnit FormattingContext::contentHeightForFormattingContextRoot(LayoutContex
     // In addition, if the element has any floating descendants whose bottom margin edge is below the element's bottom content edge,
     // then the height is increased to include those edges. Only floats that participate in this block formatting context are taken
     // into account, e.g., floats inside absolutely positioned descendants or other floats are not.
+    if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild())
+        return 0;
+
+    auto& formattingRootContainer = downcast<Container>(layoutBox);
     if (formattingRootContainer.establishesInlineFormattingContext())
         return 0;
 
index c9a7cbf..ee0ed55 100644 (file)
@@ -96,6 +96,7 @@ private:
     void computeOutOfFlowReplacedHeight(LayoutContext&, const Box&, Display::Box&) const;
     void computeOutOfFlowReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
 
+    void computeFloatingNonReplacedHeight(LayoutContext&, const Box&, Display::Box&) const;
     void computeFloatingNonReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
 
     LayoutUnit contentHeightForFormattingContextRoot(LayoutContext&, const Box&) const;