[LFC][IFC][Floats] ASSERT(committedInlineItemCount || line.hasIntrusiveFloat()) in...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Feb 2020 15:05:13 +0000 (15:05 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Feb 2020 15:05:13 +0000 (15:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=208230
<rdar://problem/59791249>

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/layoutformattingcontext/float-and-br-inline-content-only.html

Expand the ASSERT to include all the valid cases
1. Inline content is added to the line
2. Only float(s) got processed (no inline content)
3. Neither floats not inline content got processed due to intrusive floats.
(This patch slightly rearranges the body of LineLayoutContext::commitFloats and also fixes an off-by-1 error in LineLayoutContext::close.)

* layout/inlineformatting/LineLayoutContext.cpp:
(WebCore::Layout::LineLayoutContext::close):
(WebCore::Layout::LineLayoutContext::commitFloats):

LayoutTests:

* fast/layoutformattingcontext/float-and-br-inline-content-only-expected.html: Added.
* fast/layoutformattingcontext/float-and-br-inline-content-only.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only-expected.html [new file with mode: 0644]
LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp

index 80f1159..ea62fa3 100644 (file)
@@ -1,3 +1,14 @@
+2020-02-26  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC][Floats] ASSERT(committedInlineItemCount || line.hasIntrusiveFloat()) in LineLayoutContext::close
+        https://bugs.webkit.org/show_bug.cgi?id=208230
+        <rdar://problem/59791249>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/float-and-br-inline-content-only-expected.html: Added.
+        * fast/layoutformattingcontext/float-and-br-inline-content-only.html: Added.
+
 2020-02-26  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Update fast/forms/number/number-size.html after r257299
diff --git a/LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only-expected.html b/LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only-expected.html
new file mode 100644 (file)
index 0000000..03c6f4c
--- /dev/null
@@ -0,0 +1,2 @@
+<!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+empty content->
diff --git a/LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only.html b/LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only.html
new file mode 100644 (file)
index 0000000..0b79e6e
--- /dev/null
@@ -0,0 +1,7 @@
+<!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+#container {
+    float: left;
+}
+</style>
+<div>empty content-></div><br><div id="container"></div>
index de051e6..3dc6cd4 100644 (file)
@@ -1,3 +1,23 @@
+2020-02-26  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC][Floats] ASSERT(committedInlineItemCount || line.hasIntrusiveFloat()) in LineLayoutContext::close
+        https://bugs.webkit.org/show_bug.cgi?id=208230
+        <rdar://problem/59791249>
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/layoutformattingcontext/float-and-br-inline-content-only.html
+
+        Expand the ASSERT to include all the valid cases
+        1. Inline content is added to the line
+        2. Only float(s) got processed (no inline content)
+        3. Neither floats not inline content got processed due to intrusive floats.
+        (This patch slightly rearranges the body of LineLayoutContext::commitFloats and also fixes an off-by-1 error in LineLayoutContext::close.)
+
+        * layout/inlineformatting/LineLayoutContext.cpp:
+        (WebCore::Layout::LineLayoutContext::close):
+        (WebCore::Layout::LineLayoutContext::commitFloats):
+
 2020-02-26  Alicia Boya GarcĂ­a  <aboya@igalia.com>
 
         [GStreamer] Correctly remove webvttenc on WebKitTextCombiner pad release
index 0e1e811..8c39ee1 100644 (file)
@@ -327,13 +327,13 @@ LineLayoutContext::LineContent LineLayoutContext::layoutLine(LineBuilder& line,
 
 LineLayoutContext::LineContent LineLayoutContext::close(LineBuilder& line, const InlineItemRange layoutRange, unsigned committedInlineItemCount, Optional<LineContent::PartialContent> partialContent)
 {
-    ASSERT(committedInlineItemCount || line.hasIntrusiveFloat());
+    ASSERT(committedInlineItemCount || !m_floats.isEmpty() || line.hasIntrusiveFloat());
     if (!committedInlineItemCount) {
         if (m_floats.isEmpty()) {
             // We didn't manage to add a run or a float at this vertical position.
             return LineContent { { }, { }, WTFMove(m_floats), line.close(), line.lineBox() };
         }
-        unsigned trailingInlineItemIndex = layoutRange.start + m_floats.size();
+        unsigned trailingInlineItemIndex = layoutRange.start + m_floats.size() - 1;
         return LineContent { trailingInlineItemIndex, { }, WTFMove(m_floats), line.close(), line.lineBox() };
     }
     // Adjust hyphenated line count.
@@ -410,30 +410,31 @@ void LineLayoutContext::nextContentForLine(LineCandidate& lineCandidate, unsigne
 void LineLayoutContext::commitFloats(LineBuilder& line, const LineCandidate& lineCandidate, CommitIntrusiveFloatsOnly commitIntrusiveOnly)
 {
     auto& floatContent = lineCandidate.floatContent;
-    auto leftFloatsWidth = InlineLayoutUnit { };
-    auto rightFloatsWidth = InlineLayoutUnit { };
+    auto leftIntrusiveFloatsWidth = InlineLayoutUnit { };
+    auto rightIntrusiveFloatsWidth = InlineLayoutUnit { };
+    auto hasIntrusiveFloat = false;
 
     for (auto& floatCandidate : floatContent.list()) {
-        if (floatCandidate.isIntrusive && commitIntrusiveOnly == CommitIntrusiveFloatsOnly::Yes)
-            continue;
-        if (!floatCandidate.isIntrusive) {
-            m_floats.append({ LineContent::Float::Intrusive::No, floatCandidate.item });
+        if (!floatCandidate.isIntrusive && commitIntrusiveOnly == CommitIntrusiveFloatsOnly::Yes)
             continue;
+        m_floats.append({ floatCandidate.isIntrusive? LineContent::Float::Intrusive::Yes : LineContent::Float::Intrusive::No, floatCandidate.item });
+        if (floatCandidate.isIntrusive) {
+            hasIntrusiveFloat = true;
+            // This float is intrusive and it shrinks the current line.
+            // Shrink available space for current line.
+            if (floatCandidate.item->layoutBox().isLeftFloatingPositioned())
+                leftIntrusiveFloatsWidth += floatCandidate.logicalWidth;
+            else
+                rightIntrusiveFloatsWidth += floatCandidate.logicalWidth;
         }
-        m_floats.append({ LineContent::Float::Intrusive::Yes, floatCandidate.item });
-        // This float is intrusive and it shrinks the current line.
-        // Shrink available space for current line.
-        if (floatCandidate.item->layoutBox().isLeftFloatingPositioned())
-            leftFloatsWidth += floatCandidate.logicalWidth;
-        else
-            rightFloatsWidth += floatCandidate.logicalWidth;
     }
-    if (leftFloatsWidth || rightFloatsWidth) {
+    if (hasIntrusiveFloat)
         line.setHasIntrusiveFloat();
-        if (leftFloatsWidth)
-            line.moveLogicalLeft(leftFloatsWidth);
-        if (rightFloatsWidth)
-            line.moveLogicalRight(rightFloatsWidth);
+    if (leftIntrusiveFloatsWidth || rightIntrusiveFloatsWidth) {
+        if (leftIntrusiveFloatsWidth)
+            line.moveLogicalLeft(leftIntrusiveFloatsWidth);
+        if (rightIntrusiveFloatsWidth)
+            line.moveLogicalRight(rightIntrusiveFloatsWidth);
     }
 }