⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 263260 in webkit


Ignore:
Timestamp:
Jun 19, 2020, 5:43:03 AM (6 years ago)
Author:
Alan Bujtas
Message:

[LFC][BFC] Min/max-width should always be resolved against the containing block width
https://bugs.webkit.org/show_bug.cgi?id=213365

Reviewed by Antti Koivisto.

Source/WebCore:

Even when neighboring floats shrink the available horizontal space, the min/max(normal) widths should
be resolved against the containing block's logical width.

Test: fast/layoutformattingcontext/float-avoider-available-horizontal-space2.html

  • layout/blockformatting/BlockFormattingContext.cpp:

(WebCore::Layout::BlockFormattingContext::computeWidthAndMargin):

  • layout/blockformatting/BlockFormattingContext.h:
  • layout/blockformatting/BlockFormattingContextGeometry.cpp:

(WebCore::Layout::BlockFormattingContext::Geometry::computedWidthAndMargin):

  • layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:

(WebCore::Layout::TableWrapperBlockFormattingContext::computeWidthAndMarginForTableBox):

LayoutTests:

  • fast/layoutformattingcontext/float-avoider-available-horizontal-space2-expected.html: Added.
  • fast/layoutformattingcontext/float-avoider-available-horizontal-space2.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r263255 r263260  
     12020-06-19  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][BFC] Min/max-width should always be resolved against the containing block width
     4        https://bugs.webkit.org/show_bug.cgi?id=213365
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/layoutformattingcontext/float-avoider-available-horizontal-space2-expected.html: Added.
     9        * fast/layoutformattingcontext/float-avoider-available-horizontal-space2.html: Added.
     10
    1112020-06-19  Myles C. Maxfield  <mmaxfield@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r263256 r263260  
     12020-06-19  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][BFC] Min/max-width should always be resolved against the containing block width
     4        https://bugs.webkit.org/show_bug.cgi?id=213365
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Even when neighboring floats shrink the available horizontal space, the min/max(normal) widths should
     9        be resolved against the containing block's logical width.
     10
     11        Test: fast/layoutformattingcontext/float-avoider-available-horizontal-space2.html
     12
     13        * layout/blockformatting/BlockFormattingContext.cpp:
     14        (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin):
     15        * layout/blockformatting/BlockFormattingContext.h:
     16        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
     17        (WebCore::Layout::BlockFormattingContext::Geometry::computedWidthAndMargin):
     18        * layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:
     19        (WebCore::Layout::TableWrapperBlockFormattingContext::computeWidthAndMarginForTableBox):
     20
    1212020-06-10  Sergio Villar Senin  <svillar@igalia.com>
    222
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp

    r263221 r263260  
    315315void BlockFormattingContext::computeWidthAndMargin(const FloatingContext& floatingContext, const Box& layoutBox, const ConstraintsPair& constraintsPair)
    316316{
    317     auto adjustedConstraints = constraintsPair;
    318     if (layoutBox.isFloatAvoider() && layoutBox.style().logicalWidth().isAuto()) {
     317    auto availableWidthFloatAvoider = Optional<LayoutUnit> { };
     318    if (layoutBox.isFloatAvoider()) {
    319319        // Float avoiders' available width might be shrunk by existing floats in the context.
    320         if (auto availableWidthForFloatAvoider = usedAvailableWidthForFloatAvoider(floatingContext, layoutBox, constraintsPair))
    321             adjustedConstraints.containingBlock.horizontal.logicalWidth = *availableWidthForFloatAvoider;
    322     }
    323 
    324     auto contentWidthAndMargin = geometry().computedWidthAndMargin(layoutBox, adjustedConstraints);
     320        availableWidthFloatAvoider = usedAvailableWidthForFloatAvoider(floatingContext, layoutBox, constraintsPair);
     321    }
     322    auto contentWidthAndMargin = geometry().computedWidthAndMargin(layoutBox, constraintsPair.containingBlock.horizontal, availableWidthFloatAvoider);
    325323    auto& displayBox = formattingState().displayBox(layoutBox);
    326324    displayBox.setContentBoxWidth(contentWidthAndMargin.contentWidth);
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h

    r263155 r263260  
    8686        IntrinsicWidthConstraints intrinsicWidthConstraints(const Box&);
    8787
    88         ContentWidthAndMargin computedWidthAndMargin(const Box&, const ConstraintsPair&);
     88        ContentWidthAndMargin computedWidthAndMargin(const Box&, const HorizontalConstraints&, Optional<LayoutUnit> availableWidthFloatAvoider);
    8989
    9090    private:
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp

    r262951 r263260  
    284284}
    285285
    286 ContentWidthAndMargin BlockFormattingContext::Geometry::computedWidthAndMargin(const Box& layoutBox, const ConstraintsPair& constraintsPair)
    287 {
    288     auto& horizontalConstraints = constraintsPair.containingBlock.horizontal;
    289     auto compute = [&](Optional<LayoutUnit> usedWidth) {
     286ContentWidthAndMargin BlockFormattingContext::Geometry::computedWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, Optional<LayoutUnit> availableWidthFloatAvoider)
     287{
     288    auto compute = [&] (auto constraintsForWidth, Optional<LayoutUnit> usedWidth) {
    290289        if (layoutBox.isFloatingPositioned())
    291             return floatingWidthAndMargin(layoutBox, horizontalConstraints, { usedWidth, { } });
     290            return floatingWidthAndMargin(layoutBox, constraintsForWidth, { usedWidth, { } });
    292291
    293292        if (layoutBox.isInFlow())
    294             return inFlowWidthAndMargin(layoutBox, horizontalConstraints, { usedWidth, { } });
     293            return inFlowWidthAndMargin(layoutBox, constraintsForWidth, { usedWidth, { } });
    295294
    296295        ASSERT_NOT_REACHED();
     
    298297    };
    299298
    300     auto contentWidthAndMargin = compute({ });
    301 
     299    auto horizontalConstraintsForWidth = horizontalConstraints;
     300    if (layoutBox.style().logicalWidth().isAuto() && availableWidthFloatAvoider) {
     301        // While the non-auto width values should all be resolved against the containing block's width, when
     302        // the width is auto the available horizontal space is shrunk by neighboring floats.
     303        horizontalConstraintsForWidth.logicalWidth = *availableWidthFloatAvoider;
     304    }
     305    auto contentWidthAndMargin = compute(horizontalConstraintsForWidth, { });
    302306    auto availableWidth = horizontalConstraints.logicalWidth;
    303307    if (auto maxWidth = computedMaxWidth(layoutBox, availableWidth)) {
    304         auto maxWidthAndMargin = compute(maxWidth);
     308        auto maxWidthAndMargin = compute(horizontalConstraints, maxWidth);
    305309        if (contentWidthAndMargin.contentWidth > maxWidthAndMargin.contentWidth)
    306310            contentWidthAndMargin = maxWidthAndMargin;
     
    308312
    309313    auto minWidth = computedMinWidth(layoutBox, availableWidth).valueOr(0);
    310     auto minWidthAndMargin = compute(minWidth);
     314    auto minWidthAndMargin = compute(horizontalConstraints, minWidth);
    311315    if (contentWidthAndMargin.contentWidth < minWidthAndMargin.contentWidth)
    312316        contentWidthAndMargin = minWidthAndMargin;
  • trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp

    r262951 r263260  
    146146    ASSERT(tableBox.isTableBox());
    147147    if (!tableBox.hasChild()) {
    148         auto constraintsPair = ConstraintsPair { { horizontalConstraints, { } }, { horizontalConstraints, { } } };
    149         auto computedWidthAndMargin = geometry().computedWidthAndMargin(tableBox, constraintsPair);
     148        auto computedWidthAndMargin = geometry().computedWidthAndMargin(tableBox, horizontalConstraints, { });
    150149        auto& displayBox = formattingState().displayBox(tableBox);
    151150        displayBox.setContentBoxWidth(computedWidthAndMargin.contentWidth);
Note: See TracChangeset for help on using the changeset viewer.