| 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_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 {"no", "nb"}, | 144 {"no", "nb"}, |
| 145 {"mn", "mn-cyrl"}, // Mongolian | 145 {"mn", "mn-cyrl"}, // Mongolian |
| 146 {"am", "und-ethi"}, // Amharic | 146 {"am", "und-ethi"}, // Amharic |
| 147 {"byn", "und-ethi"}, // Blin | 147 {"byn", "und-ethi"}, // Blin |
| 148 {"gez", "und-ethi"}, // Geʻez | 148 {"gez", "und-ethi"}, // Geʻez |
| 149 {"ti", "und-ethi"}, // Tigrinya | 149 {"ti", "und-ethi"}, // Tigrinya |
| 150 {"wal", "und-ethi"}, // Wolaytta | 150 {"wal", "und-ethi"}, // Wolaytta |
| 151 }; | 151 }; |
| 152 LocaleMap map; | 152 LocaleMap map; |
| 153 for (const auto& it : localeFallbackData) | 153 for (const auto& it : localeFallbackData) |
| 154 map.add(it[0], it[1]); | 154 map.insert(it[0], it[1]); |
| 155 return map; | 155 return map; |
| 156 } | 156 } |
| 157 | 157 |
| 158 PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation( | 158 PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation( |
| 159 const AtomicString& locale) { | 159 const AtomicString& locale) { |
| 160 RefPtr<HyphenationMinikin> hyphenation(adoptRef(new HyphenationMinikin)); | 160 RefPtr<HyphenationMinikin> hyphenation(adoptRef(new HyphenationMinikin)); |
| 161 if (hyphenation->openDictionary(locale.lowerASCII())) | 161 if (hyphenation->openDictionary(locale.lowerASCII())) |
| 162 return hyphenation.release(); | 162 return hyphenation.release(); |
| 163 hyphenation.clear(); | 163 hyphenation.clear(); |
| 164 | 164 |
| 165 DEFINE_STATIC_LOCAL(LocaleMap, localeFallback, (createLocaleFallbackMap())); | 165 DEFINE_STATIC_LOCAL(LocaleMap, localeFallback, (createLocaleFallbackMap())); |
| 166 const auto& it = localeFallback.find(locale); | 166 const auto& it = localeFallback.find(locale); |
| 167 if (it != localeFallback.end()) | 167 if (it != localeFallback.end()) |
| 168 return LayoutLocale::get(it->value)->getHyphenation(); | 168 return LayoutLocale::get(it->value)->getHyphenation(); |
| 169 | 169 |
| 170 return nullptr; | 170 return nullptr; |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace blink | 173 } // namespace blink |
| OLD | NEW |