Title: [257469] trunk
Revision
257469
Author
[email protected]
Date
2020-02-26 07:05:13 -0800 (Wed, 26 Feb 2020)

Log Message

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

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (257468 => 257469)


--- trunk/LayoutTests/ChangeLog	2020-02-26 14:45:29 UTC (rev 257468)
+++ trunk/LayoutTests/ChangeLog	2020-02-26 15:05:13 UTC (rev 257469)
@@ -1,3 +1,14 @@
+2020-02-26  Zalan Bujtas  <[email protected]>
+
+        [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  <[email protected]>
 
         Unreviewed. Update fast/forms/number/number-size.html after r257299

Added: trunk/LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only-expected.html (0 => 257469)


--- trunk/LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only-expected.html	2020-02-26 15:05:13 UTC (rev 257469)
@@ -0,0 +1,2 @@
+<!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+empty content->

Added: trunk/LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only.html (0 => 257469)


--- trunk/LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/float-and-br-inline-content-only.html	2020-02-26 15:05:13 UTC (rev 257469)
@@ -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>

Modified: trunk/Source/WebCore/ChangeLog (257468 => 257469)


--- trunk/Source/WebCore/ChangeLog	2020-02-26 14:45:29 UTC (rev 257468)
+++ trunk/Source/WebCore/ChangeLog	2020-02-26 15:05:13 UTC (rev 257469)
@@ -1,3 +1,23 @@
+2020-02-26  Zalan Bujtas  <[email protected]>
+
+        [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  <[email protected]>
 
         [GStreamer] Correctly remove webvttenc on WebKitTextCombiner pad release

Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp (257468 => 257469)


--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp	2020-02-26 14:45:29 UTC (rev 257468)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp	2020-02-26 15:05:13 UTC (rev 257469)
@@ -327,13 +327,13 @@
 
 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::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)
+        if (!floatCandidate.isIntrusive && commitIntrusiveOnly == CommitIntrusiveFloatsOnly::Yes)
             continue;
-        if (!floatCandidate.isIntrusive) {
-            m_floats.append({ LineContent::Float::Intrusive::No, floatCandidate.item });
-            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);
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to