Changeset 230700 in webkit


Ignore:
Timestamp:
Apr 16, 2018 10:17:26 PM (6 years ago)
Author:
Alan Bujtas
Message:

[LayoutReloaded] Add support for replaced box.
https://bugs.webkit.org/show_bug.cgi?id=184680

Reviewed by Antti Koivisto.

Basic support for inline replaced.

  • LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:

(InlineFormattingContext.prototype._handleInlineBox):
(InlineFormattingContext.prototype._handleInlineBlock):
(InlineFormattingContext.prototype._handleReplaced):

  • LayoutReloaded/FormattingContext/InlineFormatting/Line.js:

(Line.prototype.lastLineBox):
(Line.prototype.addInlineBox):
(Line.prototype.addInlineContainerBox): Deleted.

  • LayoutReloaded/TreeBuilder.js:

(TreeBuilder.prototype._createAndAttachBox):

  • LayoutReloaded/Utils.js:

(Utils._dumpBox):

  • LayoutReloaded/test/index.html:
  • LayoutReloaded/test/inline-simple-replaced.html: Added.
Location:
trunk/Tools
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r230699 r230700  
     12018-04-16  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LayoutReloaded] Add support for replaced box.
     4        https://bugs.webkit.org/show_bug.cgi?id=184680
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Basic support for inline replaced.
     9
     10        * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
     11        (InlineFormattingContext.prototype._handleInlineBox):
     12        (InlineFormattingContext.prototype._handleInlineBlock):
     13        (InlineFormattingContext.prototype._handleReplaced):
     14        * LayoutReloaded/FormattingContext/InlineFormatting/Line.js:
     15        (Line.prototype.lastLineBox):
     16        (Line.prototype.addInlineBox):
     17        (Line.prototype.addInlineContainerBox): Deleted.
     18        * LayoutReloaded/TreeBuilder.js:
     19        (TreeBuilder.prototype._createAndAttachBox):
     20        * LayoutReloaded/Utils.js:
     21        (Utils._dumpBox):
     22        * LayoutReloaded/test/index.html:
     23        * LayoutReloaded/test/inline-simple-replaced.html: Added.
     24
    1252018-04-16  Zalan Bujtas  <zalan@apple.com>
    226
  • trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js

    r230699 r230700  
    105105        if (inlineBox.text())
    106106            return this._handleText(inlineBox);
     107        else
     108            return this._handleReplaced(inlineBox);
    107109    }
    108110
     
    111113        let displayBox = this.displayBox(inlineBlockBox);
    112114
    113         // TODO: auto width/height
     115        // TODO: auto width/height and check if content actually at all.
    114116        this._adjustLineForInlineContainerStart(inlineBlockBox);
    115117        displayBox.setWidth(Utils.width(inlineBlockBox) + Utils.computedHorizontalBorderAndPadding(inlineBlockBox.node()));
    116118        this.layoutState().formattingContext(inlineBlockBox).layout();
    117119        displayBox.setHeight(Utils.height(inlineBlockBox) + Utils.computedVerticalBorderAndPadding(inlineBlockBox.node()));
     120        this._line().addInlineBox(displayBox.size());
    118121        this._adjustLineForInlineContainerEnd(inlineBlockBox);
    119         this._line().addInlineContainerBox(displayBox.size());
    120122    }
    121123
     
    156158            this._line().moveContentHorizontally(floatWidth);
    157159    }
     160
     161    _handleReplaced(replacedBox) {
     162        // TODO: intrinsic size and check if content actually at all.
     163        let displayBox = this.displayBox(replacedBox);
     164        this._adjustLineForInlineContainerStart(replacedBox);
     165        displayBox.setWidth(Utils.width(replacedBox) + Utils.computedHorizontalBorderAndPadding(replacedBox.node()));
     166
     167        displayBox.setHeight(Utils.height(replacedBox) + Utils.computedVerticalBorderAndPadding(replacedBox.node()));
     168        this._line().addInlineBox(displayBox.size());
     169        displayBox.setTopLeft(this._line().lastLineBox().lineBoxRect.topLeft());
     170        this._adjustLineForInlineContainerEnd(replacedBox);
     171   }
    158172
    159173    _adjustLineForInlineContainerStart(inlineContainer) {
  • trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/Line.js

    r230656 r230700  
    3232
    3333    LayoutRect rect();
    34     lineBoxes();
     34    Vector<InlineDisplayBox> lineBoxes();
    3535
    36     shrink(float width);
    37     adjustWithOffset(LayoutUnit offset);
    38     moveContentHorizontally(LayoutUnit offset);
    39     addInlineContainerBox(LayoutSize);
    40     addTextLineBox(unsigned startPosition, unsigned endPosition, LayoutSize size);
     36    void shrink(float width);
     37    void adjustWithOffset(LayoutUnit offset);
     38    void moveContentHorizontally(LayoutUnit offset);
     39    void addInlineContainerBox(LayoutSize);
     40    void addTextLineBox(unsigned startPosition, unsigned endPosition, LayoutSize size);
    4141};
    4242*/
     
    6464    }
    6565
     66    lastLineBox() {
     67        return this.m_lineBoxes[this.m_lineBoxes.length - 1];
     68    }
     69
    6670    shrink(width) {
    6771        this.m_availableWidth -= width;
     
    8084    }
    8185
    82     addInlineContainerBox(size) {
     86    addInlineBox(size) {
    8387        let width = size.width();
    8488        ASSERT(width <= this.m_availableWidth);
  • trunk/Tools/LayoutReloaded/TreeBuilder.js

    r230655 r230700  
    5555        if (name == "RenderBlock" || name == "RenderBody")
    5656            box = new Layout.BlockContainer(node, id);
    57         else if (name == "RenderInline") {
     57        else if (name == "RenderInline")
    5858            box = new Layout.InlineContainer(node, id);
    59         } else if (name == "RenderText") {
     59        else if (name == "RenderText")
    6060            text = new Text(node, id);
    61         } else
     61        else if (name == "RenderImage")
     62            box = new Layout.InlineBox(node, id);
     63        else
    6264            box = new Layout.Box(node, id);
    6365
  • trunk/Tools/LayoutReloaded/Utils.js

    r230655 r230700  
    585585            return indentation + box.node().tagName + " " + box.name() + "\n";
    586586        }
     587        if (box.name() == "RenderImage") {
     588            let boxRect = layoutState.displayBox(box).rect();
     589            return indentation + box.node().tagName + " " + box.name() + " at (" + Utils.precisionRound(boxRect.left()) + "," + Utils.precisionRound(boxRect.top()) + ") size " + Utils.precisionRound(boxRect.width()) + "x" + Utils.precisionRound(boxRect.height()) + "\n";
     590
     591        }
    587592        if (box.isAnonymous())
    588593            return "";
  • trunk/Tools/LayoutReloaded/test/index.html

    r230655 r230700  
    8383    "inline-block-with-fixed-width-height.html",
    8484    "inline-with-relative-positioning.html",
    85     "inline-with-out-of-flow-descendant.html"
     85    "inline-with-out-of-flow-descendant.html",
     86    "inline-simple-replaced.html"
    8687];
    8788
Note: See TracChangeset for help on using the changeset viewer.