Title: [272325] trunk/Source/WebCore
Revision
272325
Author
[email protected]
Date
2021-02-03 10:26:19 -0800 (Wed, 03 Feb 2021)

Log Message

[LFC][IFC] Every leading whitespace character is tested twice
https://bugs.webkit.org/show_bug.cgi?id=221335

Reviewed by Antti Koivisto.

* layout/inlineformatting/InlineTextItem.cpp:
(WebCore::Layout::moveToNextNonWhitespacePosition):
(WebCore::Layout::InlineTextItem::createAndAppendTextItems):
(WebCore::Layout::isWhitespaceCharacter): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (272324 => 272325)


--- trunk/Source/WebCore/ChangeLog	2021-02-03 17:48:07 UTC (rev 272324)
+++ trunk/Source/WebCore/ChangeLog	2021-02-03 18:26:19 UTC (rev 272325)
@@ -1,3 +1,15 @@
+2021-02-03  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Every leading whitespace character is tested twice
+        https://bugs.webkit.org/show_bug.cgi?id=221335
+
+        Reviewed by Antti Koivisto.
+
+        * layout/inlineformatting/InlineTextItem.cpp:
+        (WebCore::Layout::moveToNextNonWhitespacePosition):
+        (WebCore::Layout::InlineTextItem::createAndAppendTextItems):
+        (WebCore::Layout::isWhitespaceCharacter): Deleted.
+
 2021-02-03  Youenn Fablet  <[email protected]>
 
         Make sure GPUProcess MediaRecorder handles correctly muted tracks

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp (272324 => 272325)


--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp	2021-02-03 17:48:07 UTC (rev 272324)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp	2021-02-03 18:26:19 UTC (rev 272325)
@@ -38,15 +38,14 @@
 
 static_assert(sizeof(InlineItem) == sizeof(InlineTextItem), "");
 
-static inline bool isWhitespaceCharacter(UChar character, bool preserveNewline)
+static size_t moveToNextNonWhitespacePosition(const StringView& textContent, size_t startPosition, bool preserveNewline)
 {
-    return character == space || character == tabCharacter || (character == newlineCharacter && !preserveNewline);
-}
+    auto isWhitespaceCharacter = [&](auto character) {
+        return character == space || character == tabCharacter || (character == newlineCharacter && !preserveNewline);
+    };
 
-static unsigned moveToNextNonWhitespacePosition(const StringView& textContent, unsigned startPosition, bool preserveNewline)
-{
     auto nextNonWhiteSpacePosition = startPosition;
-    while (nextNonWhiteSpacePosition < textContent.length() && isWhitespaceCharacter(textContent[nextNonWhiteSpacePosition], preserveNewline))
+    while (nextNonWhiteSpacePosition < textContent.length() && isWhitespaceCharacter(textContent[nextNonWhiteSpacePosition]))
         ++nextNonWhiteSpacePosition;
     return nextNonWhiteSpacePosition - startPosition;
 }
@@ -95,7 +94,7 @@
             continue;
         }
 
-        if (isWhitespaceCharacter(text[currentPosition], style.preserveNewline())) {
+        if (auto length = moveToNextNonWhitespacePosition(text, currentPosition, style.preserveNewline())) {
             auto appendWhitespaceItem = [&] (auto startPosition, auto itemLength) {
                 auto simpleSingleWhitespaceContent = inlineTextBox.canUseSimplifiedContentMeasuring() && (itemLength == 1 || whitespaceContentIsTreatedAsSingleSpace);
                 auto width = simpleSingleWhitespaceContent ? makeOptional(InlineLayoutUnit { font.spaceWidth() }) : inlineItemWidth(startPosition, itemLength);
@@ -116,13 +115,11 @@
                 }();
                 inlineContent.append(InlineTextItem::createWhitespaceItem(inlineTextBox, startPosition, itemLength, isWordSeparator, width));
             };
-
-            auto length = moveToNextNonWhitespacePosition(text, currentPosition, style.preserveNewline());
             if (style.whiteSpace() == WhiteSpace::BreakSpaces) {
                 // https://www.w3.org/TR/css-text-3/#white-space-phase-1
                 // For break-spaces, a soft wrap opportunity exists after every space and every tab.
                 // FIXME: if this turns out to be a perf hit with too many individual whitespace inline items, we should transition this logic to line breaking.
-                for (unsigned i = 0; i < length; ++i)
+                for (size_t i = 0; i < length; ++i)
                     appendWhitespaceItem(currentPosition + i, 1);
             } else
                 appendWhitespaceItem(currentPosition, length);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to