Index: third_party/WebKit/Source/platform/text/Hyphenation.cpp |
diff --git a/third_party/WebKit/Source/platform/text/Hyphenation.cpp b/third_party/WebKit/Source/platform/text/Hyphenation.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..357ffb78a9cb5c0184b227771e1e73bd9e7088f2 |
--- /dev/null |
+++ b/third_party/WebKit/Source/platform/text/Hyphenation.cpp |
@@ -0,0 +1,36 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "platform/text/Hyphenation.h" |
+ |
+#include "wtf/text/StringView.h" |
+ |
+namespace blink { |
+ |
+Hyphenation::HyphenationMap& Hyphenation::getHyphenationMap() |
+{ |
+ DEFINE_STATIC_LOCAL(HyphenationMap, hyphenationMap, ()); |
+ return hyphenationMap; |
+} |
+ |
+Hyphenation* Hyphenation::get(const AtomicString& locale) |
+{ |
+ Hyphenation::HyphenationMap& hyphenationMap = getHyphenationMap(); |
+ auto result = hyphenationMap.add(locale, nullptr); |
+ if (result.isNewEntry) |
+ result.storedValue->value = platformGetHyphenation(locale); |
+ return result.storedValue->value.get(); |
+} |
+ |
+void Hyphenation::setForTesting(const AtomicString& locale, PassRefPtr<Hyphenation> hyphenation) |
+{ |
+ getHyphenationMap().set(locale, hyphenation); |
+} |
+ |
+void Hyphenation::clearForTesting() |
+{ |
+ getHyphenationMap().clear(); |
+} |
+ |
+} // namespace blink |