| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/LayoutLocale.h" | 5 #include "platform/LayoutLocale.h" |
| 6 | 6 |
| 7 #include "platform/Language.h" | 7 #include "platform/Language.h" |
| 8 #include "platform/fonts/AcceptLanguagesResolver.h" | 8 #include "platform/fonts/AcceptLanguagesResolver.h" |
| 9 #include "platform/text/ICUError.h" | 9 #include "platform/text/ICUError.h" |
| 10 #include "platform/text/LocaleToScriptMapping.h" | 10 #include "platform/text/LocaleToScriptMapping.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 script_for_han_ = ScriptCodeForHanFromSubtags(string_); | 64 script_for_han_ = ScriptCodeForHanFromSubtags(string_); |
| 65 if (script_for_han_ == USCRIPT_COMMON) | 65 if (script_for_han_ == USCRIPT_COMMON) |
| 66 script_for_han_ = USCRIPT_SIMPLIFIED_HAN; | 66 script_for_han_ = USCRIPT_SIMPLIFIED_HAN; |
| 67 else | 67 else |
| 68 has_script_for_han_ = true; | 68 has_script_for_han_ = true; |
| 69 DCHECK(IsUnambiguousHanScript(script_for_han_)); | 69 DCHECK(IsUnambiguousHanScript(script_for_han_)); |
| 70 } | 70 } |
| 71 | 71 |
| 72 UScriptCode LayoutLocale::ScriptForHan() const { | 72 UScriptCode LayoutLocale::GetScriptForHan() const { |
| 73 if (script_for_han_ == USCRIPT_COMMON) | 73 if (script_for_han_ == USCRIPT_COMMON) |
| 74 ComputeScriptForHan(); | 74 ComputeScriptForHan(); |
| 75 return script_for_han_; | 75 return script_for_han_; |
| 76 } | 76 } |
| 77 | 77 |
| 78 bool LayoutLocale::HasScriptForHan() const { | 78 bool LayoutLocale::HasScriptForHan() const { |
| 79 if (script_for_han_ == USCRIPT_COMMON) | 79 if (script_for_han_ == USCRIPT_COMMON) |
| 80 ComputeScriptForHan(); | 80 ComputeScriptForHan(); |
| 81 return has_script_for_han_; | 81 return has_script_for_han_; |
| 82 } | 82 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 96 else if (GetDefault().HasScriptForHan()) | 96 else if (GetDefault().HasScriptForHan()) |
| 97 default_for_han_ = &GetDefault(); | 97 default_for_han_ = &GetDefault(); |
| 98 else if (GetSystem().HasScriptForHan()) | 98 else if (GetSystem().HasScriptForHan()) |
| 99 default_for_han_ = &GetSystem(); | 99 default_for_han_ = &GetSystem(); |
| 100 else | 100 else |
| 101 default_for_han_ = nullptr; | 101 default_for_han_ = nullptr; |
| 102 default_for_han_computed_ = true; | 102 default_for_han_computed_ = true; |
| 103 } | 103 } |
| 104 | 104 |
| 105 const char* LayoutLocale::LocaleForHanForSkFontMgr() const { | 105 const char* LayoutLocale::LocaleForHanForSkFontMgr() const { |
| 106 const char* locale = ToSkFontMgrLocale(ScriptForHan()); | 106 const char* locale = ToSkFontMgrLocale(GetScriptForHan()); |
| 107 DCHECK(locale); | 107 DCHECK(locale); |
| 108 return locale; | 108 return locale; |
| 109 } | 109 } |
| 110 | 110 |
| 111 LayoutLocale::LayoutLocale(const AtomicString& locale) | 111 LayoutLocale::LayoutLocale(const AtomicString& locale) |
| 112 : string_(locale), | 112 : string_(locale), |
| 113 harfbuzz_language_(ToHarfbuzLanguage(locale)), | 113 harfbuzz_language_(ToHarfbuzLanguage(locale)), |
| 114 script_(LocaleToScriptCodeForFontSelection(locale)), | 114 script_(LocaleToScriptCodeForFontSelection(locale)), |
| 115 script_for_han_(USCRIPT_COMMON), | 115 script_for_han_(USCRIPT_COMMON), |
| 116 has_script_for_han_(false), | 116 has_script_for_han_(false), |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 DCHECK_EQ(length_needed, length_needed2); | 233 DCHECK_EQ(length_needed, length_needed2); |
| 234 if (U_SUCCESS(status) && length_needed == length_needed2) | 234 if (U_SUCCESS(status) && length_needed == length_needed2) |
| 235 return AtomicString::FromUTF8(buffer.Data(), length_needed); | 235 return AtomicString::FromUTF8(buffer.Data(), length_needed); |
| 236 } | 236 } |
| 237 | 237 |
| 238 NOTREACHED(); | 238 NOTREACHED(); |
| 239 return string_; | 239 return string_; |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace blink | 242 } // namespace blink |
| OLD | NEW |