Title: [234536] trunk/Source/WebCore
Revision
234536
Author
[email protected]
Date
2018-08-02 19:32:24 -0700 (Thu, 02 Aug 2018)

Log Message

[LFC][Floating] Add FloatingState::bottom() to enable content height computation for formatting roots.
https://bugs.webkit.org/show_bug.cgi?id=188294

Reviewed by Simon Fraser.

"10.6.7 'Auto' heights for block formatting context roots
...
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..."

* layout/FloatingState.cpp:
(WebCore::Layout::FloatingState::bottom const):
* layout/FloatingState.h:
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::contentHeightForFormattingContextRoot):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (234535 => 234536)


--- trunk/Source/WebCore/ChangeLog	2018-08-03 02:10:58 UTC (rev 234535)
+++ trunk/Source/WebCore/ChangeLog	2018-08-03 02:32:24 UTC (rev 234536)
@@ -1,3 +1,22 @@
+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
+
+        Reviewed by Simon Fraser.
+
+        "10.6.7 'Auto' heights for block formatting context roots
+        ...
+        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..."
+
+        * layout/FloatingState.cpp:
+        (WebCore::Layout::FloatingState::bottom const):
+        * layout/FloatingState.h:
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::contentHeightForFormattingContextRoot):
+
 2018-08-02  Jer Noble  <[email protected]>
 
         Control center controls disappear when pausing, locking device.

Modified: trunk/Source/WebCore/layout/FloatingState.cpp (234535 => 234536)


--- trunk/Source/WebCore/layout/FloatingState.cpp	2018-08-03 02:10:58 UTC (rev 234535)
+++ trunk/Source/WebCore/layout/FloatingState.cpp	2018-08-03 02:32:24 UTC (rev 234536)
@@ -90,6 +90,29 @@
     m_floats.append({ layoutBox, *this });
 }
 
+std::optional<LayoutUnit> FloatingState::bottom(const Box& formattingContextRoot) const
+{
+    if (m_floats.isEmpty())
+        return { };
+
+    // TODO: Currently this is only called once for each formatting context root with floats per layout.
+    // Cache the value if we end up calling it more frequently (and update it at append/remove).
+    std::optional<LayoutUnit> bottom;
+    for (auto& floatItem : m_floats) {
+        // Ignore floats from other formatting contexts when the floating state is inherited.
+        if (&formattingContextRoot != &floatItem.layoutBox().formattingContextRoot())
+            continue;
+
+        auto floatsBottom = floatItem.displayBox().rectWithMargin().bottom();
+        if (bottom) {
+            bottom = std::max(*bottom, floatsBottom);
+            continue;
+        }
+        bottom = floatsBottom;
+    }
+    return bottom;
 }
+
 }
+}
 #endif

Modified: trunk/Source/WebCore/layout/FloatingState.h (234535 => 234536)


--- trunk/Source/WebCore/layout/FloatingState.h	2018-08-03 02:10:58 UTC (rev 234535)
+++ trunk/Source/WebCore/layout/FloatingState.h	2018-08-03 02:32:24 UTC (rev 234536)
@@ -51,6 +51,7 @@
     void remove(const Box& layoutBox);
 
     bool isEmpty() const { return m_floats.isEmpty(); }
+    std::optional<LayoutUnit> bottom(const Box& formattingContextRoot) const;
 
     class FloatItem {
     public:

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (234535 => 234536)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2018-08-03 02:10:58 UTC (rev 234535)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2018-08-03 02:32:24 UTC (rev 234536)
@@ -24,7 +24,9 @@
  */
 
 #include "config.h"
+#include "FloatingState.h"
 #include "FormattingContext.h"
+#include "FormattingState.h"
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
@@ -53,10 +55,12 @@
 
     auto* firstDisplayBox = layoutContext.displayBoxForLayoutBox(*formattingRootContainer.firstInFlowChild());
     auto* lastDisplayBox = layoutContext.displayBoxForLayoutBox(*formattingRootContainer.lastInFlowChild());
+    auto floatsBottom = layoutContext.establishedFormattingState(layoutBox).floatingState().bottom(layoutBox);
 
     auto top = firstDisplayBox->marginBox().top();
     auto bottom = lastDisplayBox->marginBox().bottom();
-    // FIXME: add floating support.
+    if (floatsBottom)
+        bottom = std::max(*floatsBottom, bottom);
     auto computedHeight = bottom - top;
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height] -> content height for formatting context root -> height(" << computedHeight << "px) layoutBox("<< &layoutBox << ")");
     return computedHeight;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to