Title: [253205] trunk/Source/WebCore
Revision
253205
Author
[email protected]
Date
2019-12-06 06:37:43 -0800 (Fri, 06 Dec 2019)

Log Message

[LFC][Integration] Wire line counting functions in RenderBlockFlow
https://bugs.webkit.org/show_bug.cgi?id=204943

Reviewed by Zalan Bujtas.

* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::lineCount const):
* layout/integration/LayoutIntegrationLineLayout.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::layoutRunsAndFloatsInRange):
(WebCore::ComplexLineLayout::lineCount const):
(WebCore::ComplexLineLayout::lineCountUntil const):

Move complex path specific code to ComplexLineLayout.

* rendering/ComplexLineLayout.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::adjustLinePositionForPagination):
(WebCore::RenderBlockFlow::lineCount const):
(WebCore::RenderBlockFlow::hasLines const):

Support all paths.

* rendering/RenderBlockFlow.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (253204 => 253205)


--- trunk/Source/WebCore/ChangeLog	2019-12-06 14:34:22 UTC (rev 253204)
+++ trunk/Source/WebCore/ChangeLog	2019-12-06 14:37:43 UTC (rev 253205)
@@ -1,5 +1,32 @@
 2019-12-06  Antti Koivisto  <[email protected]>
 
+        [LFC][Integration] Wire line counting functions in RenderBlockFlow
+        https://bugs.webkit.org/show_bug.cgi?id=204943
+
+        Reviewed by Zalan Bujtas.
+
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::lineCount const):
+        * layout/integration/LayoutIntegrationLineLayout.h:
+        * rendering/ComplexLineLayout.cpp:
+        (WebCore::ComplexLineLayout::layoutRunsAndFloatsInRange):
+        (WebCore::ComplexLineLayout::lineCount const):
+        (WebCore::ComplexLineLayout::lineCountUntil const):
+
+        Move complex path specific code to ComplexLineLayout.
+
+        * rendering/ComplexLineLayout.h:
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::adjustLinePositionForPagination):
+        (WebCore::RenderBlockFlow::lineCount const):
+        (WebCore::RenderBlockFlow::hasLines const):
+
+        Support all paths.
+
+        * rendering/RenderBlockFlow.h:
+
+2019-12-06  Antti Koivisto  <[email protected]>
+
         [LFC][Integration] Support isLineBreak() in iterator
         https://bugs.webkit.org/show_bug.cgi?id=204941
 

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (253204 => 253205)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2019-12-06 14:34:22 UTC (rev 253204)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2019-12-06 14:37:43 UTC (rev 253205)
@@ -102,6 +102,12 @@
     displayBox.setContentBoxWidth(m_flow.contentSize().width());
 }
 
+size_t LineLayout::lineCount() const
+{
+    auto* inlineContent = displayInlineContent();
+    return inlineContent ? inlineContent->lineBoxes.size() : 0;
+}
+
 const Display::InlineContent* LineLayout::displayInlineContent() const
 {
     return downcast<Layout::InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent();

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (253204 => 253205)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2019-12-06 14:34:22 UTC (rev 253204)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2019-12-06 14:37:43 UTC (rev 253205)
@@ -59,6 +59,8 @@
     void layout();
 
     LayoutUnit contentLogicalHeight() const { return m_contentLogicalHeight; }
+    size_t lineCount() const;
+
     const Display::InlineContent* displayInlineContent() const;
 
     void paint(PaintInfo&, const LayoutPoint& paintOffset);

Modified: trunk/Source/WebCore/rendering/ComplexLineLayout.cpp (253204 => 253205)


--- trunk/Source/WebCore/rendering/ComplexLineLayout.cpp	2019-12-06 14:34:22 UTC (rev 253204)
+++ trunk/Source/WebCore/rendering/ComplexLineLayout.cpp	2019-12-06 14:37:43 UTC (rev 253205)
@@ -1556,7 +1556,7 @@
                 lineBox = lineBox->prevRootBox();
 
             // We now want to break at this line. Remember for next layout and trigger relayout.
-            m_flow.setBreakAtLineToAvoidWidow(m_flow.lineCount(lineBox));
+            m_flow.setBreakAtLineToAvoidWidow(lineCountUntil(lineBox));
             m_flow.markLinesDirtyInBlockRange(lastRootBox()->lineBottomWithLeading(), lineBox->lineBottomWithLeading(), lineBox);
         }
     }
@@ -2108,6 +2108,27 @@
     }
 }
 
