Title: [209591] trunk
Revision
209591
Author
[email protected]
Date
2016-12-08 18:06:04 -0800 (Thu, 08 Dec 2016)

Log Message

ASSERTION FAILED: locale in WebCore::lastHyphenLocation
https://bugs.webkit.org/show_bug.cgi?id=164182

Reviewed by Zalan Bujtas.

Source/WebCore:

Our hyphenation code assumes the locale is in a small set of known locales.
However, web content can put whatever string it wants in the locale field.

Test: fast/text/hyphenation-unknown-locale.html

* platform/text/cf/HyphenationCF.cpp:
(WebCore::lastHyphenLocation):
* rendering/RenderText.cpp:
(WebCore::maxWordFragmentWidth): When computing the minimum preferred width of
an element, we want to know the size of the widest nonbreakable unit. When
hyphenation is enabled, we have to measure the width of each fragment of each
word (where "fragment" is determined by a substring between two successive
hyphenation points, appended with a hyphen character). A hyphenation point at
string offset 0 is irrelevant for this purpose, because it would lead to an
empty fragment. Therefore, skip this situation.

LayoutTests:

* fast/text/hyphenation-unknown-locale-expected.txt: Added.
* fast/text/hyphenation-unknown-locale.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (209590 => 209591)


--- trunk/LayoutTests/ChangeLog	2016-12-09 01:54:31 UTC (rev 209590)
+++ trunk/LayoutTests/ChangeLog	2016-12-09 02:06:04 UTC (rev 209591)
@@ -1,3 +1,13 @@
+2016-12-08  Myles C. Maxfield  <[email protected]>
+
+        ASSERTION FAILED: locale in WebCore::lastHyphenLocation
+        https://bugs.webkit.org/show_bug.cgi?id=164182
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/text/hyphenation-unknown-locale-expected.txt: Added.
+        * fast/text/hyphenation-unknown-locale.html: Added.
+
 2016-12-07  Ryosuke Niwa  <[email protected]>
 
         ASSERTION FAILED: m_items.isEmpty() in CustomElementReactionQueue destructor

Added: trunk/LayoutTests/fast/text/hyphenation-unknown-locale-expected.txt (0 => 209591)


--- trunk/LayoutTests/fast/text/hyphenation-unknown-locale-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/text/hyphenation-unknown-locale-expected.txt	2016-12-09 02:06:04 UTC (rev 209591)
@@ -0,0 +1 @@
+The test passes if there is no crash.

Added: trunk/LayoutTests/fast/text/hyphenation-unknown-locale.html (0 => 209591)


--- trunk/LayoutTests/fast/text/hyphenation-unknown-locale.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/hyphenation-unknown-locale.html	2016-12-09 02:06:04 UTC (rev 209591)
@@ -0,0 +1,18 @@
+<html>
+<head>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+</script>
+<style>
+* {
+    letter-spacing: 81in;
+    zoom: 7823
+}
+</style>
+</head>
+<body>
+The test passes if there is no crash.
+<l lang=0><o><e><v><f><n><q>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (209590 => 209591)


--- trunk/Source/WebCore/ChangeLog	2016-12-09 01:54:31 UTC (rev 209590)
+++ trunk/Source/WebCore/ChangeLog	2016-12-09 02:06:04 UTC (rev 209591)
@@ -1,3 +1,26 @@
+2016-12-08  Myles C. Maxfield  <[email protected]>
+
+        ASSERTION FAILED: locale in WebCore::lastHyphenLocation
+        https://bugs.webkit.org/show_bug.cgi?id=164182
+
+        Reviewed by Zalan Bujtas.
+
+        Our hyphenation code assumes the locale is in a small set of known locales.
+        However, web content can put whatever string it wants in the locale field.
+
+        Test: fast/text/hyphenation-unknown-locale.html
+
+        * platform/text/cf/HyphenationCF.cpp:
+        (WebCore::lastHyphenLocation):
+        * rendering/RenderText.cpp:
+        (WebCore::maxWordFragmentWidth): When computing the minimum preferred width of
+        an element, we want to know the size of the widest nonbreakable unit. When
+        hyphenation is enabled, we have to measure the width of each fragment of each
+        word (where "fragment" is determined by a substring between two successive
+        hyphenation points, appended with a hyphen character). A hyphenation point at
+        string offset 0 is irrelevant for this purpose, because it would lead to an
+        empty fragment. Therefore, skip this situation.
+
 2016-12-08  David Kilzer  <[email protected]>
 
         Always check the return value of pthread_key_create()

Modified: trunk/Source/WebCore/platform/text/cf/HyphenationCF.cpp (209590 => 209591)


--- trunk/Source/WebCore/platform/text/cf/HyphenationCF.cpp	2016-12-09 01:54:31 UTC (rev 209590)
+++ trunk/Source/WebCore/platform/text/cf/HyphenationCF.cpp	2016-12-09 02:06:04 UTC (rev 209591)
@@ -76,10 +76,9 @@
 size_t lastHyphenLocation(StringView text, size_t beforeIndex, const AtomicString& localeIdentifier)
 {
     RetainPtr<CFLocaleRef> locale = TinyLRUCachePolicy<AtomicString, RetainPtr<CFLocaleRef>>::cache().get(localeIdentifier);
-    ASSERT(locale);
 
     CFOptionFlags searchAcrossWordBoundaries = 1;
-    CFIndex result = CFStringGetHyphenationLocationBeforeIndex(text.createCFStringWithoutCopying().get(), beforeIndex, CFRangeMake(0, text.length()), searchAcrossWordBoundaries, locale.get(), 0);
+    CFIndex result = CFStringGetHyphenationLocationBeforeIndex(text.createCFStringWithoutCopying().get(), beforeIndex, CFRangeMake(0, text.length()), searchAcrossWordBoundaries, locale.get(), nullptr);
     return result == kCFNotFound ? 0 : result;
 }
 

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (209590 => 209591)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2016-12-09 01:54:31 UTC (rev 209590)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2016-12-09 02:06:04 UTC (rev 209591)
@@ -742,7 +742,7 @@
     Vector<int, 8> hyphenLocations;
     ASSERT(word.length() >= minimumSuffixLength);
     unsigned hyphenLocation = word.length() - minimumSuffixLength;
-    while ((hyphenLocation = lastHyphenLocation(word, hyphenLocation, style.locale())) >= minimumPrefixLength)
+    while ((hyphenLocation = lastHyphenLocation(word, hyphenLocation, style.locale())) >= std::max(minimumPrefixLength, 1U))
         hyphenLocations.append(hyphenLocation);
 
     if (hyphenLocations.isEmpty())
@@ -750,6 +750,7 @@
 
     hyphenLocations.reverse();
 
+    // FIXME: Breaking the string at these places in the middle of words is completely broken with complex text.
     float minimumFragmentWidthToConsider = font.pixelSize() * 5 / 4 + hyphenWidth(renderer, font);
     float maxFragmentWidth = 0;
     for (size_t k = 0; k < hyphenLocations.size(); ++k) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to