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

Reviewed by Antti Koivisto.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeFloatingWidth const):
(WebCore::Layout::FormattingContext::computeFloatingNonReplacedWidth const):
* layout/FormattingContext.h:

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

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

index 4734d08..2fcbbc3 100644 (file)
@@ -1,3 +1,15 @@
+2018-05-18  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Implement width computation for non-replaced floating elements.
+        https://bugs.webkit.org/show_bug.cgi?id=185759
+
+        Reviewed by Antti Koivisto.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeFloatingWidth const):
+        (WebCore::Layout::FormattingContext::computeFloatingNonReplacedWidth const):
+        * layout/FormattingContext.h:
+
 2018-05-18  Antoine Quint  <graouts@apple.com>
 
         [modern-media-controls] AirPlaySupport should be disabled by default
index 180c0a6..eb088ef 100644 (file)
@@ -90,7 +90,7 @@ void FormattingContext::computeOutOfFlowWidth(LayoutContext& layoutContext, cons
 void FormattingContext::computeFloatingWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
     if (!layoutBox.replaced()) {
-        ASSERT_NOT_IMPLEMENTED_YET();
+        computeFloatingNonReplacedWidth(layoutContext, layoutBox, displayBox);
         return;
     }
     computeReplacedWidth(layoutContext, layoutBox, displayBox);
@@ -295,6 +295,16 @@ LayoutUnit FormattingContext::contentHeightForFormattingContextRoot(LayoutContex
     return bottom - top;
 }
 
+void FormattingContext::computeFloatingNonReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
+{
+    ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced());
+    // 10.3.5 Floating, non-replaced elements
+
+    // If 'width' is computed as 'auto', the used value is the "shrink-to-fit" width.
+    auto width = layoutBox.style().logicalWidth();
+    displayBox.setWidth(width.isAuto() ? shrinkToFitWidth(layoutContext, layoutBox) : LayoutUnit(width.value()));
+}
+
 void FormattingContext::computeOutOfFlowNonReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced());
index 913dec9..b09e650 100644 (file)
@@ -94,6 +94,8 @@ private:
     void computeOutOfFlowNonReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
     void computeOutOfFlowReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
 
+    void computeFloatingNonReplacedWidth(LayoutContext&, const Box&, Display::Box&) const;
+
     LayoutUnit contentHeightForFormattingContextRoot(LayoutContext&, const Box&) const;
     LayoutUnit shrinkToFitWidth(LayoutContext&, const Box&) const;