Title: [295450] trunk/Source/WebCore/style/InlineTextBoxStyle.cpp
Revision
295450
Author
za...@apple.com
Date
2022-06-10 05:26:02 -0700 (Fri, 10 Jun 2022)

Log Message

minLogicalTopForTextDecorationLine/maxLogicalBottomForTextDecorationLine should return the min/max value
https://bugs.webkit.org/show_bug.cgi?id=241474

Reviewed by Antti Koivisto.

This improves readability and also a preparation for making decoration visual overflow work with IFC.

* Source/WebCore/style/InlineTextBoxStyle.cpp:
(WebCore::minLogicalTopForTextDecorationLine):
(WebCore::maxLogicalBottomForTextDecorationLine):
(WebCore::computeUnderlineOffset):

Canonical link: https://commits.webkit.org/251456@main

Modified Paths

Diff

Modified: trunk/Source/WebCore/style/InlineTextBoxStyle.cpp (295449 => 295450)


--- trunk/Source/WebCore/style/InlineTextBoxStyle.cpp	2022-06-10 09:37:34 UTC (rev 295449)
+++ trunk/Source/WebCore/style/InlineTextBoxStyle.cpp	2022-06-10 12:26:02 UTC (rev 295450)
@@ -48,8 +48,9 @@
     return false;
 }
 
-static void minLogicalTopForTextDecorationLine(const InlineIterator::LineBoxIterator& lineBox, float& minLogicalTop, const RenderElement* decorationRenderer, OptionSet<TextDecorationLine> textDecorationLine)
+static float minLogicalTopForTextDecorationLine(const InlineIterator::LineBoxIterator& lineBox, float textRunLogicalTop, const RenderElement* decorationRenderer, OptionSet<TextDecorationLine> textDecorationLine)
 {
+    auto minLogicalTop = textRunLogicalTop;
     for (auto run = lineBox->firstLeafBox(); run; run.traverseNextOnLine()) {
         if (run->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
@@ -63,10 +64,12 @@
         if (run->isText() || run->style().textDecorationSkipInk() == TextDecorationSkipInk::None)
             minLogicalTop = std::min<float>(minLogicalTop, run->logicalTop());
     }
+    return minLogicalTop;
 }
 
-static void maxLogicalBottomForTextDecorationLine(const InlineIterator::LineBoxIterator& lineBox, float& maxLogicalBottom, const RenderElement* decorationRenderer, OptionSet<TextDecorationLine> textDecorationLine)
+static float maxLogicalBottomForTextDecorationLine(const InlineIterator::LineBoxIterator& lineBox, float textRunLogicalBottom, const RenderElement* decorationRenderer, OptionSet<TextDecorationLine> textDecorationLine)
 {
+    auto maxLogicalBottom = textRunLogicalBottom;
     for (auto run = lineBox->firstLeafBox(); run; run.traverseNextOnLine()) {
         if (run->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
@@ -80,6 +83,7 @@
         if (run->isText() || run->style().textDecorationSkipInk() == TextDecorationSkipInk::None)
             maxLogicalBottom = std::max<float>(maxLogicalBottom, run->logicalBottom());
     }
+    return maxLogicalBottom;
 }
 
 static const RenderElement* enclosingRendererWithTextDecoration(const RenderText& renderer, OptionSet<TextDecorationLine> textDecorationLine, bool firstLine)
@@ -140,12 +144,10 @@
         
         float offset;
         if (context.renderer->style().isFlippedLinesWritingMode()) {
-            offset = context.textRunLogicalTop;
-            minLogicalTopForTextDecorationLine(context.lineBox, offset, decorationRenderer, TextDecorationLine::Underline);
-            offset = context.textRunLogicalTop - offset;
+            auto minLogicalTop = minLogicalTopForTextDecorationLine(context.lineBox, context.textRunLogicalTop, decorationRenderer, TextDecorationLine::Underline);
+            offset = context.textRunLogicalTop - minLogicalTop;
         } else {
-            offset = context.textRunLogicalBottom;
-            maxLogicalBottomForTextDecorationLine(context.lineBox, offset, decorationRenderer, TextDecorationLine::Underline);
+            offset = maxLogicalBottomForTextDecorationLine(context.lineBox, context.textRunLogicalBottom, decorationRenderer, TextDecorationLine::Underline);
             offset -= context.textRunLogicalBottom;
         }
         auto textRunLogicalHeight = context.textRunLogicalBottom - context.textRunLogicalTop;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to