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

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

Issue 2161683002: Add LayoutLocale class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test stability Created 4 years, 5 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
index 64405f6c756e9c56b5be098620747dddf0654391..5cd81c3a978d6295c072833e2d15f313937737f8 100644
--- a/third_party/WebKit/Source/platform/text/Hyphenation.cpp
+++ b/third_party/WebKit/Source/platform/text/Hyphenation.cpp
@@ -4,38 +4,11 @@
#include "platform/text/Hyphenation.h"
+#include "platform/fonts/Font.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)
-{
- DCHECK(!locale.isNull());
- Hyphenation::HyphenationMap& hyphenationMap = getHyphenationMap();
- const auto& it = hyphenationMap.find(locale);
- if (it != hyphenationMap.end())
- return it->value.get();
-
- return hyphenationMap.add(locale, platformGetHyphenation(locale))
- .storedValue->value.get();
-}
-
-void Hyphenation::setForTesting(const AtomicString& locale, PassRefPtr<Hyphenation> hyphenation)
-{
- getHyphenationMap().set(locale, hyphenation);
-}
-
-void Hyphenation::clearForTesting()
-{
- getHyphenationMap().clear();
-}
-
Vector<size_t, 8> Hyphenation::hyphenLocations(const StringView& text) const
{
Vector<size_t, 8> hyphenLocations;
@@ -50,4 +23,15 @@ Vector<size_t, 8> Hyphenation::hyphenLocations(const StringView& text) const
return hyphenLocations;
}
+int Hyphenation::minimumPrefixWidth(const Font& font)
+{
+ // If the maximum width available for the prefix before the hyphen is small, then it is very unlikely
+ // that an hyphenation opportunity exists, so do not bother to look for it.
+ // These are heuristic numbers for performance added in http://wkb.ug/45606
+ const int minimumPrefixWidthNumerator = 5;
+ const int minimumPrefixWidthDenominator = 4;
+ return font.getFontDescription().computedPixelSize()
+ * minimumPrefixWidthNumerator / minimumPrefixWidthDenominator;
+}
+
} // 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