Changeset 229758 in webkit


Ignore:
Timestamp:
Mar 20, 2018, 9:14:28 AM (7 years ago)
Author:
Alan Bujtas
Message:

[LayoutReloaded] Move Display.Box handling from FormattingContext to FormattingState
https://bugs.webkit.org/show_bug.cgi?id=183779

Reviewed by Antti Koivisto.

  • LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:

(BlockFormattingContext.prototype._computeStaticPosition):
(BlockFormattingContext.prototype._computeOutOfFlowWidth):
(BlockFormattingContext.prototype._computeFloatingWidth):
(BlockFormattingContext.prototype._computeInFlowWidth):
(BlockFormattingContext.prototype._computeOutOfFlowHeight):
(BlockFormattingContext.prototype._computeFloatingHeight):
(BlockFormattingContext.prototype._computeInFlowHeight):
(BlockFormattingContext.prototype._horizontalConstraint):
(BlockFormattingContext.prototype._contentHeight):
(BlockFormattingContext.prototype._adjustBottomWithFIXME):
(BlockFormattingContext.prototype._computeInFlowPositionedPosition):
(BlockFormattingContext.prototype._computeOutOfFlowPosition):

  • LayoutReloaded/FormattingContext/FloatingContext.js:

(FloatingContext.prototype.computePosition):
(FloatingContext.prototype._positionForClear):
(FloatingContext.prototype._computePositionToAvoidIntrudingFloats):
(FloatingContext.prototype._availableSpace):
(FloatingContext.prototype._adjustedFloatingPosition):

  • LayoutReloaded/FormattingContext/FormattingContext.js:

(FormattingContext):
(FormattingContext.prototype.absoluteMarginBox):
(FormattingContext.prototype.absoluteBorderBox):
(FormattingContext.prototype.absolutePaddingBox):
(FormattingContext.prototype.absoluteContentBox):
(FormattingContext.prototype._toAbsolutePosition):
(FormattingContext.prototype._toRootAbsolutePosition):
(FormattingContext.prototype._addToLayoutQueue):
(FormattingContext.prototype.displayBox):
(FormattingContext.prototype._createDisplayBox): Deleted.
(FormattingContext.prototype.toDisplayBox): Deleted.
(FormattingContext.prototype.toLayoutBox): Deleted.

  • LayoutReloaded/FormattingState/FormattingState.js:

