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

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

Issue 2025503002: Revert of Expand WTF::StringView's API to be more like StringPiece. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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" 7 #include "wtf/RetainPtr.h"
8 #include "wtf/text/StringView.h" 8 #include "wtf/text/StringView.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 class HyphenationCF : public Hyphenation { 12 class HyphenationCF : public Hyphenation {
13 public: 13 public:
14 HyphenationCF(RetainPtr<CFLocaleRef>& localeCF) 14 HyphenationCF(RetainPtr<CFLocaleRef>& localeCF)
15 : m_localeCF(localeCF) 15 : m_localeCF(localeCF)
16 { 16 {
17 DCHECK(m_localeCF); 17 DCHECK(m_localeCF);
18 } 18 }
19 19
20 size_t lastHyphenLocation(const StringView& text, size_t beforeIndex) const override 20 size_t lastHyphenLocation(const StringView& text, size_t beforeIndex) const override
21 { 21 {
22 CFIndex result = CFStringGetHyphenationLocationBeforeIndex( 22 CFIndex result = CFStringGetHyphenationLocationBeforeIndex(
23 text.toString().impl()->createCFString().get(), beforeIndex, 23 text.toString()->createCFString().get(), beforeIndex,
24 CFRangeMake(0, text.length()), 0, m_localeCF.get(), 0); 24 CFRangeMake(0, text.length()), 0, m_localeCF.get(), 0);
25 return result == kCFNotFound ? 0 : result; 25 return result == kCFNotFound ? 0 : result;
26 } 26 }
27 27
28 private: 28 private:
29 RetainPtr<CFLocaleRef> m_localeCF; 29 RetainPtr<CFLocaleRef> m_localeCF;
30 }; 30 };
31 31
32 PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation(const AtomicString& locale) 32 PassRefPtr<Hyphenation> Hyphenation::platformGetHyphenation(const AtomicString& locale)
33 { 33 {
34 RetainPtr<CFStringRef> localeCFString = locale.impl()->createCFString(); 34 RetainPtr<CFStringRef> localeCFString = locale.impl()->createCFString();
35 RetainPtr<CFLocaleRef> localeCF = adoptCF(CFLocaleCreate(kCFAllocatorDefault , localeCFString.get())); 35 RetainPtr<CFLocaleRef> localeCF = adoptCF(CFLocaleCreate(kCFAllocatorDefault , localeCFString.get()));
36 if (!CFStringIsHyphenationAvailableForLocale(localeCF.get())) 36 if (!CFStringIsHyphenationAvailableForLocale(localeCF.get()))
37 return nullptr; 37 return nullptr;
38 return adoptRef(new HyphenationCF(localeCF)); 38 return adoptRef(new HyphenationCF(localeCF));
39 } 39 }
40 40
41 } // namespace blink 41 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/TextRun.h ('k') | third_party/WebKit/Source/wtf/Forward.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698