summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/text/mac
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/text/mac')
-rw-r--r--WebCore/platform/text/mac/HyphenationMac.mm30
-rw-r--r--WebCore/platform/text/mac/StringImplMac.mm2
-rw-r--r--WebCore/platform/text/mac/StringMac.mm2
3 files changed, 28 insertions, 6 deletions
diff --git a/WebCore/platform/text/mac/HyphenationMac.mm b/WebCore/platform/text/mac/HyphenationMac.mm
index e64477f..56122df 100644
--- a/WebCore/platform/text/mac/HyphenationMac.mm
+++ b/WebCore/platform/text/mac/HyphenationMac.mm
@@ -28,17 +28,39 @@
#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
+#import "AtomicString.h"
+#import "AtomicStringKeyedMRUCache.h"
#import "TextBreakIteratorInternalICU.h"
#import "WebCoreSystemInterface.h"
#import <wtf/RetainPtr.h>
namespace WebCore {
-size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex)
+template<>
+bool AtomicStringKeyedMRUCache<bool>::createValueForNullKey()
{
- static bool localeIsEnglish = !strcmp("en", currentSearchLocaleID());
- if (!localeIsEnglish)
- return 0;
+ return !strcmp(currentSearchLocaleID(), "en");
+}
+
+template<>
+bool AtomicStringKeyedMRUCache<bool>::createValueForKey(const AtomicString& localeIdentifier)
+{
+ RetainPtr<CFStringRef> cfLocaleIdentifier(AdoptCF, localeIdentifier.createCFString());
+ RetainPtr<CFDictionaryRef> components(AdoptCF, CFLocaleCreateComponentsFromLocaleIdentifier(kCFAllocatorDefault, cfLocaleIdentifier.get()));
+ CFStringRef language = reinterpret_cast<CFStringRef>(CFDictionaryGetValue(components.get(), kCFLocaleLanguageCode));
+ static CFStringRef englishLanguage = CFSTR("en");
+ return language && CFEqual(language, englishLanguage);
+}
+
+bool canHyphenate(const AtomicString& localeIdentifier)
+{
+ DEFINE_STATIC_LOCAL(AtomicStringKeyedMRUCache<bool>, isEnglishCache, ());
+ return isEnglishCache.get(localeIdentifier);
+}
+
+size_t lastHyphenLocation(const UChar* characters, size_t length, size_t beforeIndex, const AtomicString& localeIdentifier)
+{
+ ASSERT_UNUSED(localeIdentifier, canHyphenate(localeIdentifier));
RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, characters, length, kCFAllocatorNull));
return wkGetHyphenationLocationBeforeIndex(string.get(), beforeIndex);
diff --git a/WebCore/platform/text/mac/StringImplMac.mm b/WebCore/platform/text/mac/StringImplMac.mm
index d14c6d8..843f396 100644
--- a/WebCore/platform/text/mac/StringImplMac.mm
+++ b/WebCore/platform/text/mac/StringImplMac.mm
@@ -23,7 +23,7 @@
#include "FoundationExtras.h"
-namespace WebCore {
+namespace WTF {
StringImpl::operator NSString *()
{
diff --git a/WebCore/platform/text/mac/StringMac.mm b/WebCore/platform/text/mac/StringMac.mm
index 758ae1d..7e98b2b 100644
--- a/WebCore/platform/text/mac/StringMac.mm
+++ b/WebCore/platform/text/mac/StringMac.mm
@@ -22,7 +22,7 @@
#include "PlatformString.h"
#include <CoreFoundation/CFString.h>
-namespace WebCore {
+namespace WTF {
String::String(NSString* str)
{