| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |