diff options
author | Ben Murdoch <benm@google.com> | 2010-08-11 14:44:44 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-08-12 19:15:41 +0100 |
commit | dd8bb3de4f353a81954234999f1fea748aee2ea9 (patch) | |
tree | 729b52bf09294f0d6c67cd5ea80aee1b727b7bd8 /WebCore/platform/text/cf | |
parent | f3d41ba51d86bf719c7a65ab5297aea3c17e2d98 (diff) | |
download | external_webkit-dd8bb3de4f353a81954234999f1fea748aee2ea9.zip external_webkit-dd8bb3de4f353a81954234999f1fea748aee2ea9.tar.gz external_webkit-dd8bb3de4f353a81954234999f1fea748aee2ea9.tar.bz2 |
Merge WebKit at r65072 : Initial merge by git.
Change-Id: Ibcf418498376b2660aacb7f8d46ea7085ef91585
Diffstat (limited to 'WebCore/platform/text/cf')
-rw-r--r-- | WebCore/platform/text/cf/HyphenationCF.cpp | 31 | ||||
-rw-r--r-- | WebCore/platform/text/cf/StringCF.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/text/cf/StringImplCF.cpp | 4 |
3 files changed, 28 insertions, 9 deletions
diff --git a/WebCore/platform/text/cf/HyphenationCF.cpp b/WebCore/platform/text/cf/HyphenationCF.cpp index 50ba4c8..b983979 100644 --- a/WebCore/platform/text/cf/HyphenationCF.cpp +++ b/WebCore/platform/text/cf/HyphenationCF.cpp @@ -28,24 +28,43 @@ #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#include "AtomicString.h" +#include "AtomicStringKeyedMRUCache.h" #include "TextBreakIteratorInternalICU.h" +#include <wtf/ListHashSet.h> #include <wtf/RetainPtr.h> namespace WebCore { -static CFLocaleRef createCurrentSearchLocale() +template<> +RetainPtr<CFLocaleRef> AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForNullKey() { - RetainPtr<CFStringRef> localeIdentifier(AdoptCF, CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, (const UInt8*)currentSearchLocaleID(), strlen(currentSearchLocaleID()), kCFStringEncodingASCII, false, kCFAllocatorNull)); - return CFLocaleCreate(kCFAllocatorDefault, localeIdentifier.get()); + RetainPtr<CFStringRef> cfLocaleIdentifier(AdoptCF, CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(currentSearchLocaleID()), strlen(currentSearchLocaleID()), kCFStringEncodingASCII, false, kCFAllocatorNull)); + RetainPtr<CFLocaleRef> locale(AdoptCF, CFLocaleCreate(kCFAllocatorDefault, cfLocaleIdentifier.get())); + return locale; } -size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex) +template<> +RetainPtr<CFLocaleRef> AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForKey(const AtomicString& localeIdentifier) +{ + RetainPtr<CFStringRef> cfLocaleIdentifier(AdoptCF, localeIdentifier.createCFString()); + RetainPtr<CFLocaleRef> locale(AdoptCF, CFLocaleCreate(kCFAllocatorDefault, cfLocaleIdentifier.get())); + return locale; +} + +bool canHyphenate(const AtomicString& /* localeIdentifer */) +{ + return true; +} + +size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier) { RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, characters, length, kCFAllocatorNull)); - static CFLocaleRef locale = createCurrentSearchLocale(); + DEFINE_STATIC_LOCAL(AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >, cfLocaleCache, ()); + RetainPtr<CFLocaleRef> locale = cfLocaleCache.get(localeIdentifier); - CFIndex result = CFStringGetHyphenationLocationBeforeIndex(string.get(), beforeIndex, CFRangeMake(0, length), 0, locale, 0); + CFIndex result = CFStringGetHyphenationLocationBeforeIndex(string.get(), beforeIndex, CFRangeMake(0, length), 0, locale.get(), 0); return result == kCFNotFound ? 0 : result; } diff --git a/WebCore/platform/text/cf/StringCF.cpp b/WebCore/platform/text/cf/StringCF.cpp index 97691e5..dcaf8fb 100644 --- a/WebCore/platform/text/cf/StringCF.cpp +++ b/WebCore/platform/text/cf/StringCF.cpp @@ -25,7 +25,7 @@ #include <CoreFoundation/CoreFoundation.h> -namespace WebCore { +namespace WTF { String::String(CFStringRef str) { diff --git a/WebCore/platform/text/cf/StringImplCF.cpp b/WebCore/platform/text/cf/StringImplCF.cpp index aff45b3..18e137f 100644 --- a/WebCore/platform/text/cf/StringImplCF.cpp +++ b/WebCore/platform/text/cf/StringImplCF.cpp @@ -32,7 +32,7 @@ #include <objc/objc-auto.h> #endif -namespace WebCore { +namespace WTF { namespace StringWrapperCFAllocator { @@ -50,7 +50,7 @@ namespace StringWrapperCFAllocator { static CFStringRef copyDescription(const void*) { - return CFSTR("WebCore::String-based allocator"); + return CFSTR("WTF::String-based allocator"); } static void* allocate(CFIndex size, CFOptionFlags, void*) |