Changeset 254404 in webkit


Ignore:
Timestamp:
Jan 11, 2020 4:05:51 PM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][BFC] BlockFormattingContext::computeEstimatedVerticalPositionForAncestors should take ConstraintsPair<HorizontalConstraints>
https://bugs.webkit.org/show_bug.cgi?id=206121
<rdar://problem/58499492>

Reviewed by Antti Koivisto.

This prevents computeEstimatedVerticalPositionForAncestors from reading geometry outside of the formatting context.

  • layout/blockformatting/BlockFormattingContext.cpp:

(WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot):
(WebCore::Layout::BlockFormattingContext::computeStaticVerticalPosition):
(WebCore::Layout::BlockFormattingContext::computeStaticPosition):
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPositionForAncestors):
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPositionForFormattingRoot):
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPositionForFloatClear):

  • layout/blockformatting/BlockFormattingContext.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r254403 r254404  
     12020-01-11  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][BFC] BlockFormattingContext::computeEstimatedVerticalPositionForAncestors should take ConstraintsPair<HorizontalConstraints>
     4        https://bugs.webkit.org/show_bug.cgi?id=206121
     5        <rdar://problem/58499492>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        This prevents computeEstimatedVerticalPositionForAncestors from reading geometry outside of the formatting context.
     10
     11        * layout/blockformatting/BlockFormattingContext.cpp:
     12        (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot):
     13        (WebCore::Layout::BlockFormattingContext::computeStaticVerticalPosition):
     14        (WebCore::Layout::BlockFormattingContext::computeStaticPosition):
     15        (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
     16        (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPositionForAncestors):
     17        (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPositionForFormattingRoot):
     18        (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPositionForFloatClear):
     19        * layout/blockformatting/BlockFormattingContext.h:
     20
    1212020-01-11  Zalan Bujtas  <zalan@apple.com>
    222
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp

    r254403 r254404  
    201201
    202202    computeBorderAndPadding(layoutBox, adjustedHorizontalConstraints.containingBlock);
    203     computeStaticVerticalPosition(floatingContext, layoutBox, verticalConstraints);
     203    computeStaticVerticalPosition(floatingContext, layoutBox, horizontalConstraints, verticalConstraints);
    204204    computeWidthAndMargin(layoutBox, adjustedHorizontalConstraints);
    205205    computeStaticHorizontalPosition(layoutBox, adjustedHorizontalConstraints);
     
    242242}
    243243
    244 void BlockFormattingContext::computeStaticVerticalPosition(const FloatingContext& floatingContext, const Box& layoutBox, const ConstraintsPair<VerticalConstraints>& verticalConstraints)
     244void BlockFormattingContext::computeStaticVerticalPosition(const FloatingContext& floatingContext, const Box& layoutBox, const ConstraintsPair<HorizontalConstraints>& horizontalConstraints, const ConstraintsPair<VerticalConstraints>& verticalConstraints)
    245245{
    246246    formattingState().displayBox(layoutBox).setTop(geometry().staticVerticalPosition(layoutBox, verticalConstraints.containingBlock));
    247247    if (layoutBox.hasFloatClear())
    248         computeEstimatedVerticalPositionForFloatClear(floatingContext, layoutBox);
     248        computeEstimatedVerticalPositionForFloatClear(floatingContext, layoutBox, horizontalConstraints);
    249249    else if (layoutBox.establishesFormattingContext())
    250         computeEstimatedVerticalPositionForFormattingRoot(layoutBox);
     250        computeEstimatedVerticalPositionForFormattingRoot(layoutBox, horizontalConstraints);
    251251}
    252252
     
    258258void BlockFormattingContext::computeStaticPosition(const FloatingContext& floatingContext, const Box& layoutBox, const ConstraintsPair<HorizontalConstraints>& horizontalConstraints, const ConstraintsPair<VerticalConstraints>& verticalConstraints)
    259259{
    260     computeStaticVerticalPosition(floatingContext, layoutBox, verticalConstraints);
     260    computeStaticVerticalPosition(floatingContext, layoutBox, horizontalConstraints, verticalConstraints);
    261261    computeStaticHorizontalPosition(layoutBox, horizontalConstraints);
    262262}
    263263
    264 void BlockFormattingContext::computeEstimatedVerticalPosition(const Box& layoutBox)
    265 {
    266     auto horizontalConstraints = Geometry::horizontalConstraintsForInFlow(geometryForBox(*layoutBox.containingBlock()));
     264void BlockFormattingContext::computeEstimatedVerticalPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints)
     265{
    267266    auto computedVerticalMargin = geometry().computedVerticalMargin(layoutBox, horizontalConstraints);
    268267    auto usedNonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
     
    281280}
    282281
    283 void BlockFormattingContext::computeEstimatedVerticalPositionForAncestors(const Box& layoutBox)
     282void BlockFormattingContext::computeEstimatedVerticalPositionForAncestors(const Box& layoutBox, const ConstraintsPair<HorizontalConstraints>& horizontalConstraints)
    284283{
    285284    // We only need to estimate margin top for float related layout (formatting context roots avoid floats).
     
    299298        if (hasEstimatedMarginBefore(*ancestor))
    300299            return;
    301         computeEstimatedVerticalPosition(*ancestor);
    302     }
    303 }
    304 
    305 void BlockFormattingContext::computeEstimatedVerticalPositionForFormattingRoot(const Box& layoutBox)
     300        auto horizontalConstraintsForAncestor = horizontalConstraints.root;
     301        if (ancestor->containingBlock() != &root())
     302            horizontalConstraintsForAncestor = Geometry::horizontalConstraintsForInFlow(geometryForBox(*ancestor->containingBlock()));
     303        computeEstimatedVerticalPosition(*ancestor, horizontalConstraintsForAncestor);
     304    }
     305}
     306
     307void BlockFormattingContext::computeEstimatedVerticalPositionForFormattingRoot(const Box& layoutBox, const ConstraintsPair<HorizontalConstraints>& horizontalConstraints)
    306308{
    307309    ASSERT(layoutBox.establishesFormattingContext());
     
    309311
    310312    if (layoutBox.isFloatingPositioned()) {
    311         computeEstimatedVerticalPositionForAncestors(layoutBox);
     313        computeEstimatedVerticalPositionForAncestors(layoutBox, horizontalConstraints);
    312314        return;
    313315    }
    314316
    315     computeEstimatedVerticalPosition(layoutBox);
    316     computeEstimatedVerticalPositionForAncestors(layoutBox);
     317    computeEstimatedVerticalPosition(layoutBox, horizontalConstraints.containingBlock);
     318    computeEstimatedVerticalPositionForAncestors(layoutBox, horizontalConstraints);
    317319
    318320    // If the inline formatting root is also the root for the floats (happens when the root box also establishes a block formatting context)
     
    320322    auto inlineContextInheritsFloats = layoutBox.establishesInlineFormattingContextOnly();
    321323    if (inlineContextInheritsFloats) {
    322         computeEstimatedVerticalPosition(layoutBox);
    323         computeEstimatedVerticalPositionForAncestors(layoutBox);
    324     }
    325 }
    326 
    327 void BlockFormattingContext::computeEstimatedVerticalPositionForFloatClear(const FloatingContext& floatingContext, const Box& layoutBox)
     324        computeEstimatedVerticalPosition(layoutBox, horizontalConstraints.containingBlock);
     325        computeEstimatedVerticalPositionForAncestors(layoutBox, horizontalConstraints);
     326    }
     327}
     328
     329void BlockFormattingContext::computeEstimatedVerticalPositionForFloatClear(const FloatingContext& floatingContext, const Box& layoutBox, const ConstraintsPair<HorizontalConstraints>& horizontalConstraints)
    328330{
    329331    ASSERT(layoutBox.hasFloatClear());
     
    331333        return;
    332334    // The static position with clear requires margin esitmation to see if clearance is needed.
    333     computeEstimatedVerticalPosition(layoutBox);
    334     computeEstimatedVerticalPositionForAncestors(layoutBox);
     335    computeEstimatedVerticalPosition(layoutBox, horizontalConstraints.containingBlock);
     336    computeEstimatedVerticalPositionForAncestors(layoutBox, horizontalConstraints);
    335337    auto verticalPositionAndClearance = floatingContext.verticalPositionWithClearance(layoutBox);
    336338    if (!verticalPositionAndClearance.position) {
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h

    r254403 r254404  
    6565
    6666    void computeStaticHorizontalPosition(const Box&, const ConstraintsPair<HorizontalConstraints>&);
    67     void computeStaticVerticalPosition(const FloatingContext&, const Box&, const ConstraintsPair<VerticalConstraints>&);
     67    void computeStaticVerticalPosition(const FloatingContext&, const Box&, const ConstraintsPair<HorizontalConstraints>&, const ConstraintsPair<VerticalConstraints>&);
    6868    void computeStaticPosition(const FloatingContext&, const Box&, const ConstraintsPair<HorizontalConstraints>&, const ConstraintsPair<VerticalConstraints>&);
    6969    void computeFloatingPosition(const FloatingContext&, const Box&);
    7070    void computePositionToAvoidFloats(const FloatingContext&, const Box&);
    7171
    72     void computeEstimatedVerticalPosition(const Box&);
    73     void computeEstimatedVerticalPositionForAncestors(const Box&);
    74     void computeEstimatedVerticalPositionForFormattingRoot(const Box&);
    75     void computeEstimatedVerticalPositionForFloatClear(const FloatingContext&, const Box&);
     72    void computeEstimatedVerticalPosition(const Box&, const HorizontalConstraints&);
     73    void computeEstimatedVerticalPositionForAncestors(const Box&, const ConstraintsPair<HorizontalConstraints>&);
     74    void computeEstimatedVerticalPositionForFormattingRoot(const Box&, const ConstraintsPair<HorizontalConstraints>&);
     75    void computeEstimatedVerticalPositionForFloatClear(const FloatingContext&, const Box&, const ConstraintsPair<HorizontalConstraints>&);
    7676
    7777    IntrinsicWidthConstraints computedIntrinsicWidthConstraints() override;
Note: See TracChangeset for help on using the changeset viewer.