[LFC] Align shrink-to-fit width computation with the layout implementation.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Nov 2018 13:41:05 +0000 (13:41 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Nov 2018 13:41:05 +0000 (13:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191179

Reviewed by Antti Koivisto.

There are many similarities between layout and shrink-to-fit.
They both operate on formatting roots only (shrink-to-fit -> float, out-of-flow, inline-block) and in both cases
the algoritm depends on what type of formatting context the element establishes.

This patch is in preparation for transforming the "shrink-to-fit" width computation to make it behave more like layout.
With this change the instrinsicWidthConstraints() computation happens in the formatting context that the element establishes (similar to layout).

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
* layout/FormattingContext.h:
(WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
(WebCore::Layout::BlockFormattingContext::instrinsicWidthConstraints const):
* layout/blockformatting/BlockFormattingContext.h:
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::layoutFormattingContextRoot const):
(WebCore::Layout::InlineFormattingContext::instrinsicWidthConstraints const):
* layout/inlineformatting/InlineFormattingContext.h:
* layout/inlineformatting/InlineFormattingContextGeometry.cpp:
(WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockWidthAndMargin):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237729 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.cpp
Source/WebCore/layout/FormattingContext.h
Source/WebCore/layout/FormattingContextGeometry.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.h
Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp

index 1c1d0fb..13974fd 100644 (file)
@@ -1,3 +1,41 @@
+2018-11-02  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Align shrink-to-fit width computation with the layout implementation.
+        https://bugs.webkit.org/show_bug.cgi?id=191179
+
+        Reviewed by Antti Koivisto.
+
+        There are many similarities between layout and shrink-to-fit.
+        They both operate on formatting roots only (shrink-to-fit -> float, out-of-flow, inline-block) and in both cases
+        the algoritm depends on what type of formatting context the element establishes.
+
+        This patch is in preparation for transforming the "shrink-to-fit" width computation to make it behave more like layout.
+        With this change the instrinsicWidthConstraints() computation happens in the formatting context that the element establishes (similar to layout).
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
+        * layout/FormattingContext.h:
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
+        (WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
+        (WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin):
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const):
+        (WebCore::Layout::BlockFormattingContext::instrinsicWidthConstraints const):
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::layoutFormattingContextRoot const):
+        (WebCore::Layout::InlineFormattingContext::instrinsicWidthConstraints const):
+        * layout/inlineformatting/InlineFormattingContext.h:
+        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+        (WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockWidthAndMargin):
+
 2018-11-01  Antoine Quint  <graouts@apple.com>
 
         [Web Animations] Make document.getAnimations() return declarative animations in the correct order
index 4a33df9..9a7094a 100644 (file)
@@ -68,7 +68,7 @@ void FormattingContext::computeOutOfFlowHorizontalGeometry(const Box& layoutBox)
     auto& layoutState = this->layoutState();
 
     auto compute = [&](std::optional<LayoutUnit> usedWidth) {
-        return Geometry::outOfFlowHorizontalGeometry(layoutState, *this, layoutBox, usedWidth);
+        return Geometry::outOfFlowHorizontalGeometry(layoutState, layoutBox, usedWidth);
     };
 
     auto horizontalGeometry = compute({ });
index 58948af..d78f97f 100644 (file)
@@ -56,7 +56,7 @@ public:
         LayoutUnit minimum;
         LayoutUnit maximum;
     };
-    virtual InstrinsicWidthConstraints instrinsicWidthConstraints(const Box&) const = 0;
+    virtual InstrinsicWidthConstraints instrinsicWidthConstraints() const = 0;
 
     static Display::Box mapBoxToAncestor(const LayoutState&, const Box&, const Container& ancestor);
     static Position mapTopLeftToAncestor(const LayoutState&, const Box&, const Container& ancestor);
