https://bugs.webkit.org/show_bug.cgi?id=136082
Reviewed by Alexey Proskuryakov.
Source/WebCore:
* platform/mac/Language.mm:
(WebCore::httpStyleLanguageCode): Replace use of WKCopyCFLocalizationPreferredName
with new WebCoreNSStringExtras helper.
* platform/mac/WebCoreNSStringExtras.mm: Replacements for the aspects of
WKCopyCFLocalizationPreferredName.
(preferredBundleLocalizationName): New helper - most preferred localization available
in the main bundle, canonicalized the way we like it.
(canonicalLocalizationName): Convert a lcalization name to a string with language and
country code, using default if necessary (e.g. "en" maps to "en_US").
* WebCore.order: Remove mention of WKCopyCFLocalizationPreferredName.
* WebCore.exp.in: ditto; also export preferredBundleLocalizationName for WebKit(2).
* platform/ios/WebCoreSystemInterfaceIOS.mm: ditto
* platform/mac/WebCoreSystemInterface.h: ditto
* platform/mac/WebCoreSystemInterface.mm: ditto
Source/WebKit/mac:
* Plugins/Hosted/NetscapePluginHostManager.mm:
(WebKit::NetscapePluginHostManager::spawnPluginHost): Get current
localization name using WebCore helper instead of SPI.
* Plugins/WebBasePluginPackage.mm: Fixed the include style for this
file.
(-[WebBasePluginPackage getPluginInfoFromPLists]): Get current
localization name using WebCore helper instead of SPI.
(+[WebBasePluginPackage preferredLocalizationName]): Deleted. This
helper no longer pulls its weight.
* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Remove mention of
WKCopyCFLocalizationPreferredName.
* WebKit.order: ditto
Source/WebKit2:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::connectToService): Remove accidental leftover retrieval
of the localization.
(WebKit::createProcess): Get current localization name from
CFBundle API instead of using SPI.
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Remove mention of WKCopyCFLocalizationPreferredName
* mac/WebKit2.order: ditto
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172866
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-08-20 Maciej Stachowiak <mjs@apple.com>
+
+ Replace use of WKCopyCFLocalizationPreferredName with NSLocale public API
+ https://bugs.webkit.org/show_bug.cgi?id=136082
+
+ Reviewed by Alexey Proskuryakov.
+
+ * platform/mac/Language.mm:
+ (WebCore::httpStyleLanguageCode): Replace use of WKCopyCFLocalizationPreferredName
+ with new WebCoreNSStringExtras helper.
+ * platform/mac/WebCoreNSStringExtras.mm: Replacements for the aspects of
+ WKCopyCFLocalizationPreferredName.
+ (preferredBundleLocalizationName): New helper - most preferred localization available
+ in the main bundle, canonicalized the way we like it.
+ (canonicalLocalizationName): Convert a lcalization name to a string with language and
+ country code, using default if necessary (e.g. "en" maps to "en_US").
+ * WebCore.order: Remove mention of WKCopyCFLocalizationPreferredName.
+ * WebCore.exp.in: ditto; also export preferredBundleLocalizationName for WebKit(2).
+ * platform/ios/WebCoreSystemInterfaceIOS.mm: ditto
+ * platform/mac/WebCoreSystemInterface.h: ditto
+ * platform/mac/WebCoreSystemInterface.mm: ditto
+
2014-08-22 Daniel Bates <dabates@apple.com>
[iOS] Disable ENABLE_IOS_{GESTURE, TOUCH}_EVENTS, and temporarily disable ENABLE_TOUCH_EVENTS
_hasCaseInsensitivePrefix
_hasCaseInsensitiveSubstring
_hasCaseInsensitiveSuffix
+_preferredBundleLocalizationName
_stringIsCaseInsensitiveEqualToString
_suggestedFilenameWithMIMEType
_wkCALayerEnumerateRectsBeingDrawnWithBlock
_wkCGPathAddRoundedRect
_wkCGPatternCreateWithImageAndTransform
_wkCTRunGetInitialAdvance
-_wkCopyCFLocalizationPreferredName
_wkCopyCFURLResponseSuggestedFilename
_wkCopyCONNECTProxyResponse
_wkCopyHTTPCookieStorage
_wkCGContextResetClip
_wkCGContextDrawsWithCorrectShadowOffsets
_wkCGPatternCreateWithImageAndTransform
-_wkCopyCFLocalizationPreferredName
_wkCopyNSURLResponseStatusLine
_wkCopyNSURLResponseCertificateChain
_wkDrawBezeledTextFieldCell
WEBCORE_EXPORT BOOL (*wkCGContextGetShouldSmoothFonts)(CGContextRef);
WEBCORE_EXPORT CGPatternRef (*wkCGPatternCreateWithImageAndTransform)(CGImageRef, CGAffineTransform, int);
WEBCORE_EXPORT void (*wkCGContextResetClip)(CGContextRef);
-WEBCORE_EXPORT CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
WEBCORE_EXPORT void (*wkClearGlyphVector)(void* glyphs);
WEBCORE_EXPORT OSStatus (*wkConvertCharToGlyphs)(void* styleGroup, const UniChar*, unsigned numCharacters, void* glyphs);
WEBCORE_EXPORT NSString* (*wkGetMIMETypeForExtension)(NSString*);
#import "Language.h"
#import "BlockExceptions.h"
-#import "WebCoreSystemInterface.h"
+#import "WebCoreNSStringExtras.h"
#import <mutex>
#import <wtf/Assertions.h>
#import <wtf/NeverDestroyed.h>
namespace WebCore {
-static String httpStyleLanguageCode(NSString *languageCode)
+static String httpStyleLanguageCode(NSString *language)
{
- // Look up the language code using CFBundle.
- RetainPtr<CFStringRef> preferredLanguageCode = adoptCF(wkCopyCFLocalizationPreferredName((CFStringRef)languageCode));
-
- if (preferredLanguageCode)
- languageCode = (NSString *)preferredLanguageCode.get();
-
- // Make the string lowercase.
- NSString *lowercaseLanguageCode = [languageCode lowercaseString];
-
- // Turn a '_' into a '-' if it appears after a 2-letter language code.
- if ([lowercaseLanguageCode length] >= 3 && [lowercaseLanguageCode characterAtIndex:2] == '_') {
- RetainPtr<NSMutableString> mutableLanguageCode = adoptNS([lowercaseLanguageCode mutableCopy]);
- [mutableLanguageCode.get() replaceCharactersInRange:NSMakeRange(2, 1) withString:@"-"];
- return mutableLanguageCode.get();
- }
-
- return lowercaseLanguageCode;
+ return [[NSLocale canonicalLanguageIdentifierFromString:canonicalLocaleName(language)] lowercaseString];
}
Vector<String> platformUserPreferredLanguages()
CFStringEncoding stringEncodingForResource(Handle resource);
#endif
+NSString *preferredBundleLocalizationName();
+NSString *canonicalLocaleName(NSString *);
+
#ifdef __cplusplus
}
#endif
return encoding;
}
+
+NSString *preferredBundleLocalizationName()
+{
+ // FIXME: Any use of this function to pass localizations to another
+ // process is likely not completely right, since it only considers
+ // one localization.
+ NSArray *preferredLocalizations = [[NSBundle mainBundle] preferredLocalizations];
+ if (!preferredLocalizations || ![preferredLocalizations count])
+ return @"en_US";
+
+ return canonicalLocaleName([preferredLocalizations objectAtIndex:0]);
+}
+
+NSString *canonicalLocaleName(NSString *language)
+{
+ // FIXME: <rdar://problem/18083880> Replace use of Script Manager
+ // to canonicalize locales with a custom Web-specific table
+ LangCode languageCode;
+ RegionCode regionCode;
+
+ OSStatus status = LocaleStringToLangAndRegionCodes([language UTF8String], &languageCode, ®ionCode);
+ if (status != noErr)
+ return @"en_US";
+
+ RetainPtr<CFStringRef> code = adoptCF(CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(0, languageCode, regionCode));
+ return [(NSString*)code.get() autorelease];
+}
+
#if COMPILER(CLANG)
#pragma clang diagnostic pop
#endif
void (*formSchedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
void (*formUnschedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
void *context);
-extern CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
extern NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
extern CFArrayRef (*wkCopyNSURLResponseCertificateChain)(NSURLResponse*);
extern CFStringEncoding (*wkGetWebDefaultCFStringEncoding)(void);
bool (*wkCGContextDrawsWithCorrectShadowOffsets)(CGContextRef);
#endif
CGPatternRef (*wkCGPatternCreateWithImageAndTransform)(CGImageRef, CGAffineTransform, int);
-CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
CFArrayRef (*wkCopyNSURLResponseCertificateChain)(NSURLResponse*);
CFStringEncoding (*wkGetWebDefaultCFStringEncoding)(void);
+2014-08-20 Maciej Stachowiak <mjs@apple.com>
+
+ Replace use of WKCopyCFLocalizationPreferredName with NSLocale public API
+ https://bugs.webkit.org/show_bug.cgi?id=136082
+
+ Reviewed by Alexey Proskuryakov.
+
+ * Plugins/Hosted/NetscapePluginHostManager.mm:
+ (WebKit::NetscapePluginHostManager::spawnPluginHost): Get current
+ localization name using WebCore helper instead of SPI.
+ * Plugins/WebBasePluginPackage.mm: Fixed the include style for this
+ file.
+ (-[WebBasePluginPackage getPluginInfoFromPLists]): Get current
+ localization name using WebCore helper instead of SPI.
+ (+[WebBasePluginPackage preferredLocalizationName]): Deleted. This
+ helper no longer pulls its weight.
+ * WebCoreSupport/WebSystemInterface.mm:
+ (InitWebCoreSystemInterface): Remove mention of
+ WKCopyCFLocalizationPreferredName.
+ * WebKit.order: ditto
+
2014-08-22 Daniel Bates <dabates@apple.com>
[iOS] Disable ENABLE_IOS_{GESTURE, TOUCH}_EVENTS, and temporarily disable ENABLE_TOUCH_EVENTS
#import "WebLocalizableStringsInternal.h"
#import "WebKitSystemInterface.h"
#import "WebNetscapePluginPackage.h"
+#import <WebCore/WebCoreNSStringExtras.h>
#import <mach/mach_port.h>
#import <servers/bootstrap.h>
#import <spawn.h>
NSString *pluginHostAppPath = [[NSBundle bundleForClass:[WebNetscapePluginPackage class]] pathForAuxiliaryExecutable:pluginHostAppName];
NSString *pluginHostAppExecutablePath = [[NSBundle bundleWithPath:pluginHostAppPath] executablePath];
- RetainPtr<CFStringRef> localization = adoptCF(WKCopyCFLocalizationPreferredName(NULL));
-
NSDictionary *launchProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
pluginHostAppExecutablePath, @"pluginHostPath",
[NSNumber numberWithInt:pluginArchitecture], @"cpuType",
- (NSString *)localization.get(), @"localization",
+ preferredBundleLocalizationName(), @"localization",
nil];
NSData *data = [NSPropertyListSerialization dataWithPropertyList:launchProperties format:NSPropertyListBinaryFormat_v1_0 options:0 error:nullptr];
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import <WebKitLegacy/WebBasePluginPackage.h>
+#import "WebBasePluginPackage.h"
-#import <algorithm>
+#import "WebKitLogging.h"
+#import "WebKitNSStringExtras.h"
+#import "WebNetscapePluginPackage.h"
+#import "WebPluginPackage.h"
+#import "WebTypesInternal.h"
+#import <WebCore/WebCoreNSStringExtras.h>
#import <WebCore/WebCoreObjCExtras.h>
-#import <WebKitLegacy/WebKitNSStringExtras.h>
-#import <WebKitLegacy/WebNetscapePluginPackage.h>
-#import <WebKitLegacy/WebPluginPackage.h>
+#import <algorithm>
+#import <mach-o/arch.h>
+#import <mach-o/fat.h>
+#import <mach-o/loader.h>
#import <runtime/InitializeThreading.h>
#import <wtf/Assertions.h>
#import <wtf/MainThread.h>
#import <wtf/Vector.h>
#import <wtf/text/CString.h>
-#import <WebKitSystemInterface.h>
-
-#import "WebKitLogging.h"
-#import "WebTypesInternal.h"
-
-#import <mach-o/arch.h>
-#import <mach-o/fat.h>
-#import <mach-o/loader.h>
#define JavaCocoaPluginIdentifier "com.apple.JavaPluginCocoa"
#define JavaCarbonPluginIdentifier "com.apple.JavaAppletPlugin"
return [pluginPackage autorelease];
}
-+ (NSString *)preferredLocalizationName
-{
- return CFBridgingRelease(WKCopyCFLocalizationPreferredName(NULL));
-}
-
#if COMPILER(CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (pList) {
// If the plist isn't localized, have the plug-in recreate it in the preferred language.
NSString *localizationName = [pList objectForKey:WebPluginLocalizationNameKey];
- if (![localizationName isEqualToString:[[self class] preferredLocalizationName]])
+ if (![localizationName isEqualToString:preferredBundleLocalizationName()])
pList = [self pListForPath:pListPath createFile:YES];
MIMETypes = [pList objectForKey:WebPluginMIMETypesKey];
} else
#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
INIT(CTFontTransformGlyphs);
#endif
- INIT(CopyCFLocalizationPreferredName);
INIT(CopyCONNECTProxyResponse);
INIT(CopyNSURLResponseStatusLine);
INIT(CopyNSURLResponseCertificateChain);
+[WebView _shouldAutomaticDashSubstitutionBeEnabled]
+[WebView _shouldAutomaticTextReplacementBeEnabled]
+[WebView _shouldAutomaticSpellingCorrectionBeEnabled]
-_WKCopyCFLocalizationPreferredName
+[WebView(WebPrivate) _setDomainRelaxationForbidden:forURLScheme:]
+[WebView(WebPrivate) _registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing:]
+[WebView(WebPrivate) _registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing:]
__ZN7WebCore13MimeClassInfoD2Ev
-[WebBasePluginPackage isNativeLibraryData:]
-[WebBasePluginPackage pListForPath:createFile:]
-+[WebBasePluginPackage preferredLocalizationName]
-[WebPluginDatabase(Internal) _addPlugin:]
-[WebBasePluginPackage path]
-[WebBasePluginPackage wasAddedToPluginDatabase:]
+2014-08-19 Maciej Stachowiak <mjs@apple.com>
+
+ Replace use of WKCopyCFLocalizationPreferredName with NSLocale public API
+ https://bugs.webkit.org/show_bug.cgi?id=136082
+
+ Reviewed by Alexey Proskuryakov.
+
+ * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+ (WebKit::connectToService): Remove accidental leftover retrieval
+ of the localization.
+ (WebKit::createProcess): Get current localization name from
+ CFBundle API instead of using SPI.
+ * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+ (InitWebCoreSystemInterface): Remove mention of WKCopyCFLocalizationPreferredName
+ * mac/WebKit2.order: ditto
+
2014-08-22 Daniel Bates <dabates@apple.com>
[iOS] Disable ENABLE_IOS_{GESTURE, TOUCH}_EVENTS, and temporarily disable ENABLE_TOUCH_EVENTS
#import "DynamicLinkerEnvironmentExtractor.h"
#import "EnvironmentVariables.h"
-#import "WebKitSystemInterface.h"
#import <WebCore/SoftLinking.h>
+#import <WebCore/WebCoreNSStringExtras.h>
#import <crt_externs.h>
#import <mach-o/dyld.h>
#import <mach/machine.h>
// 1. When the application and system frameworks simply have different localized resources available, we should match the application.
// 1.1. An important case is WebKitTestRunner, where we should use English localizations for all system frameworks.
// 2. When AppleLanguages is passed as command line argument for UI process, or set in its preferences, we should respect it in child processes.
- RetainPtr<CFStringRef> localization = adoptCF(WKCopyCFLocalizationPreferredName(0));
- if (localization && _CFBundleSetupXPCBootstrapPtr()) {
+ if (_CFBundleSetupXPCBootstrapPtr()) {
auto initializationMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
_CFBundleSetupXPCBootstrapPtr()(initializationMessage.get());
xpc_connection_set_bootstrap(connection.get(), initializationMessage.get());
// 1. When the application and system frameworks simply have different localized resources available, we should match the application.
// 1.1. An important case is WebKitTestRunner, where we should use English localizations for all system frameworks.
// 2. When AppleLanguages is passed as command line argument for UI process, or set in its preferences, we should respect it in child processes.
- CString appleLanguagesArgument = String("('" + String(adoptCF(WKCopyCFLocalizationPreferredName(0)).get()) + "')").utf8();
+ CString appleLanguagesArgument = String("('" + String(preferredBundleLocalizationName()) + "')").utf8();
Vector<const char*> args;
args.append([processAppExecutablePath fileSystemRepresentation]);
INIT(AdvanceDefaultButtonPulseAnimation);
#endif
INIT(CALayerEnumerateRectsBeingDrawnWithBlock);
- INIT(CopyCFLocalizationPreferredName);
INIT(CGContextGetShouldSmoothFonts);
INIT(CGPatternCreateWithImageAndTransform);
INIT(CGContextResetClip);
__ZN6WebKit20EnvironmentVariables11appendValueEPKcS2_c
__ZN3WTF6VectorINSt3__14pairINS_7CStringES3_EELm0ENS_15CrashOnOverflowEED2Ev
__ZN3WTF6VectorINSt3__14pairINS_7CStringES3_EELm0ENS_15CrashOnOverflowEE6shrinkEm
-_WKCopyCFLocalizationPreferredName
__ZN6WebKit15ProcessLauncher19processTypeAsStringENS0_11ProcessTypeE
__ZNK3WTF12StringAppendIPKcNS_6StringEEcvS3_Ev
__ZN3WTF6VectorINS_7CStringELm0ENS_15CrashOnOverflowEE14appendSlowCaseIS1_EEvRKT_