Title: [246468] trunk/Source/WebCore
Revision
246468
Author
[email protected]
Date
2019-06-15 12:30:06 -0700 (Sat, 15 Jun 2019)

Log Message

[LFC][BFC] Fix available width for non-floating positioned float avoiders.
https://bugs.webkit.org/show_bug.cgi?id=198886
<rdar://problem/51773643>

Reviewed by Antti Koivisto.

Normally the available width for an in-flow block level box is the width of the containing block's content box.
However a non-floating positioned float avoider box might be constrained by existing floats.
The idea here is that we pre-compute(estimate) the vertical position and check the current floating context for
left and right floats. These floats contrain the available width and this computed value should be used instead of the containing block's
content box's width whe calculating the used width for width: auto.

* layout/FormattingContext.cpp:
(WebCore::Layout::mapHorizontalPositionToAncestor):
(WebCore::Layout::FormattingContext::mapLeftToAncestor):
(WebCore::Layout::FormattingContext::mapRightToAncestor):
(WebCore::Layout::FormattingContext::mapPointToAncestor):
(WebCore::Layout::FormattingContext::mapCoordinateToAncestor): Deleted.
* layout/FormattingContext.h:
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::usedAvailableWidthForFloatAvoider const):
(WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):
(WebCore::Layout::BlockFormattingContext::computeStaticVerticalPosition const):
(WebCore::Layout::BlockFormattingContext::computeStaticHorizontalPosition const):
(WebCore::Layout::BlockFormattingContext::computeStaticPosition const):
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPositionForFormattingRoot const):
(WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
* layout/blockformatting/BlockFormattingContext.h:
(WebCore::Layout::BlockFormattingContext::computeWidthAndMargin):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::staticVerticalPosition):
(WebCore::Layout::BlockFormattingContext::Geometry::staticHorizontalPosition):
(WebCore::Layout::BlockFormattingContext::Geometry::staticPosition):
* layout/floats/FloatingState.cpp:
(WebCore::Layout::FloatingState::constraints const):
* layout/layouttree/LayoutBlockContainer.cpp:
(WebCore::Layout::BlockContainer::establishesInlineFormattingContextOnly const):
* layout/layouttree/LayoutBlockContainer.h:
* layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::isFloatAvoider const):
* layout/layouttree/LayoutBox.h:
(WebCore::Layout::Box::establishesInlineFormattingContextOnly const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (246467 => 246468)


--- trunk/Source/WebCore/ChangeLog	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/ChangeLog	2019-06-15 19:30:06 UTC (rev 246468)
@@ -1,3 +1,48 @@
+2019-06-15  Zalan Bujtas  <[email protected]>
+
+        [LFC][BFC] Fix available width for non-floating positioned float avoiders.
+        https://bugs.webkit.org/show_bug.cgi?id=198886
+        <rdar://problem/51773643>
+
+        Reviewed by Antti Koivisto.
+
+        Normally the available width for an in-flow block level box is the width of the containing block's content box.
+        However a non-floating positioned float avoider box might be constrained by existing floats.
+        The idea here is that we pre-compute(estimate) the vertical position and check the current floating context for
+        left and right floats. These floats contrain the available width and this computed value should be used instead of the containing block's
+        content box's width whe calculating the used width for width: auto.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::mapHorizontalPositionToAncestor):
+        (WebCore::Layout::FormattingContext::mapLeftToAncestor):
+        (WebCore::Layout::FormattingContext::mapRightToAncestor):
+        (WebCore::Layout::FormattingContext::mapPointToAncestor):
+        (WebCore::Layout::FormattingContext::mapCoordinateToAncestor): Deleted.
+        * layout/FormattingContext.h:
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::usedAvailableWidthForFloatAvoider const):
+        (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):
+        (WebCore::Layout::BlockFormattingContext::computeStaticVerticalPosition const):
+        (WebCore::Layout::BlockFormattingContext::computeStaticHorizontalPosition const):
+        (WebCore::Layout::BlockFormattingContext::computeStaticPosition const):
+        (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPositionForFormattingRoot const):
+        (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
+        * layout/blockformatting/BlockFormattingContext.h:
+        (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::staticVerticalPosition):
+        (WebCore::Layout::BlockFormattingContext::Geometry::staticHorizontalPosition):
+        (WebCore::Layout::BlockFormattingContext::Geometry::staticPosition):
+        * layout/floats/FloatingState.cpp:
+        (WebCore::Layout::FloatingState::constraints const):
+        * layout/layouttree/LayoutBlockContainer.cpp:
+        (WebCore::Layout::BlockContainer::establishesInlineFormattingContextOnly const):
+        * layout/layouttree/LayoutBlockContainer.h:
+        * layout/layouttree/LayoutBox.cpp:
+        (WebCore::Layout::Box::isFloatAvoider const):
+        * layout/layouttree/LayoutBox.h:
+        (WebCore::Layout::Box::establishesInlineFormattingContextOnly const):
+
 2019-06-15  Ludovico de Nittis  <[email protected]>
 
         [GTK] Stop accessing GdkEvent fields when possible

Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (246467 => 246468)


--- trunk/Source/WebCore/layout/FormattingContext.cpp	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp	2019-06-15 19:30:06 UTC (rev 246468)
@@ -165,6 +165,30 @@
     LOG_WITH_STREAM(FormattingContextLayout, stream << "End: layout out-of-flow descendants -> context: " << &layoutState << " root: " << &root());
 }
 
