Title: [234470] trunk/Source/WebCore
Revision
234470
Author
[email protected]
Date
2018-08-01 13:52:04 -0700 (Wed, 01 Aug 2018)

Log Message

[LFC][Floating] Align new floating with the bottom of the existing floatings.
https://bugs.webkit.org/show_bug.cgi?id=188213

Reviewed by Antti Koivisto.

When the incoming floating does not fit at all, align its top with the bottom of the existing floatings.

* layout/FloatingContext.cpp:
(WebCore::Layout::FloatingContext::floatingPosition const):
(WebCore::Layout::FloatingPair::bottom const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (234469 => 234470)


--- trunk/Source/WebCore/ChangeLog	2018-08-01 20:48:58 UTC (rev 234469)
+++ trunk/Source/WebCore/ChangeLog	2018-08-01 20:52:04 UTC (rev 234470)
@@ -1,3 +1,16 @@
+2018-08-01  Zalan Bujtas  <[email protected]>
+
+        [LFC][Floating] Align new floating with the bottom of the existing floatings.
+        https://bugs.webkit.org/show_bug.cgi?id=188213
+
+        Reviewed by Antti Koivisto.
+
+        When the incoming floating does not fit at all, align its top with the bottom of the existing floatings.
+
+        * layout/FloatingContext.cpp:
+        (WebCore::Layout::FloatingContext::floatingPosition const):
+        (WebCore::Layout::FloatingPair::bottom const):
+
 2018-08-01  Eric Carlson  <[email protected]>
 
         Always use MediaPlayback audio category when playing to AppleTV

Modified: trunk/Source/WebCore/layout/FloatingContext.cpp (234469 => 234470)


--- trunk/Source/WebCore/layout/FloatingContext.cpp	2018-08-01 20:48:58 UTC (rev 234469)
+++ trunk/Source/WebCore/layout/FloatingContext.cpp	2018-08-01 20:52:04 UTC (rev 234470)
@@ -66,6 +66,7 @@
     const Display::Box* right() const;
     bool intersects(const Display::Box::Rect&) const;
     LayoutUnit verticalPosition() const { return m_verticalPosition; }
+    LayoutUnit bottom() const;
     bool operator==(const FloatingPair&) const;
 
 private:
@@ -132,6 +133,7 @@
 
     auto end = Layout::end(layoutContext(), m_floatingState);
     auto top = initialVerticalPosition;
+    auto bottomMost = top;
     for (auto iterator = begin(layoutContext(), m_floatingState, initialVerticalPosition); iterator != end; ++iterator) {
         ASSERT(!(*iterator).isEmpty());
 
@@ -144,11 +146,12 @@
         if (!floatings.intersects({ top, left, boxSize.width(), boxSize.height() }))
             return { left, top };
 
+        bottomMost = floatings.bottom();
         // Move to the next floating pair.
     }
 
     // Passed all the floatings and still does not fit? 
-    return { alignWithContainingBlock(layoutBox), top };
+    return { alignWithContainingBlock(layoutBox), bottomMost };
 }
 
 LayoutUnit FloatingContext::initialVerticalPosition(const Box& layoutBox) const
@@ -264,6 +267,24 @@
     return m_leftIndex == other.m_leftIndex && m_rightIndex == other.m_rightIndex;
 }
 
+LayoutUnit FloatingPair::bottom() const
+{
+    auto* left = this->left();
+    auto* right = this->right();
+    ASSERT(left || right);
+
+    auto leftBottom = left ? std::optional<LayoutUnit>(left->bottom()) : std::nullopt;
+    auto rightBottom = right ? std::optional<LayoutUnit>(right->bottom()) : std::nullopt;
+
+    if (leftBottom && rightBottom)
+        return std::max(*leftBottom, *rightBottom);
+
+    if (leftBottom)
+        return *leftBottom;
+
+    return *rightBottom;
+}
+
 Iterator::Iterator(const LayoutContext& layoutContext, const FloatingState& floatingState, std::optional<LayoutUnit> verticalPosition)
     : m_layoutContext(layoutContext)
     , m_floatingState(floatingState)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to