Diff
Modified: trunk/LayoutTests/ChangeLog (234877 => 234878)
--- trunk/LayoutTests/ChangeLog 2018-08-15 02:42:59 UTC (rev 234877)
+++ trunk/LayoutTests/ChangeLog 2018-08-15 02:59:51 UTC (rev 234878)
@@ -1,3 +1,13 @@
+2018-08-14 Zalan Bujtas <[email protected]>
+
+ [LFC][Floating] Add support for negative clearance.
+ https://bugs.webkit.org/show_bug.cgi?id=188555
+
+ Reviewed by Simon Fraser.
+
+ * fast/block/block-only/margin-collapse-with-clearance-expected.txt: Added.
+ * fast/block/block-only/margin-collapse-with-clearance.html: Added.
+
2018-08-14 Ansh Shukla <[email protected]>
NSURLAuthenticationMethodOAuth challenges are surfaced to clients in -didReceiveAuthenticationChallenge as NSURLAuthenticationMethodDefault
Added: trunk/LayoutTests/fast/block/block-only/margin-collapse-with-clearance-expected.txt (0 => 234878)
--- trunk/LayoutTests/fast/block/block-only/margin-collapse-with-clearance-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/margin-collapse-with-clearance-expected.txt 2018-08-15 02:59:51 UTC (rev 234878)
@@ -0,0 +1,33 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x450
+ RenderBlock {HTML} at (0,0) size 800x450
+ RenderBody {BODY} at (8,8) size 784x434
+ RenderBlock {DIV} at (0,0) size 502x62 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,1) size 12x12 [border: (1px solid #000000)]
+ RenderBlock (floating) {DIV} at (1,23) size 52x22 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,45) size 12x12 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (0,62) size 502x62 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,1) size 12x12 [border: (1px solid #000000)]
+ RenderBlock (floating) {DIV} at (449,23) size 52x22 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,45) size 12x12 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (0,124) size 502x62 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,1) size 12x12 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,43) size 12x12 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (0,186) size 502x62 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,1) size 12x12 [border: (1px solid #000000)]
+ RenderBlock (floating) {DIV} at (1,23) size 52x22 [border: (1px solid #000000)]
+ RenderBlock (floating) {DIV} at (449,23) size 52x22 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,45) size 12x12 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (0,248) size 502x62 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,1) size 12x12 [border: (1px solid #000000)]
+ RenderBlock (floating) {DIV} at (1,23) size 52x22 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,45) size 12x12 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (0,310) size 502x62 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,1) size 12x12 [border: (1px solid #000000)]
+ RenderBlock (floating) {DIV} at (449,23) size 52x22 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,45) size 12x12 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (0,372) size 502x62 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,1) size 12x12 [border: (1px solid #000000)]
+ RenderBlock (floating) {DIV} at (1,23) size 52x7 [border: (1px solid #000000)]
+ RenderBlock {DIV} at (1,30) size 12x12 [border: (1px solid #000000)]
Added: trunk/LayoutTests/fast/block/block-only/margin-collapse-with-clearance.html (0 => 234878)
--- trunk/LayoutTests/fast/block/block-only/margin-collapse-with-clearance.html (rev 0)
+++ trunk/LayoutTests/fast/block/block-only/margin-collapse-with-clearance.html 2018-08-15 02:59:51 UTC (rev 234878)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+div {
+ border: 1px solid black;
+}
+</style>
+</head>
+<body>
+<div style="width: 500px; height: 60px;">
+ <div style="width: 10px; height: 10px; margin-bottom: 10px"></div>
+ <div style="float: left; width: 50px; height: 20px;"></div>
+ <div style="clear: left; width: 10px; height: 10px; margin-top: 30px"></div>
+</div>
+<div style="width: 500px; height: 60px;">
+ <div style="width: 10px; height: 10px; margin-bottom: 10px"></div>
+ <div style="float: right; width: 50px; height: 20px;"></div>
+ <div style="clear: right; width: 10px; height: 10px; margin-top: 30px"></div>
+</div>
+<div style="width: 500px; height: 60px;">
+ <div style="width: 10px; height: 10px; margin-bottom: 10px"></div>
+ <div style="clear: both; width: 10px; height: 10px; margin-top: 30px"></div>
+</div>
+<div style="width: 500px; height: 60px;">
+ <div style="width: 10px; height: 10px; margin-bottom: 10px"></div>
+ <div style="float: left; width: 50px; height: 20px;"></div>
+ <div style="float: right; width: 50px; height: 20px;"></div>
+ <div style="clear: both; width: 10px; height: 10px; margin-top: 30px"></div>
+</div>
+<div style="width: 500px; height: 60px;">
+ <div style="width: 10px; height: 10px; margin-bottom: 10px"></div>
+ <div style="float: left; width: 50px; height: 20px;"></div>
+ <div style="clear: both; width: 10px; height: 10px; margin-top: 30px"></div>
+</div>
+<div style="width: 500px; height: 60px;">
+ <div style="width: 10px; height: 10px; margin-bottom: 10px"></div>
+ <div style="float: right; width: 50px; height: 20px;"></div>
+ <div style="clear: both; width: 10px; height: 10px; margin-top: 30px"></div>
+</div>
+<div style="width: 500px; height: 60px;">
+ <div style="width: 10px; height: 10px; margin-bottom: 10px"></div>
+ <div style="float: left; width: 50px; height: 5px;"></div>
+ <div style="clear: left; width: 10px; height: 10px; margin-top: 10px"></div>
+</div>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (234877 => 234878)
--- trunk/Source/WebCore/ChangeLog 2018-08-15 02:42:59 UTC (rev 234877)
+++ trunk/Source/WebCore/ChangeLog 2018-08-15 02:59:51 UTC (rev 234878)
@@ -1,3 +1,32 @@
+2018-08-14 Zalan Bujtas <[email protected]>
+
+ [LFC][Floating] Add support for negative clearance.
+ https://bugs.webkit.org/show_bug.cgi?id=188555
+
+ Reviewed by Simon Fraser.
+
+ 1. Compute clearance to avoid float(s) (border box needs to avoid floats)
+ 2. Reset vertical margins to non-collapsed values.
+ 4. Adjust clearance with the new margins.
+ 5. Take the adjusted clearance and move the box vertically if needed.
+
+ Test: fast/block/block-only/margin-collapse-with-clearance.html
+
+ * layout/FloatingContext.cpp:
+ (WebCore::Layout::FloatingContext::verticalPositionWithClearance const):
+ * layout/FloatingState.cpp:
+ (WebCore::Layout::FloatingState::FloatItem::FloatItem):
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::mapBoxToAncestor):
+ (WebCore::Layout::FormattingContext::mapTopLeftToAncestor):
+ (WebCore::Layout::FormattingContext::mapCoordinateToAncestor):
+ (WebCore::Layout::FormattingContext::mapToAncestor): Deleted.
+ * layout/FormattingContext.h:
+ * layout/LayoutUnits.h:
+ (WebCore::Layout::Position::Position):
+ (WebCore::Layout::Position::moveBy):
+ * layout/displaytree/DisplayBox.h:
+
2018-08-14 Fujii Hironori <[email protected]>
Unreviewed, rolling out r234859.
Modified: trunk/Source/WebCore/layout/FloatingContext.cpp (234877 => 234878)
--- trunk/Source/WebCore/layout/FloatingContext.cpp 2018-08-15 02:42:59 UTC (rev 234877)
+++ trunk/Source/WebCore/layout/FloatingContext.cpp 2018-08-15 02:59:51 UTC (rev 234878)
@@ -150,13 +150,40 @@
// 1. The amount necessary to place the border edge of the block even with the bottom outer edge of the lowest float that is to be cleared.
// 2. The amount necessary to place the top border edge of the block at its hypothetical position.
- auto absoluteDisplayBox = FormattingContext::mapToAncestor(layoutContext(), layoutBox, downcast<Container>(m_floatingState.root()));
- if (floatBottom <= absoluteDisplayBox.rectWithMargin().top())
+ auto& layoutContext = this->layoutContext();
+ auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox);
+ auto rootRelativeTop = FormattingContext::mapTopLeftToAncestor(layoutContext, layoutBox, downcast<Container>(m_floatingState.root())).y;
+ auto clearance = *floatBottom - rootRelativeTop;
+ if (clearance <= 0)
return { };
+ // Clearance inhibits margin collapsing. Let's reset the relevant adjoining margins.
+ if (auto* previousInFlowSibling = layoutBox.previousInFlowSibling()) {
+ auto& previousInFlowDisplayBox = *layoutContext.displayBoxForLayoutBox(*previousInFlowSibling);
+
+ // Since the previous inflow sibling has already been laid out, its margin is collapsed by now.
+ ASSERT(!previousInFlowDisplayBox.marginBottom());
+ auto collapsedMargin = displayBox.marginTop();
+
+ // Reset previous bottom and current top margins to non-collapsing.
+ previousInFlowDisplayBox.setVerticalMargin({ previousInFlowDisplayBox.marginTop(), previousInFlowDisplayBox.nonCollapsedMarginBottom() });
+ displayBox.setVerticalMargin({ displayBox.nonCollapsedMarginTop(), displayBox.marginBottom() });
+
+ auto nonCollapsedMargin = previousInFlowDisplayBox.marginBottom() + displayBox.marginTop();
+ auto marginOffset = nonCollapsedMargin - collapsedMargin;
+ // Move the box to the position where it would be with non-collapsed margins.
+ rootRelativeTop += marginOffset;
+
+ // Having negative clearance is also normal. It just means that the box with the non-collapsed margins is now lower than it needs to be.
+ clearance -= marginOffset;
+ }
+ // Now adjust the box's position with the clearance.
+ rootRelativeTop += clearance;
+ ASSERT(*floatBottom == rootRelativeTop);
+
// The return vertical position is in the containing block's coordinate system.
- auto* containingBlockDisplayBox = layoutContext().displayBoxForLayoutBox(*layoutBox.containingBlock());
- return *floatBottom - containingBlockDisplayBox->top();
+ auto containingBlockRootRelativeTop = FormattingContext::mapTopLeftToAncestor(layoutContext, *layoutBox.containingBlock(), downcast<Container>(m_floatingState.root())).y;
+ return rootRelativeTop - containingBlockRootRelativeTop;
};
auto clear = layoutBox.style().clear();
Modified: trunk/Source/WebCore/layout/FloatingState.cpp (234877 => 234878)
--- trunk/Source/WebCore/layout/FloatingState.cpp 2018-08-15 02:42:59 UTC (rev 234877)
+++ trunk/Source/WebCore/layout/FloatingState.cpp 2018-08-15 02:59:51 UTC (rev 234878)
@@ -41,8 +41,8 @@
FloatingState::FloatItem::FloatItem(const Box& layoutBox, const FloatingState& floatingState)
: m_layoutBox(makeWeakPtr(const_cast<Box&>(layoutBox)))
, m_containingBlock(makeWeakPtr(const_cast<Container&>(*layoutBox.containingBlock())))
- , m_absoluteDisplayBox(FormattingContext::mapToAncestor(floatingState.layoutContext(), layoutBox, downcast<Container>(floatingState.root())))
- , m_containingBlockAbsoluteDisplayBox(FormattingContext::mapToAncestor(floatingState.layoutContext(), *m_containingBlock, downcast<Container>(floatingState.root())))
+ , m_absoluteDisplayBox(FormattingContext::mapBoxToAncestor(floatingState.layoutContext(), layoutBox, downcast<Container>(floatingState.root())))
+ , m_containingBlockAbsoluteDisplayBox(FormattingContext::mapBoxToAncestor(floatingState.layoutContext(), *m_containingBlock, downcast<Container>(floatingState.root())))
{
}
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (234877 => 234878)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2018-08-15 02:42:59 UTC (rev 234877)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2018-08-15 02:59:51 UTC (rev 234878)
@@ -142,7 +142,7 @@
LOG_WITH_STREAM(FormattingContextLayout, stream << "End: layout out-of-flow descendants -> context: " << &layoutContext << " root: " << &root());
}
-Display::Box FormattingContext::mapToAncestor(const LayoutContext& layoutContext, const Box& layoutBox, const Container& ancestor)
+Display::Box FormattingContext::mapBoxToAncestor(const LayoutContext& layoutContext, const Box& layoutBox, const Container& ancestor)
{
ASSERT(layoutBox.isDescendantOf(ancestor));
@@ -164,6 +164,27 @@
return mappedDisplayBox;
}
+Position FormattingContext::mapTopLeftToAncestor(const LayoutContext& layoutContext, const Box& layoutBox, const Container& ancestor)
+{
+ ASSERT(layoutBox.isDescendantOf(ancestor));
+ return mapCoordinateToAncestor(layoutContext, layoutContext.displayBoxForLayoutBox(layoutBox)->topLeft(), *layoutBox.containingBlock(), ancestor);
+}
+
+Position FormattingContext::mapCoordinateToAncestor(const LayoutContext& layoutContext, Position position, const Container& containingBlock, const Container& ancestor)
+{
+ auto mappedPosition = position;
+ auto* container = &containingBlock;
+ for (; container && container != &ancestor; container = container->containingBlock())
+ mappedPosition.moveBy(layoutContext.displayBoxForLayoutBox(*container)->topLeft());
+
+ if (!container) {
+ ASSERT_NOT_REACHED();
+ return position;
+ }
+
+ return mappedPosition;
+}
+
#ifndef NDEBUG
void FormattingContext::validateGeometryConstraintsAfterLayout(const LayoutContext& layoutContext) const
{
Modified: trunk/Source/WebCore/layout/FormattingContext.h (234877 => 234878)
--- trunk/Source/WebCore/layout/FormattingContext.h 2018-08-15 02:42:59 UTC (rev 234877)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2018-08-15 02:59:51 UTC (rev 234878)
@@ -59,7 +59,9 @@
};
virtual InstrinsicWidthConstraints instrinsicWidthConstraints(LayoutContext&, const Box&) const = 0;
- static Display::Box mapToAncestor(const LayoutContext&, const Box&, const Container& ancestor);
+ static Display::Box mapBoxToAncestor(const LayoutContext&, const Box&, const Container& ancestor);
+ static Position mapTopLeftToAncestor(const LayoutContext&, const Box&, const Container& ancestor);
+ static Position mapCoordinateToAncestor(const LayoutContext&, Position, const Container& containingBlock, const Container& ancestor);
protected:
struct LayoutPair {
Modified: trunk/Source/WebCore/layout/LayoutUnits.h (234877 => 234878)
--- trunk/Source/WebCore/layout/LayoutUnits.h 2018-08-15 02:42:59 UTC (rev 234877)
+++ trunk/Source/WebCore/layout/LayoutUnits.h 2018-08-15 02:59:51 UTC (rev 234878)
@@ -38,9 +38,32 @@
// FIXME: Use LayoutUnit<Horizontal> to avoid top/left vs. x/y confusion.
LayoutUnit x; // left
LayoutUnit y; // top
+
+ Position() = default;
+ Position(LayoutUnit, LayoutUnit);
+ Position(LayoutPoint);
+ void moveBy(LayoutPoint);
operator LayoutPoint() const { return { x, y }; }
};
+inline Position::Position(LayoutPoint point)
+ : x(point.x())
+ , y(point.y())
+{
+}
+
+inline Position::Position(LayoutUnit x, LayoutUnit y)
+ : x(x)
+ , y(y)
+{
+}
+
+inline void Position::moveBy(LayoutPoint offset)
+{
+ x += offset.x();
+ y += offset.y();
+}
+
// Margin, border, padding
struct HorizontalEdges {
LayoutUnit left;
Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (234877 => 234878)
--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2018-08-15 02:42:59 UTC (rev 234877)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2018-08-15 02:59:51 UTC (rev 234878)
@@ -38,6 +38,7 @@
namespace Layout {
class BlockFormattingContext;
class FormattingContext;
+class FloatingContext;
class LayoutContext;
}
@@ -48,6 +49,7 @@
public:
friend class Layout::BlockFormattingContext;
friend class Layout::FormattingContext;
+ friend class Layout::FloatingContext;
friend class Layout::LayoutContext;
Box(const Box&);
Modified: trunk/Tools/ChangeLog (234877 => 234878)
--- trunk/Tools/ChangeLog 2018-08-15 02:42:59 UTC (rev 234877)
+++ trunk/Tools/ChangeLog 2018-08-15 02:59:51 UTC (rev 234878)
@@ -1,3 +1,12 @@
+2018-08-14 Zalan Bujtas <[email protected]>
+
+ [LFC][Floating] Add support for negative clearance.
+ https://bugs.webkit.org/show_bug.cgi?id=188555
+
+ Reviewed by Simon Fraser.
+
+ * LayoutReloaded/misc/LFC-passing-tests.txt:
+
2018-08-14 Sihui Liu <[email protected]>
Crash in WebKit::filterPreloadHSTSEntry via NetworkProcess::getHostNamesWithHSTSCache
Modified: trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt (234877 => 234878)
--- trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt 2018-08-15 02:42:59 UTC (rev 234877)
+++ trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt 2018-08-15 02:59:51 UTC (rev 234878)
@@ -49,3 +49,4 @@
fast/block/block-only/floating-and-next-previous-inflow-with-margin.html
fast/block/block-only/floating-left-and-right-with-clearance.html
fast/block/block-only/float-and-siblings-with-margins.html
+fast/block/block-only/margin-collapse-with-clearance.html