OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "platform/text/Hyphenation.h" |
| 6 |
| 7 #include "wtf/text/StringView.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 Hyphenation::HyphenationMap& Hyphenation::getHyphenationMap() |
| 12 { |
| 13 DEFINE_STATIC_LOCAL(HyphenationMap, hyphenationMap, ()); |
| 14 return hyphenationMap; |
| 15 } |
| 16 |
| 17 Hyphenation* Hyphenation::get(const AtomicString& locale) |
| 18 { |
| 19 Hyphenation::HyphenationMap& hyphenationMap = getHyphenationMap(); |
| 20 auto result = hyphenationMap.add(locale, nullptr); |
| 21 if (result.isNewEntry) |
| 22 result.storedValue->value = platformGetHyphenation(locale); |
| 23 return result.storedValue->value.get(); |
| 24 } |
| 25 |
| 26 void Hyphenation::setForTesting(const AtomicString& locale, PassRefPtr<Hyphenati
on> hyphenation) |
| 27 { |
| 28 getHyphenationMap().set(locale, hyphenation); |
| 29 } |
| 30 |
| 31 void Hyphenation::clearForTesting() |
| 32 { |
| 33 getHyphenationMap().clear(); |
| 34 } |
| 35 |
| 36 } // namespace blink |
OLD | NEW |