Title: [233399] trunk/Source/WebCore
Revision
233399
Author
[email protected]
Date
2018-06-30 11:07:43 -0700 (Sat, 30 Jun 2018)

Log Message

[LFC] Do not add the containing block's offset while computing the out-of-flow static position.
https://bugs.webkit.org/show_bug.cgi?id=187202

Reviewed by Antti Koivisto.

The static position for an out-of-flow elements is
1. the distance from the parent's border box.
2. climbing up on the containing block chain and offset the containers until we reach the out-of-flow element's containing block.

* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::staticVerticalPositionForOutOfFlowPositioned):
(WebCore::Layout::staticHorizontalPositionForOutOfFlowPositioned):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233398 => 233399)


--- trunk/Source/WebCore/ChangeLog	2018-06-30 18:06:22 UTC (rev 233398)
+++ trunk/Source/WebCore/ChangeLog	2018-06-30 18:07:43 UTC (rev 233399)
@@ -1,5 +1,20 @@
 2018-06-30  Zalan Bujtas  <[email protected]>
 
+        [LFC] Do not add the containing block's offset while computing the out-of-flow static position.
+        https://bugs.webkit.org/show_bug.cgi?id=187202
+
+        Reviewed by Antti Koivisto.
+
+        The static position for an out-of-flow elements is
+        1. the distance from the parent's border box.
+        2. climbing up on the containing block chain and offset the containers until we reach the out-of-flow element's containing block.
+
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::staticVerticalPositionForOutOfFlowPositioned):
+        (WebCore::Layout::staticHorizontalPositionForOutOfFlowPositioned):
+
+2018-06-30  Zalan Bujtas  <[email protected]>
+
         [LFC] If the top and bottom margins of a box are adjoining, then it is possible for margins to collapse through it.
         https://bugs.webkit.org/show_bug.cgi?id=187220
 

Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (233398 => 233399)


--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2018-06-30 18:06:22 UTC (rev 233398)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp	2018-06-30 18:07:43 UTC (rev 233399)
@@ -79,19 +79,30 @@
 {
     ASSERT(layoutBox.isOutOfFlowPositioned());
 
+    // For the purposes of this section and the next, the term "static position" (of an element) refers, roughly, to the position an element would have
+    // had in the normal flow. More precisely, the static position for 'top' is the distance from the top edge of the containing block to the top margin
+    // edge 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'. (Note that due to the rules in section 9.7 this might require also assuming a different
+    // computed value for 'display'.) The value is negative if the hypothetical box is above the containing block.
+
+    // Start with this box's border box offset from the parent's border box.
     LayoutUnit top;
-    // Add sibling offset
     if (auto* previousInFlowSibling = layoutBox.previousInFlowSibling()) {
+        // Add sibling offset
         auto& previousInFlowDisplayBox = *layoutContext.displayBoxForLayoutBox(*previousInFlowSibling);
         top += previousInFlowDisplayBox.bottom() + previousInFlowDisplayBox.nonCollapsedMarginBottom();
+    } else {
+        ASSERT(layoutBox.parent());
+        top = layoutContext.displayBoxForLayoutBox(*layoutBox.parent())->contentBoxTop();
     }
+
     // Resolve top all the way up to the containing block.
     auto* containingBlock = layoutBox.containingBlock();
-    for (auto* parent = layoutBox.parent(); parent; parent = parent->parent()) {
-        auto& displayBox = *layoutContext.displayBoxForLayoutBox(*parent);
-        top += (displayBox.top() + displayBox.contentBoxTop());
-        if (parent == containingBlock)
-            break;
+    for (auto* container = layoutBox.parent(); container != containingBlock; container = container->containingBlock()) {
+        auto& displayBox = *layoutContext.displayBoxForLayoutBox(*container);
+        // Display::Box::top is the border box top position in its containing block's coordinate system.
+        top += displayBox.top();
+        ASSERT(!container->isPositioned());
     }
     // FIXME: floatings need to be taken into account.
     return top;
@@ -100,15 +111,19 @@
 static LayoutUnit staticHorizontalPositionForOutOfFlowPositioned(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned());
+    // See staticVerticalPositionForOutOfFlowPositioned for the definition of the static position.
 
-    LayoutUnit left;
+    // Start with this box's border box offset from the parent's border box.
+    ASSERT(layoutBox.parent());
+    auto left = layoutContext.displayBoxForLayoutBox(*layoutBox.parent())->contentBoxLeft();
+
     // Resolve left all the way up to the containing block.
     auto* containingBlock = layoutBox.containingBlock();
-    for (auto* parent = layoutBox.parent(); parent; parent = parent->parent()) {
-        auto& displayBox = *layoutContext.displayBoxForLayoutBox(*parent);
-        left += (displayBox.left() + displayBox.contentBoxLeft());
-        if (parent == containingBlock)
-            break;
+    for (auto* container = layoutBox.parent(); container != containingBlock; container = container->containingBlock()) {
+        auto& displayBox = *layoutContext.displayBoxForLayoutBox(*container);
+        // Display::Box::left is the border box left position in its containing block's coordinate system.
+        left += displayBox.left();
+        ASSERT(!container->isPositioned());
     }
     // FIXME: floatings need to be taken into account.
     return left;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to