Title: [249590] trunk/Source/WebCore
Revision
249590
Author
[email protected]
Date
2019-09-06 13:51:21 -0700 (Fri, 06 Sep 2019)

Log Message

[LFC] A formatting context root is always a containing block for relative: static boxes.
https://bugs.webkit.org/show_bug.cgi?id=201554
<rdar://problem/55123295>

Reviewed by Antti Koivisto.

"For other elements, if the element's position is 'relative' or 'static', the containing block is formed by the content
edge of the nearest ancestor box that is a block container or which establishes a formatting context."

* layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::containingBlock const):
* page/FrameViewLayoutContext.cpp:
(WebCore::layoutUsingFormattingContext):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (249589 => 249590)


--- trunk/Source/WebCore/ChangeLog	2019-09-06 20:42:42 UTC (rev 249589)
+++ trunk/Source/WebCore/ChangeLog	2019-09-06 20:51:21 UTC (rev 249590)
@@ -1,3 +1,19 @@
+2019-09-06  Zalan Bujtas  <[email protected]>
+
+        [LFC] A formatting context root is always a containing block for relative: static boxes.
+        https://bugs.webkit.org/show_bug.cgi?id=201554
+        <rdar://problem/55123295>
+
+        Reviewed by Antti Koivisto.
+
+        "For other elements, if the element's position is 'relative' or 'static', the containing block is formed by the content
+        edge of the nearest ancestor box that is a block container or which establishes a formatting context."
+
+        * layout/layouttree/LayoutBox.cpp:
+        (WebCore::Layout::Box::containingBlock const):
+        * page/FrameViewLayoutContext.cpp:
+        (WebCore::layoutUsingFormattingContext):
+
 2019-09-06  Sihui Liu  <[email protected]>
 
         IndexedDB: use SQL COUNT statement for count operation

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (249589 => 249590)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2019-09-06 20:42:42 UTC (rev 249589)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2019-09-06 20:51:21 UTC (rev 249590)
@@ -188,7 +188,7 @@
     ASSERT(!Phase::isInTreeBuilding());
     // The containing block in which the root element lives is a rectangle called the initial containing block.
     // For other elements, if the element's position is 'relative' or 'static', the containing block is formed by the
-    // content edge of the nearest block container ancestor box.
+    // content edge of the nearest block container ancestor box or which establishes a formatting context.
     // If the element has 'position: fixed', the containing block is established by the viewport
     // If the element has 'position: absolute', the containing block is established by the nearest ancestor with a
     // 'position' of 'absolute', 'relative' or 'fixed'.
@@ -196,9 +196,13 @@
         return nullptr;
 
     if (!isPositioned() || isInFlowPositioned()) {
-        auto* nearestBlockContainer = parent();
-        for (; nearestBlockContainer->parent() && !nearestBlockContainer->isBlockContainerBox(); nearestBlockContainer = nearestBlockContainer->parent()) { }
-        return nearestBlockContainer;
+        for (auto* nearestBlockContainerOrFormattingContextRoot = parent(); nearestBlockContainerOrFormattingContextRoot; nearestBlockContainerOrFormattingContextRoot = nearestBlockContainerOrFormattingContextRoot->parent()) {
+            if (nearestBlockContainerOrFormattingContextRoot->isBlockContainerBox() || nearestBlockContainerOrFormattingContextRoot->establishesFormattingContext())
+                return nearestBlockContainerOrFormattingContextRoot; 
+        }
+        // We should always manage to find the ICB.
+        ASSERT_NOT_REACHED();
+        return nullptr;
     }
 
     if (isFixedPositioned()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to