Chromium Code Reviews| 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/text/Hyphenation.h" | 5 #include "platform/text/Hyphenation.h" |
| 6 | 6 |
| 7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
| 8 #include "base/files/memory_mapped_file.h" | 8 #include "base/files/memory_mapped_file.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 } | 128 } |
| 129 | 129 |
| 130 using LocaleMap = HashMap<AtomicString, AtomicString, CaseFoldingHash>; | 130 using LocaleMap = HashMap<AtomicString, AtomicString, CaseFoldingHash>; |
| 131 | 131 |
| 132 static LocaleMap createLocaleFallbackMap() | 132 static LocaleMap createLocaleFallbackMap() |
| 133 { | 133 { |
| 134 // This data is from CLDR, compiled by AOSP. | 134 // This data is from CLDR, compiled by AOSP. |
| 135 // https://android.googlesource.com/platform/frameworks/base/+/master/core/j ava/android/text/Hyphenator.java | 135 // https://android.googlesource.com/platform/frameworks/base/+/master/core/j ava/android/text/Hyphenator.java |
| 136 using LocaleFallback = const char*[2]; | 136 using LocaleFallback = const char*[2]; |
| 137 static LocaleFallback localeFallbackData[] = { | 137 static LocaleFallback localeFallbackData[] = { |
| 138 { "en-AS", "en-US" }, // English (American Samoa) | 138 { "en-AS", "en-us" }, // English (American Samoa) |
| 139 { "en-GU", "en-US" }, // English (Guam) | 139 { "en-GU", "en-us" }, // English (Guam) |
| 140 { "en-MH", "en-US" }, // English (Marshall Islands) | 140 { "en-MH", "en-us" }, // English (Marshall Islands) |
| 141 { "en-MP", "en-US" }, // English (Northern Mariana Islands) | 141 { "en-MP", "en-us" }, // English (Northern Mariana Islands) |
| 142 { "en-PR", "en-US" }, // English (Puerto Rico) | 142 { "en-PR", "en-us" }, // English (Puerto Rico) |
| 143 { "en-UM", "en-US" }, // English (United States Minor Outlying Islands) | 143 { "en-UM", "en-us" }, // English (United States Minor Outlying Islands) |
| 144 { "en-VI", "en-US" }, // English (Virgin Islands) | 144 { "en-VI", "en-us" }, // English (Virgin Islands) |
| 145 { "en", "en-gb" }, | |
|
eae
2016/07/19 15:13:53
Could you add descriptions to three new lines too
| |
| 146 { "de", "de-1996" }, | |
| 147 { "de-LI-1901", "de-ch-1901" }, | |
| 145 { "no", "nb" }, | 148 { "no", "nb" }, |
| 146 { "am", "und-Ethi" }, // Amharic | 149 { "mn", "mn-cyrl" }, // Mongolian |
| 147 { "byn", "und-Ethi" }, // Blin | 150 { "am", "und-ethi" }, // Amharic |
| 148 { "gez", "und-Ethi" }, // Geʻez | 151 { "byn", "und-ethi" }, // Blin |
| 149 { "ti", "und-Ethi" }, // Tigrinya | 152 { "gez", "und-ethi" }, // Geʻez |
| 150 { "wal", "und-Ethi" }, // Wolaytta | 153 { "ti", "und-ethi" }, // Tigrinya |
| 154 { "wal", "und-ethi" }, // Wolaytta | |
| 151 }; | 155 }; |
| 152 LocaleMap map; | 156 LocaleMap map; |
| 153 for (const auto& it : localeFallbackData) | 157 for (const auto& it : localeFallbackData) |
| 154 map.add(it[0], it[1]); | 158 map.add(it[0], it[1]); |
| 155 return map; | 159 return map; |
| 156 } | 160 } |
| 157 | 161 |
| 158 PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation(const AtomicString& locale) | 162 PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation(const AtomicString& locale) |
| 159 { | 163 { |
| 160 RefPtr<HyphenationMinikin> hyphenation(adoptRef(new HyphenationMinikin)); | 164 RefPtr<HyphenationMinikin> hyphenation(adoptRef(new HyphenationMinikin)); |
| 161 if (hyphenation->openDictionary(locale.lowerASCII())) | 165 if (hyphenation->openDictionary(locale.lowerASCII())) |
| 162 return hyphenation.release(); | 166 return hyphenation.release(); |
| 163 hyphenation.clear(); | 167 hyphenation.clear(); |
| 164 | 168 |
| 165 DEFINE_STATIC_LOCAL(LocaleMap, localeFallback, (createLocaleFallbackMap())); | 169 DEFINE_STATIC_LOCAL(LocaleMap, localeFallback, (createLocaleFallbackMap())); |
| 166 const auto& it = localeFallback.find(locale); | 170 const auto& it = localeFallback.find(locale); |
| 167 if (it != localeFallback.end()) | 171 if (it != localeFallback.end()) |
| 168 return get(it->value); | 172 return get(it->value); |
| 169 | 173 |
| 170 return nullptr; | 174 return nullptr; |
| 171 } | 175 } |
| 172 | 176 |
| 173 } // namespace blink | 177 } // namespace blink |
| OLD | NEW |