(FormattingState):
(FormattingState.prototype.createDisplayBox):
(FormattingState.prototype.displayBox):

Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r229746 r229758  
     12018-03-20  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LayoutReloaded] Move Display.Box handling from FormattingContext to FormattingState
     4        https://bugs.webkit.org/show_bug.cgi?id=183779
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
     9        (BlockFormattingContext.prototype._computeStaticPosition):
     10        (BlockFormattingContext.prototype._computeOutOfFlowWidth):
     11        (BlockFormattingContext.prototype._computeFloatingWidth):
     12        (BlockFormattingContext.prototype._computeInFlowWidth):
     13        (BlockFormattingContext.prototype._computeOutOfFlowHeight):
     14        (BlockFormattingContext.prototype._computeFloatingHeight):
     15        (BlockFormattingContext.prototype._computeInFlowHeight):
     16        (BlockFormattingContext.prototype._horizontalConstraint):
     17        (BlockFormattingContext.prototype._contentHeight):
     18        (BlockFormattingContext.prototype._adjustBottomWithFIXME):
     19        (BlockFormattingContext.prototype._computeInFlowPositionedPosition):
     20        (BlockFormattingContext.prototype._computeOutOfFlowPosition):
     21        * LayoutReloaded/FormattingContext/FloatingContext.js:
     22        (FloatingContext.prototype.computePosition):
     23        (FloatingContext.prototype._positionForClear):
     24        (FloatingContext.prototype._computePositionToAvoidIntrudingFloats):
     25        (FloatingContext.prototype._availableSpace):
     26        (FloatingContext.prototype._adjustedFloatingPosition):
     27        * LayoutReloaded/FormattingContext/FormattingContext.js:
     28        (FormattingContext):
     29        (FormattingContext.prototype.absoluteMarginBox):
     30        (FormattingContext.prototype.absoluteBorderBox):
     31        (FormattingContext.prototype.absolutePaddingBox):
     32        (FormattingContext.prototype.absoluteContentBox):
     33        (FormattingContext.prototype._toAbsolutePosition):
     34        (FormattingContext.prototype._toRootAbsolutePosition):
     35        (FormattingContext.prototype._addToLayoutQueue):
     36        (FormattingContext.prototype.displayBox):
     37        (FormattingContext.prototype._createDisplayBox): Deleted.
     38        (FormattingContext.prototype.toDisplayBox): Deleted.
     39        (FormattingContext.prototype.toLayoutBox): Deleted.
     40        * LayoutReloaded/FormattingState/FormattingState.js:
     41        (FormattingState):
     42        (FormattingState.prototype.createDisplayBox):
     43        (FormattingState.prototype.displayBox):
     44
    1452018-03-20  Zalan Bujtas  <zalan@apple.com>
    246
  • trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js

    r229746 r229758  
    110110        // The vertical distance between two sibling boxes is determined by the 'margin' properties.
    111111        // Vertical margins between adjacent block-level boxes in a block formatting context collapse.
    112         let containingBlockContentBox = this.toDisplayBox(layoutBox.containingBlock()).contentBox();
     112        let containingBlockContentBox = this.displayBox(layoutBox.containingBlock()).contentBox();
    113113        // Start from the top of the container's content box.
    114114        let previousInFlowSibling = layoutBox.previousInFlowSibling();
    115115        let contentBottom = containingBlockContentBox.top()
    116116        if (previousInFlowSibling)
    117             contentBottom = this.toDisplayBox(previousInFlowSibling).bottom() + this.marginBottom(previousInFlowSibling);
     117            contentBottom = this.displayBox(previousInFlowSibling).bottom() + this.marginBottom(previousInFlowSibling);
    118118        let position = new LayoutPoint(contentBottom, containingBlockContentBox.left());
    119119        position.moveBy(new LayoutSize(this.marginLeft(layoutBox), this.marginTop(layoutBox)));
    120         this.toDisplayBox(layoutBox).setTopLeft(position);
     120        this.displayBox(layoutBox).setTopLeft(position);
    121121    }
    122122
     
    172172            width = Utils.width(layoutBox); // 4
    173173        else if (Utils.isWidthAuto(layoutBox) && !Utils.isLeftAuto(layoutBox) && !Utils.isRightAuto(layoutBox))
    174             width = Math.max(0, this.toDisplayBox(layoutBox.containingBlock()).contentBox().width() - Utils.right(layoutBox) - Utils.left(layoutBox)); // 5
     174            width = Math.max(0, this.displayBox(layoutBox.containingBlock()).contentBox().width() - Utils.right(layoutBox) - Utils.left(layoutBox)); // 5
    175175        else if (Utils.isRightAuto(layoutBox) && !Utils.isLeftAuto(layoutBox) && !Utils.isWidthAuto(layoutBox))
    176176            width = Utils.width(layoutBox); // 6
     
    178178            ASSERT_NOT_REACHED();
    179179        width += Utils.computedHorizontalBorderAndPadding(layoutBox.node());
    180         this.toDisplayBox(layoutBox).setWidth(width);
     180        this.displayBox(layoutBox).setWidth(width);
    181181    }
    182182
    183183    _computeFloatingWidth(layoutBox) {
    184184        // FIXME: missing cases
    185         this.toDisplayBox(layoutBox).setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node()));
     185        this.displayBox(layoutBox).setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node()));
    186186    }
    187187
    188188    _computeInFlowWidth(layoutBox) {
    189189        if (Utils.isWidthAuto(layoutBox))
    190             return this.toDisplayBox(layoutBox).setWidth(this._horizontalConstraint(layoutBox));
    191         return this.toDisplayBox(layoutBox).setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node()));
     190            return this.displayBox(layoutBox).setWidth(this._horizontalConstraint(layoutBox));
     191        return this.displayBox(layoutBox).setWidth(Utils.width(layoutBox) + Utils.computedHorizontalBorderAndPadding(layoutBox.node()));
    192192    }
    193193
     
    220220            height = Utils.height(layoutBox); // 6
    221221        else if (Utils.isHeightAuto((layoutBox)) && !Utils.isTopAuto((layoutBox)) && !Utils.isBottomAuto((layoutBox)))
    222             height = Math.max(0, this.toDisplayBox(layoutBox.containingBlock()).contentBox().height() - Utils.bottom(layoutBox) - Utils.top(layoutBox)); // 7
     222            height = Math.max(0, this.displayBox(layoutBox.containingBlock()).contentBox().height() - Utils.bottom(layoutBox) - Utils.top(layoutBox)); // 7
    223223        else if (Utils.isBottomAuto((layoutBox)) && !Utils.isTopAuto((layoutBox)) && !Utils.isHeightAuto((layoutBox)))
    224224            height = Utils.height(layoutBox); // 8
     
    226226            ASSERT_NOT_REACHED();
    227227        height += Utils.computedVerticalBorderAndPadding(layoutBox.node());
    228         this.toDisplayBox(layoutBox).setHeight(height);
     228        this.displayBox(layoutBox).setHeight(height);
    229229    }
    230230
    231231    _computeFloatingHeight(layoutBox) {
    232232        // FIXME: missing cases
    233         this.toDisplayBox(layoutBox).setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
     233        this.displayBox(layoutBox).setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
    234234    }
    235235
     
    241241            // The element's height is the distance from its top content edge to the first applicable of the following:
    242242            // 1. the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
    243             return this.toDisplayBox(layoutBox).setHeight(this._contentHeight(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
    244         }
    245         return this.toDisplayBox(layoutBox).setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
     243            return this.displayBox(layoutBox).setHeight(this._contentHeight(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
     244        }
     245        return this.displayBox(layoutBox).setHeight(Utils.height(layoutBox) + Utils.computedVerticalBorderAndPadding(layoutBox.node()));
    246246    }
    247247
    248248    _horizontalConstraint(layoutBox) {
    249         let horizontalConstraint = this.toDisplayBox(layoutBox.containingBlock()).contentBox().width();
     249        let horizontalConstraint = this.displayBox(layoutBox.containingBlock()).contentBox().width();
    250250        horizontalConstraint -= this.marginLeft(layoutBox) + this.marginRight(layoutBox);
    251251        return horizontalConstraint;
     
    270270            return lastLine.rect().bottom();
    271271        }
    272         let top = this.toDisplayBox(layoutBox).contentBox().top();
     272        let top = this.displayBox(layoutBox).contentBox().top();
    273273        let bottom = this._adjustBottomWithFIXME(layoutBox);
    274274        return bottom - top;
     
    281281        let bottom = lastInFlowDisplayBox.bottom() + this.marginBottom(lastInFlowChild);
    282282        // FIXME: margin for body
    283         if (lastInFlowChild.name() == "RenderBody" && Utils.isHeightAuto(lastInFlowChild) && !this.toDisplayBox(lastInFlowChild).contentBox().height())
     283        if (lastInFlowChild.name() == "RenderBody" && Utils.isHeightAuto(lastInFlowChild) && !this.displayBox(lastInFlowChild).contentBox().height())
    284284            bottom -= this.marginBottom(lastInFlowChild);
    285285        // FIXME: figure out why floatings part of the initial block formatting context get propagated to HTML
     
    294294    _computeInFlowPositionedPosition(layoutBox) {
    295295        // Start with the original, static position.
    296         let displayBox = this.toDisplayBox(layoutBox);
     296        let displayBox = this.displayBox(layoutBox);
    297297        let relativePosition = displayBox.topLeft();
    298298        // Top/bottom
     
    310310
    311311    _computeOutOfFlowPosition(layoutBox) {
    312         let displayBox = this.toDisplayBox(layoutBox);
     312        let displayBox = this.displayBox(layoutBox);
    313313        let top = Number.NaN;
    314         let containerSize = this.toDisplayBox(layoutBox.containingBlock()).contentBox().size();
     314        let containerSize = this.displayBox(layoutBox.containingBlock()).contentBox().size();
    315315        // Top/bottom
    316316        if (Utils.isTopAuto(layoutBox) && Utils.isBottomAuto(layoutBox)) {
  • trunk/Tools/LayoutReloaded/FormattingContext/FloatingContext.js

    r229734 r229758  
    3535        if (layoutBox.isOutOfFlowPositioned())
    3636            return;
    37         let displayBox = this._formattingContext().toDisplayBox(layoutBox);
     37        let displayBox = this._formattingContext().displayBox(layoutBox);
    3838        if (layoutBox.isFloatingPositioned()) {
    3939            let position = this._positionForFloating(layoutBox);
     
    7575    _positionForClear(layoutBox) {
    7676        ASSERT(Utils.hasClear(layoutBox));
    77         let displayBox = this._formattingContext().toDisplayBox(layoutBox);
     77        let displayBox = this._formattingContext().displayBox(layoutBox);
    7878        if (this._isEmpty())
    7979            return displayBox.topLeft();
     
    9797    _computePositionToAvoidIntrudingFloats(layoutBox) {
    9898        if (!layoutBox.establishesBlockFormattingContext() || this._isEmpty())
    99             return this._formattingContext().toDisplayBox(layoutBox).topLeft();
     99            return this._formattingContext().displayBox(layoutBox).topLeft();
    100100        // The border box of a table, a block-level replaced element, or an element in the normal flow that establishes
    101101        // a new block formatting context (such as an element with 'overflow' other than 'visible') must not overlap the
     
    133133
    134134    _availableSpace(containingBlock, floatingPair) {
    135         let containingBlockContentBox = this._formattingContext().toDisplayBox(containingBlock);
     135        let containingBlockContentBox = this._formattingContext().displayBox(containingBlock);
    136136        if (floatingPair.left && floatingPair.right)
    137137            return this._formattingContext().absoluteMarginBox(floatingPair.right).left() - this._formattingContext().absoluteMarginBox(floatingPair.left).right();
     
    183183        if (Utils.isFloatingLeft(floatingBox) || !Utils.isFloatingPositioned(floatingBox))
    184184            return new LayoutPoint(verticalPosition, left);
    185         return new LayoutPoint(verticalPosition, right - this._formattingContext().toDisplayBox(floatingBox).rect().width());
     185        return new LayoutPoint(verticalPosition, right - this._formattingContext().displayBox(floatingBox).rect().width());
    186186    }
    187187
  • trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js

    r229746 r229758  
    2929        this.m_layoutState = layoutState;
    3030        this.m_floatingContext = null;
    31         this.m_displayToLayout = new Map();
    32         this.m_layoutToDisplay = new Map();
    3331        this.m_layoutStack = new Array();
    3432    }
     
    7775
    7876    absoluteMarginBox(layoutBox) {
    79         let displayBox = this.toDisplayBox(layoutBox);
     77        let displayBox = this.displayBox(layoutBox);
    8078        let absoluteContentBox = new LayoutRect(this._toRootAbsolutePosition(layoutBox), displayBox.size());
    8179        absoluteContentBox.moveBy(new LayoutSize(-this.marginLeft(layoutBox), -this.marginTop(layoutBox)));
     
    8583
    8684    absoluteBorderBox(layoutBox) {
    87         let borderBox = this.toDisplayBox(layoutBox).borderBox();
     85        let borderBox = this.displayBox(layoutBox).borderBox();
    8886        let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), borderBox.size());
    8987        absoluteRect.moveBy(borderBox.topLeft());
     
    9290
    9391    absolutePaddingBox(layoutBox) {
    94         let paddingBox = this.toDisplayBox(layoutBox).paddingBox();
     92        let paddingBox = this.displayBox(layoutBox).paddingBox();
    9593        let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), paddingBox.size());
    9694        absoluteRect.moveBy(paddingBox.topLeft());
     
    9997
    10098    absoluteContentBox(layoutBox) {
    101         let contentBox = this.toDisplayBox(layoutBox).contentBox();
     99        let contentBox = this.displayBox(layoutBox).contentBox();
    102100        let absoluteRect = new LayoutRect(this._toRootAbsolutePosition(layoutBox), contentBox.size());
    103101        absoluteRect.moveBy(contentBox.topLeft());
     
    112110        while (ascendant && ascendant != container) {
    113111            ASSERT(ascendant.isDescendantOf(this.rootContainer()));
    114             absolutePosition.moveBy(this.toDisplayBox(ascendant).topLeft());
     112            absolutePosition.moveBy(this.displayBox(ascendant).topLeft());
    115113            ascendant = ascendant.containingBlock();
    116114        }
     
    119117
    120118    _toRootAbsolutePosition(layoutBox) {
    121         return this._toAbsolutePosition(this.toDisplayBox(layoutBox).topLeft(), layoutBox, this.rootContainer());
     119        return this._toAbsolutePosition(this.displayBox(layoutBox).topLeft(), layoutBox, this.rootContainer());
    122120    }
    123121
     
    128126    _addToLayoutQueue(layoutBox) {
    129127        // Initialize the corresponding display box.
    130         this._createDisplayBox(layoutBox);
     128        this.layoutState().createDisplayBox(layoutBox);
    131129        this.m_layoutStack.push(layoutBox);
    132130    }
     
    144142    }
    145143
    146     _createDisplayBox(layoutBox) {
    147         let displayBox = new Display.Box(layoutBox.node());
    148         this.m_displayToLayout.set(displayBox, layoutBox);
    149         this.m_layoutToDisplay.set(layoutBox, displayBox);
    150         // This is temporary.
    151         layoutBox.setDisplayBox(displayBox);
    152     }
    153 
    154     toDisplayBox(layoutBox) {
    155         ASSERT(layoutBox);
    156         return layoutBox.displayBox();
    157     }
    158 
    159     toLayoutBox(displayBox) {
    160         ASSERT(displayBox);
    161         ASSERT(this.m_displayToLayout.has(displayBox));
    162         return this.m_displayToLayout.get(displayBox);
     144    displayBox(layoutBox) {
     145        return this.layoutState().displayBox(layoutBox);
    163146    }
    164147
  • trunk/Tools/LayoutReloaded/FormattingState/FormattingState.js

    r229746 r229758  
    2828        this.m_layoutContext = layoutContext;
    2929        this.m_formattingContext = null;
     30        this.m_displayToLayout = new Map();
    3031    }
    3132
     
    3839    }
    3940
     41    createDisplayBox(layoutBox) {
     42        let displayBox = new Display.Box(layoutBox.node());
     43        this.m_displayToLayout.set(layoutBox, displayBox);
     44        // This is temporary.
     45        layoutBox.setDisplayBox(displayBox);
     46    }
     47
     48    displayBox(layoutBox) {
     49        ASSERT(layoutBox);
     50        return layoutBox.displayBox();
     51    }
     52
    4053    _setFormattingContext(formattingContext) {
    4154        this.m_formattingContext = formattingContext;
Note: See TracChangeset for help on using the changeset viewer.