Title: [234471] trunk/Source/WebCore
Revision
234471
Author
za...@apple.com
Date
2018-08-01 13:53:47 -0700 (Wed, 01 Aug 2018)

Log Message

[LFC][Floating] FloatingState should take the formatting root box.
https://bugs.webkit.org/show_bug.cgi?id=188214

Reviewed by Antti Koivisto.

This will be taken into use when FormattingContext takes all boxes in the coordinate system of the formatting root.

* layout/FloatingState.cpp:
(WebCore::Layout::FloatingState::FloatingState):
(WebCore::Layout::belongsToThisFloatingContext):
(WebCore::Layout::FloatingState::append):
* layout/FloatingState.h:
(WebCore::Layout::FloatingState::create):
* layout/LayoutContext.cpp:
(WebCore::Layout::LayoutContext::establishedFormattingState):

Modified Paths

Diff

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


--- trunk/Source/WebCore/ChangeLog	2018-08-01 20:52:04 UTC (rev 234470)
+++ trunk/Source/WebCore/ChangeLog	2018-08-01 20:53:47 UTC (rev 234471)
@@ -1,5 +1,23 @@
 2018-08-01  Zalan Bujtas  <za...@apple.com>
 
+        [LFC][Floating] FloatingState should take the formatting root box.
+        https://bugs.webkit.org/show_bug.cgi?id=188214
+
+        Reviewed by Antti Koivisto.
+
+        This will be taken into use when FormattingContext takes all boxes in the coordinate system of the formatting root.
+
+        * layout/FloatingState.cpp:
+        (WebCore::Layout::FloatingState::FloatingState):
+        (WebCore::Layout::belongsToThisFloatingContext):
+        (WebCore::Layout::FloatingState::append):
+        * layout/FloatingState.h:
+        (WebCore::Layout::FloatingState::create):
+        * layout/LayoutContext.cpp:
+        (WebCore::Layout::LayoutContext::establishedFormattingState):
+
+2018-08-01  Zalan Bujtas  <za...@apple.com>
+
         [LFC][Floating] Align new floating with the bottom of the existing floatings.
         https://bugs.webkit.org/show_bug.cgi?id=188213
 

Modified: trunk/Source/WebCore/layout/FloatingState.cpp (234470 => 234471)


--- trunk/Source/WebCore/layout/FloatingState.cpp	2018-08-01 20:52:04 UTC (rev 234470)
+++ trunk/Source/WebCore/layout/FloatingState.cpp	2018-08-01 20:53:47 UTC (rev 234471)
@@ -37,13 +37,32 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(FloatingState);
 
-FloatingState::FloatingState(LayoutContext& layoutContext)
+FloatingState::FloatingState(LayoutContext& layoutContext, const Box& formattingContextRoot)
     : m_layoutContext(layoutContext)
+    , m_formattingContextRoot(makeWeakPtr(const_cast<Box&>(formattingContextRoot)))
 {
 }
 
+#ifndef NDEBUG
+static bool belongsToThisFloatingContext(const Box& layoutBox, const Box& floatingStateRoot)
+{
+    auto& formattingContextRoot = layoutBox.formattingContextRoot();
+    if (&formattingContextRoot == &floatingStateRoot)
+        return true;
+
+    // Maybe the layout box belongs to an inline formatting context that inherits the floating state from the parent (block) formatting context. 
+    if (!formattingContextRoot.establishesInlineFormattingContext())
+        return false;
+
+    return &formattingContextRoot.formattingContextRoot() == &floatingStateRoot;
+}
+#endif
+
 void FloatingState::append(const Box& layoutBox)
 {
+    ASSERT(is<Container>(*m_formattingContextRoot));
+    ASSERT(belongsToThisFloatingContext(layoutBox, *m_formattingContextRoot));
+
     // Floating state should hold boxes with computed position/size.
     ASSERT(m_layoutContext.displayBoxForLayoutBox(layoutBox));
     m_last = makeWeakPtr(const_cast<Box&>(layoutBox));

Modified: trunk/Source/WebCore/layout/FloatingState.h (234470 => 234471)


--- trunk/Source/WebCore/layout/FloatingState.h	2018-08-01 20:52:04 UTC (rev 234470)
+++ trunk/Source/WebCore/layout/FloatingState.h	2018-08-01 20:53:47 UTC (rev 234471)
@@ -43,7 +43,7 @@
 class FloatingState : public RefCounted<FloatingState> {
     WTF_MAKE_ISO_ALLOCATED(FloatingState);
 public:
-    static Ref<FloatingState> create(LayoutContext& layoutContext) { return adoptRef(*new FloatingState(layoutContext)); }
+    static Ref<FloatingState> create(LayoutContext& layoutContext, const Box& formattingContextRoot) { return adoptRef(*new FloatingState(layoutContext, formattingContextRoot)); }
 
     void append(const Box& layoutBox);
 
@@ -59,11 +59,12 @@
 
 private:
     friend class FloatingContext;
-    FloatingState(LayoutContext&);
+    FloatingState(LayoutContext&, const Box& formattingContextRoot);
 
     LayoutContext& layoutContext() const { return m_layoutContext; }
 
     LayoutContext& m_layoutContext;
+    WeakPtr<Box> m_formattingContextRoot;
 
     FloatingList m_leftFloatings;
     FloatingList m_rightFloatings;

Modified: trunk/Source/WebCore/layout/LayoutContext.cpp (234470 => 234471)


--- trunk/Source/WebCore/layout/LayoutContext.cpp	2018-08-01 20:52:04 UTC (rev 234470)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp	2018-08-01 20:53:47 UTC (rev 234471)
@@ -127,7 +127,7 @@
             // should not interfere with the content inside.
             // <div style="float: left"></div><div style="overflow: hidden"> <- is a non-intrusive float, because overflow: hidden triggers new block formatting context.</div>
             if (formattingRoot.establishesBlockFormattingContext())
-                return std::make_unique<InlineFormattingState>(FloatingState::create(*this), *this);
+                return std::make_unique<InlineFormattingState>(FloatingState::create(*this, formattingRoot), *this);
 
             // Otherwise, the formatting context inherits the floats from the parent formatting context.
             // Find the formatting state in which this formatting root lives, not the one it creates and use its floating state.
@@ -139,7 +139,7 @@
         return *m_formattingStates.ensure(&formattingRoot, [&] {
 
             // Block formatting context always establishes a new floating state.
-            return std::make_unique<BlockFormattingState>(FloatingState::create(*this), *this);
+            return std::make_unique<BlockFormattingState>(FloatingState::create(*this, formattingRoot), *this);
         }).iterator->value;
     }
     CRASH();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to