Changeset 229696 in webkit


Ignore:
Timestamp:
Mar 17, 2018 1:49:54 PM (6 years ago)
Author:
Alan Bujtas
Message:

[LayoutReloaded] Ensure that positioning happens within the formatting context
https://bugs.webkit.org/show_bug.cgi?id=183722

Reviewed by Antti Koivisto.

All sizing and positioning need to happen in the formatting context that the box lives in
including the final position of in- and out-of-flow descendants.

  • LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:

(BlockFormattingContext.prototype.layout):
(BlockFormattingContext.prototype._placeInFlowPositionedChildren):

  • LayoutReloaded/LayoutTree/Box.js:

(Layout.Box.prototype.establishesBlockFormattingContext):
(Layout.Box.prototype.isPositioned):
(Layout.Box.prototype.isRelativelyPositioned):
(Layout.Box.prototype.isAbsolutelyPositioned):
(Layout.Box.prototype.isOutOfFlowPositioned):
(Layout.Box.prototype.containingBlock):
(Layout.Box.prototype.isRelativePositioned): Deleted.
(Layout.Box.prototype.isAbsolutePositioned): Deleted.

  • LayoutReloaded/Utils.js:

(Utils.isRelativelyPositioned):
(Utils.isAbsolutelyPositioned):
(Utils.isRelativePositioned): Deleted.
(Utils.isAbsolutePositioned): Deleted.

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

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r229693 r229696  
     12018-03-17  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LayoutReloaded] Ensure that positioning happens within the formatting context
     4        https://bugs.webkit.org/show_bug.cgi?id=183722
     5
     6        Reviewed by Antti Koivisto.
     7
     8        All sizing and positioning need to happen in the formatting context that the box lives in
     9        including the final position of in- and out-of-flow descendants.
     10
     11        * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
     12        (BlockFormattingContext.prototype.layout):
     13        (BlockFormattingContext.prototype._placeInFlowPositionedChildren):
     14        * LayoutReloaded/LayoutTree/Box.js:
     15        (Layout.Box.prototype.establishesBlockFormattingContext):
     16        (Layout.Box.prototype.isPositioned):
     17        (Layout.Box.prototype.isRelativelyPositioned):
     18        (Layout.Box.prototype.isAbsolutelyPositioned):
     19        (Layout.Box.prototype.isOutOfFlowPositioned):
     20        (Layout.Box.prototype.containingBlock):
     21        (Layout.Box.prototype.isRelativePositioned): Deleted.
     22        (Layout.Box.prototype.isAbsolutePositioned): Deleted.
     23        * LayoutReloaded/Utils.js:
     24        (Utils.isRelativelyPositioned):
     25        (Utils.isAbsolutelyPositioned):
     26        (Utils.isRelativePositioned): Deleted.
     27        (Utils.isAbsolutePositioned): Deleted.
     28        * LayoutReloaded/misc/headers/Box.h:
     29
    1302018-03-16  Wenson Hsieh  <wenson_hsieh@apple.com>
    231
  • trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js

    r229692 r229696  
    6666                // Adjust position now that we have all the previous floats placed in this context -if needed.
    6767                this.floatingContext().computePosition(layoutBox);
    68                 // Move positioned children to their final position.
    69                 if (layoutBox.isContainer()) {
     68                // Move in-flow positioned children to their final position. If this layoutBox also establishes a formatting context, then positioning already has happend.
     69                if (layoutBox.isContainer() && !layoutBox.establishesFormattingContext())
    7070                    this._placeInFlowPositionedChildren(layoutBox);
    71                     // Place the out of flow content.
    72                     this._placeOutOfFlowDescendants(layoutBox);
    73                 }
    7471                // We are done with laying out this box.
    7572                this._removeFromLayoutQueue(layoutBox);
     
    8077            }
    8178        }
    82         // And finally place the out of flow descendants for the root.
     79        // And finally place the in- and out-of-flow descendants.
     80        this._placeInFlowPositionedChildren(this.rootContainer());
    8381        this._placeOutOfFlowDescendants(this.rootContainer());
    8482   }
     
    122120
    123121    _placeInFlowPositionedChildren(container) {
    124         for (let inFlowChild = container.firstInFlowChild(); inFlowChild; inFlowChild = inFlowChild.nextInFlowSibling())
    125             this._computeInFlowPositionedPosition(inFlowChild);
     122        for (let inFlowChild = container.firstInFlowChild(); inFlowChild; inFlowChild = inFlowChild.nextInFlowSibling()) {
     123            if (!inFlowChild.isInFlowPositioned())
     124                continue;
     125             this._computeInFlowPositionedPosition(inFlowChild);
     126        }
    126127    }
    127128
  • trunk/Tools/LayoutReloaded/LayoutTree/Box.js

    r229671 r229696  
    178178        // that are not block boxes, and block boxes with 'overflow' other than 'visible' (except when that value has been propagated to the viewport)
    179179        // establish new block formatting contexts for their contents.
    180         return this.isFloatingPositioned() || this.isAbsolutePositioned() || (this.isBlockContainerBox() && !this.isBlockLevelBox())
     180        return this.isFloatingPositioned() || this.isAbsolutelyPositioned() || (this.isBlockContainerBox() && !this.isBlockLevelBox())
    181181            || (this.isBlockLevelBox() && !Utils.isOverflowVisible(this));
    182182    }
     
    187187
    188188    isPositioned() {
    189         return this.isOutOfFlowPositioned() || this.isRelativePositioned();
    190     }
    191 
    192     isRelativePositioned() {
    193         return Utils.isRelativePositioned(this);
    194     }
    195 
    196     isAbsolutePositioned() {
    197         return Utils.isAbsolutePositioned(this);
     189        return this.isOutOfFlowPositioned() || this.isRelativelyPositioned();
     190    }
     191
     192    isRelativelyPositioned() {
     193        return Utils.isRelativelyPositioned(this);
     194    }
     195
     196    isAbsolutelyPositioned() {
     197        return Utils.isAbsolutelyPositioned(this) || this.isFixedPositioned();
    198198    }
    199199
     
    209209
    210210    isOutOfFlowPositioned() {
    211         return this.isAbsolutePositioned() || this.isFixedPositioned();
     211        return this.isAbsolutelyPositioned() || this.isFixedPositioned();
    212212    }
    213213
     
    235235        if (!this.isPositioned() || this.isInFlowPositioned())
    236236            return this.parent();
    237         let parent = this.parent();
    238         while (parent.parent()) {
    239             if (this.isAbsolutePositioned() && parent.isPositioned())
    240                 return parent;
    241             parent = parent.parent();
    242         }
    243         return parent;
     237        if (this.isAbsolutelyPositioned() && !this.isFixedPositioned()) {
     238            let ascendant = this.parent();
     239            while (ascendant.parent() && !ascendant.isPositioned())
     240                ascendant = ascendant.parent();
     241            return ascendant;
     242        }
     243        if (this.isFixedPositioned()) {
     244            let ascendant = this.parent();
     245            while (ascendant.parent())
     246                ascendant = ascendant.parent();
     247            return ascendant;
     248        }
     249        ASSERT_NOT_REACHED();
     250        return null;
    244251    }
    245252
  • trunk/Tools/LayoutReloaded/Utils.js

    r229664 r229696  
    432432    }
    433433
    434     static isRelativePositioned(box) {
     434    static isRelativelyPositioned(box) {
    435435        if (box.isAnonymous())
    436436            return false;
     
    439439    }
    440440
    441     static isAbsolutePositioned(box) {
     441    static isAbsolutelyPositioned(box) {
    442442        if (box.isAnonymous())
    443443            return false;
  • trunk/Tools/LayoutReloaded/misc/headers/Box.h

    r229658 r229696  
    6969    bool isInFlow() const;
    7070    bool isPositioned() const;
    71     bool isRelativePositioned() const;
    72     bool isAbsolutePositioned() const;
     71    bool isRelativelyPositioned() const;
     72    bool isAbsolutelyPositioned() const;
    7373    bool isFixedPositioned() const;
    7474    bool isOutOfFlowPositioned() const;
Note: See TracChangeset for help on using the changeset viewer.