Title: [238225] trunk
Revision
238225
Author
[email protected]
Date
2018-11-15 06:42:22 -0800 (Thu, 15 Nov 2018)

Log Message

[LFC][IFC] Add support for in-flow positioned inline boxes.
https://bugs.webkit.org/show_bug.cgi?id=191672

Reviewed by Antti Koivisto.

Source/WebCore:

We might offset the in-flow positioned runs differently once runs are moved over to the display tree.

Test: fast/inline/simple-inline-inflow-positioned.html

* layout/Verification.cpp:
(WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded):
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::splitInlineRunsIfNeeded const):
(WebCore::Layout::InlineFormattingContext::postProcessInlineRuns const):
(WebCore::Layout::InlineFormattingContext::placeInFlowPositionedChildren const):
(WebCore::Layout::InlineFormattingContext::collectInlineContentForSubtree const):
* layout/inlineformatting/InlineFormattingContext.h:
* layout/inlineformatting/InlineRun.h:
(WebCore::Layout::InlineRun::moveVertically):
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::outputInlineRuns):

Tools:

* LayoutReloaded/misc/LFC-passing-tests.txt:

LayoutTests:

* fast/inline/simple-inline-inflow-positioned-expected.txt: Added.
* fast/inline/simple-inline-inflow-positioned.html: Added.
* platform/ios/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (238224 => 238225)


--- trunk/LayoutTests/ChangeLog	2018-11-15 14:39:27 UTC (rev 238224)
+++ trunk/LayoutTests/ChangeLog	2018-11-15 14:42:22 UTC (rev 238225)
@@ -1,3 +1,14 @@
+2018-11-14  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Add support for in-flow positioned inline boxes.
+        https://bugs.webkit.org/show_bug.cgi?id=191672
+
+        Reviewed by Antti Koivisto.
+
+        * fast/inline/simple-inline-inflow-positioned-expected.txt: Added.
+        * fast/inline/simple-inline-inflow-positioned.html: Added.
+        * platform/ios/TestExpectations:
+
 2018-11-15  Antti Koivisto  <[email protected]>
 
         REGRESSION(r238178): fast/forms/access-key-mutated.html and fast/forms/access-key-case-insensitive.html are timing out

Added: trunk/LayoutTests/fast/inline/simple-inline-inflow-positioned-expected.txt (0 => 238225)


