| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010, 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 static Vector<AtomicString>& preferredLanguagesOverride() { | 50 static Vector<AtomicString>& preferredLanguagesOverride() { |
| 51 DEFINE_STATIC_LOCAL(Vector<AtomicString>, override, ()); | 51 DEFINE_STATIC_LOCAL(Vector<AtomicString>, override, ()); |
| 52 return override; | 52 return override; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void overrideUserPreferredLanguages(const Vector<AtomicString>& override) { | 55 void overrideUserPreferredLanguages(const Vector<AtomicString>& override) { |
| 56 Vector<AtomicString>& canonicalized = preferredLanguagesOverride(); | 56 Vector<AtomicString>& canonicalized = preferredLanguagesOverride(); |
| 57 canonicalized.resize(0); | 57 canonicalized.resize(0); |
| 58 canonicalized.reserveCapacity(override.size()); | 58 canonicalized.reserveCapacity(override.size()); |
| 59 for (const auto& lang : override) | 59 for (const auto& lang : override) |
| 60 canonicalized.append(canonicalizeLanguageIdentifier(lang)); | 60 canonicalized.push_back(canonicalizeLanguageIdentifier(lang)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 AtomicString defaultLanguage() { | 63 AtomicString defaultLanguage() { |
| 64 Vector<AtomicString>& override = preferredLanguagesOverride(); | 64 Vector<AtomicString>& override = preferredLanguagesOverride(); |
| 65 if (!override.isEmpty()) | 65 if (!override.isEmpty()) |
| 66 return override[0]; | 66 return override[0]; |
| 67 return platformLanguage(); | 67 return platformLanguage(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 Vector<AtomicString> userPreferredLanguages() { | 70 Vector<AtomicString> userPreferredLanguages() { |
| 71 Vector<AtomicString>& override = preferredLanguagesOverride(); | 71 Vector<AtomicString>& override = preferredLanguagesOverride(); |
| 72 if (!override.isEmpty()) | 72 if (!override.isEmpty()) |
| 73 return override; | 73 return override; |
| 74 | 74 |
| 75 Vector<AtomicString> languages; | 75 Vector<AtomicString> languages; |
| 76 languages.reserveInitialCapacity(1); | 76 languages.reserveInitialCapacity(1); |
| 77 languages.append(platformLanguage()); | 77 languages.push_back(platformLanguage()); |
| 78 return languages; | 78 return languages; |
| 79 } | 79 } |
| 80 | 80 |
| 81 size_t indexOfBestMatchingLanguageInList( | 81 size_t indexOfBestMatchingLanguageInList( |
| 82 const AtomicString& language, | 82 const AtomicString& language, |
| 83 const Vector<AtomicString>& languageList) { | 83 const Vector<AtomicString>& languageList) { |
| 84 AtomicString languageWithoutLocaleMatch; | 84 AtomicString languageWithoutLocaleMatch; |
| 85 AtomicString languageMatchButNotLocale; | 85 AtomicString languageMatchButNotLocale; |
| 86 size_t languageWithoutLocaleMatchIndex = 0; | 86 size_t languageWithoutLocaleMatchIndex = 0; |
| 87 size_t languageMatchButNotLocaleMatchIndex = 0; | 87 size_t languageMatchButNotLocaleMatchIndex = 0; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (languageWithoutLocaleMatch.length()) | 119 if (languageWithoutLocaleMatch.length()) |
| 120 return languageWithoutLocaleMatchIndex; | 120 return languageWithoutLocaleMatchIndex; |
| 121 | 121 |
| 122 if (languageMatchButNotLocale.length()) | 122 if (languageMatchButNotLocale.length()) |
| 123 return languageMatchButNotLocaleMatchIndex; | 123 return languageMatchButNotLocaleMatchIndex; |
| 124 | 124 |
| 125 return languageList.size(); | 125 return languageList.size(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |