Changeset 230469 in webkit


Ignore:
Timestamp:
Apr 9, 2018 10:06:37 PM (6 years ago)
Author:
Alan Bujtas
Message:

[LayoutReloaded] Add support for relatively positioned containers in inline formatting context.
https://bugs.webkit.org/show_bug.cgi?id=184439

Reviewed by Antti Koivisto.

  • LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:

(BlockFormattingContext.prototype._placeInFlowPositionedChildren): Deleted.
(BlockFormattingContext.prototype._computeInFlowPositionedPosition): Deleted.

  • LayoutReloaded/FormattingContext/FormattingContext.js:

(FormattingContext.prototype._computeInFlowPositionedPosition):
(FormattingContext.prototype._placeInFlowPositionedChildren):

  • LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:

(InlineFormattingContext.prototype._placeInFlowPositionedChildren): Deleted.

  • LayoutReloaded/Utils.js:

(Utils._dumpBox):
(Utils._dumpLines.):
(Utils._dumpLines):
(Utils.precisionRoundWithDecimals):
(Utils.precisionRound):
(Utils):

  • LayoutReloaded/test/index.html:
  • LayoutReloaded/test/inline-with-relative-positioning.html: Added.
Location:
trunk/Tools
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r230466 r230469  
     12018-04-09  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LayoutReloaded] Add support for relatively positioned containers in inline formatting context.
     4        https://bugs.webkit.org/show_bug.cgi?id=184439
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js:
     9        (BlockFormattingContext.prototype._placeInFlowPositionedChildren): Deleted.
     10        (BlockFormattingContext.prototype._computeInFlowPositionedPosition): Deleted.
     11        * LayoutReloaded/FormattingContext/FormattingContext.js:
     12        (FormattingContext.prototype._computeInFlowPositionedPosition):
     13        (FormattingContext.prototype._placeInFlowPositionedChildren):
     14        * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
     15        (InlineFormattingContext.prototype._placeInFlowPositionedChildren): Deleted.
     16        * LayoutReloaded/Utils.js:
     17        (Utils._dumpBox):
     18        (Utils._dumpLines.):
     19        (Utils._dumpLines):
     20        (Utils.precisionRoundWithDecimals):
     21        (Utils.precisionRound):
     22        (Utils):
     23        * LayoutReloaded/test/index.html:
     24        * LayoutReloaded/test/inline-with-relative-positioning.html: Added.
     25
    1262018-04-09  Zalan Bujtas  <zalan@apple.com>
    227
  • trunk/Tools/LayoutReloaded/FormattingContext/BlockFormatting/BlockFormattingContext.js

    r230243 r230469  
    117117        position.moveBy(new LayoutSize(this.marginLeft(layoutBox), this.marginTop(layoutBox)));
    118118        this.displayBox(layoutBox).setTopLeft(position);
    119     }
    120 
    121     _placeInFlowPositionedChildren(container) {
    122         if (!container.isContainer())
    123             return;
    124         // If this layoutBox also establishes a formatting context, then positioning already has happend at the formatting context.
    125         if (container.establishesFormattingContext() && container != this.formattingRoot())
    126             return;
    127         ASSERT(container.isContainer());
    128         for (let inFlowChild = container.firstInFlowChild(); inFlowChild; inFlowChild = inFlowChild.nextInFlowSibling()) {
    129             if (!inFlowChild.isInFlowPositioned())
    130                 continue;
    131             this._computeInFlowPositionedPosition(inFlowChild);
    132         }
    133119    }
    134120
     
    278264        }
    279265        return bottom;
    280     }
    281 
    282     _computeInFlowPositionedPosition(layoutBox) {
    283         // Start with the original, static position.
    284         let displayBox = this.displayBox(layoutBox);
    285         let relativePosition = displayBox.topLeft();
    286         // Top/bottom
    287         if (!Utils.isTopAuto(layoutBox))
    288             relativePosition.shiftTop(Utils.top(layoutBox));
    289         else if (!Utils.isBottomAuto(layoutBox))
    290             relativePosition.shiftTop(-Utils.bottom(layoutBox));
    291         // Left/right
    292         if (!Utils.isLeftAuto(layoutBox))
    293             relativePosition.shiftLeft(Utils.left(layoutBox));
    294         else if (!Utils.isRightAuto(layoutBox))
    295             relativePosition.shiftLeft(-Utils.right(layoutBox));
    296         displayBox.setTopLeft(relativePosition);
    297266    }
    298267
  • trunk/Tools/LayoutReloaded/FormattingContext/FormattingContext.js

    r230373 r230469  
    118118    }
    119119
     120    _computeInFlowPositionedPosition(layoutBox) {
     121        // Start with the original, static position.
     122        let displayBox = this.displayBox(layoutBox);
     123        let relativePosition = displayBox.topLeft();
     124        // Top/bottom
     125        if (!Utils.isTopAuto(layoutBox))
     126            relativePosition.shiftTop(Utils.top(layoutBox));
     127        else if (!Utils.isBottomAuto(layoutBox))
     128            relativePosition.shiftTop(-Utils.bottom(layoutBox));
     129        // Left/right
     130        if (!Utils.isLeftAuto(layoutBox))
     131            relativePosition.shiftLeft(Utils.left(layoutBox));
     132        else if (!Utils.isRightAuto(layoutBox))
     133            relativePosition.shiftLeft(-Utils.right(layoutBox));
     134        displayBox.setTopLeft(relativePosition);
     135    }
     136
     137    _placeInFlowPositionedChildren(container) {
     138        if (!container.isContainer())
     139            return;
     140        // If this layoutBox also establishes a formatting context, then positioning already has happend at the formatting context.
     141        if (container.establishesFormattingContext() && container != this.formattingRoot())
     142            return;
     143        ASSERT(container.isContainer());
     144        for (let inFlowChild = container.firstInFlowChild(); inFlowChild; inFlowChild = inFlowChild.nextInFlowSibling()) {
     145            if (!inFlowChild.isInFlowPositioned())
     146                continue;
     147            this._computeInFlowPositionedPosition(inFlowChild);
     148        }
     149    }
     150
    120151    _outOfFlowDescendants() {
    121152        // FIXME: This is highly inefficient but will do for now.
  • trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js

    r230464 r230469  
    153153    }
    154154
    155     _placeInFlowPositionedChildren(container) {
    156 
    157     }
    158 
    159155    _placeOutOfFlowDescendants(container) {
    160156
  • trunk/Tools/LayoutReloaded/Utils.js

    r230464 r230469  
    572572                return indentation + "#text RenderText\n";
    573573        }
    574         if (box.name() == "RenderInline")
     574        if (box.name() == "RenderInline") {
     575            if (box.isInFlowPositioned()) {
     576                let displayBox = Utils._findDisplayBox(layoutState, box);
     577                let boxRect = displayBox.rect();
     578                return indentation + box.node().tagName + " " + box.name() + "  (" + Utils.precisionRoundWithDecimals(boxRect.left()) + ", " + Utils.precisionRoundWithDecimals(boxRect.top()) + ")\n";
     579            }
    575580            return indentation + box.node().tagName + " " + box.name() + "\n";
     581        }
    576582        if (box.isAnonymous())
    577583            return "";
     
    589595        lines.forEach(function(line) {
    590596            let lineRect = line.rect();
    591             content += indentation + "RootInlineBox at (" + lineRect.left() + "," + lineRect.top() + ") size " + Utils.precisionRound(lineRect.width(), 2) + "x" + lineRect.height() + "\n";
     597            content += indentation + "RootInlineBox at (" + lineRect.left() + "," + lineRect.top() + ") size " + Utils.precisionRound(lineRect.width()) + "x" + lineRect.height() + "\n";
    592598            line.lineBoxes().forEach(function(lineBox) {
    593599                let indentation = " ".repeat(level + 1);
    594600                let inlineBoxName = lineBox.startPosition === undefined ? "InlineBox" : "InlineTextBox";
    595                 content += indentation +  inlineBoxName + " at (" + Utils.precisionRound(lineBox.lineBoxRect.left(), 2) + "," + Utils.precisionRound(lineBox.lineBoxRect.top(), 2) + ") size " + Utils.precisionRound(lineBox.lineBoxRect.width(), 2) + "x" + lineBox.lineBoxRect.height() + "\n";
     601                content += indentation +  inlineBoxName + " at (" + Utils.precisionRound(lineBox.lineBoxRect.left()) + "," + Utils.precisionRound(lineBox.lineBoxRect.top()) + ") size " + Utils.precisionRound(lineBox.lineBoxRect.width()) + "x" + lineBox.lineBoxRect.height() + "\n";
    596602            });
    597603        });
     
    611617    }
    612618
    613     static precisionRound(number, precision) {
    614         let factor = Math.pow(10, precision);
     619    static precisionRoundWithDecimals(number) {
     620        return number.toFixed(2);
     621    }
     622
     623    static precisionRound(number) {
     624        let factor = Math.pow(10, 2);
    615625        return Math.round(number * factor) / factor;
    616626    }
  • trunk/Tools/LayoutReloaded/test/index.html

    r230466 r230469  
    8080    "inline-formatting-context-floats2.html",
    8181    "inline-with-padding-border-margin-offsets.html",
    82     "inline-block-with-fixed-width-height.html"
     82    "inline-block-with-fixed-width-height.html",
     83    "inline-with-relative-positioning.html"
    8384];
    8485
Note: See TracChangeset for help on using the changeset viewer.