+size_t ComplexLineLayout::lineCount() const
+{
+    size_t count = 0;
+    for (auto* box = firstRootBox(); box; box = box->nextRootBox())
+        ++count;
+
+    return count;
+}
+
+size_t ComplexLineLayout::lineCountUntil(const RootInlineBox* stopRootInlineBox) const
+{
+    size_t count = 0;
+    for (auto* box = firstRootBox(); box; box = box->nextRootBox()) {
+        ++count;
+        if (box == stopRootInlineBox)
+            break;
+    }
+
+    return count;
+}
+
 void ComplexLineLayout::deleteEllipsisLineBoxes()
 {
     TextAlignMode textAlign = style().textAlign();

Modified: trunk/Source/WebCore/rendering/ComplexLineLayout.h (253204 => 253205)


--- trunk/Source/WebCore/rendering/ComplexLineLayout.h	2019-12-06 14:34:22 UTC (rev 253204)
+++ trunk/Source/WebCore/rendering/ComplexLineLayout.h	2019-12-06 14:37:43 UTC (rev 253205)
@@ -70,6 +70,9 @@
     bool positionNewFloatOnLine(const FloatingObject& newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo&, LineWidth&);
     void addOverflowFromInlineChildren();
 
+    size_t lineCount() const;
+    size_t lineCountUntil(const RootInlineBox*) const;
+
     static void appendRunsForObject(BidiRunList<BidiRun>*, int start, int end, RenderObject&, InlineBidiResolver&);
     static void updateLogicalWidthForAlignment(RenderBlockFlow&, const TextAlignMode&, const RootInlineBox*, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount);
 

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (253204 => 253205)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2019-12-06 14:34:22 UTC (rev 253204)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2019-12-06 14:37:43 UTC (rev 253205)
@@ -1790,7 +1790,7 @@
     LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset, ExcludePageBoundary);
     overflowsFragment = (lineHeight > remainingLogicalHeight);
 
-    int lineIndex = lineCount(lineBox);
+    int lineIndex = complexLineLayout()->lineCountUntil(lineBox);
     if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex)) {
         if (lineBreakToAvoidWidow() == lineIndex)
             clearShouldBreakAtLineToAvoidWidowIfNeeded(*this);
@@ -3244,39 +3244,31 @@
     return nullptr;
 }
 
-int RenderBlockFlow::lineCount(const RootInlineBox* stopRootInlineBox, bool* found) const
+int RenderBlockFlow::lineCount() const
 {
+    // FIXME: This should be tested by clients.
     if (style().visibility() != Visibility::Visible)
         return 0;
 
-    int count = 0;
+    if (childrenInline()) {
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+        if (layoutFormattingContextLineLayout())
+            return layoutFormattingContextLineLayout()->lineCount();
+#endif
+        if (simpleLineLayout())
+            return simpleLineLayout()->lineCount();
 
-    if (childrenInline()) {
-        if (auto simpleLineLayout = this->simpleLineLayout()) {
-            ASSERT(!stopRootInlineBox);
-            return simpleLineLayout->lineCount();
-        }
-        for (auto* box = firstRootBox(); box; box = box->nextRootBox()) {
-            ++count;
-            if (box == stopRootInlineBox) {
-                if (found)
-                    *found = true;
-                break;
-            }
-        }
-        return count;
+        if (complexLineLayout())
+            return complexLineLayout()->lineCount();
+
+        return 0;
     }
 
+    int count = 0;
     for (auto& blockFlow : childrenOfType<RenderBlockFlow>(*this)) {
         if (!shouldCheckLines(blockFlow))
             continue;
-        bool recursiveFound = false;
-        count += blockFlow.lineCount(stopRootInlineBox, &recursiveFound);
-        if (recursiveFound) {
-            if (found)
-                *found = true;
-            break;
-        }
+        count += blockFlow.lineCount();
     }
 
     return count;
@@ -3613,8 +3605,12 @@
     if (!childrenInline())
         return false;
 
-    if (auto simpleLineLayout = this->simpleLineLayout())
-        return simpleLineLayout->lineCount();
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+    if (layoutFormattingContextLineLayout())
+        return layoutFormattingContextLineLayout()->lineCount();
+#endif
+    if (simpleLineLayout())
+        return simpleLineLayout()->lineCount();
 
     return complexLineLayout() && complexLineLayout()->lineBoxes().firstLineBox();
 }

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (253204 => 253205)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.h	2019-12-06 14:34:22 UTC (rev 253204)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h	2019-12-06 14:37:43 UTC (rev 253205)
@@ -350,7 +350,7 @@
 
     // Helper methods for computing line counts and heights for line counts.
     RootInlineBox* lineAtIndex(int) const;
-    int lineCount(const RootInlineBox* = nullptr, bool* = nullptr) const;
+    int lineCount() const;
     int heightForLineCount(int);
     void clearTruncation();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to