Title: [200093] trunk/Source/WebCore
Revision
200093
Author
ryanhad...@apple.com
Date
2016-04-26 10:17:46 -0700 (Tue, 26 Apr 2016)

Log Message

Unreviewed, rolling out r200089.

This change causes API test failures

Reverted changeset:

"WebCore on Mac ignores the user's preferred region (country)
while getting the language"
https://bugs.webkit.org/show_bug.cgi?id=156993
http://trac.webkit.org/changeset/200089

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200092 => 200093)


--- trunk/Source/WebCore/ChangeLog	2016-04-26 16:47:33 UTC (rev 200092)
+++ trunk/Source/WebCore/ChangeLog	2016-04-26 17:17:46 UTC (rev 200093)
@@ -1,3 +1,16 @@
+2016-04-26  Ryan Haddad  <ryanhad...@apple.com>
+
+        Unreviewed, rolling out r200089.
+
+        This change causes API test failures
+
+        Reverted changeset:
+
+        "WebCore on Mac ignores the user's preferred region (country)
+        while getting the language"
+        https://bugs.webkit.org/show_bug.cgi?id=156993
+        http://trac.webkit.org/changeset/200089
+
 2016-04-26  Brent Fulgham  <bfulg...@apple.com>
 
         GuardMalloc crash in WebCore::HTMLFrameElementBase::marginHeight() 

Modified: trunk/Source/WebCore/platform/mac/Language.mm (200092 => 200093)


--- trunk/Source/WebCore/platform/mac/Language.mm	2016-04-26 16:47:33 UTC (rev 200092)
+++ trunk/Source/WebCore/platform/mac/Language.mm	2016-04-26 17:17:46 UTC (rev 200093)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2005, 2006, 2010, 2011, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2005, 2006, 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,7 +30,6 @@
 #import "CFBundleSPI.h"
 #import "WebCoreNSStringExtras.h"
 #import <mutex>
-#import <unicode/uloc.h>
 #import <wtf/Assertions.h>
 #import <wtf/Lock.h>
 #import <wtf/NeverDestroyed.h>
@@ -70,7 +69,7 @@
 
 namespace WebCore {
 
-static String httpStyleLanguageCode(NSString *language, NSString *country)
+static String httpStyleLanguageCode(NSString *language)
 {
     SInt32 languageCode;
     SInt32 regionCode; 
@@ -88,19 +87,9 @@
 
     // Make the string lowercase.
     NSString *lowercaseLanguageCode = [language lowercaseString];
-    NSString *lowercaseCountryCode = [country lowercaseString];
-    
-    // If we see a "_" after a 2-letter language code:
-    // If the country is valid, replace the "_" and whatever comes after it with "-" followed by the
-    // country code.
-    // Otherwise, replace the "_" with a "-" and use whatever country
-    // CFBundleCopyLocalizationForLocalizationInfo() returned.
+
+    // Turn a '_' into a '-' if it appears after a 2-letter language code.
     if ([lowercaseLanguageCode length] >= 3 && [lowercaseLanguageCode characterAtIndex:2] == '_') {
-        if (country)
-            return [NSString stringWithFormat:@"%@-%@", [lowercaseLanguageCode substringWithRange:NSMakeRange(0, 2)], lowercaseCountryCode];
-        
-        // Fall back to older behavior, which used the original language-based code but just changed
-        // the "_" to a "-".
         RetainPtr<NSMutableString> mutableLanguageCode = adoptNS([lowercaseLanguageCode mutableCopy]);
         [mutableLanguageCode.get() replaceCharactersInRange:NSMakeRange(2, 1) withString:@"-"];
         return mutableLanguageCode.get();
@@ -109,18 +98,6 @@
     return lowercaseLanguageCode;
 }
 
-static bool isValidICUCountryCode(NSString* countryCode)
-{
-    const char* const* countries = uloc_getISOCountries();
-    const char* countryUTF8 = [countryCode UTF8String];
-    for (unsigned i = 0; countries[i]; ++i) {
-        const char* possibleCountry = countries[i];
-        if (!strcmp(countryUTF8, possibleCountry))
-            return true;
-    }
-    return false;
-}
-
 Vector<String> platformUserPreferredLanguages()
 {
 #if PLATFORM(MAC)
@@ -136,19 +113,13 @@
     Vector<String>& userPreferredLanguages = preferredLanguages();
 
     if (userPreferredLanguages.isEmpty()) {
-        RetainPtr<CFLocaleRef> locale = adoptCF(CFLocaleCopyCurrent());
-        NSString *countryCode = (NSString *)CFLocaleGetValue(locale.get(), kCFLocaleCountryCode);
-        
-        if (!isValidICUCountryCode(countryCode))
-            countryCode = nil;
-        
         RetainPtr<CFArrayRef> languages = adoptCF(CFLocaleCopyPreferredLanguages());
         CFIndex languageCount = CFArrayGetCount(languages.get());
         if (!languageCount)
             userPreferredLanguages.append("en");
         else {
             for (CFIndex i = 0; i < languageCount; i++)
-                userPreferredLanguages.append(httpStyleLanguageCode((NSString *)CFArrayGetValueAtIndex(languages.get(), i), countryCode));
+                userPreferredLanguages.append(httpStyleLanguageCode((NSString *)CFArrayGetValueAtIndex(languages.get(), i)));
         }
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to