--- trunk/LayoutTests/fast/inline/simple-inline-inflow-positioned-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/simple-inline-inflow-positioned-expected.txt	2018-11-15 14:42:22 UTC (rev 238225)
@@ -0,0 +1,21 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+layer at (8,8) size 202x202 clip at (9,9) size 200x200
+  RenderBlock {DIV} at (0,0) size 202x202 [border: (1px solid #008000)]
+    RenderInline {SPAN} at (0,0) size 25x18
+      RenderText {#text} at (1,1) size 25x18
+        text run at (1,1) width 25: "first"
+    RenderInline {SPAN} at (0,0) size 32x18
+      RenderText {#text} at (100,1) size 32x18
+        text run at (100,1) width 32: "forth"
+layer at (108,8) size 76x18 backgroundClip at (9,9) size 200x200 clip at (9,9) size 200x200
+  RenderInline (relative positioned) {SPAN} at (0,0) size 76x18
+    RenderInline {SPAN} at (0,0) size 46x18
+      RenderText {#text} at (25,1) size 46x18
+        text run at (25,1) width 46: "second"
+    RenderInline {SPAN} at (0,0) size 31x18
+      RenderText {#text} at (70,1) size 31x18
+        text run at (70,1) width 31: "third"

Added: trunk/LayoutTests/fast/inline/simple-inline-inflow-positioned.html (0 => 238225)


--- trunk/LayoutTests/fast/inline/simple-inline-inflow-positioned.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/simple-inline-inflow-positioned.html	2018-11-15 14:42:22 UTC (rev 238225)
@@ -0,0 +1,16 @@
+<style>
+.top {
+	border: 1px solid green;
+	width: 200px;
+	height: 200px;
+	overflow: hidden;
+}
+
+.nested {
+	position: relative;
+	left: 100px;
+}
+
+</style>
+
+<div class=top><span>first</span><span class=nested><span>second</span><span>third</span></span><span>forth</span></div>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (238224 => 238225)


--- trunk/LayoutTests/platform/ios/TestExpectations	2018-11-15 14:39:27 UTC (rev 238224)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2018-11-15 14:42:22 UTC (rev 238225)
@@ -3108,6 +3108,7 @@
 fast/inline/simple-intruding-floats3.html [ Failure ]
 fast/inline/simple-inline-block.html [ Failure ]
 fast/inline/simple-shrink-to-fit-inline-block.html [ Failure ]
+fast/inline/simple-inline-inflow-positioned.html [ Failure ]
 fast/block/basic/height-percentage-simple.html [ Failure ]
 fast/block/basic/child-block-level-box-with-height-percent.html [ Failure ]
 fast/block/basic/quirk-mode-percent-height.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (238224 => 238225)


--- trunk/Source/WebCore/ChangeLog	2018-11-15 14:39:27 UTC (rev 238224)
+++ trunk/Source/WebCore/ChangeLog	2018-11-15 14:42:22 UTC (rev 238225)
@@ -1,3 +1,27 @@
+2018-11-14  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Add support for in-flow positioned inline boxes.
+        https://bugs.webkit.org/show_bug.cgi?id=191672
+
+        Reviewed by Antti Koivisto.
+
+        We might offset the in-flow positioned runs differently once runs are moved over to the display tree.
+
+        Test: fast/inline/simple-inline-inflow-positioned.html
+
+        * layout/Verification.cpp:
+        (WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded):
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::splitInlineRunsIfNeeded const):
+        (WebCore::Layout::InlineFormattingContext::postProcessInlineRuns const):
+        (WebCore::Layout::InlineFormattingContext::placeInFlowPositionedChildren const):
+        (WebCore::Layout::InlineFormattingContext::collectInlineContentForSubtree const):
+        * layout/inlineformatting/InlineFormattingContext.h:
+        * layout/inlineformatting/InlineRun.h:
+        (WebCore::Layout::InlineRun::moveVertically):
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::outputInlineRuns):
+
 2018-11-15  Thibault Saunier  <[email protected]>
 
         [GStreamer][WebRTC] Add support for sending silence or silencing an incoming track

Modified: trunk/Source/WebCore/layout/Verification.cpp (238224 => 238225)


--- trunk/Source/WebCore/layout/Verification.cpp	2018-11-15 14:39:27 UTC (rev 238224)
+++ trunk/Source/WebCore/layout/Verification.cpp	2018-11-15 14:42:22 UTC (rev 238225)
@@ -34,6 +34,7 @@
 #include "LayoutContainer.h"
 #include "LayoutTreeBuilder.h"
 #include "RenderBox.h"
+#include "RenderInline.h"
 #include "RenderView.h"
 #include <wtf/text/TextStream.h>
 
@@ -155,6 +156,13 @@
                         break;
                 }
             }
+        } else if (is<InlineFlowBox>(inlineBox)) {
+            // FIXME: This does not work for nested InlineFlowBoxes and we should really look inside these flow boxes and verify the leaf nodes.
+            auto& renderer = inlineBox->renderer();
+            LayoutUnit xOffset;
+            if (renderer.isInFlowPositioned())
+                xOffset = downcast<RenderInline>(renderer).offsetForInFlowPosition().width();
+            matchingRuns = areEssentiallyEqual(inlineBox->logicalLeft() + xOffset, inlineRun.logicalLeft()) && areEssentiallyEqual(inlineBox->logicalRight() + xOffset, inlineRun.logicalRight());
         } else
             matchingRuns = checkForMatchingNonTextRuns(inlineRun, *inlineBox);
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (238224 => 238225)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2018-11-15 14:39:27 UTC (rev 238224)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2018-11-15 14:42:22 UTC (rev 238225)
@@ -220,12 +220,9 @@
     split(*firstUncommittedInlineItem, startPosition, uncommittedLength, contentStart);
 }
 
