<!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>[195058] trunk</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/195058">195058</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-14 09:32:24 -0800 (Thu, 14 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[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 &lt;mrobinson@igalia.com&gt; 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&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;::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="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformgtkfasttexthyphenatelocaleexpectedpng">trunk/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.png</a></li>
<li><a href="#trunkLayoutTestsplatformgtkfasttexthyphenatelocaleexpectedtxt">trunk/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformtexthyphenHyphenationLibHyphencpp">trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsplatformgtkfasttexthyphenateflexiblelocalesexpectedhtml">trunk/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales-expected.html</a></li>
<li><a href="#trunkLayoutTestsplatformgtkfasttexthyphenateflexiblelocaleshtml">trunk/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (195057 => 195058)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-01-14 16:31:58 UTC (rev 195057)
+++ trunk/LayoutTests/ChangeLog        2016-01-14 17:32:24 UTC (rev 195058)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-01-14  Martin Robinson  &lt;mrobinson@igalia.com&gt;
+
+        [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  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix problems with cross-origin redirects
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkfasttexthyphenateflexiblelocalesexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales-expected.html (0 => 195058)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales-expected.html                                (rev 0)
+++ trunk/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales-expected.html        2016-01-14 17:32:24 UTC (rev 195058)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+&lt;div style=&quot;-webkit-hyphens: auto; font-size: 36px; width: 130px;&quot;&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_US';&quot;&gt;throughout&lt;/div&gt;
+&lt;/div&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformgtkfasttexthyphenateflexiblelocaleshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales.html (0 => 195058)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales.html                                (rev 0)
+++ trunk/LayoutTests/platform/gtk/fast/text/hyphenate-flexible-locales.html        2016-01-14 17:32:24 UTC (rev 195058)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+&lt;div style=&quot;-webkit-hyphens: auto; font-size: 36px; width: 130px;&quot;&gt;
+    &lt;div style=&quot;-webkit-locale: 'en';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en-US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en_us';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'en-us';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'EN';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'EN_US';&quot;&gt;throughout&lt;/div&gt;
+    &lt;div style=&quot;-webkit-locale: 'EN-US';&quot;&gt;throughout&lt;/div&gt;
+&lt;/div&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformgtkfasttexthyphenatelocaleexpectedpng"></a>
<div class="binary"><h4>Modified: trunk/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="trunkLayoutTestsplatformgtkfasttexthyphenatelocaleexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.txt (195057 => 195058)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.txt        2016-01-14 16:31:58 UTC (rev 195057)
+++ trunk/LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.txt        2016-01-14 17:32:24 UTC (rev 195058)
</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: &quot;throughout&quot;
</span><del>-        RenderBlock {DIV} at (0,40) size 130x40
-          RenderText {#text} at (0,0) size 158x40
-            text run at (0,0) width 158: &quot;throughout&quot;
-        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: &quot;throug&quot; + hyphen string &quot;\x{2010}&quot;
</span><span class="cx">             text run at (0,40) width 64: &quot;hout&quot;
</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: &quot;throug&quot; + hyphen string &quot;\x{2010}&quot;
+            text run at (0,40) width 64: &quot;hout&quot;
+        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: &quot;throughout&quot;
</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: &quot;throughout&quot;
</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: &quot;reciprocity&quot;
</span><del>-        RenderBlock {DIV} at (0,40) size 135x40
-          RenderText {#text} at (0,0) size 156x40
-            text run at (0,0) width 156: &quot;reciprocity&quot;
-        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: &quot;recipro&quot; + hyphen string &quot;\x{2010}&quot;
</span><span class="cx">             text run at (0,40) width 54: &quot;city&quot;
</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: &quot;recipro&quot; + hyphen string &quot;\x{2010}&quot;
+            text run at (0,40) width 54: &quot;city&quot;
+        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: &quot;recipr&quot; + hyphen string &quot;\x{2010}&quot;
</span><span class="cx">             text run at (0,40) width 72: &quot;ocity&quot;
</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: &quot;reciprocity&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (195057 => 195058)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-14 16:31:58 UTC (rev 195057)
+++ trunk/Source/WebCore/ChangeLog        2016-01-14 17:32:24 UTC (rev 195058)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-01-14  Martin Robinson  &lt;mrobinson@igalia.com&gt;
+
+        [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&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;::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  Per Arne Vollan  &lt;peavo@outlook.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Remove workarounds for fixed bugs in fmod and pow.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtexthyphenHyphenationLibHyphencpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp (195057 => 195058)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp        2016-01-14 16:31:58 UTC (rev 195057)
+++ trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp        2016-01-14 17:32:24 UTC (rev 195058)
</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&lt;AtomicString, String&gt;&amp; availableLocales)
</del><ins>+static void scanDirectoryForDicionaries(const char* directoryPath, HashMap&lt;AtomicString, Vector&lt;String&gt;&gt;&amp; availableLocales)
</ins><span class="cx"> {
</span><del>-    for (const auto&amp; filePath : listDirectory(directoryPath, &quot;hyph_*.dic&quot;))
-        availableLocales.set(AtomicString(extractLocaleFromDictionaryFilePath(filePath)), filePath);
</del><ins>+    for (const auto&amp; filePath : listDirectory(directoryPath, &quot;hyph_*.dic&quot;)) {
+        String locale = extractLocaleFromDictionaryFilePath(filePath).convertToASCIILowercase();
+        availableLocales.add(locale, Vector&lt;String&gt;()).iterator-&gt;value.append(filePath);
+
+        String localeReplacingUnderscores = String(locale);
+        localeReplacingUnderscores.replace('_', '-');
+        if (locale != localeReplacingUnderscores)
+            availableLocales.add(localeReplacingUnderscores, Vector&lt;String&gt;()).iterator-&gt;value.append(filePath);
+
+        size_t dividerPosition = localeReplacingUnderscores.find('-');
+        if (dividerPosition != notFound) {
+            localeReplacingUnderscores.truncate(dividerPosition);
+            availableLocales.add(localeReplacingUnderscores, Vector&lt;String&gt;()).iterator-&gt;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&lt;AtomicString, String&gt;&amp; availableLocales)
</del><ins>+static void scanTestDictionariesDirectoryIfNecessary(HashMap&lt;AtomicString, Vector&lt;String&gt;&gt;&amp; 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&lt;AtomicString, String&gt;&amp; availableLocales()
</del><ins>+static HashMap&lt;AtomicString, Vector&lt;String&gt;&gt;&amp; availableLocales()
</ins><span class="cx"> {
</span><span class="cx">     static bool scannedLocales = false;
</span><del>-    static HashMap&lt;AtomicString, String&gt; availableLocales;
</del><ins>+    static HashMap&lt;AtomicString, Vector&lt;String&gt;&gt; availableLocales;
</ins><span class="cx"> 
</span><span class="cx">     if (!scannedLocales) {
</span><span class="cx">         for (size_t i = 0; i &lt; 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&lt;HyphenationDictionary&gt; {
</span><span class="lines">@@ -158,10 +173,9 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt;
</span><del>-RefPtr&lt;HyphenationDictionary&gt; AtomicStringKeyedMRUCache&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;::createValueForKey(const AtomicString&amp; localeIdentifier)
</del><ins>+RefPtr&lt;HyphenationDictionary&gt; AtomicStringKeyedMRUCache&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;::createValueForKey(const AtomicString&amp; 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&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;&amp; 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&amp; localeIdentifier)
</span><span class="cx"> {
</span><del>-    ASSERT(availableLocales().contains(localeIdentifier));
-    RefPtr&lt;HyphenationDictionary&gt; 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&lt;char&gt; 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-&gt;libhyphenDictionary(),
-        utf8StringCopy.data() + leadingSpaceBytes,
-        utf8StringCopy.length() - leadingSpaceBytes,
-        hyphenArrayData,
-        nullptr, /* output parameter for hyphenated word */
-        &amp;replacements,
-        &amp;positions,
-        &amp;removedCharacterCounts);
</del><ins>+    String lowercaseLocaleIdentifier = AtomicString(localeIdentifier.string().convertToASCIILowercase());
+    ASSERT(availableLocales().contains(lowercaseLocaleIdentifier));
+    for (const auto&amp; dictionaryPath : availableLocales().get(lowercaseLocaleIdentifier)) {
+        RefPtr&lt;HyphenationDictionary&gt; dictionary = hyphenDictionaryCache().get(AtomicString(dictionaryPath));
</ins><span class="cx"> 
</span><del>-    if (replacements) {
-        for (unsigned i = 0; i &lt; 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-&gt;libhyphenDictionary(),
+            utf8StringCopy.data() + leadingSpaceBytes,
+            utf8StringCopy.length() - leadingSpaceBytes,
+            hyphenArrayData,
+            nullptr, /* output parameter for hyphenated word */
+            &amp;replacements,
+            &amp;positions,
+            &amp;removedCharacterCounts);
</ins><span class="cx"> 
</span><del>-    free(positions);
-    free(removedCharacterCounts);
</del><ins>+        if (replacements) {
+            for (unsigned i = 0; i &lt; utf8StringCopy.length() - leadingSpaceBytes - 1; i++)
+                free(replacements[i]);
+            free(replacements);
+        }
</ins><span class="cx"> 
</span><del>-    for (int i = beforeIndex - leadingSpaceCharacters - 1; i &gt;= 0; i--) {
-        // libhyphen will put an odd number in hyphenArrayData at all
-        // hyphenation points. A number &amp; 1 will be true for odd numbers.
-        if (hyphenArrayData[i] &amp; 1)
-            return i + leadingSpaceCharacters;
</del><ins>+        free(positions);
+        free(removedCharacterCounts);
+
+        for (int i = beforeIndex - leadingSpaceCharacters - 1; i &gt;= 0; i--) {
+            // libhyphen will put an odd number in hyphenArrayData at all
+            // hyphenation points. A number &amp; 1 will be true for odd numbers.
+            if (hyphenArrayData[i] &amp; 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>