Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: third_party/WebKit/Source/platform/LayoutLocale.cpp

Issue 2213393002: Defer computing localeForHan until needed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: drott review Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/text/LocaleToScriptMapping.h" 9 #include "platform/text/LocaleToScriptMapping.h"
9 #include "wtf/HashMap.h" 10 #include "wtf/HashMap.h"
10 #include "wtf/text/AtomicStringHash.h" 11 #include "wtf/text/AtomicStringHash.h"
11 #include "wtf/text/StringHash.h" 12 #include "wtf/text/StringHash.h"
12 13
13 #include <hb.h> 14 #include <hb.h>
14 #include <unicode/locid.h> 15 #include <unicode/locid.h>
15 16
16 namespace blink { 17 namespace blink {
17 18
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 if (m_scriptForHan == USCRIPT_COMMON) 93 if (m_scriptForHan == USCRIPT_COMMON)
93 computeScriptForHan(); 94 computeScriptForHan();
94 return m_hasScriptForHan; 95 return m_hasScriptForHan;
95 } 96 }
96 97
97 const LayoutLocale* LayoutLocale::localeForHan(const LayoutLocale* contentLocale ) 98 const LayoutLocale* LayoutLocale::localeForHan(const LayoutLocale* contentLocale )
98 { 99 {
99 if (contentLocale && contentLocale->hasScriptForHan()) 100 if (contentLocale && contentLocale->hasScriptForHan())
100 return contentLocale; 101 return contentLocale;
101 if (!s_defaultForHanComputed) 102 if (!s_defaultForHanComputed)
102 setLocaleForHan(nullptr); 103 computeLocaleForHan();
103 return s_defaultForHan; 104 return s_defaultForHan;
104 } 105 }
105 106
106 void LayoutLocale::setLocaleForHan(const LayoutLocale* locale) 107 void LayoutLocale::computeLocaleForHan()
107 { 108 {
108 if (locale) 109 if (const LayoutLocale* locale = AcceptLanguagesResolver::localeForHan())
109 s_defaultForHan = locale; 110 s_defaultForHan = locale;
110 else if (getDefault().hasScriptForHan()) 111 else if (getDefault().hasScriptForHan())
111 s_defaultForHan = &getDefault(); 112 s_defaultForHan = &getDefault();
112 else if (getSystem().hasScriptForHan()) 113 else if (getSystem().hasScriptForHan())
113 s_defaultForHan = &getSystem(); 114 s_defaultForHan = &getSystem();
114 else 115 else
115 s_defaultForHan = nullptr; 116 s_defaultForHan = nullptr;
116 s_defaultForHanComputed = true; 117 s_defaultForHanComputed = true;
117 } 118 }
118 119
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 200 }
200 201
201 void LayoutLocale::setHyphenationForTesting(const AtomicString& localeString, Pa ssRefPtr<Hyphenation> hyphenation) 202 void LayoutLocale::setHyphenationForTesting(const AtomicString& localeString, Pa ssRefPtr<Hyphenation> hyphenation)
202 { 203 {
203 const LayoutLocale& locale = valueOrDefault(get(localeString)); 204 const LayoutLocale& locale = valueOrDefault(get(localeString));
204 locale.m_hyphenationComputed = true; 205 locale.m_hyphenationComputed = true;
205 locale.m_hyphenation = hyphenation; 206 locale.m_hyphenation = hyphenation;
206 } 207 }
207 208
208 } // namespace blink 209 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/LayoutLocale.h ('k') | third_party/WebKit/Source/platform/fonts/AcceptLanguagesResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698