Changeset 230621 in webkit


Ignore:
Timestamp:
Apr 12, 2018 8:09:03 PM (6 years ago)
Author:
Alan Bujtas
Message:

[LayoutReloaded] Move root container ownership to layout state
https://bugs.webkit.org/show_bug.cgi?id=184575

Reviewed by Antti Koivisto.

Now the root container is on the associated layout state (ICB only at this point though).

  • LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:

(BlockFormattingContext.prototype.layout):

  • LayoutReloaded/FormattingContext/FormattingContext.js:

(FormattingContext.prototype._layoutOutOfFlowDescendants):

  • LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:

(InlineFormattingContext.prototype._handleInlineBlockContainer):
(InlineFormattingContext.prototype._handleFloatingBox):

  • LayoutReloaded/Layout.js:

(layout):

  • LayoutReloaded/LayoutState.js:

(LayoutState):
(LayoutState.prototype.formattingContext):
(LayoutState.prototype.establishedFormattingState):
(LayoutState.prototype.formattingStateForBox):
(LayoutState.prototype.needsLayout):
(LayoutState.prototype.displayBox):
(LayoutState.prototype._formattingContext):
(LayoutState.prototype.layout): Deleted.
(LayoutState.prototype.formattingStates): Deleted.
(LayoutState.prototype.initialDisplayBox): Deleted.

  • LayoutReloaded/Utils.js:

(Utils._dumpBox):
(Utils._findDisplayBox): Deleted.

