Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: third_party/WebKit/Source/platform/text/Hyphenation.cpp

Issue 1917423002: Add Hyphenation class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « third_party/WebKit/Source/platform/text/Hyphenation.h ('k') | third_party/WebKit/Source/platform/text/HyphenationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698