[LFC] Miscellaneous fixes to fix simple absolute positioning.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Jun 2018 14:38:32 +0000 (14:38 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Jun 2018 14:38:32 +0000 (14:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186962

Reviewed by Antti Koivisto.

1. Collect out-of-flow formatting root descendants.
2. Remove invalid and redundant ASSERTs
  invalid because the assertion is missing border, padding etc.
  redundant becasue we assert on geometry correctness in validateGeometryConstraintsAfterLayout.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
(WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const):
(WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const):
* layout/layouttree/LayoutContainer.cpp:
(WebCore::Layout::Container::addOutOfFlowDescendant):
(WebCore::Layout::Container::setOutOfFlowDescendants): Deleted.
* layout/layouttree/LayoutContainer.h:
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createSubTree):

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

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.cpp
Source/WebCore/layout/layouttree/LayoutContainer.cpp
Source/WebCore/layout/layouttree/LayoutContainer.h
Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

index 80a4223..b7090e5 100644 (file)
@@ -1,3 +1,26 @@
+2018-06-23  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Miscellaneous fixes to fix simple absolute positioning.
+        https://bugs.webkit.org/show_bug.cgi?id=186962
+
+        Reviewed by Antti Koivisto.
+
+        1. Collect out-of-flow formatting root descendants.
+        2. Remove invalid and redundant ASSERTs
+          invalid because the assertion is missing border, padding etc.
+          redundant becasue we assert on geometry correctness in validateGeometryConstraintsAfterLayout.  
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
+        (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const):
+        (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const):
+        * layout/layouttree/LayoutContainer.cpp:
+        (WebCore::Layout::Container::addOutOfFlowDescendant):
+        (WebCore::Layout::Container::setOutOfFlowDescendants): Deleted.
+        * layout/layouttree/LayoutContainer.h:
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::TreeBuilder::createSubTree):
+
 2018-06-23  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [WTF] Add user-defined literal for ASCIILiteral
index 43ba27a..0747af3 100644 (file)
@@ -72,7 +72,6 @@ void FormattingContext::computeOutOfFlowHorizontalGeometry(LayoutContext& layout
     auto horizontalGeometry = Geometry::outOfFlowHorizontalGeometry(layoutContext, layoutBox);
     displayBox.setLeft(horizontalGeometry.left);
     displayBox.setContentBoxWidth(horizontalGeometry.widthAndMargin.width);
-    ASSERT(horizontalGeometry.left + horizontalGeometry.widthAndMargin.width == horizontalGeometry.right);
     displayBox.setHorizontalMargin(horizontalGeometry.widthAndMargin.margin);
 }
 
@@ -81,7 +80,6 @@ void FormattingContext::computeOutOfFlowVerticalGeometry(LayoutContext& layoutCo
     auto verticalGeometry = Geometry::outOfFlowVerticalGeometry(layoutContext, layoutBox);
     displayBox.setTop(verticalGeometry.top);
     displayBox.setContentBoxHeight(verticalGeometry.heightAndMargin.height);
-    ASSERT(verticalGeometry.top + verticalGeometry.heightAndMargin.height == verticalGeometry.bottom);
     displayBox.setVerticalMargin(verticalGeometry.heightAndMargin.margin);
 }
 
@@ -123,6 +121,7 @@ void FormattingContext::layoutOutOfFlowDescendants(LayoutContext& layoutContext)
         // of a hypothetical box that would have been the first box of the element if its specified 'position' value had been 'static' and
         // its specified 'float' had been 'none' and its specified 'clear' had been 'none'.
         computeStaticPosition(layoutContext, layoutBox, displayBox);
+        computeBorderAndPadding(layoutContext, layoutBox, displayBox);
         computeOutOfFlowHorizontalGeometry(layoutContext, layoutBox, displayBox);
 
         ASSERT(layoutBox.establishesFormattingContext());
index 9b62ee7..b973a99 100644 (file)
@@ -91,9 +91,12 @@ void Container::setLastChild(Box& childBox)
     m_lastChild = &childBox;
 }
 
-void Container::setOutOfFlowDescendants(Vector<WeakPtr<Box>>&& descendantList)
+void Container::addOutOfFlowDescendant(const Box& outOfFlowBox)
 {
-    m_outOfFlowDescendants = WTFMove(descendantList);
+    // Since we layout the out-of-flow boxes at the end of the formatting context layout,
+    // it's okay to store them at the formatting context root level -as opposed to the containing block level.
+    ASSERT(establishesFormattingContext());
+    m_outOfFlowDescendants.append(makeWeakPtr(const_cast<Box&>(outOfFlowBox)));
 }
 
 }
index 5cb7313..ed04cfe 100644 (file)
@@ -61,7 +61,7 @@ protected:
 private:
     void setFirstChild(Box&);
     void setLastChild(Box&);
-    void setOutOfFlowDescendants(Vector<WeakPtr<Box>>&&);
+    void addOutOfFlowDescendant(const Box&);
 
     Box* m_firstChild { nullptr };
     Box* m_lastChild { nullptr };
index b874b57..0f24d5b 100644 (file)
@@ -85,13 +85,11 @@ void TreeBuilder::createSubTree(const RenderElement& rootRenderer, Container& ro
     for (auto& child : childrenOfType<RenderElement>(rootRenderer)) {
         Box* box = nullptr;
 
-        if (is<RenderBlock>(child)) {
+        if (is<RenderBlock>(child))
             box = new BlockContainer(elementAttributes(child), RenderStyle::clone(child.style()));
-            createSubTree(child, downcast<Container>(*box));
-        } else if (is<RenderInline>(child)) {
+        else if (is<RenderInline>(child))
             box = new InlineContainer(elementAttributes(child), RenderStyle::clone(child.style()));
-            createSubTree(child, downcast<Container>(*box));
-        } else
+        else
             ASSERT_NOT_IMPLEMENTED_YET();
 
         if (!rootContainer.hasChild()) {
@@ -104,6 +102,13 @@ void TreeBuilder::createSubTree(const RenderElement& rootRenderer, Container& ro
             rootContainer.setLastChild(*box);
         }
         box->setParent(rootContainer);
+
+        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);
+        }
+        createSubTree(child, downcast<Container>(*box));
     }
 }