Title: [268986] trunk/Source/WebCore
Revision
268986
Author
[email protected]
Date
2020-10-26 10:54:31 -0700 (Mon, 26 Oct 2020)

Log Message

Move some functions from RenderBlockFlow to RenderDeprecatedFlexbox
https://bugs.webkit.org/show_bug.cgi?id=218194

Reviewed by Zalan Bujtas.

It is the only client.

* rendering/EllipsisBox.cpp:
(WebCore::EllipsisBox::markupBox const):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::lineAtIndex const): Deleted.
(WebCore::getHeightForLineCount): Deleted.
(WebCore::RenderBlockFlow::heightForLineCount): Deleted.
* rendering/RenderBlockFlow.h:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::shouldCheckLines):
(WebCore::lineAtIndex):
(WebCore::getHeightForLineCount):
(WebCore::heightForLineCount):
(WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268985 => 268986)


--- trunk/Source/WebCore/ChangeLog	2020-10-26 17:52:23 UTC (rev 268985)
+++ trunk/Source/WebCore/ChangeLog	2020-10-26 17:54:31 UTC (rev 268986)
@@ -1,3 +1,26 @@
+2020-10-26  Antti Koivisto  <[email protected]>
+
+        Move some functions from RenderBlockFlow to RenderDeprecatedFlexbox
+        https://bugs.webkit.org/show_bug.cgi?id=218194
+
+        Reviewed by Zalan Bujtas.
+
+        It is the only client.
+
+        * rendering/EllipsisBox.cpp:
+        (WebCore::EllipsisBox::markupBox const):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::lineAtIndex const): Deleted.
+        (WebCore::getHeightForLineCount): Deleted.
+        (WebCore::RenderBlockFlow::heightForLineCount): Deleted.
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderDeprecatedFlexibleBox.cpp:
+        (WebCore::shouldCheckLines):
+        (WebCore::lineAtIndex):
+        (WebCore::getHeightForLineCount):
+        (WebCore::heightForLineCount):
+        (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):
+
 2020-10-26  Zalan Bujtas  <[email protected]>
 
         [LFC][Integration] Account for margin start when setting the renderer's border box location

Modified: trunk/Source/WebCore/rendering/EllipsisBox.cpp (268985 => 268986)


--- trunk/Source/WebCore/rendering/EllipsisBox.cpp	2020-10-26 17:52:23 UTC (rev 268985)
+++ trunk/Source/WebCore/rendering/EllipsisBox.cpp	2020-10-26 17:54:31 UTC (rev 268986)
@@ -87,7 +87,7 @@
     if (!m_shouldPaintMarkupBox)
         return 0;
 
-    RootInlineBox* lastLine = blockFlow().lineAtIndex(blockFlow().lineCount() - 1);
+    RootInlineBox* lastLine = blockFlow().lastRootBox();
     if (!lastLine)
         return 0;
 

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (268985 => 268986)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2020-10-26 17:52:23 UTC (rev 268985)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2020-10-26 17:54:31 UTC (rev 268986)
@@ -3247,31 +3247,6 @@
     return !blockFlow.isFloatingOrOutOfFlowPositioned() && blockFlow.style().height().isAuto();
 }
 
-RootInlineBox* RenderBlockFlow::lineAtIndex(int i) const
-{
-    ASSERT(i >= 0);
-
-    if (style().visibility() != Visibility::Visible)
-        return nullptr;
-
-    if (childrenInline()) {
-        for (auto* box = firstRootBox(); box; box = box->nextRootBox()) {
-            if (!i--)
-                return box;
-        }
-        return nullptr;
-    }
-
-    for (auto& blockFlow : childrenOfType<RenderBlockFlow>(*this)) {
-        if (!shouldCheckLines(blockFlow))
-            continue;
-        if (RootInlineBox* box = blockFlow.lineAtIndex(i))
-            return box;
-    }
-
-    return nullptr;
-}
-
 int RenderBlockFlow::lineCount() const
 {
     // FIXME: This should be tested by clients.
@@ -3299,39 +3274,6 @@
     return count;
 }
 
