Title: [282738] trunk
Revision
282738
Author
[email protected]
Date
2021-09-19 14:18:58 -0700 (Sun, 19 Sep 2021)

Log Message

[LFC][IFC] overflow-wrap: anywhere/break-word rules over word-break: keep-all
https://bugs.webkit.org/show_bug.cgi?id=230458

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-text/overflow-wrap/overflow-wrap-break-word-keep-all-001-expected.txt:

Source/WebCore:

https://drafts.csswg.org/css-text/#overflow-wrap-property
"...An otherwise unbreakable sequence of characters may be broken at an arbitrary point if there are
no otherwise-acceptable break points in the line."

"word-break: keep all" makes the content "otherwise unbreakable sequence of characters". It simply means
that "overflow-wrap: anywhere/break-word" may break the content at an arbitrary position even when "keep-all" is set,

* layout/formattingContexts/inline/InlineContentBreaker.cpp:
(WebCore::Layout::InlineContentBreaker::wordBreakBehavior const):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (282737 => 282738)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-19 17:04:38 UTC (rev 282737)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-19 21:18:58 UTC (rev 282738)
@@ -1,3 +1,12 @@
+2021-09-19  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] overflow-wrap: anywhere/break-word rules over word-break: keep-all
+        https://bugs.webkit.org/show_bug.cgi?id=230458
+
+        Reviewed by Antti Koivisto.
+
+        * web-platform-tests/css/css-text/overflow-wrap/overflow-wrap-break-word-keep-all-001-expected.txt:
+
 2021-09-17  Simon Fraser  <[email protected]>
 
         css/cssom-view/mouseEvent-offsetXY-svg.html passes now

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/overflow-wrap/overflow-wrap-break-word-keep-all-001-expected.txt (282737 => 282738)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/overflow-wrap/overflow-wrap-break-word-keep-all-001-expected.txt	2021-09-19 17:04:38 UTC (rev 282737)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text/overflow-wrap/overflow-wrap-break-word-keep-all-001-expected.txt	2021-09-19 21:18:58 UTC (rev 282738)
@@ -1,6 +1,6 @@
 0000000000
 헬로우월드헬로우월드헬로우월드헬로우월드헬로우월드
 
-FAIL 0000000000 assert_greater_than: expected a number greater than 20 but got 20
+PASS 0000000000
 PASS 헬로우월드헬로우월드헬로우월드헬로우월드헬로우월드
 

Modified: trunk/Source/WebCore/ChangeLog (282737 => 282738)


