| 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
|
|
|