-void InlineFormattingContext::postProcessInlineRuns(Line& line, IsLastLine isLastLine, Line::RunRange runRange) const
+InlineFormattingContext::Line::RunRange InlineFormattingContext::splitInlineRunsIfNeeded(Line::RunRange runRange) const
 {
-    auto& inlineFormattingState = this->inlineFormattingState();
-    Geometry::alignRuns(inlineFormattingState, root().style().textAlign(), line, runRange, isLastLine);
-
-    auto& inlineRuns = inlineFormattingState.inlineRuns();
+    auto& inlineRuns = inlineFormattingState().inlineRuns();
     ASSERT(*runRange.lastRunIndex < inlineRuns.size());
 
     auto runIndex = *runRange.firstRunIndex;
@@ -254,8 +251,18 @@
 
         ++runIndex;
     }
+
+    return { runRange.firstRunIndex, runIndex };
 }
 
+void InlineFormattingContext::postProcessInlineRuns(Line& line, IsLastLine isLastLine, Line::RunRange runRange) const
+{
+    auto& inlineFormattingState = this->inlineFormattingState();
+    Geometry::alignRuns(inlineFormattingState, root().style().textAlign(), line, runRange, isLastLine);
+    runRange = splitInlineRunsIfNeeded(runRange);
+    placeInFlowPositionedChildren(runRange);
+}
+
 void InlineFormattingContext::closeLine(Line& line, IsLastLine isLastLine) const
 {
     auto runRange = line.close();
@@ -409,6 +416,32 @@
     displayBox.setTopLeft(floatingContext.positionForFloat(floatBox));
 }
 
+void InlineFormattingContext::placeInFlowPositionedChildren(Line::RunRange runRange) const
+{
+    auto& inlineRuns = inlineFormattingState().inlineRuns();
+    ASSERT(*runRange.lastRunIndex < inlineRuns.size());
+
+    for (auto runIndex = *runRange.firstRunIndex; runIndex <= *runRange.lastRunIndex; ++runIndex) {
+        auto& inlineRun = inlineRuns[runIndex];
+
+        auto positionOffset = [&](auto& layoutBox) {
+            // FIXME: Need to figure out whether in-flow offset should stick. This might very well be temporary.
+            std::optional<LayoutSize> offset;
+            for (auto* box = &layoutBox; box != &root(); box = box->parent()) {
+                if (!box->isInFlowPositioned())
+                    continue;
+                offset = offset.value_or(LayoutSize()) + Geometry::inFlowPositionedPositionOffset(layoutState(), *box);
+            }
+            return offset;
+        };
+
+        if (auto offset = positionOffset(inlineRun.inlineItem().layoutBox())) {
+            inlineRun.moveVertically(offset->height());
+            inlineRun.moveHorizontally(offset->width());
+        }
+    }
+}
+
 void InlineFormattingContext::computeStaticPosition(const Box&) const
 {
 }
@@ -445,12 +478,12 @@
 
     auto rootBreaksAtStart = [&] {
         // FIXME: add padding-inline-start, margin-inline-start etc.
-        return false;
+        return root.isPositioned();
     };
 
     auto rootBreaksAtEnd = [&] {
         // FIXME: add padding-inline-end, margin-inline-end etc.
-        return false;
+        return root.isPositioned();
     };
 
     if (rootBreaksAtStart()) {

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (238224 => 238225)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h	2018-11-15 14:39:27 UTC (rev 238224)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h	2018-11-15 14:42:22 UTC (rev 238225)
@@ -112,6 +112,7 @@
     void closeLine(Line&, IsLastLine) const;
     void appendContentToLine(Line&, const InlineLineBreaker::Run&) const;
     void postProcessInlineRuns(Line&, IsLastLine, Line::RunRange) const;
+    Line::RunRange splitInlineRunsIfNeeded(Line::RunRange) const  WARN_UNUSED_RETURN;
     void splitInlineRunIfNeeded(const InlineRun&, InlineRuns& splitRuns) const;
 
     void layoutFormattingContextRoot(const Box&) const;
@@ -120,6 +121,7 @@
     void computeWidthAndMargin(const Box&) const;
     void computeFloatPosition(const FloatingContext&, Line&, const Box&) const;
     void computeStaticPosition(const Box&) const override;
+    void placeInFlowPositionedChildren(Line::RunRange) const;
 
     void collectInlineContent(InlineRunProvider&) const;
     void collectInlineContentForSubtree(const Box& root, InlineRunProvider&) const;

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineRun.h (238224 => 238225)


--- trunk/Source/WebCore/layout/inlineformatting/InlineRun.h	2018-11-15 14:39:27 UTC (rev 238224)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineRun.h	2018-11-15 14:42:22 UTC (rev 238225)
@@ -48,6 +48,7 @@
     void setWidth(LayoutUnit width) { m_logicalRect.setWidth(width); }
     void setLogicalLeft(LayoutUnit logicalLeft) { m_logicalRect.setLeft(logicalLeft); }
     void setLogicalRight(LayoutUnit logicalRight) { m_logicalRect.shiftRightTo(logicalRight); }
+    void moveVertically(LayoutUnit delta) { m_logicalRect.moveVertically(delta); }
     void moveHorizontally(LayoutUnit delta) { m_logicalRect.moveHorizontally(delta); }
 
     struct ExpansionOpportunity {

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (238224 => 238225)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-11-15 14:39:27 UTC (rev 238224)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-11-15 14:42:22 UTC (rev 238225)
@@ -152,7 +152,7 @@
             stream << "(" << inlineRun.textContext()->start() << ", " << inlineRun.textContext()->start() + inlineRun.textContext()->length() << ") ";
         else
             stream << "(x, x) ";
-        stream << "(" << inlineRun.logicalLeft() << ", " << inlineRun.logicalRight() << ")";
+        stream << "at [" << inlineRun.logicalLeft() << ", " << inlineRun.logicalTop() << "] size [" << inlineRun.width() << " " << inlineRun.height() << "]";
         stream.nextLine();
     }
 }

Modified: trunk/Tools/ChangeLog (238224 => 238225)


--- trunk/Tools/ChangeLog	2018-11-15 14:39:27 UTC (rev 238224)
+++ trunk/Tools/ChangeLog	2018-11-15 14:42:22 UTC (rev 238225)
@@ -1,3 +1,12 @@
+2018-11-14  Zalan Butjas  <[email protected]>
+
+        [LFC][IFC] Add support for in-flow positioned inline boxes.
+        https://bugs.webkit.org/show_bug.cgi?id=191672
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2018-11-14  Keith Rollin  <[email protected]>
 
         Move scripts for Derived and Unified Sources to external files

Modified: trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt (238224 => 238225)


--- trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2018-11-15 14:39:27 UTC (rev 238224)
+++ trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2018-11-15 14:42:22 UTC (rev 238225)
@@ -69,6 +69,7 @@
 fast/inline/simple-intruding-floats3.html
 fast/inline/simple-inline-block.html
 fast/inline/simple-shrink-to-fit-inline-block.html
+fast/inline/simple-inline-inflow-positioned.html
 fast/block/basic/height-percentage-simple.html
 fast/block/basic/child-block-level-box-with-height-percent.html
 fast/block/basic/quirk-mode-percent-height.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to