[LFC] Add support for inflow non replaced content height when the box is an inline...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Oct 2018 14:48:11 +0000 (14:48 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Oct 2018 14:48:11 +0000 (14:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191011

Reviewed by Antti Koivisto.

Source/WebCore:

// 10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
// Height is the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines

This is temporary until after inline runs transition to the display tree.

Test: fast/inline/simple-intruding-floats2.html

* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
* layout/inlineformatting/InlineRun.h:
(WebCore::Layout::InlineRun::logicalLeft const):
(WebCore::Layout::InlineRun::logicalRight const):
(WebCore::Layout::InlineRun::logicalTop const):
(WebCore::Layout::InlineRun::logicalBottom const):
(WebCore::Layout::InlineRun::width const):
(WebCore::Layout::InlineRun::height const):
(WebCore::Layout::InlineRun::setWidth):
(WebCore::Layout::InlineRun::setLogicalLeft):
(WebCore::Layout::InlineRun::setLogicalRight):
(WebCore::Layout::InlineRun::moveHorizontally):
(WebCore::Layout::InlineRun::InlineRun):
* layout/inlineformatting/Line.cpp:
(WebCore::Layout::InlineFormattingContext::Line::appendContent):

Tools:

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

LayoutTests:

* fast/inline/simple-intruding-floats2-expected.txt: Added.
* fast/inline/simple-intruding-floats2.html: Added.
* platform/ios/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237551 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/inline/simple-intruding-floats2-expected.txt [new file with mode: 0644]
LayoutTests/fast/inline/simple-intruding-floats2.html [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
Source/WebCore/layout/inlineformatting/InlineRun.h
Source/WebCore/layout/inlineformatting/Line.cpp
Tools/ChangeLog
Tools/LayoutReloaded/misc/LFC-passing-tests.txt

index b571d40..cffefef 100644 (file)
@@ -1,5 +1,16 @@
 2018-10-29  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC] Add support for inflow non replaced content height when the box is an inline formatting root.
+        https://bugs.webkit.org/show_bug.cgi?id=191011
+
+        Reviewed by Antti Koivisto.
+
+        * fast/inline/simple-intruding-floats2-expected.txt: Added.
+        * fast/inline/simple-intruding-floats2.html: Added.
+        * platform/ios/TestExpectations:
+
+2018-10-29  Zalan Bujtas  <zalan@apple.com>
+
         Missing from r237549
 
         Reviewed by Antti Koivisto.
diff --git a/LayoutTests/fast/inline/simple-intruding-floats2-expected.txt b/LayoutTests/fast/inline/simple-intruding-floats2-expected.txt
new file mode 100644 (file)
index 0000000..3eab1cd
--- /dev/null
@@ -0,0 +1,30 @@
+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
+      RenderImage {IMG} at (0,0) size 20x100
+      RenderBlock {DIV} at (0,0) size 300x54
+        RenderText {#text} at (40,0) size 34x18
+          text run at (40,0) width 34: "thisis"
+        RenderImage {IMG} at (20,0) size 20x75
+        RenderText {#text} at (73,0) size 216x36
+          text run at (73,0) width 183: "onerun, next to 2 floats. One"
+          text run at (40,18) width 138: "intruding, one in this "
+        RenderInline {SPAN} at (0,0) size 246x36
+          RenderText {#text} at (177,18) size 246x36
+            text run at (177,18) width 109: "inline formatting"
+            text run at (40,36) width 48: "context"
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,54) size 300x54
+        RenderInline {SPAN} at (0,0) size 258x54
+          RenderImage {IMG} at (40,0) size 20x15
+          RenderText {#text} at (60,0) size 258x54
+            text run at (60,0) width 218: "this next inline formatting context"
+            text run at (40,18) width 204: "has 3 floats. 2 out of those 3 are"
+            text run at (20,36) width 59: "intruding"
+      RenderBlock (anonymous) at (0,108) size 784x18
+        RenderInline {SPAN} at (0,0) size 430x18
+          RenderText {#text} at (0,0) size 430x18
+            text run at (0,0) width 430: "and now we are back to the left edge. no intrudings at this position."
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/fast/inline/simple-intruding-floats2.html b/LayoutTests/fast/inline/simple-intruding-floats2.html
new file mode 100644 (file)
index 0000000..e28d8a5
--- /dev/null
@@ -0,0 +1,5 @@
+<img style="float: left;" src="foobar.jpg" height="100" width="20">
+<div style="text-align: left; width: 300px;">thisis<img style="float: left;" src="foobar.jpg" height="75" width="20">onerun, next to 2 floats. One intruding, one in this
+<span>inline formatting context</span>
+</div>
+<div style="width: 300px"><span><img style="float: left;" src="foobar.jpg" height="15" width="20">this next inline formatting context has 3 floats. 2 out of those 3 are intruding </span></div><span>and now we are back to the left edge. no intrudings at this position.</span>
index ee37c74..b72160c 100644 (file)
@@ -3110,6 +3110,7 @@ fast/block/block-only/absolute-position-min-max-height.html [ Failure ]
 fast/block/basic/inline-content-with-floating-image.html [ Failure ]
 fast/block/basic/inline-content-with-floating-images2.html [ Failure ]
 fast/inline/simple-intruding-float1.html [ Failure ]
+fast/inline/simple-intruding-floats2.html [ Failure ]
 
 # Datalist
 webkit.org/b/186714 fast/forms/datalist/datalist-textinput-keydown.html [ Skip ]
index ba25487..df1656c 100644 (file)
@@ -1,5 +1,36 @@
 2018-10-29  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC] Add support for inflow non replaced content height when the box is an inline formatting root.
+        https://bugs.webkit.org/show_bug.cgi?id=191011
+
+        Reviewed by Antti Koivisto.
+
+        // 10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
+        // Height is the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
+
+        This is temporary until after inline runs transition to the display tree.
+
+        Test: fast/inline/simple-intruding-floats2.html
+
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        * layout/inlineformatting/InlineRun.h:
+        (WebCore::Layout::InlineRun::logicalLeft const):
+        (WebCore::Layout::InlineRun::logicalRight const):
+        (WebCore::Layout::InlineRun::logicalTop const):
+        (WebCore::Layout::InlineRun::logicalBottom const):
+        (WebCore::Layout::InlineRun::width const):
+        (WebCore::Layout::InlineRun::height const):
+        (WebCore::Layout::InlineRun::setWidth):
+        (WebCore::Layout::InlineRun::setLogicalLeft):
+        (WebCore::Layout::InlineRun::setLogicalRight):
+        (WebCore::Layout::InlineRun::moveHorizontally):
+        (WebCore::Layout::InlineRun::InlineRun):
+        * layout/inlineformatting/Line.cpp:
+        (WebCore::Layout::InlineFormattingContext::Line::appendContent):
+
+2018-10-29  Zalan Bujtas  <zalan@apple.com>
+
         [LFC][IFC] Add support for simple intruding floats.
         https://bugs.webkit.org/show_bug.cgi?id=190998
 
index 83f9b97..fc72f90 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
 #include "FormattingContext.h"
+#include "InlineFormattingState.h"
 #include "LayoutChildIterator.h"
 #include "Logging.h"
 #include <wtf/text/TextStream.h>
@@ -120,8 +121,9 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMarg
 
         // 1. the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
         if (layoutBox.establishesInlineFormattingContext()) {
-            // height = lastLineBox().bottom();
-            return { 0, nonCollapsedMargin, collapsedMargin };
+            // This is temp and will be replaced by the correct display box once inline runs move over to the display tree.
+            auto& lastInlineRun = downcast<InlineFormattingState>(layoutContext.establishedFormattingState(layoutBox)).inlineRuns().last();
+            return { lastInlineRun.logicalBottom(), nonCollapsedMargin, collapsedMargin };
         }
 
         // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin...
index 951bb00..5f0e558 100644 (file)
@@ -34,16 +34,20 @@ namespace WebCore {
 namespace Layout {
 
 struct InlineRun {
-    InlineRun(LayoutUnit logcialLeft, LayoutUnit width, const InlineItem&);
+    InlineRun(Display::Box::Rect logicalRect, const InlineItem&);
 
-    LayoutUnit logicalLeft() const { return m_logicalLeft; }
-    LayoutUnit logicalRight() const { return logicalLeft() + width(); }
-    LayoutUnit width() const { return m_width; }
+    LayoutUnit logicalLeft() const { return m_logicalRect.left(); }
+    LayoutUnit logicalRight() const { return m_logicalRect.right(); }
+    LayoutUnit logicalTop() const { return m_logicalRect.top(); }
+    LayoutUnit logicalBottom() const { return m_logicalRect.bottom(); }
 
-    void setWidth(LayoutUnit width) { m_width = width; }
-    void setLogicalLeft(LayoutUnit logicalLeft) { m_logicalLeft = logicalLeft; }
-    void setLogicalRight(LayoutUnit logicalRight) { m_width -= (this->logicalRight() - logicalRight); }
-    void moveHorizontally(LayoutUnit delta) { m_logicalLeft += delta; }
+    LayoutUnit width() const { return m_logicalRect.width(); }
+    LayoutUnit height() const { return m_logicalRect.height(); }
+
+    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 moveHorizontally(LayoutUnit delta) { m_logicalRect.moveHorizontally(delta); }
 
     struct ExpansionOpportunity {
         unsigned count { 0 };
@@ -73,8 +77,7 @@ struct InlineRun {
     const InlineItem& inlineItem() const { return m_inlineItem; }
 
 private:
-    LayoutUnit m_logicalLeft;
-    LayoutUnit m_width;
+    Display::Box::Rect m_logicalRect;
     ExpansionOpportunity m_expansionOpportunity;
 
     const InlineItem& m_inlineItem;
@@ -83,9 +86,8 @@ private:
 
 using InlineRuns = Vector<InlineRun>;
 
-inline InlineRun::InlineRun(LayoutUnit logicalLeft, LayoutUnit width, const InlineItem& inlineItem)
-    : m_logicalLeft(logicalLeft)
-    , m_width(width)
+inline InlineRun::InlineRun(Display::Box::Rect logicalRect, const InlineItem& inlineItem)
+    : m_logicalRect(logicalRect)
     , m_inlineItem(inlineItem)
 {
 }
index ac72f32..f1adf7a 100644 (file)
@@ -151,7 +151,8 @@ void InlineFormattingContext::Line::appendContent(const InlineLineBreaker::Run&
 
     auto requiresNewInlineRun = !hasContent() || !content.isText() || !m_lastRunCanExpand;
     if (requiresNewInlineRun) {
-        auto inlineRun = InlineRun { contentLogicalRight(), run.width, content.inlineItem() };
+        // FIXME: This needs proper baseline handling
+        auto inlineRun = InlineRun { { logicalTop(), contentLogicalRight(), run.width, logicalBottom() - logicalTop() }, content.inlineItem() };
         if (textRun)
             inlineRun.setTextContext({ textRun->start(), textRun->length() });
         m_formattingState.appendInlineRun(inlineRun);
index ec15e1b..11ca6b2 100644 (file)
@@ -1,5 +1,14 @@
 2018-10-29  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC] Add support for inflow non replaced content height when the box is an inline formatting root.
+        https://bugs.webkit.org/show_bug.cgi?id=191011
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
+2018-10-29  Zalan Bujtas  <zalan@apple.com>
+
         Missing from r237549
 
         Reviewed by Antti Koivisto.
index 257cdb9..5c729fc 100644 (file)
@@ -65,3 +65,4 @@ fast/block/block-only/min-max-height-percentage.html
 fast/block/basic/inline-content-with-floating-image.html
 fast/block/basic/inline-content-with-floating-images2.html
 fast/inline/simple-intruding-float1.html
+fast/inline/simple-intruding-floats2.html