-static int getHeightForLineCount(const RenderBlockFlow& block, int lineCount, bool includeBottom, int& count)
-{
-    if (block.style().visibility() != Visibility::Visible)
-        return -1;
-
-    if (block.childrenInline()) {
-        for (auto* box = block.firstRootBox(); box; box = box->nextRootBox()) {
-            if (++count == lineCount)
-                return box->lineBottom() + (includeBottom ? (block.borderBottom() + block.paddingBottom()) : 0_lu);
-        }
-    } else {
-        RenderBox* normalFlowChildWithoutLines = nullptr;
-        for (auto* obj = block.firstChildBox(); obj; obj = obj->nextSiblingBox()) {
-            if (is<RenderBlockFlow>(*obj) && shouldCheckLines(downcast<RenderBlockFlow>(*obj))) {
-                int result = getHeightForLineCount(downcast<RenderBlockFlow>(*obj), lineCount, false, count);
-                if (result != -1)
-                    return result + obj->y() + (includeBottom ? (block.borderBottom() + block.paddingBottom()) : 0_lu);
-            } else if (!obj->isFloatingOrOutOfFlowPositioned())
-                normalFlowChildWithoutLines = obj;
-        }
-        if (normalFlowChildWithoutLines && !lineCount)
-            return normalFlowChildWithoutLines->y() + normalFlowChildWithoutLines->height();
-    }
-    
-    return -1;
-}
-
-int RenderBlockFlow::heightForLineCount(int lineCount)
-{
-    int count = 0;
-    return getHeightForLineCount(*this, lineCount, true, count);
-}
-
 void RenderBlockFlow::clearTruncation()
 {
     if (style().visibility() != Visibility::Visible)

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (268985 => 268986)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.h	2020-10-26 17:52:23 UTC (rev 268985)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h	2020-10-26 17:54:31 UTC (rev 268986)
@@ -347,10 +347,7 @@
     LineLayoutPath lineLayoutPath() const { return static_cast<LineLayoutPath>(renderBlockFlowLineLayoutPath()); }
     void setLineLayoutPath(LineLayoutPath path) { setRenderBlockFlowLineLayoutPath(path); }
 
-    // Helper methods for computing line counts and heights for line counts.
-    RootInlineBox* lineAtIndex(int) const;
     int lineCount() const;
-    int heightForLineCount(int);
     void clearTruncation();
 
     void setHasMarkupTruncation(bool b) { setRenderBlockFlowHasMarkupTruncation(b); }

Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (268985 => 268986)


--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2020-10-26 17:52:23 UTC (rev 268985)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp	2020-10-26 17:54:31 UTC (rev 268986)
@@ -27,6 +27,7 @@
 
 #include "FontCascade.h"
 #include "LayoutRepainter.h"
+#include "RenderIterator.h"
 #include "RenderLayer.h"
 #include "RenderLayoutState.h"
 #include "RenderView.h"
@@ -940,6 +941,69 @@
         setHeight(oldHeight);
 }
 
+static bool shouldCheckLines(const RenderBlockFlow& blockFlow)
+{
+    return !blockFlow.isFloatingOrOutOfFlowPositioned() && blockFlow.style().height().isAuto();
+}
+
+static RootInlineBox* lineAtIndex(const RenderBlockFlow& flow, int i)
+{
+    ASSERT(i >= 0);
+
+    if (flow.style().visibility() != Visibility::Visible)
+        return nullptr;
+
+    if (flow.childrenInline()) {
+        for (auto* box = flow.firstRootBox(); box; box = box->nextRootBox()) {
+            if (!i--)
+                return box;
+        }
+        return nullptr;
+    }
+
+    for (auto& blockFlow : childrenOfType<RenderBlockFlow>(flow)) {
+        if (!shouldCheckLines(blockFlow))
+            continue;
+        if (RootInlineBox* box = lineAtIndex(blockFlow, i))
+            return box;
+    }
+
+    return nullptr;
+}
+
+static int getHeightForLineCount(const RenderBlockFlow& block, int lineCount, bool includeBottom, int& count)
+{
+    if (block.style().visibility() != Visibility::Visible)
+        return -1;
+
+    if (block.childrenInline()) {
+        for (auto* box = block.firstRootBox(); box; box = box->nextRootBox()) {
+            if (++count == lineCount)
+                return box->lineBottom() + (includeBottom ? (block.borderBottom() + block.paddingBottom()) : 0_lu);
+        }
+    } else {
+        RenderBox* normalFlowChildWithoutLines = nullptr;
+        for (auto* obj = block.firstChildBox(); obj; obj = obj->nextSiblingBox()) {
+            if (is<RenderBlockFlow>(*obj) && shouldCheckLines(downcast<RenderBlockFlow>(*obj))) {
+                int result = getHeightForLineCount(downcast<RenderBlockFlow>(*obj), lineCount, false, count);
+                if (result != -1)
+                    return result + obj->y() + (includeBottom ? (block.borderBottom() + block.paddingBottom()) : 0_lu);
+            } else if (!obj->isFloatingOrOutOfFlowPositioned())
+                normalFlowChildWithoutLines = obj;
+        }
+        if (normalFlowChildWithoutLines && !lineCount)
+            return normalFlowChildWithoutLines->y() + normalFlowChildWithoutLines->height();
+    }
+
+    return -1;
+}
+
+static int heightForLineCount(const RenderBlockFlow& flow, int lineCount)
+{
+    int count = 0;
+    return getHeightForLineCount(flow, lineCount, true, count);
+}
+
 void RenderDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool relayoutChildren)
 {
     int maxLineCount = 0;
@@ -979,7 +1043,7 @@
         if (lineCount <= numVisibleLines)
             continue;
 
-        LayoutUnit newHeight = blockChild.heightForLineCount(numVisibleLines);
+        LayoutUnit newHeight = heightForLineCount(blockChild, numVisibleLines);
         if (newHeight == child->height())
             continue;
 
@@ -992,11 +1056,11 @@
             continue;
 
         // Get the last line
-        RootInlineBox* lastLine = blockChild.lineAtIndex(lineCount - 1);
+        RootInlineBox* lastLine = lineAtIndex(blockChild, lineCount - 1);
         if (!lastLine)
             continue;
 
-        RootInlineBox* lastVisibleLine = blockChild.lineAtIndex(numVisibleLines - 1);
+        RootInlineBox* lastVisibleLine = lineAtIndex(blockChild, numVisibleLines - 1);
         if (!lastVisibleLine || !lastVisibleLine->firstChild())
             continue;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to