Title: [285602] trunk/Source/WebCore
- Revision
- 285602
- Author
- [email protected]
- Date
- 2021-11-10 11:40:14 -0800 (Wed, 10 Nov 2021)
Log Message
[LFC][IFC] ubidi expects non-preserved new lines as whitespace characters
https://bugs.webkit.org/show_bug.cgi?id=232921
Reviewed by Antti Koivisto.
* layout/formattingContexts/inline/InlineItemsBuilder.cpp:
(WebCore::Layout::replaceNonPreservedNewLineCharactersAndAppend):
(WebCore::Layout::buildBidiParagraph):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (285601 => 285602)
--- trunk/Source/WebCore/ChangeLog 2021-11-10 19:37:36 UTC (rev 285601)
+++ trunk/Source/WebCore/ChangeLog 2021-11-10 19:40:14 UTC (rev 285602)
@@ -1,3 +1,14 @@
+2021-11-10 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] ubidi expects non-preserved new lines as whitespace characters
+ https://bugs.webkit.org/show_bug.cgi?id=232921
+
+ Reviewed by Antti Koivisto.
+
+ * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
+ (WebCore::Layout::replaceNonPreservedNewLineCharactersAndAppend):
+ (WebCore::Layout::buildBidiParagraph):
+
2021-11-10 Alex Christensen <[email protected]>
Implement serialization and deserialization of redirect and modify headers actions for WKContentRuleList
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp (285601 => 285602)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp 2021-11-10 19:37:36 UTC (rev 285601)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp 2021-11-10 19:40:14 UTC (rev 285602)
@@ -139,6 +139,38 @@
}
}
+static void replaceNonPreservedNewLineCharactersAndAppend(const InlineTextBox& inlineTextBox, StringBuilder& paragraphContentBuilder)
+{
+ // ubidi prefers non-preserved new lines as whitespace characters.
+ if (TextUtil::shouldPreserveNewline(inlineTextBox))
+ return paragraphContentBuilder.append(inlineTextBox.content());
+
+ auto textContent = inlineTextBox.content();
+ auto contentLength = textContent.length();
+ auto needsUnicodeHandling = !textContent.is8Bit();
+ size_t nonReplacedContentStartPosition = 0;
+ for (size_t position = 0; position < contentLength;) {
+ auto startPosition = position;
+ auto isNewLineCharacter = [&] {
+ if (needsUnicodeHandling) {
+ UChar32 character;
+ U16_NEXT(textContent.characters16(), position, contentLength, character);
+ return character == newlineCharacter;
+ }
+ return textContent[position++] == newlineCharacter;
+ };
+ if (!isNewLineCharacter())
+ continue;
+
+ if (nonReplacedContentStartPosition < startPosition)
+ paragraphContentBuilder.append(textContent.substring(nonReplacedContentStartPosition, startPosition - nonReplacedContentStartPosition));
+ paragraphContentBuilder.append(space);
+ nonReplacedContentStartPosition = position;
+ }
+ if (nonReplacedContentStartPosition < contentLength)
+ paragraphContentBuilder.append(textContent.right(contentLength - nonReplacedContentStartPosition));
+}
+
using InlineItemOffsetList = Vector<std::optional<size_t>>;
static inline void buildBidiParagraph(const InlineItems& inlineItems, StringBuilder& paragraphContentBuilder, InlineItemOffsetList& inlineItemOffsetList)
{
@@ -151,7 +183,7 @@
if (inlineItem.isText()) {
if (lastInlineTextBox != &layoutBox) {
inlineTextBoxOffset = paragraphContentBuilder.length();
- paragraphContentBuilder.append(downcast<InlineTextBox>(layoutBox).content());
+ replaceNonPreservedNewLineCharactersAndAppend(downcast<InlineTextBox>(layoutBox), paragraphContentBuilder);
lastInlineTextBox = &layoutBox;
}
inlineItemOffsetList.uncheckedAppend({ inlineTextBoxOffset + downcast<InlineTextItem>(inlineItem).start() });
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes