Title: [233260] trunk/Source/WebCore
Revision
233260
Author
[email protected]
Date
2018-06-27 09:18:00 -0700 (Wed, 27 Jun 2018)

Log Message

[LFC] Move formatting context root layout logic to a dedicated function.
https://bugs.webkit.org/show_bug.cgi?id=187097

Reviewed by Antti Koivisto.

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layout const):
(WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):
* layout/blockformatting/BlockFormattingContext.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233259 => 233260)


--- trunk/Source/WebCore/ChangeLog	2018-06-27 16:13:48 UTC (rev 233259)
+++ trunk/Source/WebCore/ChangeLog	2018-06-27 16:18:00 UTC (rev 233260)
@@ -1,5 +1,17 @@
 2018-06-27  Zalan Bujtas  <[email protected]>
 
+        [LFC] Move formatting context root layout logic to a dedicated function.
+        https://bugs.webkit.org/show_bug.cgi?id=187097
+
+        Reviewed by Antti Koivisto.
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layout const):
+        (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):
+        * layout/blockformatting/BlockFormattingContext.h:
+
+2018-06-27  Zalan Bujtas  <[email protected]>
+
         [LFC] Compute static position for out-of-flow elements only when required.
         https://bugs.webkit.org/show_bug.cgi?id=187096
 

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (233259 => 233260)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-06-27 16:13:48 UTC (rev 233259)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-06-27 16:18:00 UTC (rev 233260)
@@ -77,16 +77,18 @@
             auto& layoutPair = *layoutQueue.last();
             auto& layoutBox = layoutPair.layoutBox;
             auto& displayBox = layoutPair.displayBox;
+
+            if (layoutBox.establishesFormattingContext()) {
+                layoutFormattingContextRoot(layoutContext, formattingState, layoutBox, displayBox);
+                layoutQueue.removeLast();
+                // Since this box is a formatting context root, it takes care of its entire subtree.
+                break;
+            }
             
             LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &layoutBox << ")");
             computeStaticPosition(layoutContext, layoutBox, displayBox);
             computeBorderAndPadding(layoutContext, layoutBox, displayBox);
             computeWidthAndMargin(layoutContext, layoutBox, displayBox);
-            if (layoutBox.establishesFormattingContext()) {
-                auto formattingContext = layoutContext.formattingContext(layoutBox);
-                formattingContext->layout(layoutContext, layoutContext.establishedFormattingState(layoutBox, *formattingContext));
-                break;
-            }
             if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild())
                 break;
             auto& firstChild = *downcast<Container>(layoutBox).firstInFlowOrFloatingChild();
@@ -99,7 +101,10 @@
             auto layoutPair = layoutQueue.takeLast();
             auto& layoutBox = layoutPair->layoutBox;
             auto& displayBox = layoutPair->displayBox;
+
             LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Height][Margin] -> for layoutBox(" << &layoutBox << ")");
+            // Formatting root boxes are special-cased and they don't come here.
+            ASSERT(!layoutBox.establishesFormattingContext());
 
             computeHeightAndMargin(layoutContext, layoutBox, displayBox);
             // Adjust position now that we have all the previous floats placed in this context -if needed.
@@ -125,6 +130,25 @@
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> block formatting context -> layout context(" << &layoutContext << ") formatting root(" << &root() << ")");
 }
 
+void BlockFormattingContext::layoutFormattingContextRoot(LayoutContext& layoutContext, FormattingState& formattingState, const Box& layoutBox, Display::Box& displayBox) const
+{
+    // Start laying out this formatting root in the formatting contenxt it lives in.
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &layoutBox << ")");
+    computeStaticPosition(layoutContext, layoutBox, displayBox);
+    computeBorderAndPadding(layoutContext, layoutBox, displayBox);
+    computeWidthAndMargin(layoutContext, layoutBox, displayBox);
+
+    // Swich over to the new formatting context (the one that the root creates).
+    auto formattingContext = layoutContext.formattingContext(layoutBox);
+    auto& establishedFormattingState = layoutContext.establishedFormattingState(layoutBox, *formattingContext);
+    formattingContext->layout(layoutContext, establishedFormattingState);
+
+    // Come back and finalize the root's geometry.
+    FloatingContext(formattingState.floatingState()).computePosition(layoutBox, displayBox);
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Height][Margin] -> for layoutBox(" << &layoutBox << ")");
+    computeHeightAndMargin(layoutContext, layoutBox, displayBox);
+}
+
 std::unique_ptr<FormattingState> BlockFormattingContext::createFormattingState(Ref<FloatingState>&& floatingState) const
 {
     return std::make_unique<BlockFormattingState>(WTFMove(floatingState));

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (233259 => 233260)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-06-27 16:13:48 UTC (rev 233259)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-06-27 16:18:00 UTC (rev 233260)
@@ -51,6 +51,8 @@
     Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const override;
 
 private:
+    void layoutFormattingContextRoot(LayoutContext&, FormattingState&, const Box&, Display::Box&) const;
+
     void computeWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
     void computeHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to