[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 6ef1558..2243d68 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 1ff34f0..5b71b49 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 505da27..2bcc6f4 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 359c72d..ba2d866 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;