Title: [231400] trunk/Source/WebCore
- Revision
- 231400
- Author
- [email protected]
- Date
- 2018-05-06 13:00:31 -0700 (Sun, 06 May 2018)
Log Message
[LFC] Add BlockFormattingContext::computeStaticPosition
https://bugs.webkit.org/show_bug.cgi?id=185352
Reviewed by Antti Koivisto.
This is the core logic for positioning inflow boxes in a block formatting context (very naive though).
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeStaticPosition const):
* layout/displaytree/DisplayBox.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (231399 => 231400)
--- trunk/Source/WebCore/ChangeLog 2018-05-06 01:06:09 UTC (rev 231399)
+++ trunk/Source/WebCore/ChangeLog 2018-05-06 20:00:31 UTC (rev 231400)
@@ -1,3 +1,16 @@
+2018-05-06 Zalan Bujtas <[email protected]>
+
+ [LFC] Add BlockFormattingContext::computeStaticPosition
+ https://bugs.webkit.org/show_bug.cgi?id=185352
+
+ Reviewed by Antti Koivisto.
+
+ This is the core logic for positioning inflow boxes in a block formatting context (very naive though).
+
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::computeStaticPosition const):
+ * layout/displaytree/DisplayBox.h:
+
2018-05-05 Sam Weinig <[email protected]>
Cleanup XMLHttpRequestUpload a little
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (231399 => 231400)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-05-06 01:06:09 UTC (rev 231399)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-05-06 20:00:31 UTC (rev 231400)
@@ -124,8 +124,22 @@
return FloatingState::create();
}
-void BlockFormattingContext::computeStaticPosition(const Box&, Display::Box&) const
+void BlockFormattingContext::computeStaticPosition(const Box& layoutBox, Display::Box& displayBox) const
{
+ // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
+ // In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block.
+ // The vertical distance between two sibling boxes is determined by the 'margin' properties.
+ // 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).
+ auto containingBlockContentBox = layoutContext().displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBox();
+ // Start from the top of the container's content box.
+ auto top = containingBlockContentBox.y();
+ auto left = containingBlockContentBox.x();
+ if (auto* previousInFlowSibling = layoutBox.previousInFlowSibling())
+ top = layoutContext().displayBoxForLayoutBox(*previousInFlowSibling)->bottom() + marginBottom(*previousInFlowSibling);
+ LayoutPoint topLeft = { top, left };
+ topLeft.moveBy({ marginLeft(layoutBox), marginTop(layoutBox) });
+ displayBox.setTopLeft(topLeft);
}
void BlockFormattingContext::computeInFlowWidth(const Box&, Display::Box&) const
Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (231399 => 231400)
--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2018-05-06 01:06:09 UTC (rev 231399)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2018-05-06 20:00:31 UTC (rev 231400)
@@ -36,6 +36,7 @@
namespace Layout {
class LayoutContext;
+class BlockFormattingContext;
}
namespace Display {
@@ -44,6 +45,7 @@
WTF_MAKE_ISO_ALLOCATED(Box);
public:
friend class Layout::LayoutContext;
+ friend class Layout::BlockFormattingContext;
~Box();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes