- Revision
- 240240
- Author
- [email protected]
- Date
- 2019-01-21 12:15:53 -0800 (Mon, 21 Jan 2019)
Log Message
[LFC][Floats] Take float top position into account when computing containing block height.
https://bugs.webkit.org/show_bug.cgi?id=193655
Reviewed by Antti Koivisto.
Source/WebCore:
When computing the containing block height, we take the first in-flow child's top position and use it as the base position.
However when the first in-flow child clears a previous sibling, its vertical position is not necessarily the correct base for
computing the containing block's height. Let's take the relevant floats into account as well.
Test: fast/block/float/float-first-child-and-clear-sibling.html
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::contentHeightForFormattingContextRoot):
* layout/floats/FloatingContext.cpp:
(WebCore::Layout::FloatingContext::verticalPositionWithClearance const):
* layout/floats/FloatingState.cpp:
(WebCore::Layout::FloatingState::top const):
* layout/floats/FloatingState.h:
Tools:
* LayoutReloaded/misc/LFC-passing-tests.txt:
LayoutTests:
* fast/block/float/float-first-child-and-clear-sibling-expected.html: Added.
* fast/block/float/float-first-child-and-clear-sibling.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (240239 => 240240)
--- trunk/LayoutTests/ChangeLog 2019-01-21 19:51:59 UTC (rev 240239)
+++ trunk/LayoutTests/ChangeLog 2019-01-21 20:15:53 UTC (rev 240240)
@@ -1,3 +1,13 @@
+2019-01-21 Zalan Bujtas <[email protected]>
+
+ [LFC][Floats] Take float top position into account when computing containing block height.
+ https://bugs.webkit.org/show_bug.cgi?id=193655
+
+ Reviewed by Antti Koivisto.
+
+ * fast/block/float/float-first-child-and-clear-sibling-expected.html: Added.
+ * fast/block/float/float-first-child-and-clear-sibling.html: Added.
+
2019-01-21 Frederic Wang <[email protected]>
Add a basic test for scrollable iframe on iOS
Added: trunk/LayoutTests/fast/block/float/float-first-child-and-clear-sibling-expected.html (0 => 240240)
--- trunk/LayoutTests/fast/block/float/float-first-child-and-clear-sibling-expected.html (rev 0)
+++ trunk/LayoutTests/fast/block/float/float-first-child-and-clear-sibling-expected.html 2019-01-21 20:15:53 UTC (rev 240240)
@@ -0,0 +1,2 @@
+<div style="height: 20px; width: 50px; background-color: blue;"></div>
+<div style="height: 20px; width: 50px; background-color: green;"></div>
Added: trunk/LayoutTests/fast/block/float/float-first-child-and-clear-sibling.html (0 => 240240)
--- trunk/LayoutTests/fast/block/float/float-first-child-and-clear-sibling.html (rev 0)
+++ trunk/LayoutTests/fast/block/float/float-first-child-and-clear-sibling.html 2019-01-21 20:15:53 UTC (rev 240240)
@@ -0,0 +1,4 @@
+<div style="overflow: hidden;">
+ <div style="height: 20px; width: 50px; background-color: blue; float: left;"></div>
+ <div style="height: 20px; width: 50px; background-color: green; clear: left;"></div>
+</div>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (240239 => 240240)
--- trunk/Source/WebCore/ChangeLog 2019-01-21 19:51:59 UTC (rev 240239)
+++ trunk/Source/WebCore/ChangeLog 2019-01-21 20:15:53 UTC (rev 240240)
@@ -1,3 +1,24 @@
+2019-01-21 Zalan Bujtas <[email protected]>
+
+ [LFC][Floats] Take float top position into account when computing containing block height.
+ https://bugs.webkit.org/show_bug.cgi?id=193655
+
+ Reviewed by Antti Koivisto.
+
+ When computing the containing block height, we take the first in-flow child's top position and use it as the base position.
+ However when the first in-flow child clears a previous sibling, its vertical position is not necessarily the correct base for
+ computing the containing block's height. Let's take the relevant floats into account as well.
+
+ Test: fast/block/float/float-first-child-and-clear-sibling.html
+
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::contentHeightForFormattingContextRoot):
+ * layout/floats/FloatingContext.cpp:
+ (WebCore::Layout::FloatingContext::verticalPositionWithClearance const):
+ * layout/floats/FloatingState.cpp:
+ (WebCore::Layout::FloatingState::top const):
+ * layout/floats/FloatingState.h:
+
2019-01-21 David Kilzer <[email protected]>
REGRESSION (r240237): Revert changes to WebCore Xcode project
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (240239 => 240240)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-01-21 19:51:59 UTC (rev 240239)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-01-21 20:15:53 UTC (rev 240240)
@@ -129,9 +129,14 @@
formattingContextRoot = &layoutBox.formattingContextRoot();
}
- auto floatsBottom = layoutState.establishedFormattingState(*formattingContextRoot).floatingState().bottom(*formattingContextRoot);
- if (floatsBottom)
- bottom = std::max<LayoutUnit>(*floatsBottom, bottom);
+ auto& floatingState = layoutState.establishedFormattingState(*formattingContextRoot).floatingState();
+ auto floatBottom = floatingState.bottom(*formattingContextRoot);
+ if (floatBottom) {
+ bottom = std::max<LayoutUnit>(*floatBottom, bottom);
+ auto floatTop = floatingState.top(*formattingContextRoot);
+ ASSERT(floatTop);
+ top = std::min<LayoutUnit>(*floatTop, top);
+ }
auto computedHeight = bottom - top;
LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height] -> content height for formatting context root -> height(" << computedHeight << "px) layoutBox("<< &layoutBox << ")");
Modified: trunk/Source/WebCore/layout/floats/FloatingContext.cpp (240239 => 240240)
--- trunk/Source/WebCore/layout/floats/FloatingContext.cpp 2019-01-21 19:51:59 UTC (rev 240239)
+++ trunk/Source/WebCore/layout/floats/FloatingContext.cpp 2019-01-21 20:15:53 UTC (rev 240240)
@@ -249,7 +249,10 @@
rootRelativeTop += clearance;
ASSERT(*floatBottom == rootRelativeTop);
- // The return vertical position is in the containing block's coordinate system.
+ // The return vertical position is in the containing block's coordinate system. Convert it to the formatting root's coordinate system if needed.
+ if (layoutBox.containingBlock() == &m_floatingState.root())
+ return Position { rootRelativeTop };
+
auto containingBlockRootRelativeTop = FormattingContext::mapTopLeftToAncestor(layoutState, *layoutBox.containingBlock(), downcast<Container>(m_floatingState.root())).y;
return Position { rootRelativeTop - containingBlockRootRelativeTop };
};
Modified: trunk/Source/WebCore/layout/floats/FloatingState.cpp (240239 => 240240)
--- trunk/Source/WebCore/layout/floats/FloatingState.cpp 2019-01-21 19:51:59 UTC (rev 240239)
+++ trunk/Source/WebCore/layout/floats/FloatingState.cpp 2019-01-21 20:15:53 UTC (rev 240240)
@@ -184,6 +184,27 @@
return bottom;
}
+Optional<PositionInContextRoot> FloatingState::top(const Box& formattingContextRoot) const
+{
+ if (m_floats.isEmpty())
+ return { };
+
+ Optional<PositionInContextRoot> top;
+ for (auto& floatItem : m_floats) {
+ // Ignore floats from ancestor formatting contexts when the floating state is inherited.
+ if (!floatItem.isDescendantOfFormattingRoot(formattingContextRoot))
+ continue;
+
+ auto floatTop = floatItem.rectWithMargin().top();
+ if (top) {
+ top = std::max<PositionInContextRoot>(*top, { floatTop });
+ continue;
+ }
+ top = PositionInContextRoot { floatTop };
+ }
+ return top;
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/floats/FloatingState.h (240239 => 240240)
--- trunk/Source/WebCore/layout/floats/FloatingState.h 2019-01-21 19:51:59 UTC (rev 240239)
+++ trunk/Source/WebCore/layout/floats/FloatingState.h 2019-01-21 20:15:53 UTC (rev 240240)
@@ -54,6 +54,7 @@
const Box& root() const { return *m_formattingContextRoot; }
+ Optional<PositionInContextRoot> top(const Box& formattingContextRoot) const;
Optional<PositionInContextRoot> leftBottom(const Box& formattingContextRoot) const;
Optional<PositionInContextRoot> rightBottom(const Box& formattingContextRoot) const;
Optional<PositionInContextRoot> bottom(const Box& formattingContextRoot) const;
Modified: trunk/Tools/ChangeLog (240239 => 240240)
--- trunk/Tools/ChangeLog 2019-01-21 19:51:59 UTC (rev 240239)
+++ trunk/Tools/ChangeLog 2019-01-21 20:15:53 UTC (rev 240240)
@@ -1,3 +1,12 @@
+2019-01-21 Zalan Bujtas <[email protected]>
+
+ [LFC][Floats] Take float top position into account when computing containing block height.
+ https://bugs.webkit.org/show_bug.cgi?id=193655
+
+ Reviewed by Antti Koivisto.
+
+ * LayoutReloaded/misc/LFC-passing-tests.txt:
+
2019-01-21 David Kilzer <[email protected]>
Switch remaining VideoToolbox soft-linking in WebCore over to VideoToolboxSoftLink.{cpp,h}
Modified: trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt (240239 => 240240)
--- trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt 2019-01-21 19:51:59 UTC (rev 240239)
+++ trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt 2019-01-21 20:15:53 UTC (rev 240240)
@@ -123,6 +123,7 @@
fast/block/float/float-in-descendant-formatting-context.html
fast/block/float/floats-with-negative-horizontal-margin.html
fast/block/float/float-forced-below-other-floats.html
+fast/block/float/float-first-child-and-clear-sibling.html
fast/block/margin-collapse/002.html
fast/block/margin-collapse/003.html
fast/block/margin-collapse/026.html