Changeset 233260 in webkit


Ignore:
Timestamp:
Jun 27, 2018 9:18:00 AM (6 years ago)
Author:
Alan Bujtas
Message:

[LFC] Move formatting context root layout logic to a dedicated function.
https://bugs.webkit.org/show_bug.cgi?id=187097

Reviewed by Antti Koivisto.

  • layout/blockformatting/BlockFormattingContext.cpp:

(WebCore::Layout::BlockFormattingContext::layout const):
(WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r233259 r233260  
     12018-06-27  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC] Move formatting context root layout logic to a dedicated function.
     4        https://bugs.webkit.org/show_bug.cgi?id=187097
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * layout/blockformatting/BlockFormattingContext.cpp:
     9        (WebCore::Layout::BlockFormattingContext::layout const):
     10        (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):
     11        * layout/blockformatting/BlockFormattingContext.h:
     12
    1132018-06-27  Zalan Bujtas  <zalan@apple.com>
    214
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp

    r232914 r233260  
    7878            auto& layoutBox = layoutPair.layoutBox;
    7979            auto& displayBox = layoutPair.displayBox;
     80
     81            if (layoutBox.establishesFormattingContext()) {
     82                layoutFormattingContextRoot(layoutContext, formattingState, layoutBox, displayBox);
     83                layoutQueue.removeLast();
     84                // Since this box is a formatting context root, it takes care of its entire subtree.
     85                break;
     86            }
    8087           
    8188            LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &layoutBox << ")");
     
    8390            computeBorderAndPadding(layoutContext, layoutBox, displayBox);
    8491            computeWidthAndMargin(layoutContext, layoutBox, displayBox);
    85             if (layoutBox.establishesFormattingContext()) {
    86                 auto formattingContext = layoutContext.formattingContext(layoutBox);
    87                 formattingContext->layout(layoutContext, layoutContext.establishedFormattingState(layoutBox, *formattingContext));
    88                 break;
    89             }
    9092            if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild())
    9193                break;
     
    100102            auto& layoutBox = layoutPair->layoutBox;
    101103            auto& displayBox = layoutPair->displayBox;
     104
    102105            LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Height][Margin] -> for layoutBox(" << &layoutBox << ")");
     106            // Formatting root boxes are special-cased and they don't come here.
     107            ASSERT(!layoutBox.establishesFormattingContext());
    103108
    104109            computeHeightAndMargin(layoutContext, layoutBox, displayBox);
     
    126131}
    127132
     133void BlockFormattingContext::layoutFormattingContextRoot(LayoutContext& layoutContext, FormattingState& formattingState, const Box& layoutBox, Display::Box& displayBox) const
     134{
     135    // Start laying out this formatting root in the formatting contenxt it lives in.
     136    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &layoutBox << ")");
     137    computeStaticPosition(layoutContext, layoutBox, displayBox);
     138    computeBorderAndPadding(layoutContext, layoutBox, displayBox);
     139    computeWidthAndMargin(layoutContext, layoutBox, displayBox);
     140
     141    // Swich over to the new formatting context (the one that the root creates).
     142    auto formattingContext = layoutContext.formattingContext(layoutBox);
     143    auto& establishedFormattingState = layoutContext.establishedFormattingState(layoutBox, *formattingContext);
     144    formattingContext->layout(layoutContext, establishedFormattingState);
     145
     146    // Come back and finalize the root's geometry.
     147    FloatingContext(formattingState.floatingState()).computePosition(layoutBox, displayBox);
     148    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Height][Margin] -> for layoutBox(" << &layoutBox << ")");
     149    computeHeightAndMargin(layoutContext, layoutBox, displayBox);
     150}
     151
    128152std::unique_ptr<FormattingState> BlockFormattingContext::createFormattingState(Ref<FloatingState>&& floatingState) const
    129153{
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h

    r233188 r233260  
    5252
    5353private:
     54    void layoutFormattingContextRoot(LayoutContext&, FormattingState&, const Box&, Display::Box&) const;
     55
    5456    void computeWidthAndMargin(LayoutContext&, const Box&, Display::Box&) const;
    5557    void computeHeightAndMargin(LayoutContext&, const Box&, Display::Box&) const;
Note: See TracChangeset for help on using the changeset viewer.