Title: [276357] trunk
Revision
276357
Author
za...@apple.com
Date
2021-04-21 06:36:34 -0700 (Wed, 21 Apr 2021)

Log Message

REGRESSION(r256107): Text moves around when selecting at https://www.tokyo-sports.co.jp/entame/news/2834187/
https://bugs.webkit.org/show_bug.cgi?id=224839
<rdar://74958484>

Reviewed by Darin Adler.

Source/WebCore:

Pass in locale information when constructing the text iterator for the content (locale affects soft wrap opportunities).

Test: fast/text/line-break-with-locale.html

* layout/inlineformatting/InlineTextItem.cpp:
(WebCore::Layout::InlineTextItem::createAndAppendTextItems):
* layout/inlineformatting/text/TextUtil.cpp: In addition to locale, add missing line breaking mode.
(WebCore::Layout::TextUtil::lineBreakIteratorMode):
* layout/inlineformatting/text/TextUtil.h:

LayoutTests:

* fast/text/line-break-with-locale-expected.html: Added.
* fast/text/line-break-with-locale.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (276356 => 276357)


--- trunk/LayoutTests/ChangeLog	2021-04-21 13:34:12 UTC (rev 276356)
+++ trunk/LayoutTests/ChangeLog	2021-04-21 13:36:34 UTC (rev 276357)
@@ -1,3 +1,14 @@
+2021-04-21  Zalan Bujtas  <za...@apple.com>
+
+        REGRESSION(r256107): Text moves around when selecting at https://www.tokyo-sports.co.jp/entame/news/2834187/
+        https://bugs.webkit.org/show_bug.cgi?id=224839
+        <rdar://74958484>
+
+        Reviewed by Darin Adler.
+
+        * fast/text/line-break-with-locale-expected.html: Added.
+        * fast/text/line-break-with-locale.html: Added.
+
 2021-04-21  Martin Robinson  <mrobin...@webkit.org>
 
         Add basic (non-momentum) wheel event handling for scroll snap

Added: trunk/LayoutTests/fast/text/line-break-with-locale-expected.html (0 => 276357)


--- trunk/LayoutTests/fast/text/line-break-with-locale-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/line-break-with-locale-expected.html	2021-04-21 13:36:34 UTC (rev 276357)
@@ -0,0 +1,8 @@
+<style>
+div {
+  width: 72px;
+  height: 78px;
+  background-color: green;
+}
+</style>
+<div></div>

Added: trunk/LayoutTests/fast/text/line-break-with-locale.html (0 => 276357)


--- trunk/LayoutTests/fast/text/line-break-with-locale.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/line-break-with-locale.html	2021-04-21 13:36:34 UTC (rev 276357)
@@ -0,0 +1,11 @@
+<html lang="ja">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<style>
+div {
+  width: 72px;
+  font-size: 25.5px;
+  color: green;
+  background-color: green;
+}
+</style>
+<div>っっっっ</div>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (276356 => 276357)


--- trunk/LayoutTests/platform/ios/TestExpectations	2021-04-21 13:34:12 UTC (rev 276356)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2021-04-21 13:36:34 UTC (rev 276357)
@@ -3413,3 +3413,5 @@
 webkit.org/b/222844 imported/blink/compositing/draws-content/webgl-simple-background.html [ Pass ImageOnlyFailure ]
 
 webkit.org/b/222239 webgl/conformance/extensions/khr-parallel-shader-compile.html [ Skip ]
+
+fast/text/line-break-with-locale.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (276356 => 276357)


--- trunk/Source/WebCore/ChangeLog	2021-04-21 13:34:12 UTC (rev 276356)
+++ trunk/Source/WebCore/ChangeLog	2021-04-21 13:36:34 UTC (rev 276357)
@@ -1,3 +1,21 @@
+2021-04-21  Zalan Bujtas  <za...@apple.com>
+
+        REGRESSION(r256107): Text moves around when selecting at https://www.tokyo-sports.co.jp/entame/news/2834187/
+        https://bugs.webkit.org/show_bug.cgi?id=224839
+        <rdar://74958484>
+
+        Reviewed by Darin Adler.
+
+        Pass in locale information when constructing the text iterator for the content (locale affects soft wrap opportunities).
+
+        Test: fast/text/line-break-with-locale.html
+
+        * layout/inlineformatting/InlineTextItem.cpp:
+        (WebCore::Layout::InlineTextItem::createAndAppendTextItems):
+        * layout/inlineformatting/text/TextUtil.cpp: In addition to locale, add missing line breaking mode.
+        (WebCore::Layout::TextUtil::lineBreakIteratorMode):
+        * layout/inlineformatting/text/TextUtil.h:
+
 2021-04-21  Ziran Sun  <z...@igalia.com>
 
         [css-grid] last-baseline shouldn't affect baseline alignment

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp (276356 => 276357)


