[LFC] Adjust static position with containing block's content box top/left
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jun 2018 15:01:35 +0000 (15:01 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Jun 2018 15:01:35 +0000 (15:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186999

Reviewed by Antti Koivisto.

* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::staticPosition):
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::contentBox const):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::contentBoxTop const):
(WebCore::Display::Box::contentBoxLeft const):

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

Source/WebCore/ChangeLog
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
Source/WebCore/layout/displaytree/DisplayBox.cpp
Source/WebCore/layout/displaytree/DisplayBox.h

index 6ef15583b012195ae78b84f8c770d4e1812d5297..2243d681c2a44c1c2ac0bd0b5d8f699183a582cc 100644 (file)
@@ -1,3 +1,18 @@
+2018-06-25  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Adjust static position with containing block's content box top/left
+        https://bugs.webkit.org/show_bug.cgi?id=186999
+
+        Reviewed by Antti Koivisto.
+
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::staticPosition):
+        * layout/displaytree/DisplayBox.cpp:
+        (WebCore::Display::Box::contentBox const):
+        * layout/displaytree/DisplayBox.h:
+        (WebCore::Display::Box::contentBoxTop const):
+        (WebCore::Display::Box::contentBoxLeft const):
+
 2018-06-25  David Kilzer  <ddkilzer@apple.com>
 
         REGRESSION (r233140): Windows build failure due to incomplete DocumentAnimationScheduler type
index 1ff34f0ea1e816cf36d69e46fcbe96a2fabfd471..5b71b49a3bf523a776c93214dfdb2fe831cd8324 100644 (file)
@@ -270,13 +270,14 @@ FormattingContext::Geometry::Position BlockFormattingContext::Geometry::staticPo
     // Vertical margins between adjacent block-level boxes in a block formatting context collapse.
     // In a block formatting context, each box's left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch).
 
-    // Start from the top of the container's content box.
-    LayoutUnit top = { };
-    LayoutUnit left = { };
+    auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock());
+    LayoutUnit top;
     if (auto* previousInFlowSibling = layoutBox.previousInFlowSibling()) {
         auto& previousInFlowDisplayBox = *layoutContext.displayBoxForLayoutBox(*previousInFlowSibling);
         top = previousInFlowDisplayBox.bottom() + previousInFlowDisplayBox.marginBottom();
-    }
+    } else
+        top = containingBlockDisplayBox.contentBoxTop();
+    auto left = containingBlockDisplayBox.contentBoxLeft();
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position] -> static -> top(" << top << "px) left(" << left << "px) layoutBox(" << &layoutBox << ")");
     return { left, top };
 }
index 505da27b9f6d35b526dbb6d397a2a6d4d83509c5..2bcc6f4aece7712b9a54ea94ede50a3f3fa61019 100644 (file)
@@ -84,13 +84,11 @@ Box::Rect Box::paddingBox() const
 
 Box::Rect Box::contentBox() const
 {
-    auto paddingBox = this->paddingBox();
-
     Rect contentBox;
-    contentBox.setTop(paddingBox.top() + paddingTop());
-    contentBox.setLeft(paddingBox.left() + paddingLeft());
-    contentBox.setWidth(m_contentWidth);
-    contentBox.setHeight(m_contentHeight);
+    contentBox.setTop(contentBoxTop());
+    contentBox.setLeft(contentBoxLeft());
+    contentBox.setWidth(contentBoxWidth());
+    contentBox.setHeight(contentBoxHeight());
     return contentBox;
 }
 
index 359c72d70cbe18e096367bc4852c74058728b715..ba2d866a1a21be4b54acaf9ba64428c631838788 100644 (file)
@@ -141,6 +141,8 @@ public:
     LayoutUnit paddingBottom() const;
     LayoutUnit paddingRight() const;
 
+    LayoutUnit contentBoxTop() const { return borderTop() + paddingTop(); }
+    LayoutUnit contentBoxLeft() const { return borderLeft() + paddingLeft(); }
     LayoutUnit contentBoxHeight() const;
     LayoutUnit contentBoxWidth() const;