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

Unified Diff: third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp

Issue 1994443002: Support Mac system hyphenation dictionary (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fix to hyphens-auto-expected.html Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/hyphens/hyphens-auto-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/hyphens/hyphens-auto-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698