Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: third_party/WebKit/Source/platform/LayoutLocale.cpp

Issue 2222283002: Fix scriptCodeForHanFromSubtags() may return non-Han scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/LayoutLocaleTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/LayoutLocale.h" 5 #include "platform/LayoutLocale.h"
6 6
7 #include "platform/Language.h" 7 #include "platform/Language.h"
8 #include "platform/text/LocaleToScriptMapping.h" 8 #include "platform/text/LocaleToScriptMapping.h"
9 #include "wtf/HashMap.h" 9 #include "wtf/HashMap.h"
10 #include "wtf/text/AtomicStringHash.h" 10 #include "wtf/text/AtomicStringHash.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 const char* LayoutLocale::localeForSkFontMgr() const 47 const char* LayoutLocale::localeForSkFontMgr() const
48 { 48 {
49 if (m_stringForSkFontMgr.isNull()) { 49 if (m_stringForSkFontMgr.isNull()) {
50 m_stringForSkFontMgr = toSkFontMgrLocale(m_script); 50 m_stringForSkFontMgr = toSkFontMgrLocale(m_script);
51 if (m_stringForSkFontMgr.isNull()) 51 if (m_stringForSkFontMgr.isNull())
52 m_stringForSkFontMgr = m_string.ascii(); 52 m_stringForSkFontMgr = m_string.ascii();
53 } 53 }
54 return m_stringForSkFontMgr.data(); 54 return m_stringForSkFontMgr.data();
55 } 55 }
56 56
57 static bool isUnambiguousHanScript(UScriptCode script)
58 {
59 // localeToScriptCodeForFontSelection() does not return these values.
60 DCHECK(script != USCRIPT_HIRAGANA && script != USCRIPT_KATAKANA);
61 return script == USCRIPT_KATAKANA_OR_HIRAGANA
62 || script == USCRIPT_SIMPLIFIED_HAN
63 || script == USCRIPT_TRADITIONAL_HAN
64 || script == USCRIPT_HANGUL;
65 }
66
67 void LayoutLocale::computeScriptForHan() const 57 void LayoutLocale::computeScriptForHan() const
68 { 58 {
69 if (isUnambiguousHanScript(m_script)) { 59 if (isUnambiguousHanScript(m_script)) {
70 m_scriptForHan = m_script; 60 m_scriptForHan = m_script;
71 m_hasScriptForHan = true; 61 m_hasScriptForHan = true;
72 return; 62 return;
73 } 63 }
74 64
75 m_scriptForHan = scriptCodeForHanFromSubtags(m_string); 65 m_scriptForHan = scriptCodeForHanFromSubtags(m_string);
76 if (m_scriptForHan == USCRIPT_COMMON) 66 if (m_scriptForHan == USCRIPT_COMMON)
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 189 }
200 190
201 void LayoutLocale::setHyphenationForTesting(const AtomicString& localeString, Pa ssRefPtr<Hyphenation> hyphenation) 191 void LayoutLocale::setHyphenationForTesting(const AtomicString& localeString, Pa ssRefPtr<Hyphenation> hyphenation)
202 { 192 {
203 const LayoutLocale& locale = valueOrDefault(get(localeString)); 193 const LayoutLocale& locale = valueOrDefault(get(localeString));
204 locale.m_hyphenationComputed = true; 194 locale.m_hyphenationComputed = true;
205 locale.m_hyphenation = hyphenation; 195 locale.m_hyphenation = hyphenation;
206 } 196 }
207 197
208 } // namespace blink 198 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/LayoutLocaleTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698