+static LayoutUnit mapHorizontalPositionToAncestor(const LayoutState& layoutState, LayoutUnit horizontalPosition, const Container& containingBlock, const Container& ancestor)
+{
+    // "horizontalPosition" is in the coordinate system of the "containingBlock". -> map from containingBlock to ancestor.
+    if (&containingBlock == &ancestor)
+        return horizontalPosition;
+    ASSERT(containingBlock.isDescendantOf(ancestor));
+    for (auto* container = &containingBlock; container && container != &ancestor; container = container->containingBlock())
+        horizontalPosition += layoutState.displayBoxForLayoutBox(*container).left();
+    return horizontalPosition;
+}
+
+// FIXME: turn these into templates.
+LayoutUnit FormattingContext::mapLeftToAncestor(const LayoutState& layoutState, const Box& layoutBox, const Container& ancestor)
+{
+    ASSERT(layoutBox.containingBlock());
+    return mapHorizontalPositionToAncestor(layoutState, layoutState.displayBoxForLayoutBox(layoutBox).left(), *layoutBox.containingBlock(), ancestor);
+}
+
+LayoutUnit FormattingContext::mapRightToAncestor(const LayoutState& layoutState, const Box& layoutBox, const Container& ancestor)
+{
+    ASSERT(layoutBox.containingBlock());
+    return mapHorizontalPositionToAncestor(layoutState, layoutState.displayBoxForLayoutBox(layoutBox).right(), *layoutBox.containingBlock(), ancestor);
+}
+
 Display::Box FormattingContext::mapBoxToAncestor(const LayoutState& layoutState, const Box& layoutBox, const Container& ancestor)
 {
     ASSERT(layoutBox.isDescendantOf(ancestor));
@@ -196,7 +220,7 @@
     return top;
 }
 
-Point FormattingContext::mapCoordinateToAncestor(const LayoutState& layoutState, Point position, const Container& containingBlock, const Container& ancestor)
+Point FormattingContext::mapPointToAncestor(const LayoutState& layoutState, Point position, const Container& containingBlock, const Container& ancestor)
 {
     auto mappedPosition = position;
     auto* container = &containingBlock;

Modified: trunk/Source/WebCore/layout/FormattingContext.h (246467 => 246468)


--- trunk/Source/WebCore/layout/FormattingContext.h	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/layout/FormattingContext.h	2019-06-15 19:30:06 UTC (rev 246468)
@@ -60,7 +60,9 @@
 
     static Display::Box mapBoxToAncestor(const LayoutState&, const Box&, const Container& ancestor);
     static LayoutUnit mapTopToAncestor(const LayoutState&, const Box&, const Container& ancestor);
-    static Point mapCoordinateToAncestor(const LayoutState&, Point, const Container& containingBlock, const Container& ancestor);
+    static LayoutUnit mapLeftToAncestor(const LayoutState&, const Box&, const Container& ancestor);
+    static LayoutUnit mapRightToAncestor(const LayoutState&, const Box&, const Container& ancestor);
+    static Point mapPointToAncestor(const LayoutState&, Point, const Container& containingBlock, const Container& ancestor);
 
 protected:
     using LayoutQueue = Vector<const Box*>;

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (246467 => 246468)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2019-06-15 19:30:06 UTC (rev 246468)
@@ -118,13 +118,51 @@
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> block formatting context -> formatting root(" << &root() << ")");
 }
 