--- trunk/Source/WebCore/ChangeLog	2021-09-19 17:04:38 UTC (rev 282737)
+++ trunk/Source/WebCore/ChangeLog	2021-09-19 21:18:58 UTC (rev 282738)
@@ -1,3 +1,20 @@
+2021-09-19  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] overflow-wrap: anywhere/break-word rules over word-break: keep-all
+        https://bugs.webkit.org/show_bug.cgi?id=230458
+
+        Reviewed by Antti Koivisto.
+
+        https://drafts.csswg.org/css-text/#overflow-wrap-property
+        "...An otherwise unbreakable sequence of characters may be broken at an arbitrary point if there are
+        no otherwise-acceptable break points in the line."
+
+        "word-break: keep all" makes the content "otherwise unbreakable sequence of characters". It simply means
+        that "overflow-wrap: anywhere/break-word" may break the content at an arbitrary position even when "keep-all" is set,  
+
+        * layout/formattingContexts/inline/InlineContentBreaker.cpp:
+        (WebCore::Layout::InlineContentBreaker::wordBreakBehavior const):
+
 2021-09-19  Antti Koivisto  <[email protected]>
 
         [lFC][Integration] Enable some text painting features

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp (282737 => 282738)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp	2021-09-19 17:04:38 UTC (rev 282737)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp	2021-09-19 21:18:58 UTC (rev 282738)
@@ -397,32 +397,37 @@
 OptionSet<InlineContentBreaker::WordBreakRule> InlineContentBreaker::wordBreakBehavior(const RenderStyle& style, bool hasWrapOpportunityAtPreviousPosition) const
 {
     // Disregard any prohibition against line breaks mandated by the word-break property.
-    // The different wrapping opportunities must not be prioritized. Hyphenation is not applied.
+    // The different wrapping opportunities must not be prioritized.
+    // Note hyphenation is not applied.
     if (style.lineBreak() == LineBreak::Anywhere)
         return { WordBreakRule::AtArbitraryPosition };
+
+    auto includeHyphenationIfAllowed = [&](std::optional<InlineContentBreaker::WordBreakRule> wordBreakRule) -> OptionSet<InlineContentBreaker::WordBreakRule> {
+        auto hyphenationIsAllowed = !n_hyphenationIsDisabled && style.hyphens() == Hyphens::Auto && canHyphenate(style.computedLocale());
+        if (hyphenationIsAllowed) {
+            if (wordBreakRule)
+                return { *wordBreakRule, WordBreakRule::AtHyphenationOpportunities };
+            return { WordBreakRule::AtHyphenationOpportunities };
+        }
+        if (wordBreakRule)
+            return *wordBreakRule;
+        return { };
+    };
     // Breaking is allowed within “words”.
     if (style.wordBreak() == WordBreak::BreakAll)
-        return { WordBreakRule::AtArbitraryPosition };
+        return includeHyphenationIfAllowed(WordBreakRule::AtArbitraryPosition);
+    // For compatibility with legacy content, the word-break property also supports a deprecated break-word keyword.
+    // When specified, this has the same effect as word-break: normal and overflow-wrap: anywhere, regardless of the actual value of the overflow-wrap property.
+    if (style.wordBreak() == WordBreak::BreakWord && !hasWrapOpportunityAtPreviousPosition)
+        return includeHyphenationIfAllowed(WordBreakRule::AtArbitraryPosition);
+    // OverflowWrap::BreakWord/Anywhere An otherwise unbreakable sequence of characters may be broken at an arbitrary point if there are no otherwise-acceptable break points in the line.
+    // Note that this applies to content where CSS properties (e.g. WordBreak::KeepAll) make it unbreakable. 
+    if ((style.overflowWrap() == OverflowWrap::BreakWord || style.overflowWrap() == OverflowWrap::Anywhere) && !hasWrapOpportunityAtPreviousPosition)
+        return includeHyphenationIfAllowed(WordBreakRule::AtArbitraryPosition);
     // Breaking is forbidden within “words”.
     if (style.wordBreak() == WordBreak::KeepAll)
         return { };
-
-    auto breakRules = OptionSet<WordBreakRule> { };
-    auto hyphenationIsAllowed = !n_hyphenationIsDisabled && style.hyphens() == Hyphens::Auto && canHyphenate(style.computedLocale());
-    if (hyphenationIsAllowed)
-        breakRules.add({ WordBreakRule::AtHyphenationOpportunities });
-    // For compatibility with legacy content, the word-break property also supports a deprecated break-word keyword.
-    // When specified, this has the same effect as word-break: normal and overflow-wrap: anywhere, regardless of the actual value of the overflow-wrap property.
-    if (style.wordBreak() == WordBreak::BreakWord && !hasWrapOpportunityAtPreviousPosition) {
-        breakRules.add({ WordBreakRule::AtArbitraryPosition });
-        return breakRules;
-    }
-    // OverflowWrap::BreakWord/Anywhere An otherwise unbreakable sequence of characters may be broken at an arbitrary point if there are no otherwise-acceptable break points in the line.
-    if ((style.overflowWrap() == OverflowWrap::BreakWord || style.overflowWrap() == OverflowWrap::Anywhere) && !hasWrapOpportunityAtPreviousPosition) {
-        breakRules.add({ WordBreakRule::AtArbitraryPosition });
-        return breakRules;
-    }
-    return breakRules;
+    return includeHyphenationIfAllowed({ });
 }
 
 std::optional<InlineContentBreaker::PartialRun> InlineContentBreaker::tryBreakingTextRun(const ContinuousContent::Run& overflowingRun, InlineLayoutUnit logicalLeft, std::optional<InlineLayoutUnit> availableWidth, bool hasWrapOpportunityAtPreviousPosition) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to