Title: [292689] trunk/Source/WebCore
Revision
292689
Author
za...@apple.com
Date
2022-04-10 14:56:21 -0700 (Sun, 10 Apr 2022)

Log Message

Line clamp specific line-count code should be in RenderDeprecatedFlexibleBox
https://bugs.webkit.org/show_bug.cgi?id=239029

Reviewed by Antti Koivisto.

Moving the line-clamp specific code to RenderDeprecatedFlexibleBox enables us to
make RenderBlockFlow::lineCount "children inline" only.

* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::lineCountFor):
(WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (292688 => 292689)


--- trunk/Source/WebCore/ChangeLog	2022-04-10 16:50:36 UTC (rev 292688)
+++ trunk/Source/WebCore/ChangeLog	2022-04-10 21:56:21 UTC (rev 292689)
@@ -1,3 +1,17 @@
+2022-04-10  Alan Bujtas  <za...@apple.com>
+
+        Line clamp specific line-count code should be in RenderDeprecatedFlexibleBox
+        https://bugs.webkit.org/show_bug.cgi?id=239029
+
+        Reviewed by Antti Koivisto.
+
+        Moving the line-clamp specific code to RenderDeprecatedFlexibleBox enables us to
+        make RenderBlockFlow::lineCount "children inline" only.
+
+        * rendering/RenderDeprecatedFlexibleBox.cpp:
+        (WebCore::lineCountFor):
+        (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):
+
 2022-04-10  Tyler Wilcock  <tyle...@apple.com>
 
         Fix accessibility/aria-invalid.html in isolated tree mode

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (292688 => 292689)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-04-10 16:50:36 UTC (rev 292688)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-04-10 21:56:21 UTC (rev 292689)
@@ -3232,29 +3232,18 @@
 
 int RenderBlockFlow::lineCount() const
 {
-    // FIXME: This should be tested by clients.
-    if (style().visibility() != Visibility::Visible)
+    if (!childrenInline()) {
+        ASSERT_NOT_REACHED();
         return 0;
-
-    if (childrenInline()) {
+    }
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-        if (modernLineLayout())
-            return modernLineLayout()->lineCount();
+    if (modernLineLayout())
+        return modernLineLayout()->lineCount();
 #endif
-        if (legacyLineLayout())
-            return legacyLineLayout()->lineCount();
+    if (legacyLineLayout())
+        return legacyLineLayout()->lineCount();
 
-        return 0;
-    }
-
-    int count = 0;
-    for (auto& blockFlow : childrenOfType<RenderBlockFlow>(*this)) {
-        if (!shouldIncludeLinesForParentLineCount(blockFlow))
-            continue;
-        count += blockFlow.lineCount();
-    }
-
-    return count;
+    return 0;
 }
 
 void RenderBlockFlow::clearTruncation()
@@ -3550,15 +3539,7 @@
 
 bool RenderBlockFlow::hasLines() const
 {
-    if (!childrenInline())
-        return false;
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-    if (modernLineLayout())
-        return modernLineLayout()->lineCount();
-#endif
-
-    return legacyLineLayout() && legacyLineLayout()->lineBoxes().firstLineBox();
+    return childrenInline() ? lineCount() : false;
 }
 
 void RenderBlockFlow::invalidateLineLayoutPath()
@@ -3812,6 +3793,8 @@
                 lineCountInBlock = this->lineCount();
             else {
                 for (auto& listItem : childrenOfType<RenderListItem>(*this)) {
+                    if (!listItem.childrenInline() || listItem.style().visibility() != Visibility::Visible)
+                        continue;
                     lineCountInBlock += listItem.lineCount();
                     if (lineCountInBlock > 1)
                         break;

Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (292688 => 292689)


--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2022-04-10 16:50:36 UTC (rev 292688)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2022-04-10 21:56:21 UTC (rev 292689)
@@ -995,6 +995,23 @@
     return getHeightForLineCount(flow, lineCount, true, count);
 }
 
+static size_t lineCountFor(const RenderBlockFlow& blockFlow)
+{
+    if (blockFlow.style().visibility() != Visibility::Visible)
+        return 0;
+
+    if (blockFlow.childrenInline())
+        return blockFlow.lineCount();
+
+    size_t count = 0;
+    for (auto& child : childrenOfType<RenderBlockFlow>(blockFlow)) {
+        if (blockFlow.isFloatingOrOutOfFlowPositioned() || !blockFlow.style().height().isAuto())
+            continue;
+        count += lineCountFor(child);
+    }
+    return count;
+}
+
 void RenderDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool relayoutChildren)
 {
     int maxLineCount = 0;
@@ -1015,7 +1032,7 @@
         }
         child->layoutIfNeeded();
         if (child->style().height().isAuto() && is<RenderBlockFlow>(*child))
-            maxLineCount = std::max(maxLineCount, downcast<RenderBlockFlow>(*child).lineCount());
+            maxLineCount = std::max<int>(maxLineCount, lineCountFor(downcast<RenderBlockFlow>(*child)));
     }
 
     // Get the number of lines and then alter all block flow children with auto height to use the
@@ -1030,7 +1047,7 @@
             continue;
 
         RenderBlockFlow& blockChild = downcast<RenderBlockFlow>(*child);
-        int lineCount = blockChild.lineCount();
+        int lineCount = lineCountFor(blockChild);
         if (lineCount <= numVisibleLines)
             continue;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to