+Optional<LayoutUnit> BlockFormattingContext::usedAvailableWidthForFloatAvoider(const FloatingContext& floatingContext, const Box& layoutBox) const
+{
+    // Normally the available width for an in-flow block level box is the width of the containing block's content box.
+    // However (and can't find it anywhere in the spec) non-floating positioned float avoider block level boxes are constrained by existing floats.
+    if (!layoutBox.isFloatAvoider() || layoutBox.isFloatingPositioned())
+        return { };
+    auto& floatingState = floatingContext.floatingState();
+    if (floatingState.isEmpty())
+        return { };
+    // Vertical static position is not computed yet, so let's just estimate it for now.
+    auto& formattingRoot = downcast<Container>(root());
+    auto verticalPosition = FormattingContext::mapTopToAncestor(layoutState(), layoutBox, formattingRoot);
+    auto constraints = floatingState.constraints({ verticalPosition }, formattingRoot);
+    if (!constraints.left && !constraints.right)
+        return { };
+    auto& containingBlock = downcast<Container>(*layoutBox.containingBlock());
+    auto& containingBlockDisplayBox = layoutState().displayBoxForLayoutBox(containingBlock);
+    auto availableWidth = containingBlockDisplayBox.contentBoxWidth();
+
+    LayoutUnit containingBlockLeft;
+    LayoutUnit containingBlockRight = containingBlockDisplayBox.right();
+    if (&containingBlock != &formattingRoot) {
+        // Move containing block left/right to the root's coordinate system.
+        containingBlockLeft = FormattingContext::mapLeftToAncestor(layoutState(), containingBlock, formattingRoot);
+        containingBlockRight = FormattingContext::mapRightToAncestor(layoutState(), containingBlock, formattingRoot);
+    }
+    auto containingBlockContentBoxLeft = containingBlockLeft + containingBlockDisplayBox.borderLeft() + containingBlockDisplayBox.paddingLeft().valueOr(0);
+    auto containingBlockContentBoxRight = containingBlockRight - containingBlockDisplayBox.borderRight() + containingBlockDisplayBox.paddingRight().valueOr(0);
+
+    // Shrink the available space if the floats are actually intruding at this vertical position.
+    availableWidth -= (std::max<LayoutUnit>(0, constraints.left.valueOr(PositionInContextRoot { 0 }) - containingBlockContentBoxLeft)
+        + std::max<LayoutUnit>(0, containingBlockContentBoxRight - constraints.right.valueOr(PositionInContextRoot { containingBlockContentBoxRight })));
+    return availableWidth;
+}
+
 void BlockFormattingContext::layoutFormattingContextRoot(FloatingContext& floatingContext, const Box& layoutBox) const
 {
+    ASSERT(layoutBox.establishesFormattingContext());
     // Start laying out this formatting root in the formatting contenxt it lives in.
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &layoutBox << ")");
     computeBorderAndPadding(layoutBox);
-    computeWidthAndMargin(layoutBox);
-    computeStaticPosition(floatingContext, layoutBox);
+    computeStaticVerticalPosition(floatingContext, layoutBox);
+
+    computeWidthAndMargin(layoutBox, usedAvailableWidthForFloatAvoider(floatingContext, layoutBox));
+    computeStaticHorizontalPosition(layoutBox);
     // Swich over to the new formatting context (the one that the root creates).
     auto formattingContext = layoutState().createFormattingContext(layoutBox);
     formattingContext->layout();