--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp	2021-04-21 13:34:12 UTC (rev 276356)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp	2021-04-21 13:36:34 UTC (rev 276357)
@@ -80,8 +80,8 @@
     auto& style = inlineTextBox.style();
     auto& font = style.fontCascade();
     auto whitespaceContentIsTreatedAsSingleSpace = !TextUtil::shouldPreserveSpacesAndTabs(inlineTextBox);
-    auto shouldPreseveNewline = TextUtil::shouldPreserveNewline(inlineTextBox);
-    LazyLineBreakIterator lineBreakIterator(text);
+    auto shouldPreserveNewline = TextUtil::shouldPreserveNewline(inlineTextBox);
+    auto lineBreakIterator = LazyLineBreakIterator { text, style.computedLocale(), TextUtil::lineBreakIteratorMode(style.lineBreak()) };
     unsigned currentPosition = 0;
 
     auto inlineItemWidth = [&](auto startPosition, auto length) -> Optional<InlineLayoutUnit> {
@@ -96,13 +96,13 @@
         };
 
         // Segment breaks with preserve new line style (white-space: pre, pre-wrap, break-spaces and pre-line) compute to forced line break.
-        if (isSegmentBreakCandidate(text[currentPosition]) && shouldPreseveNewline) {
+        if (isSegmentBreakCandidate(text[currentPosition]) && shouldPreserveNewline) {
             inlineContent.append(InlineSoftLineBreakItem::createSoftLineBreakItem(inlineTextBox, currentPosition));
             ++currentPosition;
             continue;
         }
 
-        if (auto whitespaceContent = moveToNextNonWhitespacePosition(text, currentPosition, shouldPreseveNewline, !whitespaceContentIsTreatedAsSingleSpace)) {
+        if (auto whitespaceContent = moveToNextNonWhitespacePosition(text, currentPosition, shouldPreserveNewline, !whitespaceContentIsTreatedAsSingleSpace)) {
             ASSERT(whitespaceContent->length);
             auto appendWhitespaceItem = [&] (auto startPosition, auto itemLength) {
                 auto simpleSingleWhitespaceContent = inlineTextBox.canUseSimplifiedContentMeasuring() && (itemLength == 1 || whitespaceContentIsTreatedAsSingleSpace);

Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp (276356 => 276357)


--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp	2021-04-21 13:34:12 UTC (rev 276356)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp	2021-04-21 13:36:34 UTC (rev 276357)
@@ -152,6 +152,24 @@
     return whitespace == WhiteSpace::Pre || whitespace == WhiteSpace::PreWrap || whitespace == WhiteSpace::BreakSpaces || whitespace == WhiteSpace::PreLine; 
 }
 
+LineBreakIteratorMode TextUtil::lineBreakIteratorMode(LineBreak lineBreak)
+{
+    switch (lineBreak) {
+    case LineBreak::Auto:
+    case LineBreak::AfterWhiteSpace:
+    case LineBreak::Anywhere:
+        return LineBreakIteratorMode::Default;
+    case LineBreak::Loose:
+        return LineBreakIteratorMode::Loose;
+    case LineBreak::Normal:
+        return LineBreakIteratorMode::Normal;
+    case LineBreak::Strict:
+        return LineBreakIteratorMode::Strict;
+    }
+    ASSERT_NOT_REACHED();
+    return LineBreakIteratorMode::Default;
 }
+
 }
+}
 #endif

Modified: trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h (276356 => 276357)


--- trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h	2021-04-21 13:34:12 UTC (rev 276356)
+++ trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h	2021-04-21 13:36:34 UTC (rev 276357)
@@ -52,7 +52,9 @@
         InlineLayoutUnit logicalWidth { 0 };
     };
     static SplitData split(const InlineTextItem&, InlineLayoutUnit textWidth, InlineLayoutUnit availableWidth, InlineLayoutUnit contentLogicalLeft);
+
     static unsigned findNextBreakablePosition(LazyLineBreakIterator&, unsigned startPosition, const RenderStyle&);
+    static LineBreakIteratorMode lineBreakIteratorMode(LineBreak);
 
     static bool shouldPreserveSpacesAndTabs(const Box&);
     static bool shouldPreserveNewline(const Box&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to