Changeset 256380 in webkit


Ignore:
Timestamp:
Feb 11, 2020 3:13:00 PM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC] Introduce Layout::ReplacedBox
https://bugs.webkit.org/show_bug.cgi?id=207561
<rdar://problem/59353151>

Reviewed by Antti Koivisto.

This is in preparation for making Layout::Box an "abstract" box (so that it stops being a leaf type of box).

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • layout/FormattingContext.cpp:

(WebCore::Layout::FormattingContext::validateGeometryConstraintsAfterLayout const):

  • layout/FormattingContext.h:
  • layout/FormattingContextGeometry.cpp:

(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry const):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry const):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry const):
(WebCore::Layout::FormattingContext::Geometry::complicatedCases const):
(WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin const):
(WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin const):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowVerticalGeometry const):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin const):
(WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin):
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin const):
(WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin const):

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

(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin const):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::intrinsicWidthConstraints):

  • layout/blockformatting/BlockMarginCollapse.cpp:

(WebCore::Layout::BlockFormattingContext::MarginCollapse::marginsCollapseThrough const):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedMarginBefore):

  • layout/inlineformatting/InlineFormattingContext.cpp:

(WebCore::Layout::InlineFormattingContext::computedIntrinsicWidthConstraints):
(WebCore::Layout::InlineFormattingContext::computeWidthAndMargin):
(WebCore::Layout::InlineFormattingContext::computeHeightAndMargin):

  • layout/inlineformatting/InlineFormattingContextGeometry.cpp:

(WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockWidthAndMargin):
(WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockHeightAndMargin const):

  • layout/inlineformatting/InlineLineBuilder.cpp:

(WebCore::Layout::LineBuilder::append):
(WebCore::Layout::LineBuilder::appendReplacedInlineBox):
(WebCore::Layout::LineBuilder::runContentHeight const):
(WebCore::Layout::LineBuilder::isVisuallyNonEmpty const):

  • layout/inlineformatting/LineLayoutContext.cpp:

(WebCore::Layout::LineLayoutContext::inlineItemWidth const):

  • layout/layouttree/LayoutBox.cpp:

(WebCore::Layout::Box::Box):
(WebCore::Layout::Box::isInlineBox const):
(WebCore::Layout::Box::replaced const): Deleted.
(WebCore::Layout::Box::replaced): Deleted.

  • layout/layouttree/LayoutBox.h:

(WebCore::Layout::Box::isTableCell const):
(WebCore::Layout::Box::isReplacedBox const):
(WebCore::Layout::Box::isReplaced const): Deleted.

  • layout/layouttree/LayoutReplacedBox.cpp: Renamed from Source/WebCore/layout/layouttree/LayoutReplaced.cpp.

(WebCore::Layout::ReplacedBox::ReplacedBox):
(WebCore::Layout::ReplacedBox::hasIntrinsicWidth const):
(WebCore::Layout::ReplacedBox::hasIntrinsicHeight const):
(WebCore::Layout::ReplacedBox::hasIntrinsicRatio const):
(WebCore::Layout::ReplacedBox::intrinsicWidth const):
(WebCore::Layout::ReplacedBox::intrinsicHeight const):
(WebCore::Layout::ReplacedBox::intrinsicRatio const):
(WebCore::Layout::ReplacedBox::hasAspectRatio const):

  • layout/layouttree/LayoutReplacedBox.h: Renamed from Source/WebCore/layout/layouttree/LayoutReplaced.h.

(WebCore::Layout::ReplacedBox::setCachedImage):
(WebCore::Layout::ReplacedBox::cachedImage const):
(WebCore::Layout::ReplacedBox::setIntrinsicSize):
(WebCore::Layout::ReplacedBox::setIntrinsicRatio):

  • layout/layouttree/LayoutTreeBuilder.cpp:

(WebCore::Layout::TreeBuilder::createLayoutBox):
(WebCore::Layout::outputLayoutBox):

Location:
trunk/Source/WebCore
Files:
18 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r256377 r256380  
     12020-02-11  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC] Introduce Layout::ReplacedBox
     4        https://bugs.webkit.org/show_bug.cgi?id=207561
     5        <rdar://problem/59353151>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        This is in preparation for making Layout::Box an "abstract" box (so that it stops being a leaf type of box).
     10
     11        * Sources.txt:
     12        * WebCore.xcodeproj/project.pbxproj:
     13        * layout/FormattingContext.cpp:
     14        (WebCore::Layout::FormattingContext::validateGeometryConstraintsAfterLayout const):
     15        * layout/FormattingContext.h:
     16        * layout/FormattingContextGeometry.cpp:
     17        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry const):
     18        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
     19        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry const):
     20        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry const):
     21        (WebCore::Layout::FormattingContext::Geometry::complicatedCases const):
     22        (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin):
     23        (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin const):
     24        (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin const):
     25        (WebCore::Layout::FormattingContext::Geometry::outOfFlowVerticalGeometry const):
     26        (WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry):
     27        (WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin const):
     28        (WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin):
     29        (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin const):
     30        (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin const):
     31        * layout/blockformatting/BlockFormattingContext.h:
     32        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
     33        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
     34        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin const):
     35        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
     36        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin):
     37        (WebCore::Layout::BlockFormattingContext::Geometry::intrinsicWidthConstraints):
     38        * layout/blockformatting/BlockMarginCollapse.cpp:
     39        (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginsCollapseThrough const):
     40        (WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedMarginBefore):
     41        * layout/inlineformatting/InlineFormattingContext.cpp:
     42        (WebCore::Layout::InlineFormattingContext::computedIntrinsicWidthConstraints):
     43        (WebCore::Layout::InlineFormattingContext::computeWidthAndMargin):
     44        (WebCore::Layout::InlineFormattingContext::computeHeightAndMargin):
     45        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
     46        (WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockWidthAndMargin):
     47        (WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockHeightAndMargin const):
     48        * layout/inlineformatting/InlineLineBuilder.cpp:
     49        (WebCore::Layout::LineBuilder::append):
     50        (WebCore::Layout::LineBuilder::appendReplacedInlineBox):
     51        (WebCore::Layout::LineBuilder::runContentHeight const):
     52        (WebCore::Layout::LineBuilder::isVisuallyNonEmpty const):
     53        * layout/inlineformatting/LineLayoutContext.cpp:
     54        (WebCore::Layout::LineLayoutContext::inlineItemWidth const):
     55        * layout/layouttree/LayoutBox.cpp:
     56        (WebCore::Layout::Box::Box):
     57        (WebCore::Layout::Box::isInlineBox const):
     58        (WebCore::Layout::Box::replaced const): Deleted.
     59        (WebCore::Layout::Box::replaced): Deleted.
     60        * layout/layouttree/LayoutBox.h:
     61        (WebCore::Layout::Box::isTableCell const):
     62        (WebCore::Layout::Box::isReplacedBox const):
     63        (WebCore::Layout::Box::isReplaced const): Deleted.
     64        * layout/layouttree/LayoutReplacedBox.cpp: Renamed from Source/WebCore/layout/layouttree/LayoutReplaced.cpp.
     65        (WebCore::Layout::ReplacedBox::ReplacedBox):
     66        (WebCore::Layout::ReplacedBox::hasIntrinsicWidth const):
     67        (WebCore::Layout::ReplacedBox::hasIntrinsicHeight const):
     68        (WebCore::Layout::ReplacedBox::hasIntrinsicRatio const):
     69        (WebCore::Layout::ReplacedBox::intrinsicWidth const):
     70        (WebCore::Layout::ReplacedBox::intrinsicHeight const):
     71        (WebCore::Layout::ReplacedBox::intrinsicRatio const):
     72        (WebCore::Layout::ReplacedBox::hasAspectRatio const):
     73        * layout/layouttree/LayoutReplacedBox.h: Renamed from Source/WebCore/layout/layouttree/LayoutReplaced.h.
     74        (WebCore::Layout::ReplacedBox::setCachedImage):
     75        (WebCore::Layout::ReplacedBox::cachedImage const):
     76        (WebCore::Layout::ReplacedBox::setIntrinsicSize):
     77        (WebCore::Layout::ReplacedBox::setIntrinsicRatio):
     78        * layout/layouttree/LayoutTreeBuilder.cpp:
     79        (WebCore::Layout::TreeBuilder::createLayoutBox):
     80        (WebCore::Layout::outputLayoutBox):
     81
    1822020-02-11  Youenn Fablet  <youenn@apple.com>
    283
  • trunk/Source/WebCore/Headers.cmake

    r256304 r256380  
    686686
    687687    layout/layouttree/LayoutBox.h
    688     layout/layouttree/LayoutReplaced.h
    689688
    690689    loader/AdClickAttribution.h
  • trunk/Source/WebCore/Sources.txt

    r256311 r256380  
    14541454layout/layouttree/LayoutInlineTextBox.cpp
    14551455layout/layouttree/LayoutLineBreakBox.cpp
    1456 layout/layouttree/LayoutReplaced.cpp
     1456layout/layouttree/LayoutReplacedBox.cpp
    14571457layout/layouttree/LayoutTreeBuilder.cpp
    14581458layout/tableformatting/TableFormattingContext.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r256372 r256380  
    375375                112FB352239C23C40087054A /* DisplayInlineRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 112FB350239C23C40087054A /* DisplayInlineRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
    376376                11310CF220BA4A320065A8D0 /* LayoutTreeBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 11100FD7209514DF0081AA6C /* LayoutTreeBuilder.h */; settings = {ATTRIBUTES = (Private, ); }; };
    377                 11310CF320BA4A370065A8D0 /* LayoutReplaced.h in Headers */ = {isa = PBXBuildFile; fileRef = 111C615620AD1AE1005B82FA /* LayoutReplaced.h */; settings = {ATTRIBUTES = (Private, ); }; };
     377                11310CF320BA4A370065A8D0 /* LayoutReplacedBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 111C615620AD1AE1005B82FA /* LayoutReplacedBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
    378378                11310CF420BA4A3D0065A8D0 /* LayoutIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 11100FC72092764C0081AA6C /* LayoutIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    379379                11310CF520BA4A4C0065A8D0 /* LayoutDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 11B042FB20B0E21400828A6B /* LayoutDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    58975897                11100FD5209514DE0081AA6C /* LayoutTreeBuilder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutTreeBuilder.cpp; sourceTree = "<group>"; };
    58985898                11100FD7209514DF0081AA6C /* LayoutTreeBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutTreeBuilder.h; sourceTree = "<group>"; };
    5899                 111C615620AD1AE1005B82FA /* LayoutReplaced.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutReplaced.h; sourceTree = "<group>"; };
    5900                 111C615720AD1AE1005B82FA /* LayoutReplaced.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutReplaced.cpp; sourceTree = "<group>"; };
     5899                111C615620AD1AE1005B82FA /* LayoutReplacedBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutReplacedBox.h; sourceTree = "<group>"; };
     5900                111C615720AD1AE1005B82FA /* LayoutReplacedBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutReplacedBox.cpp; sourceTree = "<group>"; };
    59015901                112B34D01E60B8A700BB310A /* SimpleLineLayoutPagination.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutPagination.cpp; sourceTree = "<group>"; };
    59025902                112B34D41E60B98300BB310A /* SimpleLineLayoutPagination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutPagination.h; sourceTree = "<group>"; };
     
    1673816738                                6FFA4BFE23F2FECD007E4EBC /* LayoutLineBreakBox.cpp */,
    1673916739                                6FFA4C0023F2FED9007E4EBC /* LayoutLineBreakBox.h */,
    16740                                 111C615720AD1AE1005B82FA /* LayoutReplaced.cpp */,
    16741                                 111C615620AD1AE1005B82FA /* LayoutReplaced.h */,
     16740                                111C615720AD1AE1005B82FA /* LayoutReplacedBox.cpp */,
     16741                                111C615620AD1AE1005B82FA /* LayoutReplacedBox.h */,
    1674216742                                11100FD5209514DE0081AA6C /* LayoutTreeBuilder.cpp */,
    1674316743                                11100FD7209514DF0081AA6C /* LayoutTreeBuilder.h */,
     
    3129131291                                141DC053164834B900371E5A /* LayoutRect.h in Headers */,
    3129231292                                A12538D413F9B60A00024754 /* LayoutRepainter.h in Headers */,
    31293                                 11310CF320BA4A370065A8D0 /* LayoutReplaced.h in Headers */,
     31293                                11310CF320BA4A370065A8D0 /* LayoutReplacedBox.h in Headers */,
    3129431294                                141DC054164834B900371E5A /* LayoutSize.h in Headers */,
    3129531295                                6F7CA3C6208C2957002F29AB /* LayoutState.h in Headers */,
  • trunk/Source/WebCore/layout/FormattingContext.cpp

    r254933 r256380  
    3636#include "LayoutContext.h"
    3737#include "LayoutDescendantIterator.h"
     38#include "LayoutReplacedBox.h"
    3839#include "LayoutState.h"
    3940#include "Logging.h"
     
    325326        // 10.3.3 Block-level, non-replaced elements in normal flow
    326327        // 10.3.7 Absolutely positioned, non-replaced elements
    327         if ((layoutBox.isBlockLevelBox() || layoutBox.isOutOfFlowPositioned()) && !layoutBox.replaced()) {
     328        if ((layoutBox.isBlockLevelBox() || layoutBox.isOutOfFlowPositioned()) && !layoutBox.isReplacedBox()) {
    328329            // margin-left + border-left-width + padding-left + width + padding-right + border-right-width + margin-right = width of containing block
    329330            auto containingBlockWidth = containingBlockGeometry.contentBoxWidth();
     
    332333
    333334        // 10.6.4 Absolutely positioned, non-replaced elements
    334         if (layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced()) {
     335        if (layoutBox.isOutOfFlowPositioned() && !layoutBox.isReplacedBox()) {
    335336            // top + margin-top + border-top-width + padding-top + height + padding-bottom + border-bottom-width + margin-bottom + bottom = height of containing block
    336337            auto containingBlockHeight = containingBlockGeometry.contentBoxHeight();
  • trunk/Source/WebCore/layout/FormattingContext.h

    r254336 r256380  
    4545
    4646class Box;
     47class ReplacedBox;
    4748struct ComputedHorizontalMargin;
    4849struct ComputedVerticalMargin;
     
    119120        ContentWidthAndMargin floatingWidthAndMargin(const Box&, const HorizontalConstraints&, const OverrideHorizontalValues&);
    120121
    121         ContentHeightAndMargin inlineReplacedHeightAndMargin(const Box&, const HorizontalConstraints&, Optional<VerticalConstraints>, const OverrideVerticalValues&) const;
    122         ContentWidthAndMargin inlineReplacedWidthAndMargin(const Box&, const HorizontalConstraints&, const OverrideHorizontalValues&) const;
     122        ContentHeightAndMargin inlineReplacedHeightAndMargin(const ReplacedBox&, const HorizontalConstraints&, Optional<VerticalConstraints>, const OverrideVerticalValues&) const;
     123        ContentWidthAndMargin inlineReplacedWidthAndMargin(const ReplacedBox&, const HorizontalConstraints&, const OverrideHorizontalValues&) const;
    123124
    124125        LayoutSize inFlowPositionedPositionOffset(const Box&, const HorizontalConstraints&) const;
     
    165166
    166167    private:
    167         VerticalGeometry outOfFlowReplacedVerticalGeometry(const Box&, const HorizontalConstraints&, const VerticalConstraints&, const OverrideVerticalValues&) const;
    168         HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const Box&, const HorizontalConstraints&, const OverrideHorizontalValues&) const;
     168        VerticalGeometry outOfFlowReplacedVerticalGeometry(const ReplacedBox&, const HorizontalConstraints&, const VerticalConstraints&, const OverrideVerticalValues&) const;
     169        HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const ReplacedBox&, const HorizontalConstraints&, const OverrideHorizontalValues&) const;
    169170
    170171        VerticalGeometry outOfFlowNonReplacedVerticalGeometry(const Box&, const HorizontalConstraints&, const VerticalConstraints&, const OverrideVerticalValues&) const;
    171172        HorizontalGeometry outOfFlowNonReplacedHorizontalGeometry(const Box&, const HorizontalConstraints&, const OverrideHorizontalValues&);
    172173
    173         ContentHeightAndMargin floatingReplacedHeightAndMargin(const Box&, const HorizontalConstraints&, const OverrideVerticalValues&) const;
    174         ContentWidthAndMargin floatingReplacedWidthAndMargin(const Box&, const HorizontalConstraints&, const OverrideHorizontalValues&) const;
     174        ContentHeightAndMargin floatingReplacedHeightAndMargin(const ReplacedBox&, const HorizontalConstraints&, const OverrideVerticalValues&) const;
     175        ContentWidthAndMargin floatingReplacedWidthAndMargin(const ReplacedBox&, const HorizontalConstraints&, const OverrideHorizontalValues&) const;
    175176
    176177        ContentWidthAndMargin floatingNonReplacedWidthAndMargin(const Box&, const HorizontalConstraints&, const OverrideHorizontalValues&);
  • trunk/Source/WebCore/layout/FormattingContextGeometry.cpp

    r255257 r256380  
    300300VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
    301301{
    302     ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced());
     302    ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.isReplacedBox());
    303303    ASSERT(verticalConstraints.logicalHeight);
    304304
     
    419419HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues)
    420420{
    421     ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced());
     421    ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.isReplacedBox());
    422422   
    423423    // 10.3.7 Absolutely positioned, non-replaced elements
     
    560560}
    561561
    562 VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
    563 {
    564     ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced());
     562VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry(const ReplacedBox& replacedBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
     563{
     564    ASSERT(replacedBox.isOutOfFlowPositioned());
    565565    ASSERT(verticalConstraints.logicalHeight);
    566566
     
    576576
    577577    auto& formattingContext = this->formattingContext();
    578     auto& style = layoutBox.style();
    579     auto& boxGeometry = formattingContext.geometryForBox(layoutBox);
     578    auto& style = replacedBox.style();
     579    auto& boxGeometry = formattingContext.geometryForBox(replacedBox);
    580580    auto containingBlockHeight = *verticalConstraints.logicalHeight;
    581581    auto containingBlockWidth = horizontalConstraints.logicalWidth;
     
    583583    auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth);
    584584    auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth);
    585     auto height = inlineReplacedHeightAndMargin(layoutBox, horizontalConstraints, verticalConstraints, overrideVerticalValues).contentHeight;
    586     auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, horizontalConstraints);
     585    auto height = inlineReplacedHeightAndMargin(replacedBox, horizontalConstraints, verticalConstraints, overrideVerticalValues).contentHeight;
     586    auto computedVerticalMargin = Geometry::computedVerticalMargin(replacedBox, horizontalConstraints);
    587587    Optional<LayoutUnit> usedMarginBefore = computedVerticalMargin.before;
    588588    Optional<LayoutUnit> usedMarginAfter = computedVerticalMargin.after;
     
    594594    if (!top && !bottom) {
    595595        // #1
    596         top = staticVerticalPositionForOutOfFlowPositioned(layoutBox, verticalConstraints);
     596        top = staticVerticalPositionForOutOfFlowPositioned(replacedBox, verticalConstraints);
    597597    }
    598598
     
    638638    ASSERT(usedMarginBefore);
    639639    ASSERT(usedMarginAfter);
    640     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow replaced -> top(" << *top << "px) bottom("  << *bottom << "px) height(" << height << "px) margin(" << *usedMarginBefore << "px, "  << *usedMarginAfter << "px) layoutBox(" << &layoutBox << ")");
     640    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow replaced -> top(" << *top << "px) bottom("  << *bottom << "px) height(" << height << "px) margin(" << *usedMarginBefore << "px, "  << *usedMarginAfter << "px) layoutBox(" << &replacedBox << ")");
    641641    return { *top, *bottom, { height, { *usedMarginBefore, *usedMarginAfter } } };
    642642}
    643643
    644 HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues) const
    645 {
    646     ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced());
     644HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(const ReplacedBox& replacedBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues) const
     645{
     646    ASSERT(replacedBox.isOutOfFlowPositioned());
    647647
    648648    // 10.3.8 Absolutely positioned, replaced elements
     
    661661
    662662    auto& formattingContext = this->formattingContext();
    663     auto& style = layoutBox.style();
    664     auto& boxGeometry = formattingContext.geometryForBox(layoutBox);
     663    auto& style = replacedBox.style();
     664    auto& boxGeometry = formattingContext.geometryForBox(replacedBox);
    665665    auto containingBlockWidth = horizontalConstraints.logicalWidth;
    666     auto isLeftToRightDirection = layoutBox.containingBlock()->style().isLeftToRightDirection();
     666    auto isLeftToRightDirection = replacedBox.containingBlock()->style().isLeftToRightDirection();
    667667
    668668    auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
    669669    auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth);
    670     auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, horizontalConstraints);
     670    auto computedHorizontalMargin = Geometry::computedHorizontalMargin(replacedBox, horizontalConstraints);
    671671    Optional<LayoutUnit> usedMarginStart = computedHorizontalMargin.start;
    672672    Optional<LayoutUnit> usedMarginEnd = computedHorizontalMargin.end;
    673     auto width = inlineReplacedWidthAndMargin(layoutBox, horizontalConstraints, overrideHorizontalValues).contentWidth;
     673    auto width = inlineReplacedWidthAndMargin(replacedBox, horizontalConstraints, overrideHorizontalValues).contentWidth;
    674674    auto paddingLeft = boxGeometry.paddingLeft().valueOr(0);
    675675    auto paddingRight = boxGeometry.paddingRight().valueOr(0);
     
    679679    if (!left && !right) {
    680680        // #1
    681         auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutBox, horizontalConstraints);
     681        auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(replacedBox, horizontalConstraints);
    682682        if (isLeftToRightDirection)
    683683            left = staticHorizontalPosition;
     
    742742    *right += containingBlockPaddingVerticalEdge;
    743743
    744     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow replaced -> left(" << *left << "px) right("  << *right << "px) width(" << width << "px) margin(" << *usedMarginStart << "px, "  << *usedMarginEnd << "px) layoutBox(" << &layoutBox << ")");
     744    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow replaced -> left(" << *left << "px) right("  << *right << "px) width(" << width << "px) margin(" << *usedMarginStart << "px, "  << *usedMarginEnd << "px) layoutBox(" << &replacedBox << ")");
    745745    return { *left, *right, { width, { *usedMarginStart, *usedMarginEnd }, computedHorizontalMargin } };
    746746}
     
    748748ContentHeightAndMargin FormattingContext::Geometry::complicatedCases(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
    749749{
    750     ASSERT(!layoutBox.replaced());
     750    ASSERT(!layoutBox.isReplacedBox());
    751751    // TODO: Use complicated-case for document renderer for now (see BlockFormattingContext::Geometry::inFlowHeightAndMargin).
    752752    ASSERT((layoutBox.isBlockLevelBox() && layoutBox.isInFlow() && !layoutBox.isOverflowVisible()) || layoutBox.isInlineBlockBox() || layoutBox.isFloatingPositioned() || layoutBox.isDocumentBox() || layoutBox.isTableBox());
     
    779779ContentWidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues)
    780780{
    781     ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced());
     781    ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.isReplacedBox());
    782782
    783783    // 10.3.5 Floating, non-replaced elements
     
    799799}
    800800
    801 ContentHeightAndMargin FormattingContext::Geometry::floatingReplacedHeightAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
    802 {
    803     ASSERT(layoutBox.isFloatingPositioned() && layoutBox.replaced());
     801ContentHeightAndMargin FormattingContext::Geometry::floatingReplacedHeightAndMargin(const ReplacedBox& replacedBox, const HorizontalConstraints& horizontalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
     802{
     803    ASSERT(replacedBox.isFloatingPositioned());
    804804
    805805    // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block'
    806806    // replaced elements in normal flow and floating replaced elements
    807807    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating replaced -> redirected to inline replaced");
    808     return inlineReplacedHeightAndMargin(layoutBox, horizontalConstraints, { }, overrideVerticalValues);
    809 }
    810 
    811 ContentWidthAndMargin FormattingContext::Geometry::floatingReplacedWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues) const
    812 {
    813     ASSERT(layoutBox.isFloatingPositioned() && layoutBox.replaced());
     808    return inlineReplacedHeightAndMargin(replacedBox, horizontalConstraints, { }, overrideVerticalValues);
     809}
     810
     811ContentWidthAndMargin FormattingContext::Geometry::floatingReplacedWidthAndMargin(const ReplacedBox& replacedBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues) const
     812{
     813    ASSERT(replacedBox.isFloatingPositioned());
    814814
    815815    // 10.3.6 Floating, replaced elements
     
    817817    // 1. If 'margin-left' or 'margin-right' are computed as 'auto', their used value is '0'.
    818818    // 2. The used value of 'width' is determined as for inline replaced elements.
    819     auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, horizontalConstraints);
     819    auto computedHorizontalMargin = Geometry::computedHorizontalMargin(replacedBox, horizontalConstraints);
    820820
    821821    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating replaced -> redirected to inline replaced");
    822822    auto usedMargin = UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) };
    823     return inlineReplacedWidthAndMargin(layoutBox, horizontalConstraints, { overrideHorizontalValues.width, usedMargin });
     823    return inlineReplacedWidthAndMargin(replacedBox, horizontalConstraints, { overrideHorizontalValues.width, usedMargin });
    824824}
    825825
     
    828828    ASSERT(layoutBox.isOutOfFlowPositioned());
    829829
    830     if (!layoutBox.replaced())
     830    if (!layoutBox.isReplacedBox())
    831831        return outOfFlowNonReplacedVerticalGeometry(layoutBox, horizontalConstraints, verticalConstraints, overrideVerticalValues);
    832     return outOfFlowReplacedVerticalGeometry(layoutBox, horizontalConstraints, verticalConstraints, overrideVerticalValues);
     832    return outOfFlowReplacedVerticalGeometry(downcast<ReplacedBox>(layoutBox), horizontalConstraints, verticalConstraints, overrideVerticalValues);
    833833}
    834834
     
    837837    ASSERT(layoutBox.isOutOfFlowPositioned());
    838838
    839     if (!layoutBox.replaced())
     839    if (!layoutBox.isReplacedBox())
    840840        return outOfFlowNonReplacedHorizontalGeometry(layoutBox, horizontalConstraints, overrideHorizontalValues);
    841     return outOfFlowReplacedHorizontalGeometry(layoutBox, horizontalConstraints, overrideHorizontalValues);
     841    return outOfFlowReplacedHorizontalGeometry(downcast<ReplacedBox>(layoutBox), horizontalConstraints, overrideHorizontalValues);
    842842}
    843843
     
    846846    ASSERT(layoutBox.isFloatingPositioned());
    847847
    848     if (!layoutBox.replaced())
     848    if (!layoutBox.isReplacedBox())
    849849        return complicatedCases(layoutBox, horizontalConstraints, overrideVerticalValues);
    850     return floatingReplacedHeightAndMargin(layoutBox, horizontalConstraints, overrideVerticalValues);
     850    return floatingReplacedHeightAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, overrideVerticalValues);
    851851}
    852852
     
    855855    ASSERT(layoutBox.isFloatingPositioned());
    856856
    857     if (!layoutBox.replaced())
     857    if (!layoutBox.isReplacedBox())
    858858        return floatingNonReplacedWidthAndMargin(layoutBox, horizontalConstraints, overrideHorizontalValues);
    859     return floatingReplacedWidthAndMargin(layoutBox, horizontalConstraints, overrideHorizontalValues);
    860 }
    861 
    862 ContentHeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, Optional<VerticalConstraints> verticalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
    863 {
    864     ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced());
    865 
     859    return floatingReplacedWidthAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, overrideHorizontalValues);
     860}
     861
     862ContentHeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(const ReplacedBox& replacedBox, const HorizontalConstraints& horizontalConstraints, Optional<VerticalConstraints> verticalConstraints, const OverrideVerticalValues& overrideVerticalValues) const
     863{
    866864    // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements
    867865    //
     
    876874    // #1
    877875    auto& formattingContext = this->formattingContext();
    878     auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, horizontalConstraints);
     876    auto computedVerticalMargin = Geometry::computedVerticalMargin(replacedBox, horizontalConstraints);
    879877    auto usedVerticalMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
    880     auto& style = layoutBox.style();
    881     auto replaced = layoutBox.replaced();
    882 
    883     auto height = overrideVerticalValues.height ? overrideVerticalValues.height.value() : computedContentHeight(layoutBox, verticalConstraints ? verticalConstraints->logicalHeight : WTF::nullopt);
    884     auto heightIsAuto = !overrideVerticalValues.height && isHeightAuto(layoutBox);
     878    auto& style = replacedBox.style();
     879
     880    auto height = overrideVerticalValues.height ? overrideVerticalValues.height.value() : computedContentHeight(replacedBox, verticalConstraints ? verticalConstraints->logicalHeight : WTF::nullopt);
     881    auto heightIsAuto = !overrideVerticalValues.height && isHeightAuto(replacedBox);
    885882    auto widthIsAuto = style.logicalWidth().isAuto();
    886883
    887     if (heightIsAuto && widthIsAuto && replaced->hasIntrinsicHeight()) {
     884    if (heightIsAuto && widthIsAuto && replacedBox.hasIntrinsicHeight()) {
    888885        // #2
    889         height = replaced->intrinsicHeight();
    890     } else if (heightIsAuto && replaced->hasIntrinsicRatio()) {
     886        height = replacedBox.intrinsicHeight();
     887    } else if (heightIsAuto && replacedBox.hasIntrinsicRatio()) {
    891888        // #3
    892         auto usedWidth = formattingContext.geometryForBox(layoutBox).width();
    893         height = usedWidth / replaced->intrinsicRatio();
    894     } else if (heightIsAuto && replaced->hasIntrinsicHeight()) {
     889        auto usedWidth = formattingContext.geometryForBox(replacedBox).width();
     890        height = usedWidth / replacedBox.intrinsicRatio();
     891    } else if (heightIsAuto && replacedBox.hasIntrinsicHeight()) {
    895892        // #4
    896         height = replaced->intrinsicHeight();
     893        height = replacedBox.intrinsicHeight();
    897894    } else if (heightIsAuto) {
    898895        // #5
     
    902899    ASSERT(height);
    903900
    904     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow replaced -> height(" << *height << "px) margin(" << usedVerticalMargin.before << "px, " << usedVerticalMargin.after << "px) -> layoutBox(" << &layoutBox << ")");
     901    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow replaced -> height(" << *height << "px) margin(" << usedVerticalMargin.before << "px, " << usedVerticalMargin.after << "px) -> layoutBox(" << &replacedBox << ")");
    905902    return { *height, usedVerticalMargin };
    906903}
    907904
    908 ContentWidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues) const
    909 {
    910     ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced());
    911 
     905ContentWidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(const ReplacedBox& replacedBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues) const
     906{
    912907    // 10.3.2 Inline, replaced elements
    913908    //
     
    929924    //    If 300px is too wide to fit the device, UAs should use the width of the largest rectangle that has a 2:1 ratio and fits the device instead.
    930925
    931     auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, horizontalConstraints);
     926    auto computedHorizontalMargin = Geometry::computedHorizontalMargin(replacedBox, horizontalConstraints);
    932927
    933928    auto usedMarginStart = [&] {
     
    943938    };
    944939
    945     auto replaced = layoutBox.replaced();
    946     ASSERT(replaced);
    947 
    948     auto width = overrideHorizontalValues.width ? overrideHorizontalValues.width : computedContentWidth(layoutBox, horizontalConstraints.logicalWidth);
    949     auto heightIsAuto = isHeightAuto(layoutBox);
    950     auto height = computedContentHeight(layoutBox);
    951 
    952     if (!width && heightIsAuto && replaced->hasIntrinsicWidth()) {
     940    auto width = overrideHorizontalValues.width ? overrideHorizontalValues.width : computedContentWidth(replacedBox, horizontalConstraints.logicalWidth);
     941    auto heightIsAuto = isHeightAuto(replacedBox);
     942    auto height = computedContentHeight(replacedBox);
     943
     944    if (!width && heightIsAuto && replacedBox.hasIntrinsicWidth()) {
    953945        // #1
    954         width = replaced->intrinsicWidth();
    955     } else if ((!width && heightIsAuto && !replaced->hasIntrinsicWidth() && replaced->hasIntrinsicHeight() && replaced->hasIntrinsicRatio())
    956         || (!width && height && replaced->hasIntrinsicRatio())) {
     946        width = replacedBox.intrinsicWidth();
     947    } else if ((!width && heightIsAuto && !replacedBox.hasIntrinsicWidth() && replacedBox.hasIntrinsicHeight() && replacedBox.hasIntrinsicRatio())
     948        || (!width && height && replacedBox.hasIntrinsicRatio())) {
    957949        // #2
    958         width = height.valueOr(replaced->hasIntrinsicHeight()) * replaced->intrinsicRatio();
    959     } else if (!width && heightIsAuto && replaced->hasIntrinsicRatio() && !replaced->hasIntrinsicWidth() && !replaced->hasIntrinsicHeight()) {
     950        width = height.valueOr(replacedBox.hasIntrinsicHeight()) * replacedBox.intrinsicRatio();
     951    } else if (!width && heightIsAuto && replacedBox.hasIntrinsicRatio() && !replacedBox.hasIntrinsicWidth() && !replacedBox.hasIntrinsicHeight()) {
    960952        // #3
    961953        // FIXME: undefined but surely doable.
    962954        ASSERT_NOT_IMPLEMENTED_YET();
    963     } else if (!width && replaced->hasIntrinsicWidth()) {
     955    } else if (!width && replacedBox.hasIntrinsicWidth()) {
    964956        // #4
    965         width = replaced->intrinsicWidth();
     957        width = replacedBox.intrinsicWidth();
    966958    } else if (!width) {
    967959        // #5
     
    971963    ASSERT(width);
    972964
    973     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << *width << "px) margin(" << usedMarginStart() << "px, " << usedMarginEnd() << "px) -> layoutBox(" << &layoutBox << ")");
     965    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << *width << "px) margin(" << usedMarginStart() << "px, " << usedMarginEnd() << "px) -> layoutBox(" << &replacedBox << ")");
    974966    return { *width, { usedMarginStart(), usedMarginEnd() }, computedHorizontalMargin };
    975967}
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h

    r256106 r256380  
    9393        ContentHeightAndMargin inFlowNonReplacedHeightAndMargin(const Box&, const HorizontalConstraints&, const OverrideVerticalValues&);
    9494        ContentWidthAndMargin inFlowNonReplacedWidthAndMargin(const Box&, const HorizontalConstraints&, const OverrideHorizontalValues&) const;
    95         ContentWidthAndMargin inFlowReplacedWidthAndMargin(const Box&, const HorizontalConstraints&, const OverrideHorizontalValues&) const;
     95        ContentWidthAndMargin inFlowReplacedWidthAndMargin(const ReplacedBox&, const HorizontalConstraints&, const OverrideHorizontalValues&) const;
    9696        Point staticPositionForOutOfFlowPositioned(const Box&) const;
    9797
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp

    r255899 r256380  
    3535#include "LayoutChildIterator.h"
    3636#include "LayoutContext.h"
     37#include "LayoutReplacedBox.h"
    3738#include "Logging.h"
    3839#include <wtf/text/TextStream.h>
     
    4344ContentHeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideVerticalValues& overrideVerticalValues)
    4445{
    45     ASSERT(layoutBox.isInFlow() && !layoutBox.replaced());
     46    ASSERT(layoutBox.isInFlow() && !layoutBox.isReplacedBox());
    4647    ASSERT(layoutBox.isOverflowVisible());
    4748
     
    201202}
    202203
    203 ContentWidthAndMargin BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues) const
    204 {
    205     ASSERT(layoutBox.isInFlow() && layoutBox.replaced());
     204ContentWidthAndMargin BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin(const ReplacedBox& replacedBox, const HorizontalConstraints& horizontalConstraints, const OverrideHorizontalValues& overrideHorizontalValues) const
     205{
     206    ASSERT(replacedBox.isInFlow());
    206207
    207208    // 10.3.4 Block-level, replaced elements in normal flow
     
    211212
    212213    // #1
    213     auto usedWidth = inlineReplacedWidthAndMargin(layoutBox, horizontalConstraints, overrideHorizontalValues).contentWidth;
     214    auto usedWidth = inlineReplacedWidthAndMargin(replacedBox, horizontalConstraints, overrideHorizontalValues).contentWidth;
    214215    // #2
    215     auto nonReplacedWidthAndMargin = inFlowNonReplacedWidthAndMargin(layoutBox, horizontalConstraints, OverrideHorizontalValues { usedWidth, overrideHorizontalValues.margin });
    216 
    217     LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << usedWidth  << "px) margin(" << nonReplacedWidthAndMargin.usedMargin.start << "px, " << nonReplacedWidthAndMargin.usedMargin.end << "px) -> layoutBox(" << &layoutBox << ")");
     216    auto nonReplacedWidthAndMargin = inFlowNonReplacedWidthAndMargin(replacedBox, horizontalConstraints, OverrideHorizontalValues { usedWidth, overrideHorizontalValues.margin });
     217
     218    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << usedWidth  << "px) margin(" << nonReplacedWidthAndMargin.usedMargin.start << "px, " << nonReplacedWidthAndMargin.usedMargin.end << "px) -> layoutBox(" << &replacedBox << ")");
    218219    return { usedWidth, nonReplacedWidthAndMargin.usedMargin, nonReplacedWidthAndMargin.computedMargin };
    219220}
     
    250251    // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block'
    251252    // replaced elements in normal flow and floating replaced elements
    252     if (layoutBox.replaced())
    253         return inlineReplacedHeightAndMargin(layoutBox, horizontalConstraints, { }, overrideVerticalValues);
     253    if (layoutBox.isReplacedBox())
     254        return inlineReplacedHeightAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, { }, overrideVerticalValues);
    254255
    255256    ContentHeightAndMargin contentHeightAndMargin;
     
    280281    ASSERT(layoutBox.isInFlow());
    281282
    282     if (!layoutBox.replaced()) {
     283    if (!layoutBox.isReplacedBox()) {
    283284        if (!layoutBox.establishesTableFormattingContext())
    284285            return inFlowNonReplacedWidthAndMargin(layoutBox, horizontalConstraints, overrideHorizontalValues);
     
    288289        return inFlowNonReplacedWidthAndMargin(layoutBox, horizontalConstraints, OverrideHorizontalValues { usedWidth, overrideHorizontalValues.margin });
    289290    }
    290     return inFlowReplacedWidthAndMargin(layoutBox, horizontalConstraints, overrideHorizontalValues);
     291    return inFlowReplacedWidthAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, overrideHorizontalValues);
    291292}
    292293
     
    312313            return { };
    313314
    314         if (auto* replaced = layoutBox.replaced()) {
    315             if (replaced->hasIntrinsicWidth()) {
    316                 auto replacedWidth = replaced->intrinsicWidth();
     315        if (layoutBox.isReplacedBox()) {
     316            auto& replacedBox = downcast<ReplacedBox>(layoutBox);
     317            if (replacedBox.hasIntrinsicWidth()) {
     318                auto replacedWidth = replacedBox.intrinsicWidth();
    317319                return { replacedWidth, replacedWidth };
    318320            }
  • trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp

    r256106 r256380  
    378378
    379379    // FIXME: Block replaced boxes clearly don't collapse through their margins, but I couldn't find it in the spec yet (and no, it's not a quirk).
    380     if (layoutBox.replaced())
     380    if (layoutBox.isReplacedBox())
    381381        return false;
    382382
     
    577577    // Don't pre-compute vertical margins for out of flow boxes.
    578578    ASSERT(layoutBox.isInFlow() || layoutBox.isFloatingPositioned());
    579     ASSERT(!layoutBox.replaced());
     579    ASSERT(!layoutBox.isReplacedBox());
    580580
    581581    auto marginsCollapseThrough = this->marginsCollapseThrough(layoutBox);
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp

    r256311 r256380  
    3838#include "LayoutContext.h"
    3939#include "LayoutInlineTextBox.h"
     40#include "LayoutReplacedBox.h"
    4041#include "LayoutState.h"
    4142#include "Logging.h"
     
    190191            continue;
    191192        }
    192         if (layoutBox->isReplaced()) {
     193        if (layoutBox->isReplacedBox()) {
    193194            computeBorderAndPadding(*layoutBox, horizontalConstraints);
    194195            computeWidthAndMargin(*layoutBox, horizontalConstraints);
     
    277278    else if (layoutBox.isInlineBlockBox())
    278279        contentWidthAndMargin = geometry().inlineBlockWidthAndMargin(layoutBox, horizontalConstraints, usedWidth);
    279     else if (layoutBox.replaced())
    280         contentWidthAndMargin = geometry().inlineReplacedWidthAndMargin(layoutBox, horizontalConstraints, usedWidth);
     280    else if (layoutBox.isReplacedBox())
     281        contentWidthAndMargin = geometry().inlineReplacedWidthAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, usedWidth);
    281282    else
    282283        ASSERT_NOT_REACHED();
     
    297298    else if (layoutBox.isInlineBlockBox())
    298299        contentHeightAndMargin = geometry().inlineBlockHeightAndMargin(layoutBox, horizontalConstraints, usedHeight);
    299     else if (layoutBox.replaced())
    300         contentHeightAndMargin = geometry().inlineReplacedHeightAndMargin(layoutBox, horizontalConstraints, { }, usedHeight);
     300    else if (layoutBox.isReplacedBox())
     301        contentHeightAndMargin = geometry().inlineReplacedHeightAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, { }, usedHeight);
    301302    else
    302303        ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp

    r254277 r256380  
    4444
    4545    // Exactly as inline replaced elements.
    46     if (formattingContextRoot.replaced())
    47         return inlineReplacedWidthAndMargin(formattingContextRoot, horizontalConstraints, overrideHorizontalValues);
     46    if (formattingContextRoot.isReplacedBox())
     47        return inlineReplacedWidthAndMargin(downcast<ReplacedBox>(formattingContextRoot), horizontalConstraints, overrideHorizontalValues);
    4848
    4949    // 10.3.9 'Inline-block', non-replaced elements in normal flow
     
    6767
    6868    // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements
    69     if (layoutBox.replaced())
    70         return inlineReplacedHeightAndMargin(layoutBox, horizontalConstraints, { }, overrideVerticalValues);
     69    if (layoutBox.isReplacedBox())
     70        return inlineReplacedHeightAndMargin(downcast<ReplacedBox>(layoutBox), horizontalConstraints, { }, overrideVerticalValues);
    7171
    7272    // 10.6.6 Complicated cases
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp

    r256304 r256380  
    402402    else if (inlineItem.isContainerEnd())
    403403        appendInlineContainerEnd(inlineItem, logicalWidth);
    404     else if (inlineItem.layoutBox().replaced())
     404    else if (inlineItem.layoutBox().isReplacedBox())
    405405        appendReplacedInlineBox(inlineItem, logicalWidth);
    406406    else if (inlineItem.isBox())
     
    505505void LineBuilder::appendReplacedInlineBox(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
    506506{
    507     ASSERT(inlineItem.layoutBox().isReplaced());
     507    ASSERT(inlineItem.layoutBox().isReplacedBox());
    508508    // FIXME: Surely replaced boxes behave differently.
    509509    appendNonReplacedInlineBox(inlineItem, logicalWidth);
     
    618618    auto& layoutBox = run.layoutBox();
    619619    auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
    620     if (layoutBox.replaced() || layoutBox.isFloatingPositioned())
     620    if (layoutBox.isReplacedBox() || layoutBox.isFloatingPositioned())
    621621        return boxGeometry.contentBoxHeight();
    622622
     
    645645
    646646    if (run.isBox()) {
    647         if (run.layoutBox().isReplaced())
     647        if (run.layoutBox().isReplacedBox())
    648648            return true;
    649649        ASSERT(run.layoutBox().isInlineBlockBox() || run.layoutBox().isInlineTableBox());
  • trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp

    r256304 r256380  
    228228        return boxGeometry.marginBoxWidth();
    229229
    230     if (layoutBox.replaced())
     230    if (layoutBox.isReplacedBox())
    231231        return boxGeometry.width();
    232232
  • trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp

    r256304 r256380  
    4848    , m_isAnonymous(false)
    4949{
    50     if (isReplaced())
    51         ensureRareData().replaced = makeUnique<Replaced>(*this);
    5250}
    5351
     
    302300    // An inline box is one that is both inline-level and whose contents participate in its containing inline formatting context.
    303301    // A non-replaced element with a 'display' value of 'inline' generates an inline box.
    304     return m_style.display() == DisplayType::Inline && !isReplaced();
     302    return m_style.display() == DisplayType::Inline && !isReplacedBox();
    305303}
    306304
     
    400398}
    401399
    402 const Replaced* Box::replaced() const
    403 {
    404     return const_cast<Box*>(this)->replaced();
    405 }
    406 
    407 Replaced* Box::replaced()
    408 {
    409     if (!isReplaced()) {
    410         ASSERT(!hasRareData() || !rareData().replaced.get());
    411         return nullptr;
    412     }
    413     ASSERT(hasRareData() && rareData().replaced.get());
    414     return rareData().replaced.get();
    415 }
    416 
    417400void Box::setRowSpan(unsigned rowSpan)
    418401{
  • trunk/Source/WebCore/layout/layouttree/LayoutBox.h

    r256311 r256380  
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "LayoutReplaced.h"
    3130#include "RenderStyle.h"
    3231#include <wtf/IsoMalloc.h>
     
    6665        InlineTextBox          = 1 << 1,
    6766        LineBreakBox           = 1 << 2,
    68         ContainerFlag          = 1 << 3
     67        ReplacedBox            = 1 << 3,
     68        ContainerFlag          = 1 << 4
    6969    };
    7070    typedef unsigned BaseTypeFlags;
     
    125125    bool isTableColumn() const { return style().display() == DisplayType::TableColumn; }
    126126    bool isTableCell() const { return style().display() == DisplayType::TableCell; }
    127     bool isReplaced() const { return isImage() || isIFrame(); }
    128127    bool isIFrame() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::IFrame; }
    129128    bool isImage() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::Image; }
     
    143142    bool isInlineTextBox() const { return m_baseTypeFlags & InlineTextBox; }
    144143    bool isLineBreakBox() const { return m_baseTypeFlags & LineBreakBox; }
     144    bool isReplacedBox() const { return m_baseTypeFlags & ReplacedBox; }
    145145
    146146    bool isPaddingApplicable() const;
     
    149149    void updateStyle(const RenderStyle& newStyle);
    150150    const RenderStyle& style() const { return m_style; }
    151 
    152     const Replaced* replaced() const;
    153     // FIXME: Temporary until after intrinsic size change is tracked by Replaced.
    154     Replaced* replaced();
    155151
    156152    // FIXME: Find a better place for random DOM things.
     
    183179        BoxRareData() = default;
    184180
    185         std::unique_ptr<Replaced> replaced;
    186181        unsigned rowSpan { 1 };
    187182        unsigned columnSpan { 1 };
  • trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.cpp

    r256379 r256380  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
    27 #include "LayoutReplaced.h"
     27#include "LayoutReplacedBox.h"
    2828
    2929#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    3030
    31 #include "LayoutBox.h"
    3231#include "RenderStyle.h"
    3332#include <wtf/IsoMallocInlines.h>
     
    3635namespace Layout {
    3736
    38 WTF_MAKE_ISO_ALLOCATED_IMPL(Replaced);
     37WTF_MAKE_ISO_ALLOCATED_IMPL(ReplacedBox);
    3938
    40 Replaced::Replaced(const Box& layoutBox)
    41     : m_layoutBox(makeWeakPtr(layoutBox))
     39ReplacedBox::ReplacedBox(RenderStyle&& style)
     40    : Box({ }, WTFMove(style), Box::ReplacedBox)
    4241{
    4342}
    4443
    45 bool Replaced::hasIntrinsicWidth() const
     44bool ReplacedBox::hasIntrinsicWidth() const
    4645{
    4746    return m_intrinsicSize || m_layoutBox->style().logicalWidth().isIntrinsic();
    4847}
    4948
    50 bool Replaced::hasIntrinsicHeight() const
     49bool ReplacedBox::hasIntrinsicHeight() const
    5150{
    5251    return m_intrinsicSize || m_layoutBox->style().logicalHeight().isIntrinsic();
    5352}
    5453
    55 bool Replaced::hasIntrinsicRatio() const
     54bool ReplacedBox::hasIntrinsicRatio() const
    5655{
    5756    if (!hasAspectRatio())
     
    6059}
    6160
    62 LayoutUnit Replaced::intrinsicWidth() const
     61LayoutUnit ReplacedBox::intrinsicWidth() const
    6362{
    6463    ASSERT(hasIntrinsicWidth());
     
    6867}
    6968
    70 LayoutUnit Replaced::intrinsicHeight() const
     69LayoutUnit ReplacedBox::intrinsicHeight() const
    7170{
    7271    ASSERT(hasIntrinsicHeight());
     
    7675}
    7776
    78 LayoutUnit Replaced::intrinsicRatio() const
     77LayoutUnit ReplacedBox::intrinsicRatio() const
    7978{
    8079    ASSERT(hasIntrinsicRatio() || (hasIntrinsicWidth() && hasIntrinsicHeight()));
     
    8685}
    8786
    88 bool Replaced::hasAspectRatio() const
     87bool ReplacedBox::hasAspectRatio() const
    8988{
    9089    return m_layoutBox->isImage() || m_layoutBox->style().aspectRatioType() == AspectRatioType::FromIntrinsic;
  • trunk/Source/WebCore/layout/layouttree/LayoutReplacedBox.h

    r256379 r256380  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929
    3030#include "CachedImage.h"
     31#include "LayoutBox.h"
    3132#include "LayoutSize.h"
    3233#include "LayoutUnit.h"
     
    3738namespace Layout {
    3839
    39 class Box;
    40 
    41 // HTMLAudioElement, HTMLCanvasElement. HTMLEmbedElement, HTMLIFrameElement, HTMLImageElement, HTMLInputElement, HTMLObjectElement, HTMLVideoElement.
    42 class Replaced {
    43     WTF_MAKE_ISO_ALLOCATED(Replaced);
     40class ReplacedBox : public Box {
     41    WTF_MAKE_ISO_ALLOCATED(ReplacedBox);
    4442public:
    45     Replaced(const Box&);
    46     ~Replaced() = default;
     43    ReplacedBox(RenderStyle&&);
     44    virtual ~ReplacedBox() = default;
    4745
    4846    void setCachedImage(CachedImage& cachedImage) { m_cachedImage = &cachedImage; }
    4947    CachedImage* cachedImage() const { return m_cachedImage; }
    5048
    51     // FIXME: Temporary until after intrinsic size change is tracked internallys.
     49    // FIXME: Temporary until after intrinsic size change is tracked internally.
    5250    void setIntrinsicSize(LayoutSize size) { m_intrinsicSize = size; }
    5351    void setIntrinsicRatio(LayoutUnit ratio) { m_intrinsicRatio = ratio; };
     
    7169}
    7270}
     71
     72SPECIALIZE_TYPE_TRAITS_LAYOUT_BOX(ReplacedBox, isReplacedBox())
     73
    7374#endif
  • trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

    r256311 r256380  
    4646#include "LayoutLineBreakBox.h"
    4747#include "LayoutPhase.h"
     48#include "LayoutReplacedBox.h"
    4849#include "LayoutSize.h"
    4950#include "LayoutState.h"
     
    145146}
    146147
    147 Box& TreeBuilder::createBox(Optional<Box::ElementAttributes> elementAttributes, RenderStyle&& style)
    148 {
    149     auto newBox = makeUnique<Box>(elementAttributes, WTFMove(style));
     148Box& TreeBuilder::createReplacedBox(RenderStyle&& style)
     149{
     150    auto newBox = makeUnique<ReplacedBox>(WTFMove(style));
    150151    auto& box = *newBox;
    151152    m_layoutTreeContent.addBox(WTFMove(newBox));
     
    219220            childLayoutBox->setIsAnonymous();
    220221        } else if (is<RenderReplaced>(renderer)) {
    221             if (displayType == DisplayType::Block)
    222                 childLayoutBox = &createBox(elementAttributes(renderer), WTFMove(clonedStyle));
    223             else
    224                 childLayoutBox = &createBox(elementAttributes(renderer), WTFMove(clonedStyle));
     222            childLayoutBox = &createReplacedBox(WTFMove(clonedStyle));
    225223            // FIXME: We don't yet support all replaced elements and this is temporary anyway.
    226             if (childLayoutBox->replaced())
    227                 childLayoutBox->replaced()->setIntrinsicSize(downcast<RenderReplaced>(renderer).intrinsicSize());
     224            downcast<ReplacedBox>(*childLayoutBox).setIntrinsicSize(downcast<RenderReplaced>(renderer).intrinsicSize());
    228225            if (is<RenderImage>(renderer)) {
    229226                auto& imageRenderer = downcast<RenderImage>(renderer);
    230227                if (imageRenderer.shouldDisplayBrokenImageIcon())
    231                     childLayoutBox->replaced()->setIntrinsicRatio(1);
     228                    downcast<ReplacedBox>(*childLayoutBox).setIntrinsicRatio(1);
    232229                if (imageRenderer.cachedImage())
    233                     childLayoutBox->replaced()->setCachedImage(*imageRenderer.cachedImage());
     230                    downcast<ReplacedBox>(*childLayoutBox).setCachedImage(*imageRenderer.cachedImage());
    234231            }
    235232        } else {
     
    396393        if (layoutBox.isInlineBox())
    397394            stream << "SPAN inline box";
    398         else if (layoutBox.replaced())
     395        else if (layoutBox.isReplacedBox())
    399396            stream << "IMG replaced inline box";
    400397        else if (layoutBox.isAnonymous())
  • trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h

    r256311 r256380  
    9191    Box* createLayoutBox(const Container& parentContainer, const RenderObject& childRenderer);
    9292
    93     Box& createBox(Optional<Box::ElementAttributes>, RenderStyle&&);
     93    Box& createReplacedBox(RenderStyle&&);
    9494    Box& createTextBox(String text, bool canUseSimplifiedTextMeasuring, RenderStyle&&);
    9595    Box& createLineBreakBox(bool isOptional, RenderStyle&&);
Note: See TracChangeset for help on using the changeset viewer.