@@ -172,10 +210,10 @@
     LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> parent: " << &layoutBox);
 }
 
-void BlockFormattingContext::computeStaticPosition(const FloatingContext& floatingContext, const Box& layoutBox) const
+void BlockFormattingContext::computeStaticVerticalPosition(const FloatingContext& floatingContext, const Box& layoutBox) const
 {
     auto& layoutState = this->layoutState();
-    layoutState.displayBoxForLayoutBox(layoutBox).setTopLeft(Geometry::staticPosition(layoutState, layoutBox));
+    layoutState.displayBoxForLayoutBox(layoutBox).setTop(Geometry::staticVerticalPosition(layoutState, layoutBox));
     if (layoutBox.hasFloatClear())
         computeEstimatedVerticalPositionForFloatClear(floatingContext, layoutBox);
     else if (layoutBox.establishesFormattingContext())
@@ -182,6 +220,17 @@
         computeEstimatedVerticalPositionForFormattingRoot(layoutBox);
 }
 
+void BlockFormattingContext::computeStaticHorizontalPosition(const Box& layoutBox) const
+{
+    layoutState().displayBoxForLayoutBox(layoutBox).setLeft(Geometry::staticHorizontalPosition(layoutState(), layoutBox));
+}
+
+void BlockFormattingContext::computeStaticPosition(const FloatingContext& floatingContext, const Box& layoutBox) const
+{
+    computeStaticVerticalPosition(floatingContext, layoutBox);
+    computeStaticHorizontalPosition(layoutBox);
+}
+
 void BlockFormattingContext::computeEstimatedVerticalPosition(const Box& layoutBox) const
 {
     auto& layoutState = this->layoutState();
@@ -226,13 +275,17 @@
     ASSERT(layoutBox.establishesFormattingContext());
     ASSERT(!layoutBox.hasFloatClear());
 
-    auto avoidsFloats = layoutBox.isFloatingPositioned() || layoutBox.establishesBlockFormattingContext();
-    if (avoidsFloats)
+    if (layoutBox.isFloatingPositioned()) {
         computeEstimatedVerticalPositionForAncestors(layoutBox);
+        return;
+    }
 
+    computeEstimatedVerticalPosition(layoutBox);
+    computeEstimatedVerticalPositionForAncestors(layoutBox);
+
     // If the inline formatting root is also the root for the floats (happens when the root box also establishes a block formatting context)
     // the floats are in the coordinate system of this root. No need to find the final vertical position.
-    auto inlineContextInheritsFloats = layoutBox.establishesInlineFormattingContext() && !layoutBox.establishesBlockFormattingContext();
+    auto inlineContextInheritsFloats = layoutBox.establishesInlineFormattingContextOnly();
     if (inlineContextInheritsFloats) {
         computeEstimatedVerticalPosition(layoutBox);
         computeEstimatedVerticalPositionForAncestors(layoutBox);
@@ -295,13 +348,18 @@
         layoutState.displayBoxForLayoutBox(layoutBox).setTopLeft(*adjustedPosition);
 }
 
-void BlockFormattingContext::computeWidthAndMargin(const Box& layoutBox) const
+void BlockFormattingContext::computeWidthAndMargin(const Box& layoutBox, Optional<LayoutUnit> usedAvailableWidth) const
 {
     auto& layoutState = this->layoutState();
-    auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
 
+    LayoutUnit availableWidth;
+    if (usedAvailableWidth)
+        availableWidth = *usedAvailableWidth;
+    else
+        availableWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth();
+
     auto compute = [&](Optional<LayoutUnit> usedWidth) -> WidthAndMargin {
-        auto usedValues = UsedHorizontalValues { containingBlockWidth, usedWidth, { } };
+        auto usedValues = UsedHorizontalValues { availableWidth, usedWidth, { } };
         if (layoutBox.isInFlow())
             return Geometry::inFlowWidthAndMargin(layoutState, layoutBox, usedValues);
 
@@ -314,13 +372,13 @@
 
     auto widthAndMargin = compute({ });
 
-    if (auto maxWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMaxWidth(), containingBlockWidth)) {
+    if (auto maxWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMaxWidth(), availableWidth)) {
         auto maxWidthAndMargin = compute(maxWidth);
         if (widthAndMargin.width > maxWidthAndMargin.width)
             widthAndMargin = maxWidthAndMargin;
     }
 
-    auto minWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMinWidth(), containingBlockWidth).valueOr(0);
+    auto minWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMinWidth(), availableWidth).valueOr(0);
     auto minWidthAndMargin = compute(minWidth);
     if (widthAndMargin.width < minWidthAndMargin.width)
         widthAndMargin = minWidthAndMargin;

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (246467 => 246468)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2019-06-15 19:30:06 UTC (rev 246468)
@@ -55,9 +55,11 @@
     void layoutFormattingContextRoot(FloatingContext&, const Box&) const;
     void placeInFlowPositionedChildren(const Box&) const;
 
