Changeset 257507 in webkit


Ignore:
Timestamp:
Feb 26, 2020 1:30:58 PM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][BFC][MarginCollapsing] Decouple regular and pre-computed margin collapsing logic
https://bugs.webkit.org/show_bug.cgi?id=208247
<rdar://problem/59808951>

Reviewed by Antti Koivisto.

The pre-computed path is so peculiar it deserves a dedicated file.

This is in preparation for fixing a flaw in the pre-computed logic where we end up
accessing a not-yet-computed horizontal constraint. No change in functionality at this point.

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • layout/blockformatting/BlockFormattingContext.h:
  • layout/blockformatting/BlockMarginCollapse.cpp:

(WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeValues const):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedMarginBefore): Deleted.

  • layout/blockformatting/PrecomputedBlockMarginCollapse.cpp: Added.

(WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeValues const):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeMarginBefore const):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedMarginBefore):

  • layout/integration/LayoutIntegrationBoxTree.cpp:
Location:
trunk/Source/WebCore
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r257505 r257507  
     12020-02-26  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][BFC][MarginCollapsing] Decouple regular and pre-computed margin collapsing logic
     4        https://bugs.webkit.org/show_bug.cgi?id=208247
     5        <rdar://problem/59808951>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        The pre-computed path is so peculiar it deserves a dedicated file.
     10
     11        This is in preparation for fixing a flaw in the pre-computed logic where we end up
     12        accessing a not-yet-computed horizontal constraint. No change in functionality at this point.
     13
     14        * Sources.txt:
     15        * WebCore.xcodeproj/project.pbxproj:
     16        * layout/blockformatting/BlockFormattingContext.h:
     17        * layout/blockformatting/BlockMarginCollapse.cpp:
     18        (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeValues const):
     19        (WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedMarginBefore): Deleted.
     20        * layout/blockformatting/PrecomputedBlockMarginCollapse.cpp: Added.
     21        (WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeValues const):
     22        (WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeMarginBefore const):
     23        (WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedMarginBefore):
     24        * layout/integration/LayoutIntegrationBoxTree.cpp:
     25
    1262020-02-26  Keith Rollin  <krollin@apple.com>
    227
  • trunk/Source/WebCore/Sources.txt

    r257156 r257507  
    14311431layout/blockformatting/BlockFormattingState.cpp
    14321432layout/blockformatting/BlockMarginCollapse.cpp
     1433layout/blockformatting/PrecomputedBlockMarginCollapse.cpp
    14331434layout/displaytree/DisplayBox.cpp
    14341435layout/displaytree/DisplayInlineContent.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r257394 r257507  
    93289328                6F995A2F1A70833700A735F4 /* JSWebGLVertexArrayObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLVertexArrayObject.cpp; sourceTree = "<group>"; };
    93299329                6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLVertexArrayObject.h; sourceTree = "<group>"; };
     9330                6FAE16BA2406DE7E00A48414 /* PrecomputedBlockMarginCollapse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PrecomputedBlockMarginCollapse.cpp; sourceTree = "<group>"; };
    93309331                6FB11B5921783FCF00E2A574 /* TextUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUtil.h; sourceTree = "<group>"; };
    93319332                6FB11B5B21783FCF00E2A574 /* TextUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextUtil.cpp; sourceTree = "<group>"; };
     
    1676816769                                115CFA78208B8D9D001E6991 /* BlockFormattingState.h */,
    1676916770                                115CFA89208B921A001E6991 /* BlockMarginCollapse.cpp */,
     16771                                6FAE16BA2406DE7E00A48414 /* PrecomputedBlockMarginCollapse.cpp */,
    1677016772                        );
    1677116773                        path = blockformatting;
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h

    r256840 r257507  
    131131        PositiveAndNegativeVerticalMargin::Values positiveNegativeMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues) const;
    132132        PositiveAndNegativeVerticalMargin::Values positiveNegativeMarginAfter(const Box&, UsedVerticalMargin::NonCollapsedValues) const;
     133
     134        PositiveAndNegativeVerticalMargin::Values precomputedPositiveNegativeMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues) const;
     135        PositiveAndNegativeVerticalMargin::Values precomputedPositiveNegativeValues(const Box&, MarginType) const;
     136
    133137        bool hasClearance(const Box&) const;
    134138
  • trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp

    r256417 r257507  
    508508PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::positiveNegativeValues(const Box& layoutBox, MarginType marginType) const
    509509{
    510     auto& layoutState = this->layoutState();
    511     auto& blockFormattingState = downcast<BlockFormattingState>(layoutState.formattingStateForBox(layoutBox));
    512     if (blockFormattingState.hasPositiveAndNegativeVerticalMargin(layoutBox)) {
    513         auto positiveAndNegativeVerticalMargin = blockFormattingState.positiveAndNegativeVerticalMargin(layoutBox);
    514         return marginType == MarginType::Before ? positiveAndNegativeVerticalMargin.before : positiveAndNegativeVerticalMargin.after;
    515     }
    516     // This is the pre-computed path. We don't yet have positive/negative margin computed.
    517     auto computedVerticalMargin = formattingContext().geometry().computedVerticalMargin(layoutBox, Geometry::horizontalConstraintsForInFlow(formattingContext().geometryForBox(*layoutBox.containingBlock())));
    518     auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
    519 
    520     if (marginType == MarginType::Before)
    521         return positiveNegativeMarginBefore(layoutBox, nonCollapsedMargin);
    522     return positiveNegativeMarginAfter(layoutBox, nonCollapsedMargin);
     510    auto& blockFormattingState = downcast<BlockFormattingState>(layoutState().formattingStateForBox(layoutBox));
     511    // By the time we get here in BFC layout to gather positive and negative margin values for a either a previous sibling or a child box,
     512    // we mush have computed and cached those valued.
     513    ASSERT(blockFormattingState.hasPositiveAndNegativeVerticalMargin(layoutBox));
     514    auto positiveAndNegativeVerticalMargin = blockFormattingState.positiveAndNegativeVerticalMargin(layoutBox);
     515    return marginType == MarginType::Before ? positiveAndNegativeVerticalMargin.before : positiveAndNegativeVerticalMargin.after;
    523516}
    524517
     
    572565}
    573566
    574 PrecomputedMarginBefore BlockFormattingContext::MarginCollapse::precomputedMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues usedNonCollapsedMargin)
    575 {
    576     ASSERT(layoutBox.isBlockLevelBox());
    577     // Don't pre-compute vertical margins for out of flow boxes.
    578     ASSERT(layoutBox.isInFlow() || layoutBox.isFloatingPositioned());
    579     ASSERT(!layoutBox.isReplacedBox());
    580 
    581     auto marginsCollapseThrough = this->marginsCollapseThrough(layoutBox);
    582     auto positiveNegativeMarginBefore = this->positiveNegativeMarginBefore(layoutBox, usedNonCollapsedMargin);
    583 
    584     auto collapsedMarginBefore = marginValue(!marginsCollapseThrough ? positiveNegativeMarginBefore
    585         : computedPositiveAndNegativeMargin(positiveNegativeMarginBefore, positiveNegativeMarginAfter(layoutBox, usedNonCollapsedMargin)));
    586 
    587     return { usedNonCollapsedMargin.before, collapsedMarginBefore, marginsCollapseThrough };
    588 }
    589 
    590567LayoutUnit BlockFormattingContext::MarginCollapse::marginBeforeIgnoringCollapsingThrough(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues)
    591568{
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp

    r256311 r257507  
    2929#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    3030
     31#include "LayoutInlineTextBox.h"
    3132#include "LayoutLineBreakBox.h"
    3233#include "RenderBlockFlow.h"
Note: See TracChangeset for help on using the changeset viewer.