Changeset 229739 in webkit


Ignore:
Timestamp:
Mar 19, 2018 10:02:41 PM (6 years ago)
Author:
Alan Bujtas
Message:

[LayoutReloaded] Layout.Box should not create the formatting context.
https://bugs.webkit.org/show_bug.cgi?id=183766

Reviewed by Antti Koivisto.

Since the formattingContext's lifetime is tied to the layout, the LayoutContext
should construct it instead.

  • LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:

(BlockFormattingContext):
(BlockFormattingContext.prototype.layout):
(BlockFormattingContext.prototype._layoutOutOfFlowDescendants):
(BlockFormattingContext.prototype._contentHeight):

  • LayoutReloaded/FormattingContext/FormattingContext.js:

(FormattingContext):
(FormattingContext.prototype.layoutContext):
(FormattingContext.prototype.toDisplayBox):
(FormattingContext.prototype._outOfFlowDescendants):

  • LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:

(InlineFormattingContext):
(InlineFormattingContext.prototype.layout):

  • LayoutReloaded/Layout.js:

(layout):

  • LayoutReloaded/LayoutContext.js:

(LayoutContext.prototype.layout):
(LayoutContext.prototype._createFormattingContext):
(LayoutContext):
(LayoutContext.prototype.layoutFormattingContext): Deleted.

  • LayoutReloaded/LayoutTree/Box.js:

(Layout.Box):
(Layout.Box.prototype.establishedFormattingContext): Deleted.

  • LayoutReloaded/misc/headers/Box.h:
Location:
trunk/Tools
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r229735 r229739  
     12018-03-19  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LayoutReloaded] Layout.Box should not create the formatting context.
     4        https://bugs.webkit.org/show_bug.cgi?id=183766
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Since the formattingContext's lifetime is tied to the layout, the LayoutContext
     9        should construct it instead.
     10
     11        * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
     12        (BlockFormattingContext):
     13        (BlockFormattingContext.prototype.layout):
     14        (BlockFormattingContext.prototype._layoutOutOfFlowDescendants):
     15        (BlockFormattingContext.prototype._contentHeight):
     16        * LayoutReloaded/FormattingContext/FormattingContext.js:
     17        (FormattingContext):
     18        (FormattingContext.prototype.layoutContext):
     19        (FormattingContext.prototype.toDisplayBox):
     20        (FormattingContext.prototype._outOfFlowDescendants):
     21        * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
     22        (InlineFormattingContext):
     23        (InlineFormattingContext.prototype.layout):
     24        * LayoutReloaded/Layout.js:
     25        (layout):
     26        * LayoutReloaded/LayoutContext.js:
     27        (LayoutContext.prototype.layout):
     28        (LayoutContext.prototype._createFormattingContext):
     29        (LayoutContext):
     30        (LayoutContext.prototype.layoutFormattingContext): Deleted.
     31        * LayoutReloaded/LayoutTree/Box.js:
     32        (Layout.Box):
     33        (Layout.Box.prototype.establishedFormattingContext): Deleted.
     34        * LayoutReloaded/misc/headers/Box.h:
     35
    1362018-03-19  Chris Dumez  <cdumez@apple.com>
    237
  • trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js

    r229734 r229739  
    2424 */
    2525class BlockFormattingContext extends FormattingContext {
    26     constructor(root) {
    27         super(root);
     26    constructor(root, layoutContext) {
     27        super(root, layoutContext);
    2828        // New block formatting context always establishes a new floating context.
    2929        this.m_floatingContext = new FloatingContext(this);
    3030    }
    3131
    32     layout(layoutContext) {
     32    layout() {
    3333        // 9.4.1 Block formatting contexts
    3434        // In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block.
     
    5151                this._computeStaticPosition(layoutBox);
    5252                if (layoutBox.establishesFormattingContext()) {
    53                     layoutContext.layoutFormattingContext(layoutBox.establishedFormattingContext());
     53                    this.layoutContext().layout(layoutBox);
    5454                    break;
    5555                }
     
    7979        this._placeInFlowPositionedChildren(this.rootContainer());
    8080        // And take care of out-of-flow boxes as the final step.
    81         this._layoutOutOfFlowDescendants(layoutContext);
     81        this._layoutOutOfFlowDescendants();
    8282   }
    8383
     
    135135    }
    136136
    137     _layoutOutOfFlowDescendants(layoutContext) {
     137    _layoutOutOfFlowDescendants() {
    138138        // This lays out all the out-of-flow boxes that belong to this formatting context even if
    139139        // the root container is not the containing block.
     
    142142            this._addToLayoutQueue(outOfFlowBox);
    143143            this.computeWidth(outOfFlowBox);
    144             layoutContext.layoutFormattingContext(outOfFlowBox.establishedFormattingContext());
     144            this.layoutContext().layout(outOfFlowBox);
    145145            this.computeHeight(outOfFlowBox);
    146146            this._computeOutOfFlowPosition(outOfFlowBox);
     
    264264            return 0;
    265265        if (layoutBox.establishesInlineFormattingContext()) {
    266             ASSERT(layoutBox.establishedFormattingContext());
    267266            let lines = layoutBox.establishedFormattingContext().lines();
    268267            if (!lines.length)
  • trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js

    r229734 r229739  
    2525
    2626class FormattingContext {
    27     constructor(rootContainer) {
     27    constructor(rootContainer, layoutContext) {
    2828        this.m_rootContainer = rootContainer;
     29        this.m_layoutContext = layoutContext;
    2930        this.m_floatingContext = null;
    3031        this.m_displayToLayout = new Map();
     
    3536    rootContainer() {
    3637        return this.m_rootContainer;
     38    }
     39
     40    layoutContext() {
     41        return this.m_layoutContext;
    3742    }
    3843
     
    144149    toDisplayBox(layoutBox) {
    145150        ASSERT(layoutBox);
    146         ASSERT(this.m_layoutToDisplay.has(layoutBox) || layoutBox.establishedFormattingContext() == this);
    147         if (layoutBox.establishedFormattingContext() == this)
    148             return layoutBox.displayBox();
    149         return this.m_layoutToDisplay.get(layoutBox);
     151        return layoutBox.displayBox();
    150152    }
    151153
     
    183185                outOfFlowBoxes.push(outOfFlowBox);
    184186            else if (containingBlock.isDescendantOf(this.rootContainer())) {
    185                 if (!containingBlock.establishedFormattingContext() || !containingBlock.isPositioned())
     187                if (!containingBlock.establishesFormattingContext() || !containingBlock.isPositioned())
    186188                    outOfFlowBoxes.push(outOfFlowBox);
    187189            }
  • trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js

    r229692 r229739  
    2525
    2626class InlineFormattingContext extends FormattingContext {
    27     constructor(root) {
    28         super(root);
     27    constructor(root, layoutContext) {
     28        super(root, layoutContext);
    2929        // If the block container box that initiates this inline formatting contex also establishes a block context, create a new float for us.
    3030        ASSERT(root.isBlockContainerBox());
     
    4040    }
    4141
    42     layout(layoutContext) {
     42    layout() {
    4343        // 9.4.2 Inline formatting contexts
    4444        // In an inline formatting context, boxes are laid out horizontally, one after the other, beginning at the top of a containing block.
     
    5353                let layoutBox = this._nextInLayoutQueue();
    5454                if (layoutBox.establishesFormattingContext()) {
    55                     layoutContext.layoutFormattingContext(layoutBox.establishedFormattingContext());
     55                    this.layoutContext().layout(layoutBox);
    5656                    break;
    5757                }
  • trunk/Tools/LayoutReloaded/Layout.js

    r229702 r229739  
    3232
    3333    let layoutContext = new LayoutContext(initialContainingBlock);
    34     layoutContext.layoutFormattingContext(initialContainingBlock.establishedFormattingContext());
     34    layoutContext.layout(initialContainingBlock);
    3535    return Utils.layoutTreeDump(initialContainingBlock);
    3636}
  • trunk/Tools/LayoutReloaded/LayoutContext.js

    r229473 r229739  
    2828    }
    2929
    30     layoutFormattingContext(formattingContext) {
    31         formattingContext.layout(this);
     30    layout(formattingRoot) {
     31        let formattingContext = this._createFormattingContext(formattingRoot);
     32        formattingContext.layout();
     33    }
     34
     35    _createFormattingContext(formattingRoot) {
     36        ASSERT(formattingRoot.establishesFormattingContext());
     37        if (formattingRoot.establishesBlockFormattingContext())
     38            return new BlockFormattingContext(formattingRoot, this);
     39        if (formattingRoot.establishesInlineFormattingContext())
     40            return new InlineFormattingContext(formattingRoot, this);
     41        ASSERT_NOT_REACHED();
     42        return null;
    3243    }
    3344}
  • trunk/Tools/LayoutReloaded/LayoutTree/Box.js

    r229734 r229739  
    3535        this.m_previousSibling = null;
    3636        this.m_isAnonymous = false;
    37         this.m_establishedFormattingContext = null;
    3837        this.m_displayBox = null;
    3938    }
     
    147146            return false;
    148147        return this.establishesBlockFormattingContext() || this.establishesInlineFormattingContext();
    149     }
    150 
    151     establishedFormattingContext() {
    152         if (this.establishesFormattingContext() && !this.m_establishedFormattingContext)
    153             this.m_establishedFormattingContext = this.establishesBlockFormattingContext() ? new BlockFormattingContext(this) : new InlineFormattingContext(this);
    154         return this.m_establishedFormattingContext;
    155148    }
    156149
  • trunk/Tools/LayoutReloaded/misc/headers/Box.h

    r229696 r229739  
    6565    bool establishesBlockFormattingContext() const;
    6666
    67     FormattingContext* establishedFormattingContext();
    68 
    6967    bool isInFlow() const;
    7068    bool isPositioned() const;
     
    9290    bool m_isAnonymous { false };
    9391    LayoutRect m_rect;
    94     FormattingContext* m_establishedFormattingContext { nullptr };
    9592};
    9693
Note: See TracChangeset for help on using the changeset viewer.