@@ -84,17 +84,17 @@ protected:
     class Geometry {
     public:
         static VerticalGeometry outOfFlowVerticalGeometry(const LayoutState&, const Box&, std::optional<LayoutUnit> usedHeight = { });
-        static HorizontalGeometry outOfFlowHorizontalGeometry(LayoutState&, const FormattingContext&, const Box&, std::optional<LayoutUnit> usedWidth = { });
+        static HorizontalGeometry outOfFlowHorizontalGeometry(LayoutState&, const Box&, std::optional<LayoutUnit> usedWidth = { });
 
         static HeightAndMargin floatingHeightAndMargin(const LayoutState&, const Box&, std::optional<LayoutUnit> usedHeight = { });
-        static WidthAndMargin floatingWidthAndMargin(LayoutState&, const FormattingContext&, const Box&, std::optional<LayoutUnit> usedWidth = { });
+        static WidthAndMargin floatingWidthAndMargin(LayoutState&, const Box&, std::optional<LayoutUnit> usedWidth = { });
 
         static HeightAndMargin inlineReplacedHeightAndMargin(const LayoutState&, const Box&, std::optional<LayoutUnit> usedHeight = { });
         static WidthAndMargin inlineReplacedWidthAndMargin(const LayoutState&, const Box&, std::optional<LayoutUnit> usedWidth = { }, 
             std::optional<LayoutUnit> precomputedMarginLeft = { }, std::optional<LayoutUnit> precomputedMarginRight = { });
 
         static HeightAndMargin complicatedCases(const LayoutState&, const Box&, std::optional<LayoutUnit> usedHeight = { });
-        static LayoutUnit shrinkToFitWidth(const LayoutState&, const FormattingContext&, const Box&);
+        static LayoutUnit shrinkToFitWidth(LayoutState&, const Box&);
 
         static Edges computedBorder(const LayoutState&, const Box&);
         static std::optional<Edges> computedPadding(const LayoutState&, const Box&);
@@ -113,12 +113,12 @@ protected:
         static HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const LayoutState&, const Box&, std::optional<LayoutUnit> usedWidth = { });
 
         static VerticalGeometry outOfFlowNonReplacedVerticalGeometry(const LayoutState&, const Box&, std::optional<LayoutUnit> usedHeight = { });
-        static HorizontalGeometry outOfFlowNonReplacedHorizontalGeometry(LayoutState&, const FormattingContext&, const Box&, std::optional<LayoutUnit> usedWidth = { });
+        static HorizontalGeometry outOfFlowNonReplacedHorizontalGeometry(LayoutState&, const Box&, std::optional<LayoutUnit> usedWidth = { });
 
         static HeightAndMargin floatingReplacedHeightAndMargin(const LayoutState&, const Box&, std::optional<LayoutUnit> usedHeight = { });
         static WidthAndMargin floatingReplacedWidthAndMargin(const LayoutState&, const Box&, std::optional<LayoutUnit> usedWidth = { });
 
-        static WidthAndMargin floatingNonReplacedWidthAndMargin(LayoutState&, const FormattingContext&, const Box&, std::optional<LayoutUnit> usedWidth = { });
+        static WidthAndMargin floatingNonReplacedWidthAndMargin(LayoutState&, const Box&, std::optional<LayoutUnit> usedWidth = { });
     };
 
 private:
index a92b992..3dd0858 100644 (file)
@@ -208,9 +208,11 @@ static LayoutUnit staticHorizontalPositionForOutOfFlowPositioned(const LayoutSta
     return left;
 }
 
-LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(const LayoutState& layoutState, const FormattingContext& formattingContext, const Box& layoutBox)
+LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(LayoutState& layoutState, const Box& formattingRoot)
 {
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width] -> shrink to fit -> unsupported -> width(" << LayoutUnit { } << "px) layoutBox: " << &layoutBox << ")");
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width] -> shrink to fit -> unsupported -> width(" << LayoutUnit { } << "px) layoutBox: " << &formattingRoot << ")");
+    ASSERT(formattingRoot.establishesFormattingContext());
+
     // Calculation of the shrink-to-fit width is similar to calculating the width of a table cell using the automatic table layout algorithm.
     // Roughly: calculate the preferred width by formatting the content without breaking lines other than where explicit line breaks occur,
     // and also calculate the preferred minimum width, e.g., by trying all possible line breaks. CSS 2.2 does not define the exact algorithm.
@@ -218,8 +220,9 @@ LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(const LayoutState& layo
     // 'padding-left', 'padding-right', 'border-right-width', 'margin-right', and the widths of any relevant scroll bars.
 
     // Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width).
-    auto availableWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).width();
-    auto instrinsicWidthConstraints = formattingContext.instrinsicWidthConstraints(layoutBox);
+    auto availableWidth = layoutState.displayBoxForLayoutBox(*formattingRoot.containingBlock()).width();
+    auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(formattingRoot);
+    auto instrinsicWidthConstraints = formattingState.formattingContext(formattingRoot)->instrinsicWidthConstraints();
     return std::min(std::max(instrinsicWidthConstraints.minimum, availableWidth), instrinsicWidthConstraints.maximum);
 }
 