-    void computeWidthAndMargin(const Box&) const;
+    void computeWidthAndMargin(const Box&, Optional<LayoutUnit> usedAvailableWidth = { }) const;
     void computeHeightAndMargin(const Box&) const;
 
+    void computeStaticHorizontalPosition(const Box&) const;
+    void computeStaticVerticalPosition(const FloatingContext&, const Box&) const;
     void computeStaticPosition(const FloatingContext&, const Box&) const;
     void computeFloatingPosition(const FloatingContext&, const Box&) const;
     void computePositionToAvoidFloats(const FloatingContext&, const Box&) const;
@@ -77,6 +79,8 @@
         static WidthAndMargin inFlowWidthAndMargin(const LayoutState&, const Box&, UsedHorizontalValues);
 
         static Point staticPosition(const LayoutState&, const Box&);
+        static LayoutUnit staticVerticalPosition(const LayoutState&, const Box&);
+        static LayoutUnit staticHorizontalPosition(const LayoutState&, const Box&);
 
         static bool intrinsicWidthConstraintsNeedChildrenWidth(const Box&);
         static IntrinsicWidthConstraints intrinsicWidthConstraints(const LayoutState&, const Box&);
@@ -131,6 +135,7 @@
     void setEstimatedMarginBefore(const Box&, const EstimatedMarginBefore&) const;
     void removeEstimatedMarginBefore(const Box& layoutBox) const { m_estimatedMarginBeforeList.remove(&layoutBox); }
     bool hasEstimatedMarginBefore(const Box&) const;
+    Optional<LayoutUnit> usedAvailableWidthForFloatAvoider(const FloatingContext&, const Box&) const;
 #ifndef NDEBUG
     EstimatedMarginBefore estimatedMarginBefore(const Box& layoutBox) const { return m_estimatedMarginBeforeList.get(&layoutBox); }
     bool hasPrecomputedMarginBefore(const Box&) const;

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (246467 => 246468)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-06-15 19:30:06 UTC (rev 246468)
@@ -222,27 +222,31 @@
     return { *usedValues.width, nonReplacedWidthAndMargin.usedMargin, nonReplacedWidthAndMargin.computedMargin };
 }
 
-Point BlockFormattingContext::Geometry::staticPosition(const LayoutState& layoutState, const Box& layoutBox)
+LayoutUnit BlockFormattingContext::Geometry::staticVerticalPosition(const LayoutState& layoutState, const Box& layoutBox)
 {
     // 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).
-
-    LayoutUnit top;
-    auto& containingBlockDisplayBox = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock());
     if (auto* previousInFlowSibling = layoutBox.previousInFlowSibling()) {
         auto& previousInFlowDisplayBox = layoutState.displayBoxForLayoutBox(*previousInFlowSibling);
-        top = previousInFlowDisplayBox.bottom() + previousInFlowDisplayBox.marginAfter();
-    } else
-        top = containingBlockDisplayBox.contentBoxTop();
+        return previousInFlowDisplayBox.bottom() + previousInFlowDisplayBox.marginAfter();
+    }
+    return layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxTop();
+}
 
