Title: [230386] trunk/Tools
Revision
230386
Author
za...@apple.com
Date
2018-04-08 20:59:10 -0700 (Sun, 08 Apr 2018)

Log 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.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (230385 => 230386)


--- trunk/Tools/ChangeLog	2018-04-09 02:58:40 UTC (rev 230385)
+++ trunk/Tools/ChangeLog	2018-04-09 03:59:10 UTC (rev 230386)
@@ -1,3 +1,26 @@
+2018-04-08  Zalan Bujtas  <za...@apple.com>
+
+        [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.
+
 2018-04-07  Zalan Bujtas  <za...@apple.com>
 
         [LayoutReloaded] Add support for InlineContainer

Modified: trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js (230385 => 230386)


--- trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js	2018-04-09 02:58:40 UTC (rev 230385)
+++ trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/InlineFormattingContext.js	2018-04-09 03:59:10 UTC (rev 230386)
@@ -42,7 +42,7 @@
             if (layoutBox.isInlineContainer()) {
                 if (inlineContainerStack.indexOf(layoutBox) == -1) {
                     inlineContainerStack.push(layoutBox);
-                    this._adjustLineForInlineContainerStart();
+                    this._adjustLineForInlineContainerStart(layoutBox);
                     if (layoutBox.establishesFormattingContext())
                         this.layoutState().layout(layoutBox);
                     else
@@ -49,7 +49,7 @@
                         this._addToLayoutQueue(layoutBox.firstInFlowOrFloatChild());
                 } else {
                     inlineContainerStack.pop(layoutBox);
-                    this._adjustLineForInlineContainerEnd();
+                    this._adjustLineForInlineContainerEnd(layoutBox);
                     this._removeFromLayoutQueue(layoutBox);
                     this._addToLayoutQueue(layoutBox.nextInFlowOrFloatSibling());
                     // Place the inflow positioned children.
@@ -116,15 +116,20 @@
         // Check if the floating box is actually on the current line or got pushed further down.
         if (displayBox.top() >= this._line().rect().bottom())
             return;
-        this._line().addFloatingBox(displayBox, Utils.isFloatingLeft(floatingBox));
+        let floatWidth = displayBox.width();
+        this._line().shrink(floatWidth);
+        if (Utils.isFloatingLeft(floatingBox))
+            this._line().moveContentHorizontally(floatWidth);
     }
 
     _adjustLineForInlineContainerStart(inlineContainer) {
-
+        let offset = this.marginLeft(inlineContainer) + Utils.computedBorderAndPaddingLeft(inlineContainer.node());
+        this._line().adjustWithOffset(offset);
     }
 
     _adjustLineForInlineContainerEnd(inlineContainer) {
-
+        let offset = this.marginRight(inlineContainer) + Utils.computedBorderAndPaddingRight(inlineContainer.node());
+        this._line().adjustWithOffset(offset);
     }
 
     _placeInFlowPositionedChildren(container) {

Modified: trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/Line.js (230385 => 230386)


--- trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/Line.js	2018-04-09 02:58:40 UTC (rev 230385)
+++ trunk/Tools/LayoutReloaded/FormattingContext/InlineFormatting/Line.js	2018-04-09 03:59:10 UTC (rev 230386)
@@ -46,6 +46,22 @@
         return this.m_lineBoxes;
     }
 
+    shrink(width) {
+        this.m_availableWidth -= width;
+    }
+
+    adjustWithOffset(offset) {
+        this.m_availableWidth -= offset;
+        this.m_lineRect.growBy(new LayoutSize(offset, 0));
+    }
+
+    moveContentHorizontally(offset) {
+        // Push non-floating boxes to the right.
+        for (let lineBox of this.m_lineBoxes)
+            lineBox.lineBoxRect.moveHorizontally(offset);
+        this.m_lineRect.moveHorizontally(offset);
+    }
+
     addTextLineBox(startPosition, endPosition, size) {
         ASSERT(size.width() <= this.m_availableWidth);
         this.m_availableWidth -= size.width();
@@ -54,16 +70,4 @@
         this.m_lineBoxes.push({startPosition, endPosition, lineBoxRect});
         this.m_lineRect.growBy(new LayoutSize(size.width(), 0));
     }
-
-    addFloatingBox(floatingDisplayBox, isFloatingLeft) {
-        let width = floatingDisplayBox.width();
-        ASSERT(width <= this.m_availableWidth);
-        this.m_availableWidth -= width;
-        if (!isFloatingLeft)
-            return;
-        // Push non-floating boxes to the right.
-        for (let lineBox of this.m_lineBoxes)
-            lineBox.lineBoxRect.moveHorizontally(width);
-        this.m_lineRect.moveHorizontally(width);
-    }
 }

Modified: trunk/Tools/LayoutReloaded/misc/LayoutReloadedWebKit.patch (230385 => 230386)


--- trunk/Tools/LayoutReloaded/misc/LayoutReloadedWebKit.patch	2018-04-09 02:58:40 UTC (rev 230385)
+++ trunk/Tools/LayoutReloaded/misc/LayoutReloadedWebKit.patch	2018-04-09 03:59:10 UTC (rev 230386)
@@ -38,7 +38,7 @@
  rendering/LayoutRepainter.cpp
  rendering/LayoutState.cpp
 diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
-index 690b9e941bd..3ffc4406907 100644
+index 2ae0c8a22d5..edcd82aa95a 100644
 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
 +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
 @@ -396,6 +396,10 @@
@@ -578,15 +578,18 @@
  }
  
 diff --git a/Source/WebCore/rendering/InlineBox.cpp b/Source/WebCore/rendering/InlineBox.cpp