@@ -339,7 +342,7 @@ VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeomet
     return { *top, *bottom, { *height, { *marginTop, *marginBottom }, { } } };
 }
 
-HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(LayoutState& layoutState, const FormattingContext& formattingContext, const Box& layoutBox, std::optional<LayoutUnit> usedWidth)
+HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox, std::optional<LayoutUnit> usedWidth)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced());
     
@@ -448,7 +451,7 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGe
 
     if (!left && !width && right) {
         // #1
-        width = shrinkToFitWidth(layoutState, formattingContext, layoutBox);
+        width = shrinkToFitWidth(layoutState, layoutBox);
         left = containingBlockWidth - (*marginLeft + borderLeft + paddingLeft + *width + paddingRight  + borderRight + *marginRight + *right);
     } else if (!left && !right && width) {
         // #2
@@ -462,7 +465,7 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGe
         }
     } else if (!width && !right && left) {
         // #3
-        width = shrinkToFitWidth(layoutState, formattingContext, layoutBox);
+        width = shrinkToFitWidth(layoutState, layoutBox);
         right = containingBlockWidth - (*left + *marginLeft + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginRight);
     } else if (!left && width && right) {
         // #4
@@ -695,7 +698,7 @@ HeightAndMargin FormattingContext::Geometry::complicatedCases(const LayoutState&
     return HeightAndMargin { *height, { *marginTop, *marginBottom }, { } };
 }
 
-WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutState& layoutState, const FormattingContext& formattingContext, const Box& layoutBox, std::optional<LayoutUnit> usedWidth)
+WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, std::optional<LayoutUnit> usedWidth)
 {
     ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced());
 
@@ -712,7 +715,7 @@ WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(La
     // #2
     auto width = computedValueIfNotAuto(usedWidth ? Length { usedWidth.value(), Fixed } : layoutBox.style().logicalWidth(), containingBlockWidth);
     if (!width)
-        width = shrinkToFitWidth(layoutState, formattingContext, layoutBox);
+        width = shrinkToFitWidth(layoutState, layoutBox);
 
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> floating non-replaced -> width(" << *width << "px) margin(" << margin.left << "px, " << margin.right << "px) -> layoutBox(" << &layoutBox << ")");
     return WidthAndMargin { *width, margin, margin };
@@ -751,12 +754,12 @@ VerticalGeometry FormattingContext::Geometry::outOfFlowVerticalGeometry(const La
     return outOfFlowReplacedVerticalGeometry(layoutState, layoutBox, usedHeight);
 }
 
-HorizontalGeometry FormattingContext::Geometry::outOfFlowHorizontalGeometry(LayoutState& layoutState, const FormattingContext& formattingContext, const Box& layoutBox, std::optional<LayoutUnit> usedWidth)
+HorizontalGeometry FormattingContext::Geometry::outOfFlowHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox, std::optional<LayoutUnit> usedWidth)
 {
     ASSERT(layoutBox.isOutOfFlowPositioned());
 
     if (!layoutBox.replaced())
-        return outOfFlowNonReplacedHorizontalGeometry(layoutState, formattingContext, layoutBox, usedWidth);
+        return outOfFlowNonReplacedHorizontalGeometry(layoutState, layoutBox, usedWidth);
     return outOfFlowReplacedHorizontalGeometry(layoutState, layoutBox, usedWidth);
 }
 
@@ -769,12 +772,12 @@ HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(const Layou
     return floatingReplacedHeightAndMargin(layoutState, layoutBox, usedHeight);
 }
 
-WidthAndMargin FormattingContext::Geometry::floatingWidthAndMargin(LayoutState& layoutState, const FormattingContext& formattingContext, const Box& layoutBox, std::optional<LayoutUnit> usedWidth)
+WidthAndMargin FormattingContext::Geometry::floatingWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, std::optional<LayoutUnit> usedWidth)
 {
     ASSERT(layoutBox.isFloatingPositioned());
 
     if (!layoutBox.replaced())
-        return floatingNonReplacedWidthAndMargin(layoutState, formattingContext, layoutBox, usedWidth);
+        return floatingNonReplacedWidthAndMargin(layoutState, layoutBox, usedWidth);
     return floatingReplacedWidthAndMargin(layoutState, layoutBox, usedWidth);
 }
 
index 3a4f791..091ad10 100644 (file)
@@ -290,7 +290,7 @@ void BlockFormattingContext::computeWidthAndMargin(const Box& layoutBox) const
             return Geometry::inFlowWidthAndMargin(layoutState, layoutBox, usedWidth);
 
         if (layoutBox.isFloatingPositioned())
