Changeset 230386 in webkit


Ignore:
Timestamp:
Apr 8, 2018 8:59:10 PM (6 years ago)
Author:
Alan Bujtas
Message:

[LayoutReloaded] Adjust line with inline container's margin border and padding
https://bugs.webkit.org/show_bug.cgi?id=184409

Reviewed by Antti Koivisto.

  • LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:

(InlineFormattingContext.prototype.layout):
(InlineFormattingContext.prototype._handleFloatingBox):
(InlineFormattingContext.prototype._adjustLineForInlineContainerStart):
(InlineFormattingContext.prototype._adjustLineForInlineContainerEnd):

  • LayoutReloaded/FormattingContext/InlineFormatting/Line.js:

(Line.prototype.shrink):
(Line.prototype.adjustWithOffset):
(Line.prototype.moveContentHorizontally):
(Line.prototype.addTextLineBox):
(Line):
(Line.prototype.addFloatingBox): Deleted.

  • LayoutReloaded/misc/LayoutReloadedWebKit.patch:
  • LayoutReloaded/test/index.html:
  • LayoutReloaded/test/inline-with-padding-border-margin-offsets.html: Added.
Location:
trunk/Tools
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r230373 r230386  
     12018-04-08  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LayoutReloaded] Adjust line with inline container's margin border and padding
     4        https://bugs.webkit.org/show_bug.cgi?id=184409
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js:
     9        (InlineFormattingContext.prototype.layout):
     10        (InlineFormattingContext.prototype._handleFloatingBox):
     11        (InlineFormattingContext.prototype._adjustLineForInlineContainerStart):
     12        (InlineFormattingContext.prototype._adjustLineForInlineContainerEnd):
     13        * LayoutReloaded/FormattingContext/InlineFormatting/Line.js:
     14        (Line.prototype.shrink):
     15        (Line.prototype.adjustWithOffset):
     16        (Line.prototype.moveContentHorizontally):
     17        (Line.prototype.addTextLineBox):
     18        (Line):
     19        (Line.prototype.addFloatingBox): Deleted.
     20        * LayoutReloaded/misc/LayoutReloadedWebKit.patch:
     21        * LayoutReloaded/test/index.html:
     22        * LayoutReloaded/test/inline-with-padding-border-margin-offsets.html: Added.
     23
    1242018-04-07  Zalan Bujtas  <zalan@apple.com>
    225
  • trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js

    r230373 r230386  
    4343                if (inlineContainerStack.indexOf(layoutBox) == -1) {
    4444                    inlineContainerStack.push(layoutBox);
    45                     this._adjustLineForInlineContainerStart();
     45                    this._adjustLineForInlineContainerStart(layoutBox);
    4646                    if (layoutBox.establishesFormattingContext())
    4747                        this.layoutState().layout(layoutBox);
     
    5050                } else {
    5151                    inlineContainerStack.pop(layoutBox);
    52                     this._adjustLineForInlineContainerEnd();
     52                    this._adjustLineForInlineContainerEnd(layoutBox);
    5353                    this._removeFromLayoutQueue(layoutBox);
    5454                    this._addToLayoutQueue(layoutBox.nextInFlowOrFloatSibling());
     
    117117        if (displayBox.top() >= this._line().rect().bottom())
    118118            return;
    119         this._line().addFloatingBox(displayBox, Utils.isFloatingLeft(floatingBox));
     119        let floatWidth = displayBox.width();
     120        this._line().shrink(floatWidth);
     121        if (Utils.isFloatingLeft(floatingBox))
     122            this._line().moveContentHorizontally(floatWidth);
    120123    }
    121124
    122125    _adjustLineForInlineContainerStart(inlineContainer) {
    123 
     126        let offset = this.marginLeft(inlineContainer) + Utils.computedBorderAndPaddingLeft(inlineContainer.node());
     127        this._line().adjustWithOffset(offset);
    124128    }
    125129
    126130    _adjustLineForInlineContainerEnd(inlineContainer) {
    127 
     131        let offset = this.marginRight(inlineContainer) + Utils.computedBorderAndPaddingRight(inlineContainer.node());
     132        this._line().adjustWithOffset(offset);
    128133    }
    129134
  • trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/Line.js

    r230324 r230386  
    4747    }
    4848
     49    shrink(width) {
     50        this.m_availableWidth -= width;
     51    }
     52
     53    adjustWithOffset(offset) {
     54        this.m_availableWidth -= offset;
     55        this.m_lineRect.growBy(new LayoutSize(offset, 0));
     56    }
     57
     58    moveContentHorizontally(offset) {
     59        // Push non-floating boxes to the right.
     60        for (let lineBox of this.m_lineBoxes)
     61            lineBox.lineBoxRect.moveHorizontally(offset);
     62        this.m_lineRect.moveHorizontally(offset);
     63    }
     64
    4965    addTextLineBox(startPosition, endPosition, size) {
    5066        ASSERT(size.width() <= this.m_availableWidth);
     
    5571        this.m_lineRect.growBy(new LayoutSize(size.width(), 0));
    5672    }
    57 
    58     addFloatingBox(floatingDisplayBox, isFloatingLeft) {
    59         let width = floatingDisplayBox.width();
    60         ASSERT(width <= this.m_availableWidth);
    61         this.m_availableWidth -= width;
    62         if (!isFloatingLeft)
    63             return;
    64         // Push non-floating boxes to the right.
    65         for (let lineBox of this.m_lineBoxes)
    66             lineBox.lineBoxRect.moveHorizontally(width);
    67         this.m_lineRect.moveHorizontally(width);
    68     }
    6973}
  • trunk/Tools/LayoutReloaded/misc/LayoutReloadedWebKit.patch

    r230366 r230386  
    3939 rendering/LayoutState.cpp
    4040diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
    41 index 690b9e941bd..3ffc4406907 100644
     41index 2ae0c8a22d5..edcd82aa95a 100644
    4242--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
    4343+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
     
    579579 
    580580diff --git a/Source/WebCore/rendering/InlineBox.cpp b/Source/WebCore/rendering/InlineBox.cpp
    581 index cd23ae0b97c..da072efdfa9 100644
     581index cd23ae0b97c..7cfd4bb2d42 100644
    582582--- a/Source/WebCore/rendering/InlineBox.cpp
    583583+++ b/Source/WebCore/rendering/InlineBox.cpp
    584 @@ -123,6 +123,15 @@ void InlineBox::outputLineBox(TextStream& stream, bool mark, int depth) const
     584@@ -123,6 +123,18 @@ void InlineBox::outputLineBox(TextStream& stream, bool mark, int depth) const
    585585     stream.nextLine();
    586586 }
     
    588588+void InlineBox::outputSimplifiedLineTree(TextStream& stream, int depth) const
    589589+{
     590+    // Ignore inline flows for now. LayoutReloaded does not have the concept of flow boxes.
     591+    if (is<InlineFlowBox>(*this) && !is<RootInlineBox>(*this))
     592+        return;
    590593+    int printedCharacters = 0;
    591594+    while (++printedCharacters <= depth)
     
    611614 #endif
    612615diff --git a/Source/WebCore/rendering/InlineFlowBox.cpp b/Source/WebCore/rendering/InlineFlowBox.cpp
    613 index 063f3b64189..5494aabe546 100644
     616index 063f3b64189..ee32b981371 100644
    614617--- a/Source/WebCore/rendering/InlineFlowBox.cpp
    615618+++ b/Source/WebCore/rendering/InlineFlowBox.cpp
    616 @@ -1720,6 +1720,13 @@ void InlineFlowBox::outputLineTreeAndMark(WTF::TextStream& stream, const InlineB
     619@@ -1720,6 +1720,18 @@ void InlineFlowBox::outputLineTreeAndMark(WTF::TextStream& stream, const InlineB
    617620         box->outputLineTreeAndMark(stream, markedBox, depth + 1);
    618621 }
     
    621624+{
    622625+    InlineBox::outputSimplifiedLineTree(stream, depth);
    623 +    for (auto* box = firstChild(); box; box = box->nextOnLine())
    624 +        box->outputSimplifiedLineTree(stream, depth + 1);
     626+    for (auto* box = firstChild(); box; box = box->nextOnLine()) {
     627+        // DO not increment depth for flow boxes. LayoutReloaded does not have the concept of them.
     628+        if (is<InlineFlowBox>(*box) && !is<RootInlineBox>(*box))
     629+            box->outputSimplifiedLineTree(stream, depth);
     630+        else
     631+            box->outputSimplifiedLineTree(stream, depth + 1);
     632+    }
    625633+}
    626634+
  • trunk/Tools/LayoutReloaded/test/index.html

    r230373 r230386  
    7878    "inline-floating1.html",
    7979    "inline-formatting-context-floats1.html",
    80     "inline-formatting-context-floats2.html"
     80    "inline-formatting-context-floats2.html",
     81    "inline-with-padding-border-margin-offsets.html"
    8182];
    8283
Note: See TracChangeset for help on using the changeset viewer.