Title: [270747] trunk/Source/WebCore
- Revision
- 270747
- Author
- [email protected]
- Date
- 2020-12-12 23:03:06 -0800 (Sat, 12 Dec 2020)
Log Message
[LFC][IFC] tabCharacter and newlineCharacter are also word separators when not preserved
https://bugs.webkit.org/show_bug.cgi?id=219784
Reviewed by Antti Koivisto.
* layout/inlineformatting/InlineTextItem.cpp:
(WebCore::Layout::isWhitespaceCharacter):
(WebCore::Layout::shouldPreserveSpacesAndTabs):
(WebCore::Layout::InlineTextItem::createAndAppendTextItems):
(WebCore::Layout::InlineTextItem::shouldPreserveSpacesAndTabs):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (270746 => 270747)
--- trunk/Source/WebCore/ChangeLog 2020-12-13 05:43:50 UTC (rev 270746)
+++ trunk/Source/WebCore/ChangeLog 2020-12-13 07:03:06 UTC (rev 270747)
@@ -1,3 +1,16 @@
+2020-12-12 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] tabCharacter and newlineCharacter are also word separators when not preserved
+ https://bugs.webkit.org/show_bug.cgi?id=219784
+
+ Reviewed by Antti Koivisto.
+
+ * layout/inlineformatting/InlineTextItem.cpp:
+ (WebCore::Layout::isWhitespaceCharacter):
+ (WebCore::Layout::shouldPreserveSpacesAndTabs):
+ (WebCore::Layout::InlineTextItem::createAndAppendTextItems):
+ (WebCore::Layout::InlineTextItem::shouldPreserveSpacesAndTabs):
+
2020-12-12 Frank Olivier <[email protected]>
Implement WebVTT VTTCue region attribute
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp (270746 => 270747)
--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2020-12-13 05:43:50 UTC (rev 270746)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2020-12-13 07:03:06 UTC (rev 270747)
@@ -40,7 +40,7 @@
static inline bool isWhitespaceCharacter(UChar character, bool preserveNewline)
{
- return character == ' ' || character == '\t' || (character == '\n' && !preserveNewline);
+ return character == space || character == tabCharacter || (character == newlineCharacter && !preserveNewline);
}
static unsigned moveToNextNonWhitespacePosition(const StringView& textContent, unsigned startPosition, bool preserveNewline)
@@ -73,6 +73,7 @@
auto& style = inlineTextBox.style();
auto& font = style.fontCascade();
+ auto whitespaceContentIsTreatedAsSingleSpace = !TextUtil::shouldPreserveSpacesAndTabs(inlineTextBox);
LazyLineBreakIterator lineBreakIterator(text);
unsigned currentPosition = 0;
@@ -96,18 +97,23 @@
if (isWhitespaceCharacter(text[currentPosition], style.preserveNewline())) {
auto appendWhitespaceItem = [&] (auto startPosition, auto itemLength) {
- auto simpleSingleWhitespaceContent = inlineTextBox.canUseSimplifiedContentMeasuring() && (itemLength == 1 || style.collapseWhiteSpace());
+ auto simpleSingleWhitespaceContent = inlineTextBox.canUseSimplifiedContentMeasuring() && (itemLength == 1 || whitespaceContentIsTreatedAsSingleSpace);
auto width = simpleSingleWhitespaceContent ? makeOptional(InlineLayoutUnit { font.spaceWidth() }) : inlineItemWidth(startPosition, itemLength);
- auto isWordSeparator = true;
- if (itemLength == 1) {
- // FIXME: Check if the collapsible content (multiple whitespace) is not always a word separator.
- isWordSeparator = text[startPosition] == space
- || text[startPosition] == noBreakSpace
- || text[startPosition] == ethiopicWordspace
- || text[startPosition] == aegeanWordSeparatorLine
- || text[startPosition] == aegeanWordSeparatorDot
- || text[startPosition] == ugariticWordDivider;
- }
+ auto isWordSeparator = [&] {
+ if (whitespaceContentIsTreatedAsSingleSpace)
+ return true;
+ if (itemLength != 1) {
+ // FIXME: Add support for cases where the whitespace content contains different type of characters (e.g "\t \t \t").
+ return false;
+ }
+ auto whitespaceCharacter = text[startPosition];
+ return whitespaceCharacter == space
+ || whitespaceCharacter == noBreakSpace
+ || whitespaceCharacter == ethiopicWordspace
+ || whitespaceCharacter == aegeanWordSeparatorLine
+ || whitespaceCharacter == aegeanWordSeparatorDot
+ || whitespaceCharacter == ugariticWordDivider;
+ }();
inlineContent.append(InlineTextItem::createWhitespaceItem(inlineTextBox, startPosition, itemLength, isWordSeparator, width));
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes