| Index: third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp
|
| diff --git a/third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp b/third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp
|
| index ca2b39fe6cce5b64bfbea81e4f691d92e2a85acc..0792e3db8c1602217487d4befa2427360ae252e1 100644
|
| --- a/third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp
|
| +++ b/third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp
|
| @@ -4,11 +4,38 @@
|
|
|
| #include "platform/text/Hyphenation.h"
|
|
|
| +#include "wtf/RetainPtr.h"
|
| +#include "wtf/text/StringView.h"
|
| +
|
| namespace blink {
|
|
|
| -PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation(const AtomicString&)
|
| +class HyphenationCF : public Hyphenation {
|
| +public:
|
| + HyphenationCF(RetainPtr<CFLocaleRef>& localeCF)
|
| + : m_localeCF(localeCF)
|
| + {
|
| + DCHECK(m_localeCF);
|
| + }
|
| +
|
| + size_t lastHyphenLocation(const StringView& text, size_t beforeIndex) const override
|
| + {
|
| + CFIndex result = CFStringGetHyphenationLocationBeforeIndex(
|
| + text.toString()->createCFString().get(), beforeIndex,
|
| + CFRangeMake(0, text.length()), 0, m_localeCF.get(), 0);
|
| + return result == kCFNotFound ? 0 : result;
|
| + }
|
| +
|
| +private:
|
| + RetainPtr<CFLocaleRef> m_localeCF;
|
| +};
|
| +
|
| +PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation(const AtomicString& locale)
|
| {
|
| - return nullptr;
|
| + RetainPtr<CFStringRef> localeCFString = locale.impl()->createCFString();
|
| + RetainPtr<CFLocaleRef> localeCF = adoptCF(CFLocaleCreate(kCFAllocatorDefault, localeCFString.get()));
|
| + if (!CFStringIsHyphenationAvailableForLocale(localeCF.get()))
|
| + return nullptr;
|
| + return adoptRef(new HyphenationCF(localeCF));
|
| }
|
|
|
| } // namespace blink
|
|
|