-            return Geometry::floatingWidthAndMargin(layoutState, *this, layoutBox, usedWidth);
+            return Geometry::floatingWidthAndMargin(layoutState, layoutBox, usedWidth);
 
         ASSERT_NOT_REACHED();
         return { };
@@ -357,18 +357,18 @@ void BlockFormattingContext::computeHeightAndMargin(const Box& layoutBox) const
         displayBox.moveVertically(heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin).top);
 }
 
-FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsicWidthConstraints(const Box& layoutBox) const
+FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsicWidthConstraints() const
 {
     auto& layoutState = this->layoutState();
-    auto& formattingState = layoutState.formattingStateForBox(layoutBox);
-    ASSERT(formattingState.isBlockFormattingState());
-    if (auto instrinsicWidthConstraints = formattingState.instrinsicWidthConstraints(layoutBox))
+    auto& formattingRoot = root();
+    auto& formattingStateForRoot = layoutState.formattingStateForBox(formattingRoot);
+    if (auto instrinsicWidthConstraints = formattingStateForRoot.instrinsicWidthConstraints(formattingRoot))
         return *instrinsicWidthConstraints;
 
     // Can we just compute them without checking the children?
-    if (!Geometry::instrinsicWidthConstraintsNeedChildrenWidth(layoutBox)) {
-        auto instrinsicWidthConstraints = Geometry::instrinsicWidthConstraints(layoutState, layoutBox);
-        formattingState.setInstrinsicWidthConstraints(layoutBox, instrinsicWidthConstraints);
+    if (!Geometry::instrinsicWidthConstraintsNeedChildrenWidth(formattingRoot)) {
+        auto instrinsicWidthConstraints = Geometry::instrinsicWidthConstraints(layoutState, formattingRoot);
+        formattingStateForRoot.setInstrinsicWidthConstraints(formattingRoot, instrinsicWidthConstraints);
         return instrinsicWidthConstraints;
     }
 
@@ -379,25 +379,25 @@ FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsic
     // (Any subtrees with new formatting contexts need to layout synchronously)
     Vector<const Box*> queue;
     // Non-containers early return.
-    ASSERT(is<Container>(layoutBox));
-    if (auto* firstChild = downcast<Container>(layoutBox).firstInFlowOrFloatingChild())
+    ASSERT(is<Container>(formattingRoot));
+    if (auto* firstChild = downcast<Container>(formattingRoot).firstInFlowOrFloatingChild())
         queue.append(firstChild);
 
-    auto& formattingStateForChildren = layoutBox.establishesFormattingContext() ? layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox) : formattingState;
+    auto& formattingState = this->formattingState();
     while (!queue.isEmpty()) {
         while (true) {
             auto& childBox = *queue.last(); 
             // Already computed?
-            auto instrinsicWidthConstraints = formattingStateForChildren.instrinsicWidthConstraints(childBox);
+            auto instrinsicWidthConstraints = formattingState.instrinsicWidthConstraints(childBox);
             // Can we just compute them without checking the children?
             if (!instrinsicWidthConstraints && !Geometry::instrinsicWidthConstraintsNeedChildrenWidth(childBox))
                 instrinsicWidthConstraints = Geometry::instrinsicWidthConstraints(layoutState, childBox);
             // Is it a formatting context root?
             if (!instrinsicWidthConstraints && childBox.establishesFormattingContext())
-                instrinsicWidthConstraints = formattingStateForChildren.formattingContext(childBox)->instrinsicWidthConstraints(childBox);
+                instrinsicWidthConstraints = formattingState.formattingContext(childBox)->instrinsicWidthConstraints();
             // Go to the next sibling (and skip the descendants) if this box's min/max width is computed.
             if (instrinsicWidthConstraints) {
-                formattingStateForChildren.setInstrinsicWidthConstraints(childBox, *instrinsicWidthConstraints); 
+                formattingState.setInstrinsicWidthConstraints(childBox, *instrinsicWidthConstraints); 
                 queue.removeLast();
                 if (!childBox.nextInFlowOrFloatingSibling())
                     break;
@@ -414,7 +414,7 @@ FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsic
         // Compute min/max intrinsic width bottom up.
         while (!queue.isEmpty()) {
             auto& childBox = *queue.takeLast();
-            formattingStateForChildren.setInstrinsicWidthConstraints(childBox, Geometry::instrinsicWidthConstraints(layoutState, childBox)); 
+            formattingState.setInstrinsicWidthConstraints(childBox, Geometry::instrinsicWidthConstraints(layoutState, childBox)); 
             // Move over to the next sibling or take the next box in the queue.
             if (!is<Container>(childBox) || !downcast<Container>(childBox).nextInFlowOrFloatingSibling())
                 continue;
@@ -422,8 +422,8 @@ FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsic
         }
     }
 
-    auto instrinsicWidthConstraints = Geometry::instrinsicWidthConstraints(layoutState, layoutBox);
-    formattingState.setInstrinsicWidthConstraints(layoutBox, instrinsicWidthConstraints); 
+    auto instrinsicWidthConstraints = Geometry::instrinsicWidthConstraints(layoutState, formattingRoot);
+    formattingStateForRoot.setInstrinsicWidthConstraints(formattingRoot, instrinsicWidthConstraints); 
     return instrinsicWidthConstraints;
 }
 
index c767ba4..e615ecc 100644 (file)
@@ -66,7 +66,7 @@ private:
 
     void precomputeVerticalPositionForFormattingRootIfNeeded(const Box&) const;
 
-    InstrinsicWidthConstraints instrinsicWidthConstraints(const Box&) const override;
+    InstrinsicWidthConstraints instrinsicWidthConstraints() const override;
 
     // This class implements positioning and sizing for boxes participating in a block formatting context.
     class Geometry : public FormattingContext::Geometry {
index 6056263..004f0d1 100644 (file)
@@ -215,7 +215,7 @@ void InlineFormattingContext::layoutFormattingContextRoot(const Box& layoutBox)
         WidthAndMargin widthAndMargin;
 
         if (layoutBox.isFloatingPositioned())
-            widthAndMargin = Geometry::floatingWidthAndMargin(layoutState, *this, layoutBox);
+            widthAndMargin = Geometry::floatingWidthAndMargin(layoutState, layoutBox);
         else if (layoutBox.isInlineBlockBox())
             widthAndMargin = Geometry::inlineBlockWidthAndMargin(layoutState, layoutBox);
         else
@@ -301,7 +301,7 @@ void InlineFormattingContext::computeInFlowPositionedPosition(const Box&) const
 {
 }
 
-FormattingContext::InstrinsicWidthConstraints InlineFormattingContext::instrinsicWidthConstraints(const Box&) const
+FormattingContext::InstrinsicWidthConstraints InlineFormattingContext::instrinsicWidthConstraints() const
 {
     return { };
 }
index 6d8c8c6..f7d65ec 100644 (file)
@@ -99,7 +99,7 @@ private:
     class Geometry : public FormattingContext::Geometry {
     public:
         static HeightAndMargin inlineBlockHeightAndMargin(const LayoutState&, const Box&);
-        static WidthAndMargin inlineBlockWidthAndMargin(const LayoutState&, const Box&);
+        static WidthAndMargin inlineBlockWidthAndMargin(LayoutState&, const Box&);
     };
 
     void layoutInlineContent(const InlineRunProvider&) const;
@@ -111,7 +111,7 @@ private:
     void computeStaticPosition(const Box&) const override;
     void computeInFlowPositionedPosition(const Box&) const override;
 
-    InstrinsicWidthConstraints instrinsicWidthConstraints(const Box&) const override;
+    InstrinsicWidthConstraints instrinsicWidthConstraints() const override;
 };
 
 }
index dbd9faf..7c9e29e 100644 (file)
@@ -37,7 +37,7 @@
 namespace WebCore {
 namespace Layout {
 
-WidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(const LayoutState& layoutState, const Box& formattingContextRoot)
+WidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(LayoutState& layoutState, const Box& formattingContextRoot)
 {
     ASSERT(formattingContextRoot.isInFlow());
 
@@ -55,10 +55,8 @@ WidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(cons
     auto containingBlockWidth = layoutState.displayBoxForLayoutBox(containingBlock).contentBoxWidth();
     // #1
     auto width = computedValueIfNotAuto(formattingContextRoot.style().logicalWidth(), containingBlockWidth);
-    if (!width) {
-        auto formattingContext = layoutState.establishedFormattingState(formattingContextRoot).formattingContext(formattingContextRoot);
-        width = shrinkToFitWidth(layoutState, *formattingContext, formattingContextRoot);
-    }
+    if (!width)
+        width = shrinkToFitWidth(layoutState, formattingContextRoot);
 
     // #2
     auto margin = computedNonCollapsedHorizontalMarginValue(layoutState, formattingContextRoot);