Location:
trunk/Tools
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r230601 r230621  
     12018-04-12  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LayoutReloaded] Move root container ownership to layout state
     4        https://bugs.webkit.org/show_bug.cgi?id=184575
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Now the root container is on the associated layout state (ICB only at this point though).
     9
     10        * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
     11        (BlockFormattingContext.prototype.layout):
     12        * LayoutReloaded/FormattingContext/FormattingContext.js:
     13        (FormattingContext.prototype._layoutOutOfFlowDescendants):
     14        * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
     15        (InlineFormattingContext.prototype._handleInlineBlockContainer):
     16        (InlineFormattingContext.prototype._handleFloatingBox):
     17        * LayoutReloaded/Layout.js:
     18        (layout):
     19        * LayoutReloaded/LayoutState.js:
     20        (LayoutState):
     21        (LayoutState.prototype.formattingContext):
     22        (LayoutState.prototype.establishedFormattingState):
     23        (LayoutState.prototype.formattingStateForBox):
     24        (LayoutState.prototype.needsLayout):
     25        (LayoutState.prototype.displayBox):
     26        (LayoutState.prototype._formattingContext):
     27        (LayoutState.prototype.layout): Deleted.
     28        (LayoutState.prototype.formattingStates): Deleted.
     29        (LayoutState.prototype.initialDisplayBox): Deleted.
     30        * LayoutReloaded/Utils.js:
     31        (Utils._dumpBox):
     32        (Utils._findDisplayBox): Deleted.
     33
    1342018-04-12  Jonathan Bedard  <jbedard@apple.com>
    235
  • trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js

    r230573 r230621  
    4848                this._computeStaticPosition(layoutBox);
    4949                if (layoutBox.establishesFormattingContext()) {
    50                     this.layoutState().layout(layoutBox);
     50                    this.layoutState().formattingContext(layoutBox).layout();
    5151                    break;
    5252                }
  • trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js

    r230580 r230621  
    174174            this._addToLayoutQueue(outOfFlowBox);
    175175            this._computeOutOfFlowWidth(outOfFlowBox);
    176             this.layoutState().layout(outOfFlowBox);
     176            this.layoutState().formattingContext(outOfFlowBox).layout();
    177177            this._computeOutOfFlowHeight(outOfFlowBox);
    178178            this._computeOutOfFlowPosition(outOfFlowBox);
  • trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js

    r230573 r230621  
    8282        this._adjustLineForInlineContainerStart(inlineBlockContainer);
    8383        displayBox.setWidth(Utils.width(inlineBlockContainer) + Utils.computedHorizontalBorderAndPadding(inlineBlockContainer.node()));
    84         this.layoutState().layout(inlineBlockContainer);
     84        this.layoutState().formattingContext(inlineBlockContainer).layout();
    8585        displayBox.setHeight(Utils.height(inlineBlockContainer) + Utils.computedVerticalBorderAndPadding(inlineBlockContainer.node()));
    8686        this._adjustLineForInlineContainerEnd(inlineBlockContainer);
     
    123123    _handleFloatingBox(floatingBox) {
    124124        this._computeFloatingWidth(floatingBox);
    125         this.layoutState().layout(floatingBox);
     125        this.layoutState().formattingContext(floatingBox).layout();
    126126        this._computeFloatingHeight(floatingBox);
    127127        let displayBox = this.displayBox(floatingBox);
  • trunk/Tools/LayoutReloaded/Layout.js

    r229786 r230621  
    2929    let displayBox = new Display.Box();
    3030    displayBox.setSize(viewportSize);
    31     let layoutState = new LayoutState(displayBox);
    32     layoutState.layout(initialContainingBlock);
     31    let layoutState = new LayoutState(initialContainingBlock, displayBox);
     32    layoutState.formattingContext(initialContainingBlock).layout();
    3333    return Utils.layoutTreeDump(initialContainingBlock, layoutState);
    3434}
  • trunk/Tools/LayoutReloaded/LayoutState.js

    r230580 r230621  
    2525
    2626class LayoutState {
    27     constructor(initialDisplayBox) {
     27    constructor(rootContainer, rootDisplayBox) {
     28        ASSERT(rootContainer.establishesFormattingContext());
     29        this.m_rootContainer = rootContainer;
     30        this.m_rootDisplayBox = rootDisplayBox;
     31
    2832        this.m_formattingStates = new Map();
    29         this.m_initialDisplayBox = initialDisplayBox;
    3033    }
    3134
    32     layout(formattingRoot) {
    33         let formattingState = this._createFormattingState(formattingRoot);
    34         this.m_formattingStates.set(formattingRoot, formattingState);
    35         this.formattingContext(formattingState).layout();
    36     }
    37 
    38     formattingContext(formattingState) {
    39         if (formattingState instanceof BlockFormattingState)
    40             return new BlockFormattingContext(formattingState);
    41         if (formattingState instanceof InlineFormattingState)
    42             return new InlineFormattingContext(formattingState);
    43         ASSERT_NOT_REACHED();
    44         return null;
    45     }
    46 
    47     formattingStates() {
    48         return this.m_formattingStates;
     35    formattingContext(formattingRoot) {
     36        return this._formattingContext(this.establishedFormattingState(formattingRoot));
    4937    }
    5038
    5139    establishedFormattingState(formattingRoot) {
    5240        ASSERT(formattingRoot.establishesFormattingContext());
    53         return this.m_formattingStates.get(formattingRoot);
     41        let formattingState = this.m_formattingStates.get(formattingRoot);
     42        if (formattingState)
     43            return formattingState;
     44        formattingState = this._createFormattingState(formattingRoot);
     45        this.m_formattingStates.set(formattingRoot, formattingState);
     46        return formattingState;
    5447    }
    5548
    5649    formattingStateForBox(layoutBox) {
    57         for (let formattingEntry of this.formattingStates()) {
     50        for (let formattingEntry of this.m_formattingStates) {
    5851            let formattingRoot = formattingEntry[0];
    5952            let formattingState = formattingEntry[1];
     
    7467
    7568    needsLayout() {
    76         for (let formattingEntry of this.formattingStates()) {
     69        for (let formattingEntry of this.m_formattingStates) {
    7770            let formattingState = formattingEntry[1];
    7871            if (formattingState.layoutNeeded())
     
    8376
    8477    displayBox(layoutBox) {
    85         for (let formattingEntry of this.formattingStates()) {
     78        for (let formattingEntry of this.m_formattingStates) {
    8679            let formattingState = formattingEntry[1];
    8780            let displayBox = formattingState.displayBoxes().get(layoutBox);
     
    8982                return displayBox;
    9083        }
    91         // It must be the ICB.
    92         ASSERT(!layoutBox.parent());
    93         return this.initialDisplayBox();
    94     }
    95 
    96     initialDisplayBox() {
    97         return this.m_initialDisplayBox;
     84        // It must be the root container.
     85        ASSERT(layoutBox == this.m_rootContainer);
     86        return this.m_rootDisplayBox;
    9887    }
    9988
     
    10897    }
    10998
     99    _formattingContext(formattingState) {
     100        if (formattingState instanceof BlockFormattingState)
     101            return new BlockFormattingContext(formattingState);
     102        if (formattingState instanceof InlineFormattingState)
     103            return new InlineFormattingContext(formattingState);
     104        ASSERT_NOT_REACHED();
     105        return null;
     106    }
    110107}
  • trunk/Tools/LayoutReloaded/Utils.js

    r230580 r230621  
    554554    }
    555555
    556     static _findDisplayBox(layoutState, box) {
    557         for (let formattingEntry of layoutState.formattingStates()) {
    558             let formattingState = formattingEntry[1];
    559             let displayBox = formattingState.displayBoxes().get(box);
    560             if (displayBox)
    561                 return displayBox;
    562         }
    563         ASSERT(!box.parent());
    564         return layoutState.initialDisplayBox();
    565     }
    566 
    567556    static _dumpBox(layoutState, box, level) {
    568557        // Skip anonymous boxes for now -This is the case where WebKit does not generate an anon inline container for text content where the text is a direct child
     
    575564        if (box.name() == "RenderInline") {
    576565            if (box.isInFlowPositioned()) {
    577                 let displayBox = Utils._findDisplayBox(layoutState, box);
     566                let displayBox = layoutState.displayBox(box);
    578567                let boxRect = displayBox.rect();
    579568                return indentation + box.node().tagName + " " + box.name() + "  (" + Utils.precisionRoundWithDecimals(boxRect.left()) + ", " + Utils.precisionRoundWithDecimals(boxRect.top()) + ")\n";
     
    583572        if (box.isAnonymous())
    584573            return "";
    585         let displayBox = Utils._findDisplayBox(layoutState, box);
     574        let displayBox = layoutState.displayBox(box);
    586575        let boxRect = displayBox.rect();
    587576        return indentation + (box.node().tagName ? (box.node().tagName + " ") : "")  + box.name() + " at (" + boxRect.left() + "," + boxRect.top() + ") size " + boxRect.width() + "x" + boxRect.height() + "\n";
Note: See TracChangeset for help on using the changeset viewer.