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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/text/Hyphenation.h" 5 #include "platform/text/Hyphenation.h"
6 6
7 #include "wtf/RetainPtr.h"
8 #include "wtf/text/StringView.h"
9
7 namespace blink { 10 namespace blink {
8 11
9 PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation(const AtomicString&) 12 class HyphenationCF : public Hyphenation {
13 public:
14 HyphenationCF(RetainPtr<CFLocaleRef>& localeCF)
15 : m_localeCF(localeCF)
16 {
17 DCHECK(m_localeCF);
18 }
19
20 size_t lastHyphenLocation(const StringView& text, size_t beforeIndex) const override
21 {
22 CFIndex result = CFStringGetHyphenationLocationBeforeIndex(
23 text.toString()->createCFString().get(), beforeIndex,
24 CFRangeMake(0, text.length()), 0, m_localeCF.get(), 0);
25 return result == kCFNotFound ? 0 : result;
26 }
27
28 private:
29 RetainPtr<CFLocaleRef> m_localeCF;
30 };
31
32 PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation(const AtomicString& locale)
10 { 33 {
11 return nullptr; 34 RetainPtr<CFStringRef> localeCFString = locale.impl()->createCFString();
35 RetainPtr<CFLocaleRef> localeCF = adoptCF(CFLocaleCreate(kCFAllocatorDefault , localeCFString.get()));
36 if (!CFStringIsHyphenationAvailableForLocale(localeCF.get()))
37 return nullptr;
38 return adoptRef(new HyphenationCF(localeCF));
12 } 39 }
13 40
14 } // namespace blink 41 } // namespace blink
OLDNEW
« 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