-index cd23ae0b97c..da072efdfa9 100644
+index cd23ae0b97c..7cfd4bb2d42 100644
 --- a/Source/WebCore/rendering/InlineBox.cpp
 +++ b/Source/WebCore/rendering/InlineBox.cpp
-@@ -123,6 +123,15 @@ void InlineBox::outputLineBox(TextStream& stream, bool mark, int depth) const
+@@ -123,6 +123,18 @@ void InlineBox::outputLineBox(TextStream& stream, bool mark, int depth) const
      stream.nextLine();
  }
  
 +void InlineBox::outputSimplifiedLineTree(TextStream& stream, int depth) const
 +{
++    // Ignore inline flows for now. LayoutReloaded does not have the concept of flow boxes.
++    if (is<InlineFlowBox>(*this) && !is<RootInlineBox>(*this))
++        return;
 +    int printedCharacters = 0;
 +    while (++printedCharacters <= depth)
 +        stream << " ";
@@ -610,10 +613,10 @@
      virtual const char* boxName() const;
  #endif
 diff --git a/Source/WebCore/rendering/InlineFlowBox.cpp b/Source/WebCore/rendering/InlineFlowBox.cpp
-index 063f3b64189..5494aabe546 100644
+index 063f3b64189..ee32b981371 100644
 --- a/Source/WebCore/rendering/InlineFlowBox.cpp
 +++ b/Source/WebCore/rendering/InlineFlowBox.cpp
-@@ -1720,6 +1720,13 @@ void InlineFlowBox::outputLineTreeAndMark(WTF::TextStream& stream, const InlineB
+@@ -1720,6 +1720,18 @@ void InlineFlowBox::outputLineTreeAndMark(WTF::TextStream& stream, const InlineB
          box->outputLineTreeAndMark(stream, markedBox, depth + 1);
  }
  
@@ -620,8 +623,13 @@
 +void InlineFlowBox::outputSimplifiedLineTree(WTF::TextStream& stream, int depth) const
 +{
 +    InlineBox::outputSimplifiedLineTree(stream, depth);
-+    for (auto* box = firstChild(); box; box = box->nextOnLine())
-+        box->outputSimplifiedLineTree(stream, depth + 1);
++    for (auto* box = firstChild(); box; box = box->nextOnLine()) {
++        // DO not increment depth for flow boxes. LayoutReloaded does not have the concept of them.
++        if (is<InlineFlowBox>(*box) && !is<RootInlineBox>(*box))
++            box->outputSimplifiedLineTree(stream, depth);
++        else
++            box->outputSimplifiedLineTree(stream, depth + 1);
++    }
 +}
 +
  #endif

Modified: trunk/Tools/LayoutReloaded/test/index.html (230385 => 230386)


--- trunk/Tools/LayoutReloaded/test/index.html	2018-04-09 02:58:40 UTC (rev 230385)
+++ trunk/Tools/LayoutReloaded/test/index.html	2018-04-09 03:59:10 UTC (rev 230386)
@@ -77,7 +77,8 @@
     "inline-content-simple2.html",
     "inline-floating1.html",
     "inline-formatting-context-floats1.html",
-    "inline-formatting-context-floats2.html"
+    "inline-formatting-context-floats2.html",
+    "inline-with-padding-border-margin-offsets.html"
 ];
 
 let debugThis = [];

Added: trunk/Tools/LayoutReloaded/test/inline-with-padding-border-margin-offsets.html (0 => 230386)


--- trunk/Tools/LayoutReloaded/test/inline-with-padding-border-margin-offsets.html	                        (rev 0)
+++ trunk/Tools/LayoutReloaded/test/inline-with-padding-border-margin-offsets.html	2018-04-09 03:59:10 UTC (rev 230386)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div><span style="padding-left: 1px; border-left: 1px solid green;">foobar</span><span style="margin-left: 10px; padding-left: 1px">foobar</span></div>
+<div><span style="padding-right: 1px; border-right: 1px solid green;">foobar</span><span style="margin-right: 10px; padding-right: 1px">foobar</span></div>
+<div style="margin: 50px;"><span style="padding: 1px; border: 1px solid green;">foobar</span><span style="margin: 10px; padding: 1px">foobar</span></div>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to