<!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>[189038] 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/189038">189038</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2015-08-27 11:09:20 -0700 (Thu, 27 Aug 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Cocoa] Generic font families do not consult with the user's preferred language
https://bugs.webkit.org/show_bug.cgi?id=148499
&lt;rdar://problem/22407296&gt;

Reviewed by Antti Koivisto.

Source/WebCore:

When WebKit encounters markup like lang=&quot;zh&quot; style=&quot;font-family: sans-serif;&quot;
we currently always use Simplified Chinese fonts. However, the user may
have specifically selected Traditional Chinese in their user preferences.
In this absence of other signals, we should consult with the user
preferences when determining which font to pick.

Tests: fast/text/international/generic-font-family-language-simplified.html
       fast/text/international/generic-font-family-language-traditional.html

* platform/Language.cpp:
(WebCore::observerMap):
(WebCore::overrideUserPreferredLanguages):
* platform/graphics/FontGenericFamilies.cpp:
(WebCore::computeUserPrefersSimplified):
(WebCore::cachedUserPrefersSimplified):
(WebCore::languageChanged):
(WebCore::genericFontFamilyForScript):
(WebCore::FontGenericFamilies::FontGenericFamilies):
* platform/text/LocaleToScriptMappingDefault.cpp:
(WebCore::scriptNameToCode):

LayoutTests:

Mock the user's font preferences.

