<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[195266] releases/WebKitGTK/webkit-2.10</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/195266">195266</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-19 01:00:42 -0800 (Tue, 19 Jan 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/195058">r195058</a> - [GTK] [EFL] Hyphenation can never work in practice due to requirements on lang tags
https://bugs.webkit.org/show_bug.cgi?id=147310
Patch by Martin Robinson <mrobinson@igalia.com> on 2016-01-14
Reviewed by Michael Catanzaro.
Source/WebCore:
Test: platform/gtk/fast/text/hyphenate-flexible-locales.html
* platform/text/hyphen/HyphenationLibHyphen.cpp: Make locale matching for dictionary
selection a lot looser by matching case insensitively, matching multiple dictionaries
when only the language is specified, and ignoring the difference between '_' and '-' in
the locale name.
(WebCore::scanDirectoryForDicionaries): Now produce HashMap of Vectors instead of a single
path for each locale. Also add alternate entries to handle different ways of specifying
the locale.
(WebCore::scanTestDictionariesDirectoryIfNecessary): Update to handle the difference
in HashMap type.
(WebCore::availableLocales): Ditto.
(WebCore::canHyphenate): Also look for the lowercased version of the locale.
(WebCore::AtomicStringKeyedMRUCache<RefPtr<HyphenationDictionary>>::createValueForKey):
Key on the dictionary path now so that we can load more than one dictionary per locale.
(WebCore::lastHyphenLocation): Iterate through each matched dictionary in turn.
LayoutTests:
Update some baselines and add a GTK+ specific test for locale variations.
* platform/gtk/fast/text/hyphenate-flexible-locales-expected.html: Added.
* platform/gtk/fast/text/hyphenate-flexible-locales.html: Added.
* platform/gtk/fast/text/hyphenate-locale-expected.png: We now properly hyphenate
text with the 'en' locale.
* platform/gtk/fast/text/hyphenate-locale-expected.txt:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit210LayoutTestsChangeLog">releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210LayoutTestsplatformgtkfasttexthyphenatelocaleexpectedpng">releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.png</a></li>
<li><a href="#releasesWebKitGTKwebkit210LayoutTestsplatformgtkfasttexthyphenatelocaleexpectedtxt">releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.txt</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformtexthyphenHyphenationLibHyphencpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit210LayoutTestsplatformgtkfasttexthyphenateflexiblelocalesexpectedhtml">releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales-expected.html</a></li>
<li><a href="#releasesWebKitGTKwebkit210LayoutTestsplatformgtkfasttexthyphenateflexiblelocaleshtml">releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit210LayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog (195265 => 195266)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog        2016-01-19 08:59:16 UTC (rev 195265)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog        2016-01-19 09:00:42 UTC (rev 195266)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-01-14 Martin Robinson <mrobinson@igalia.com>
+
+ [GTK] [EFL] Hyphenation can never work in practice due to requirements on lang tags
+ https://bugs.webkit.org/show_bug.cgi?id=147310
+
+ Reviewed by Michael Catanzaro.
+
+ Update some baselines and add a GTK+ specific test for locale variations.
+
+ * platform/gtk/fast/text/hyphenate-flexible-locales-expected.html: Added.
+ * platform/gtk/fast/text/hyphenate-flexible-locales.html: Added.
+ * platform/gtk/fast/text/hyphenate-locale-expected.png: We now properly hyphenate
+ text with the 'en' locale.
+ * platform/gtk/fast/text/hyphenate-locale-expected.txt:
+
</ins><span class="cx"> 2016-01-14 Youenn Fablet <youenn.fablet@crf.canon.fr>
</span><span class="cx">
</span><span class="cx"> Fix problems with cross-origin redirects
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210LayoutTestsplatformgtkfasttexthyphenateflexiblelocalesexpectedhtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales-expected.html (0 => 195266)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales-expected.html         (rev 0)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales-expected.html        2016-01-19 09:00:42 UTC (rev 195266)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+<div style="-webkit-hyphens: auto; font-size: 36px; width: 130px;">
+ <div style="-webkit-locale: 'en_US';">throughout</div>
+ <div style="-webkit-locale: 'en_US';">throughout</div>
+ <div style="-webkit-locale: 'en_US';">throughout</div>
+ <div style="-webkit-locale: 'en_US';">throughout</div>
+ <div style="-webkit-locale: 'en_US';">throughout</div>
+ <div style="-webkit-locale: 'en_US';">throughout</div>
+ <div style="-webkit-locale: 'en_US';">throughout</div>
+ <div style="-webkit-locale: 'en_US';">throughout</div>
+ <div style="-webkit-locale: 'en_US';">throughout</div>
+</div>
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit210LayoutTestsplatformgtkfasttexthyphenateflexiblelocaleshtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales.html (0 => 195266)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales.html         (rev 0)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales.html        2016-01-19 09:00:42 UTC (rev 195266)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+<div style="-webkit-hyphens: auto; font-size: 36px; width: 130px;">
+ <div style="-webkit-locale: 'en';">throughout</div>
+ <div style="-webkit-locale: 'en_US';">throughout</div>
+ <div style="-webkit-locale: 'en-US';">throughout</div>
+ <div style="-webkit-locale: 'en';">throughout</div>
+ <div style="-webkit-locale: 'en_us';">throughout</div>
+ <div style="-webkit-locale: 'en-us';">throughout</div>
+ <div style="-webkit-locale: 'EN';">throughout</div>
+ <div style="-webkit-locale: 'EN_US';">throughout</div>
+ <div style="-webkit-locale: 'EN-US';">throughout</div>
+</div>
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit210LayoutTestsplatformgtkfasttexthyphenatelocaleexpectedpng"></a>
<div class="binary"><h4>Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210LayoutTestsplatformgtkfasttexthyphenatelocaleexpectedtxt"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.txt (195265 => 195266)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.txt        2016-01-19 08:59:16 UTC (rev 195265)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.txt        2016-01-19 09:00:42 UTC (rev 195266)
</span><span class="lines">@@ -1,40 +1,42 @@
</span><del>-layer at (0,0) size 800x600
- RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
- RenderBlock {HTML} at (0,0) size 800x600
- RenderBody {BODY} at (8,8) size 784x584
- RenderBlock {DIV} at (0,0) size 130x240
</del><ins>+layer at (0,0) size 785x616
+ RenderView at (0,0) size 785x600
+layer at (0,0) size 785x616
+ RenderBlock {HTML} at (0,0) size 785x616
+ RenderBody {BODY} at (8,8) size 769x600
+ RenderBlock {DIV} at (0,0) size 130x280
</ins><span class="cx"> RenderBlock {DIV} at (0,0) size 130x40
</span><span class="cx"> RenderText {#text} at (0,0) size 158x40
</span><span class="cx"> text run at (0,0) width 158: "throughout"
</span><del>- RenderBlock {DIV} at (0,40) size 130x40
- RenderText {#text} at (0,0) size 158x40
- text run at (0,0) width 158: "throughout"
- RenderBlock {DIV} at (0,80) size 130x80
</del><ins>+ RenderBlock {DIV} at (0,40) size 130x80
</ins><span class="cx"> RenderText {#text} at (0,0) size 106x80
</span><span class="cx"> text run at (0,0) width 106: "throug" + hyphen string "\x{2010}"
</span><span class="cx"> text run at (0,40) width 64: "hout"
</span><del>- RenderBlock {DIV} at (0,160) size 130x40
</del><ins>+ RenderBlock {DIV} at (0,120) size 130x80
+ RenderText {#text} at (0,0) size 106x80
+ text run at (0,0) width 106: "throug" + hyphen string "\x{2010}"
+ text run at (0,40) width 64: "hout"
+ RenderBlock {DIV} at (0,200) size 130x40
</ins><span class="cx"> RenderText {#text} at (0,0) size 158x40
</span><span class="cx"> text run at (0,0) width 158: "throughout"
</span><del>- RenderBlock {DIV} at (0,200) size 130x40
</del><ins>+ RenderBlock {DIV} at (0,240) size 130x40
</ins><span class="cx"> RenderText {#text} at (0,0) size 158x40
</span><span class="cx"> text run at (0,0) width 158: "throughout"
</span><del>- RenderBlock {DIV} at (0,240) size 135x280
</del><ins>+ RenderBlock {DIV} at (0,280) size 135x320
</ins><span class="cx"> RenderBlock {DIV} at (0,0) size 135x40
</span><span class="cx"> RenderText {#text} at (0,0) size 156x40
</span><span class="cx"> text run at (0,0) width 156: "reciprocity"
</span><del>- RenderBlock {DIV} at (0,40) size 135x40
- RenderText {#text} at (0,0) size 156x40
- text run at (0,0) width 156: "reciprocity"
- RenderBlock {DIV} at (0,80) size 135x80
</del><ins>+ RenderBlock {DIV} at (0,40) size 135x80
</ins><span class="cx"> RenderText {#text} at (0,0) size 114x80
</span><span class="cx"> text run at (0,0) width 114: "recipro" + hyphen string "\x{2010}"
</span><span class="cx"> text run at (0,40) width 54: "city"
</span><del>- RenderBlock {DIV} at (0,160) size 135x80
</del><ins>+ RenderBlock {DIV} at (0,120) size 135x80
+ RenderText {#text} at (0,0) size 114x80
+ text run at (0,0) width 114: "recipro" + hyphen string "\x{2010}"
+ text run at (0,40) width 54: "city"
+ RenderBlock {DIV} at (0,200) size 135x80
</ins><span class="cx"> RenderText {#text} at (0,0) size 96x80
</span><span class="cx"> text run at (0,0) width 96: "recipr" + hyphen string "\x{2010}"
</span><span class="cx"> text run at (0,40) width 72: "ocity"
</span><del>- RenderBlock {DIV} at (0,240) size 135x40
</del><ins>+ RenderBlock {DIV} at (0,280) size 135x40
</ins><span class="cx"> RenderText {#text} at (0,0) size 156x40
</span><span class="cx"> text run at (0,0) width 156: "reciprocity"
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (195265 => 195266)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog        2016-01-19 08:59:16 UTC (rev 195265)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog        2016-01-19 09:00:42 UTC (rev 195266)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-01-14 Martin Robinson <mrobinson@igalia.com>
+
+ [GTK] [EFL] Hyphenation can never work in practice due to requirements on lang tags
+ https://bugs.webkit.org/show_bug.cgi?id=147310
+
+ Reviewed by Michael Catanzaro.
+
+ Test: platform/gtk/fast/text/hyphenate-flexible-locales.html
+
+ * platform/text/hyphen/HyphenationLibHyphen.cpp: Make locale matching for dictionary
+ selection a lot looser by matching case insensitively, matching multiple dictionaries
+ when only the language is specified, and ignoring the difference between '_' and '-' in
+ the locale name.
+ (WebCore::scanDirectoryForDicionaries): Now produce HashMap of Vectors instead of a single
+ path for each locale. Also add alternate entries to handle different ways of specifying
+ the locale.
+ (WebCore::scanTestDictionariesDirectoryIfNecessary): Update to handle the difference
+ in HashMap type.
+ (WebCore::availableLocales): Ditto.
+ (WebCore::canHyphenate): Also look for the lowercased version of the locale.
+ (WebCore::AtomicStringKeyedMRUCache<RefPtr<HyphenationDictionary>>::createValueForKey):
+ Key on the dictionary path now so that we can load more than one dictionary per locale.
+ (WebCore::lastHyphenLocation): Iterate through each matched dictionary in turn.
+
</ins><span class="cx"> 2016-01-14 Youenn Fablet <youenn.fablet@crf.canon.fr>
</span><span class="cx">
</span><span class="cx"> Fix problems with cross-origin redirects
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformtexthyphenHyphenationLibHyphencpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp (195265 => 195266)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp        2016-01-19 08:59:16 UTC (rev 195265)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp        2016-01-19 09:00:42 UTC (rev 195266)
</span><span class="lines">@@ -60,14 +60,27 @@
</span><span class="cx"> return fileName.substring(prefixLength, fileName.length() - prefixLength - suffixLength);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void scanDirectoryForDicionaries(const char* directoryPath, HashMap<AtomicString, String>& availableLocales)
</del><ins>+static void scanDirectoryForDicionaries(const char* directoryPath, HashMap<AtomicString, Vector<String>>& availableLocales)
</ins><span class="cx"> {
</span><del>- for (const auto& filePath : listDirectory(directoryPath, "hyph_*.dic"))
- availableLocales.set(AtomicString(extractLocaleFromDictionaryFilePath(filePath)), filePath);
</del><ins>+ for (const auto& filePath : listDirectory(directoryPath, "hyph_*.dic")) {
+ String locale = extractLocaleFromDictionaryFilePath(filePath).convertToASCIILowercase();
+ availableLocales.add(locale, Vector<String>()).iterator->value.append(filePath);
+
+ String localeReplacingUnderscores = String(locale);
+ localeReplacingUnderscores.replace('_', '-');
+ if (locale != localeReplacingUnderscores)
+ availableLocales.add(localeReplacingUnderscores, Vector<String>()).iterator->value.append(filePath);
+
+ size_t dividerPosition = localeReplacingUnderscores.find('-');
+ if (dividerPosition != notFound) {
+ localeReplacingUnderscores.truncate(dividerPosition);
+ availableLocales.add(localeReplacingUnderscores, Vector<String>()).iterator->value.append(filePath);
+ }
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(DEVELOPER_MODE)
</span><del>-static void scanTestDictionariesDirectoryIfNecessary(HashMap<AtomicString, String>& availableLocales)
</del><ins>+static void scanTestDictionariesDirectoryIfNecessary(HashMap<AtomicString, Vector<String>>& availableLocales)
</ins><span class="cx"> {
</span><span class="cx"> // It's unfortunate that we need to look for the dictionaries this way, but
</span><span class="cx"> // libhyphen doesn't have the concept of installed dictionaries. Instead,
</span><span class="lines">@@ -89,10 +102,10 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-static HashMap<AtomicString, String>& availableLocales()
</del><ins>+static HashMap<AtomicString, Vector<String>>& availableLocales()
</ins><span class="cx"> {
</span><span class="cx"> static bool scannedLocales = false;
</span><del>- static HashMap<AtomicString, String> availableLocales;
</del><ins>+ static HashMap<AtomicString, Vector<String>> availableLocales;
</ins><span class="cx">
</span><span class="cx"> if (!scannedLocales) {
</span><span class="cx"> for (size_t i = 0; i < WTF_ARRAY_LENGTH(gDictionaryDirectories); i++)
</span><span class="lines">@@ -112,7 +125,9 @@
</span><span class="cx"> {
</span><span class="cx"> if (localeIdentifier.isNull())
</span><span class="cx"> return false;
</span><del>- return availableLocales().contains(localeIdentifier);
</del><ins>+ if (availableLocales().contains(localeIdentifier))
+ return true;
+ return availableLocales().contains(AtomicString(localeIdentifier.string().convertToASCIILowercase()));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> class HyphenationDictionary : public RefCounted<HyphenationDictionary> {
</span><span class="lines">@@ -158,10 +173,9 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template<>
</span><del>-RefPtr<HyphenationDictionary> AtomicStringKeyedMRUCache<RefPtr<HyphenationDictionary>>::createValueForKey(const AtomicString& localeIdentifier)
</del><ins>+RefPtr<HyphenationDictionary> AtomicStringKeyedMRUCache<RefPtr<HyphenationDictionary>>::createValueForKey(const AtomicString& dictionaryPath)
</ins><span class="cx"> {
</span><del>- ASSERT(availableLocales().get(localeIdentifier));
- return HyphenationDictionary::create(fileSystemRepresentation(availableLocales().get(localeIdentifier)));
</del><ins>+ return HyphenationDictionary::create(fileSystemRepresentation(dictionaryPath.string()));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static AtomicStringKeyedMRUCache<RefPtr<HyphenationDictionary>>& hyphenDictionaryCache()
</span><span class="lines">@@ -190,9 +204,6 @@
</span><span class="cx">
</span><span class="cx"> size_t lastHyphenLocation(StringView string, size_t beforeIndex, const AtomicString& localeIdentifier)
</span><span class="cx"> {
</span><del>- ASSERT(availableLocales().contains(localeIdentifier));
- RefPtr<HyphenationDictionary> dictionary = hyphenDictionaryCache().get(localeIdentifier);
-
</del><span class="cx"> // libhyphen accepts strings in UTF-8 format, but WebCore can only provide StringView
</span><span class="cx"> // which stores either UTF-16 or Latin1 data. This is unfortunate for performance
</span><span class="cx"> // reasons and we should consider switching to a more flexible hyphenation library
</span><span class="lines">@@ -211,32 +222,38 @@
</span><span class="cx"> Vector<char> hyphenArray(utf8StringCopy.length() - leadingSpaceBytes + 5);
</span><span class="cx"> char* hyphenArrayData = hyphenArray.data();
</span><span class="cx">
</span><del>- char** replacements = nullptr;
- int* positions = nullptr;
- int* removedCharacterCounts = nullptr;
- hnj_hyphen_hyphenate2(dictionary->libhyphenDictionary(),
- utf8StringCopy.data() + leadingSpaceBytes,
- utf8StringCopy.length() - leadingSpaceBytes,
- hyphenArrayData,
- nullptr, /* output parameter for hyphenated word */
- &replacements,
- &positions,
- &removedCharacterCounts);
</del><ins>+ String lowercaseLocaleIdentifier = AtomicString(localeIdentifier.string().convertToASCIILowercase());
+ ASSERT(availableLocales().contains(lowercaseLocaleIdentifier));
+ for (const auto& dictionaryPath : availableLocales().get(lowercaseLocaleIdentifier)) {
+ RefPtr<HyphenationDictionary> dictionary = hyphenDictionaryCache().get(AtomicString(dictionaryPath));
</ins><span class="cx">
</span><del>- if (replacements) {
- for (unsigned i = 0; i < utf8StringCopy.length() - leadingSpaceBytes - 1; i++)
- free(replacements[i]);
- free(replacements);
- }
</del><ins>+ char** replacements = nullptr;
+ int* positions = nullptr;
+ int* removedCharacterCounts = nullptr;
+ hnj_hyphen_hyphenate2(dictionary->libhyphenDictionary(),
+ utf8StringCopy.data() + leadingSpaceBytes,
+ utf8StringCopy.length() - leadingSpaceBytes,
+ hyphenArrayData,
+ nullptr, /* output parameter for hyphenated word */
+ &replacements,
+ &positions,
+ &removedCharacterCounts);
</ins><span class="cx">
</span><del>- free(positions);
- free(removedCharacterCounts);
</del><ins>+ if (replacements) {
+ for (unsigned i = 0; i < utf8StringCopy.length() - leadingSpaceBytes - 1; i++)
+ free(replacements[i]);
+ free(replacements);
+ }
</ins><span class="cx">
</span><del>- for (int i = beforeIndex - leadingSpaceCharacters - 1; i >= 0; i--) {
- // libhyphen will put an odd number in hyphenArrayData at all
- // hyphenation points. A number & 1 will be true for odd numbers.
- if (hyphenArrayData[i] & 1)
- return i + leadingSpaceCharacters;
</del><ins>+ free(positions);
+ free(removedCharacterCounts);
+
+ for (int i = beforeIndex - leadingSpaceCharacters - 1; i >= 0; i--) {
+ // libhyphen will put an odd number in hyphenArrayData at all
+ // hyphenation points. A number & 1 will be true for odd numbers.
+ if (hyphenArrayData[i] & 1)
+ return i + leadingSpaceCharacters;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return 0;
</span></span></pre>
</div>
</div>
</body>
</html>