Source/WebCore:
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Aug 2018 14:22:45 +0000 (14:22 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Aug 2018 14:22:45 +0000 (14:22 +0000)
commit95c3127b0a5b0e5c5cf87fa22d8ff3549f6597d0
treef9141ee0013a6d432b78ec42a39cfb2b9da49fb1
parentcb1cac079439de183458c4332fb37b420c995684
Source/WebCore:
[LFC][Floating] Adjust vertical position with non-collapsed previous sibling margin.
https://bugs.webkit.org/show_bug.cgi?id=188543

Reviewed by Antti Koivisto.

This patch ensures that the inital vertical position for a float is adjusted with the non-collapsed sibling margin.

<div id=A style="margin-bottom: 20px;"></div>
<div id=B style='float: left'></div>
<div id=C style="margin-top: 10px;"></div>

While computing the static position for element "B", we simply call marginBottom() on A.
In the case above, A's margin bottom is collapsed with C's margin top and the value is 0 (C.marginTop() is 20px).
However CSS spec says that in block formatting context, the non-collapsed margin should be used instead to offset the float box.
(The reason why this should not be part of the BlockMarginCollapse::marginBottom() logic is because it can not differentiate the context of
sibling float/sibling inflow. When we margin collapse, we always do it in the context of inflow boxes.)

Test: fast/block/block-only/float-and-siblings-with-margins.html

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):
(WebCore::Layout::BlockFormattingContext::computeFloatingPosition const):
* layout/blockformatting/BlockFormattingContext.h:

Tools:
[LFC][Floating] Adjust vertical position with non-collapsing previous sibling margin.
https://bugs.webkit.org/show_bug.cgi?id=188543

Reviewed by Antti Koivisto.

* LayoutReloaded/misc/LFC-passing-tests.txt:

LayoutTests:
[LFC][Floating] Adjust vertical position with non-collapsing previous sibling margin.
https://bugs.webkit.org/show_bug.cgi?id=188543

Reviewed by Antti Koivisto.

* fast/block/block-only/float-and-siblings-with-margins-expected.txt: Added.
* fast/block/block-only/float-and-siblings-with-margins.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234847 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/block/block-only/float-and-siblings-with-margins-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/block-only/float-and-siblings-with-margins.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.h
Tools/ChangeLog
Tools/LayoutReloaded/misc/LFC-passing-tests.txt