[LFC][BFC] Layout out-of-flow descendants only on the formatting context root.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Aug 2018 17:57:35 +0000 (17:57 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Aug 2018 17:57:35 +0000 (17:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188312

Reviewed by Antti Koivisto.

Collect out-of-flow descendants on the formatting root container instead of the containing block and run layout on them on the root level. It's more efficient this way.

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layout const):
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createSubTree):

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

Source/WebCore/ChangeLog
Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

index 700e397..7e3d4cb 100644 (file)
@@ -1,3 +1,17 @@
+2018-08-03  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][BFC] Layout out-of-flow descendants only on the formatting context root.
+        https://bugs.webkit.org/show_bug.cgi?id=188312
+
+        Reviewed by Antti Koivisto.
+
+        Collect out-of-flow descendants on the formatting root container instead of the containing block and run layout on them on the root level. It's more efficient this way.
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layout const):
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::TreeBuilder::createSubTree):
+
 2018-08-03  Andy Estes  <aestes@apple.com>
 
         ContentFilterUnblockHandler's constructors access moved-from variables
index 07fe948..8cd6aa9 100644 (file)
@@ -117,7 +117,6 @@ void BlockFormattingContext::layout(LayoutContext& layoutContext, FormattingStat
             auto& container = downcast<Container>(layoutBox);
             // Move in-flow positioned children to their final position.
             placeInFlowPositionedChildren(layoutContext, container);
-            layoutOutOfFlowDescendants(layoutContext, container);
             if (auto* nextSibling = container.nextInFlowOrFloatingSibling()) {
                 layoutQueue.append(std::make_unique<LayoutPair>(LayoutPair {*nextSibling, layoutContext.createDisplayBox(*nextSibling)}));
                 break;
index e62f3f6..1e31fe8 100644 (file)
@@ -110,7 +110,8 @@ void TreeBuilder::createSubTree(const RenderElement& rootRenderer, Container& ro
         if (box->isOutOfFlowPositioned()) {
             // Not efficient, but this is temporary anyway.
             // Collect the out-of-flow descendants at the formatting root lever (as opposed to at the containing block level, though they might be the same).
-            const_cast<Container&>(box->formattingContextRoot()).addOutOfFlowDescendant(*box);
+            auto& containingBlockFormattingContextRoot = box->containingBlock()->formattingContextRoot();
+            const_cast<Container&>(containingBlockFormattingContextRoot).addOutOfFlowDescendant(*box);
         }
         if (is<RenderElement>(child))
             createSubTree(downcast<RenderElement>(child), downcast<Container>(*box));