-    auto left = containingBlockDisplayBox.contentBoxLeft() + layoutState.displayBoxForLayoutBox(layoutBox).marginStart();
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position] -> static -> top(" << top << "px) left(" << left << "px) layoutBox(" << &layoutBox << ")");
-    return { left, top };
+LayoutUnit BlockFormattingContext::Geometry::staticHorizontalPosition(const LayoutState& layoutState, const Box& layoutBox)
+{
+    // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
+    // 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).
+    return layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxLeft() + layoutState.displayBoxForLayoutBox(layoutBox).marginStart();
 }
 
+Point BlockFormattingContext::Geometry::staticPosition(const LayoutState& layoutState, const Box& layoutBox)
+{
+    return { staticHorizontalPosition(layoutState, layoutBox), staticVerticalPosition(layoutState, layoutBox) };
+}
+
 HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues)
 {
     ASSERT(layoutBox.isInFlow());

Modified: trunk/Source/WebCore/layout/floats/FloatingState.cpp (246467 => 246468)


--- trunk/Source/WebCore/layout/floats/FloatingState.cpp	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/layout/floats/FloatingState.cpp	2019-06-15 19:30:06 UTC (rev 246468)
@@ -121,7 +121,7 @@
     auto adjustedPosition = Point { 0, verticalPosition };
 
     if (coordinateMappingIsRequired)
-        adjustedPosition = FormattingContext::mapCoordinateToAncestor(m_layoutState, adjustedPosition, downcast<Container>(formattingContextRoot), downcast<Container>(root()));
+        adjustedPosition = FormattingContext::mapPointToAncestor(m_layoutState, adjustedPosition, downcast<Container>(formattingContextRoot), downcast<Container>(root()));
 
     Constraints constraints;
     for (int index = m_floats.size() - 1; index >= 0; --index) {

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.cpp (246467 => 246468)


--- trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.cpp	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.cpp	2019-06-15 19:30:06 UTC (rev 246468)
@@ -53,7 +53,12 @@
     return false;
 }
 
+bool BlockContainer::establishesInlineFormattingContextOnly() const
+{
+    return establishesInlineFormattingContext() && !establishesBlockFormattingContext();
 }
+
 }
+}
 
 #endif

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.h (246467 => 246468)


--- trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.h	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBlockContainer.h	2019-06-15 19:30:06 UTC (rev 246468)
@@ -42,7 +42,7 @@
     BlockContainer(Optional<ElementAttributes>, RenderStyle&&, BaseTypeFlags = BlockContainerFlag);
 
     bool establishesInlineFormattingContext() const final;
-
+    bool establishesInlineFormattingContextOnly() const final;
 };
 
 }

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (246467 => 246468)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2019-06-15 19:30:06 UTC (rev 246468)
@@ -134,6 +134,11 @@
     return m_style.clear() != Clear::None;
 }
 
+bool Box::isFloatAvoider() const
+{
+    return establishesBlockFormattingContext() || isFloatingPositioned();
+}
+
 const Container* Box::containingBlock() const
 {
     // The containing block in which the root element lives is a rectangle called the initial containing block.

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (246467 => 246468)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2019-06-15 18:33:03 UTC (rev 246467)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2019-06-15 19:30:06 UTC (rev 246468)
@@ -78,6 +78,7 @@
     bool establishesBlockFormattingContext() const;
     bool establishesBlockFormattingContextOnly() const;
     virtual bool establishesInlineFormattingContext() const { return false; }
+    virtual bool establishesInlineFormattingContextOnly() const { return false; }
 
     bool isInFlow() const { return !isFloatingOrOutOfFlowPositioned(); }
     bool isPositioned() const { return isInFlowPositioned() || isOutOfFlowPositioned(); }
@@ -91,6 +92,7 @@
     bool isLeftFloatingPositioned() const;
     bool isRightFloatingPositioned() const;
     bool hasFloatClear() const;
+    bool isFloatAvoider() const;
 
     bool isFloatingOrOutOfFlowPositioned() const { return isFloatingPositioned() || isOutOfFlowPositioned(); }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to