* fast/text/international/font-fallback-to-common-script.html:
* fast/text/international/generic-font-family-language-simplified-expected.html: Added.
* fast/text/international/generic-font-family-language-simplified.html: Added.
* fast/text/international/generic-font-family-language-traditional-expected.html: Added.
* fast/text/international/generic-font-family-language-traditional.html: Added.
* fast/text/international/lang-sensitive-fonts-xml.xhtml:
* fast/text/international/lang-sensitive-fonts.html:
* fast/text/international/locale-sensitive-fonts.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfasttextinternationalfontfallbacktocommonscripthtml">trunk/LayoutTests/fast/text/international/font-fallback-to-common-script.html</a></li>
<li><a href="#trunkLayoutTestsfasttextinternationallangsensitivefontsxmlxhtml">trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml</a></li>
<li><a href="#trunkLayoutTestsfasttextinternationallangsensitivefontshtml">trunk/LayoutTests/fast/text/international/lang-sensitive-fonts.html</a></li>
<li><a href="#trunkLayoutTestsfasttextinternationallocalesensitivefontshtml">trunk/LayoutTests/fast/text/international/locale-sensitive-fonts.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformLanguagecpp">trunk/Source/WebCore/platform/Language.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontGenericFamiliescpp">trunk/Source/WebCore/platform/graphics/FontGenericFamilies.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformtextLocaleToScriptMappingDefaultcpp">trunk/Source/WebCore/platform/text/LocaleToScriptMappingDefault.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextinternationalgenericfontfamilylanguagesimplifiedexpectedhtml">trunk/LayoutTests/fast/text/international/generic-font-family-language-simplified-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttextinternationalgenericfontfamilylanguagesimplifiedhtml">trunk/LayoutTests/fast/text/international/generic-font-family-language-simplified.html</a></li>
<li><a href="#trunkLayoutTestsfasttextinternationalgenericfontfamilylanguagetraditionalexpectedhtml">trunk/LayoutTests/fast/text/international/generic-font-family-language-traditional-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttextinternationalgenericfontfamilylanguagetraditionalhtml">trunk/LayoutTests/fast/text/international/generic-font-family-language-traditional.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (189037 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-08-27 18:03:43 UTC (rev 189037)
+++ trunk/LayoutTests/ChangeLog        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2015-08-27  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        [Cocoa] Generic font families do not consult with the user's preferred language
+        https://bugs.webkit.org/show_bug.cgi?id=148499
+        &lt;rdar://problem/22407296&gt;
+
+        Reviewed by Antti Koivisto.
+
+        Mock the user's font preferences.
+
+        * fast/text/international/font-fallback-to-common-script.html:
+        * fast/text/international/generic-font-family-language-simplified-expected.html: Added.
+        * fast/text/international/generic-font-family-language-simplified.html: Added.
+        * fast/text/international/generic-font-family-language-traditional-expected.html: Added.
+        * fast/text/international/generic-font-family-language-traditional.html: Added.
+        * fast/text/international/lang-sensitive-fonts-xml.xhtml:
+        * fast/text/international/lang-sensitive-fonts.html:
+        * fast/text/international/locale-sensitive-fonts.html:
+
</ins><span class="cx"> 2015-08-27  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Standardize on CSSStyleSheet.Type enum and move more protocol enum conversion to the manager
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationalfontfallbacktocommonscripthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/text/international/font-fallback-to-common-script.html (189037 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/font-fallback-to-common-script.html        2015-08-27 18:03:43 UTC (rev 189037)
+++ trunk/LayoutTests/fast/text/international/font-fallback-to-common-script.html        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -8,6 +8,8 @@
</span><span class="cx">     window.internals.settings.setStandardFontFamily(&quot;Ahem&quot;, &quot;Zyyy&quot;);
</span><span class="cx"> 
</span><span class="cx">     window.internals.settings.setSansSerifFontFamily(&quot;Ahem&quot;, &quot;Zyyy&quot;);
</span><ins>+
+    window.internals.setUserPreferredLanguages(&quot;en&quot;, &quot;zh-cn&quot;);
</ins><span class="cx"> }
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationalgenericfontfamilylanguagesimplifiedexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/international/generic-font-family-language-simplified-expected.html (0 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/generic-font-family-language-simplified-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/international/generic-font-family-language-simplified-expected.html        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;/head&gt;
+&lt;body&gt;
+This test makes sure that generic font families consult with the system language preferences for Chinese when we can't tell
+from the lang if we should use Simplified Chinese of Traditional Chinese.
+&lt;div lang=&quot;zh-hans&quot; style=&quot;font-size: 50px;&quot;&gt;
+&lt;div style=&quot;font-family: sans-serif;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: serif;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: -webkit-standard;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: fixed;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationalgenericfontfamilylanguagesimplifiedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/international/generic-font-family-language-simplified.html (0 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/generic-font-family-language-simplified.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/international/generic-font-family-language-simplified.html        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+window.internals.setUserPreferredLanguages([&quot;en&quot;, &quot;zh-cn&quot;]);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+This test makes sure that generic font families consult with the system language preferences for Chinese when we can't tell
+from the lang if we should use Simplified Chinese of Traditional Chinese.
+&lt;div lang=&quot;zh&quot; style=&quot;font-size: 50px;&quot;&gt;
+&lt;div style=&quot;font-family: sans-serif;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: serif;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: -webkit-standard;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: fixed;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationalgenericfontfamilylanguagetraditionalexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/international/generic-font-family-language-traditional-expected.html (0 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/generic-font-family-language-traditional-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/international/generic-font-family-language-traditional-expected.html        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;/head&gt;
+&lt;body&gt;
+This test makes sure that generic font families consult with the system language preferences for Chinese when we can't tell
+from the lang if we should use Simplified Chinese of Traditional Chinese.
+&lt;div lang=&quot;zh-hant&quot; style=&quot;font-size: 50px;&quot;&gt;
+&lt;div style=&quot;font-family: sans-serif;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: serif;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: -webkit-standard;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: fixed;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationalgenericfontfamilylanguagetraditionalhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/international/generic-font-family-language-traditional.html (0 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/generic-font-family-language-traditional.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/international/generic-font-family-language-traditional.html        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+window.internals.setUserPreferredLanguages([&quot;en&quot;, &quot;zh-tw&quot;]);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+This test makes sure that generic font families consult with the system language preferences for Chinese when we can't tell
+from the lang if we should use Simplified Chinese of Traditional Chinese.
+&lt;div lang=&quot;zh&quot; style=&quot;font-size: 50px;&quot;&gt;
+&lt;div style=&quot;font-family: sans-serif;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: serif;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: -webkit-standard;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;div style=&quot;font-family: fixed;&quot;&gt;&amp;#x900f;&amp;#x904e;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationallangsensitivefontsxmlxhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml (189037 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml        2015-08-27 18:03:43 UTC (rev 189037)
+++ trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -6,6 +6,8 @@
</span><span class="cx"> if (window.internals) {
</span><span class="cx">     window.internals.settings.setStandardFontFamily(&quot;Ahem&quot;, &quot;Hans&quot;);
</span><span class="cx">     window.internals.settings.setFantasyFontFamily(&quot;Ahem&quot;, &quot;Hans&quot;);
</span><ins>+
+    window.internals.setUserPreferredLanguages(&quot;en&quot;, &quot;zh-cn&quot;);
</ins><span class="cx"> }
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationallangsensitivefontshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/text/international/lang-sensitive-fonts.html (189037 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/lang-sensitive-fonts.html        2015-08-27 18:03:43 UTC (rev 189037)
+++ trunk/LayoutTests/fast/text/international/lang-sensitive-fonts.html        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -5,6 +5,8 @@
</span><span class="cx"> if (window.internals) {
</span><span class="cx">     window.internals.settings.setStandardFontFamily(&quot;Ahem&quot;, &quot;Hans&quot;);
</span><span class="cx">     window.internals.settings.setFantasyFontFamily(&quot;Ahem&quot;, &quot;Hans&quot;);
</span><ins>+
+    window.internals.setUserPreferredLanguages(&quot;en&quot;, &quot;zh-cn&quot;);
</ins><span class="cx"> }
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextinternationallocalesensitivefontshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/text/international/locale-sensitive-fonts.html (189037 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/international/locale-sensitive-fonts.html        2015-08-27 18:03:43 UTC (rev 189037)
+++ trunk/LayoutTests/fast/text/international/locale-sensitive-fonts.html        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -5,6 +5,8 @@
</span><span class="cx"> if (window.internals) {
</span><span class="cx">     window.internals.settings.setStandardFontFamily(&quot;Ahem&quot;, &quot;Hans&quot;);
</span><span class="cx">     window.internals.settings.setFantasyFontFamily(&quot;Ahem&quot;, &quot;Hans&quot;);
</span><ins>+
+    window.internals.setUserPreferredLanguages(&quot;en&quot;, &quot;zh-cn&quot;);
</ins><span class="cx"> }
</span><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (189037 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-08-27 18:03:43 UTC (rev 189037)
+++ trunk/Source/WebCore/ChangeLog        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -1,5 +1,34 @@
</span><span class="cx"> 2015-08-27  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        [Cocoa] Generic font families do not consult with the user's preferred language
+        https://bugs.webkit.org/show_bug.cgi?id=148499
+        &lt;rdar://problem/22407296&gt;
+
+        Reviewed by Antti Koivisto.
+
+        When WebKit encounters markup like lang=&quot;zh&quot; style=&quot;font-family: sans-serif;&quot;
+        we currently always use Simplified Chinese fonts. However, the user may
+        have specifically selected Traditional Chinese in their user preferences.
+        In this absence of other signals, we should consult with the user
+        preferences when determining which font to pick.
+
+        Tests: fast/text/international/generic-font-family-language-simplified.html
+               fast/text/international/generic-font-family-language-traditional.html
+
+        * platform/Language.cpp:
+        (WebCore::observerMap):
+        (WebCore::overrideUserPreferredLanguages):
+        * platform/graphics/FontGenericFamilies.cpp:
+        (WebCore::computeUserPrefersSimplified):
+        (WebCore::cachedUserPrefersSimplified):
+        (WebCore::languageChanged):
+        (WebCore::genericFontFamilyForScript):
+        (WebCore::FontGenericFamilies::FontGenericFamilies):
+        * platform/text/LocaleToScriptMappingDefault.cpp:
+        (WebCore::scriptNameToCode):
+
+2015-08-27  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
</ins><span class="cx">         Update Grid Layout to use fewer magic -1s
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=148505
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLanguagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Language.cpp (189037 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Language.cpp        2015-08-27 18:03:43 UTC (rev 189037)
+++ trunk/Source/WebCore/platform/Language.cpp        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;Language.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -39,8 +40,8 @@
</span><span class="cx"> typedef HashMap&lt;void*, LanguageChangeObserverFunction&gt; ObserverMap;
</span><span class="cx"> static ObserverMap&amp; observerMap()
</span><span class="cx"> {
</span><del>-    DEPRECATED_DEFINE_STATIC_LOCAL(ObserverMap, map, ());
-    return map;
</del><ins>+    static NeverDestroyed&lt;ObserverMap&gt; map;
+    return map.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void addLanguageChangeObserver(void* context, LanguageChangeObserverFunction customObserver)
</span><span class="lines">@@ -84,6 +85,7 @@
</span><span class="cx"> void overrideUserPreferredLanguages(const Vector&lt;String&gt;&amp; override)
</span><span class="cx"> {
</span><span class="cx">     preferredLanguagesOverride() = override;
</span><ins>+    languageDidChange();
</ins><span class="cx"> }
</span><span class="cx">     
</span><span class="cx"> Vector&lt;String&gt; userPreferredLanguages()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontGenericFamiliescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontGenericFamilies.cpp (189037 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontGenericFamilies.cpp        2015-08-27 18:03:43 UTC (rev 189037)
+++ trunk/Source/WebCore/platform/graphics/FontGenericFamilies.cpp        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;FontGenericFamilies.h&quot;
</span><ins>+#include &quot;Language.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -46,11 +47,41 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline bool computeUserPrefersSimplified()
+{
+    const Vector&lt;String&gt;&amp; preferredLanguages = userPreferredLanguages();
+    for (auto&amp; language : preferredLanguages) {
+        if (equalIgnoringASCIICase(language, &quot;zh-tw&quot;))
+            return false;
+        if (equalIgnoringASCIICase(language, &quot;zh-cn&quot;))
+            return true;
+    }
+    return true;
+}
+
+static bool&amp; cachedUserPrefersSimplified()
+{
+    static bool cached = true;
+    return cached;
+}
+
+static void languageChanged(void*)
+{
+    cachedUserPrefersSimplified() = computeUserPrefersSimplified();
+}
+
</ins><span class="cx"> static const AtomicString&amp; genericFontFamilyForScript(const ScriptFontFamilyMap&amp; fontMap, UScriptCode script)
</span><span class="cx"> {
</span><span class="cx">     ScriptFontFamilyMap::const_iterator it = fontMap.find(static_cast&lt;int&gt;(script));
</span><span class="cx">     if (it != fontMap.end())
</span><span class="cx">         return it-&gt;value;
</span><ins>+    // Content using USCRIPT_HAN doesn't tell us if we should be using Simplified Chinese or Traditional Chinese. In the
+    // absence of all other signals, we consult with the user's system preferences.
+    if (script == USCRIPT_HAN) {
+        it = fontMap.find(static_cast&lt;int&gt;(cachedUserPrefersSimplified() ? USCRIPT_SIMPLIFIED_HAN : USCRIPT_TRADITIONAL_HAN));
+        if (it != fontMap.end())
+            return it-&gt;value;
+    }
</ins><span class="cx">     if (script != USCRIPT_COMMON)
</span><span class="cx">         return genericFontFamilyForScript(fontMap, USCRIPT_COMMON);
</span><span class="cx">     return emptyAtom;
</span><span class="lines">@@ -58,6 +89,8 @@
</span><span class="cx"> 
</span><span class="cx"> FontGenericFamilies::FontGenericFamilies()
</span><span class="cx"> {
</span><ins>+    addLanguageChangeObserver(this, &amp;languageChanged);
+    languageChanged(nullptr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const AtomicString&amp; FontGenericFamilies::standardFontFamily(UScriptCode script) const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextLocaleToScriptMappingDefaultcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/LocaleToScriptMappingDefault.cpp (189037 => 189038)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/LocaleToScriptMappingDefault.cpp        2015-08-27 18:03:43 UTC (rev 189037)
+++ trunk/Source/WebCore/platform/text/LocaleToScriptMappingDefault.cpp        2015-08-27 18:09:20 UTC (rev 189038)
</span><span class="lines">@@ -164,14 +164,14 @@
</span><span class="cx"> 
</span><span class="cx"> UScriptCode scriptNameToCode(const String&amp; scriptName)
</span><span class="cx"> {
</span><del>-    DEPRECATED_DEFINE_STATIC_LOCAL(ScriptNameCodeMap, scriptNameCodeMap, ());
-    if (scriptNameCodeMap.isEmpty()) {
</del><ins>+    static NeverDestroyed&lt;ScriptNameCodeMap&gt; scriptNameCodeMap;
+    if (scriptNameCodeMap.get().isEmpty()) {
</ins><span class="cx">         for (size_t i = 0; i &lt; sizeof(scriptNameCodeList) / sizeof(ScriptNameCode); ++i)
</span><del>-            scriptNameCodeMap.set(ASCIILiteral(scriptNameCodeList[i].name), scriptNameCodeList[i].code);
</del><ins>+            scriptNameCodeMap.get().set(ASCIILiteral(scriptNameCodeList[i].name), scriptNameCodeList[i].code);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ScriptNameCodeMap::iterator it = scriptNameCodeMap.find(scriptName.lower());
-    if (it != scriptNameCodeMap.end())
</del><ins>+    ScriptNameCodeMap::iterator it = scriptNameCodeMap.get().find(scriptName.lower());
+    if (it != scriptNameCodeMap.get().end())
</ins><span class="cx">         return it-&gt;value;
</span><span class="cx">     return USCRIPT_INVALID_CODE;
</span><span class="cx"> }
</span><span class="lines">@@ -376,7 +376,7 @@
</span><span class="cx">     { &quot;yap&quot;, USCRIPT_LATIN },
</span><span class="cx">     { &quot;yo&quot;, USCRIPT_LATIN },
</span><span class="cx">     { &quot;za&quot;, USCRIPT_LATIN },
</span><del>-    { &quot;zh&quot;, USCRIPT_SIMPLIFIED_HAN }, // FIXME: This mapping in incorrect. Instead, we should consult with an external source (such as the user's language preferences).
</del><ins>+    { &quot;zh&quot;, USCRIPT_HAN },
</ins><span class="cx">     { &quot;zh_hk&quot;, USCRIPT_TRADITIONAL_HAN },
</span><span class="cx">     { &quot;zh_tw&quot;, USCRIPT_TRADITIONAL_HAN },
</span><span class="cx">     { &quot;zu&quot;, USCRIPT_LATIN }
</span></span></pre>
</div>
</div>

</body>
</html>