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

Side by Side Diff: ui/base/webui/web_ui_util.cc

Issue 747923004: webui: minimize webui flicker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: creis@ + davidben@ review Created 6 years 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
« no previous file with comments | « ui/base/webui/web_ui_util.h ('k') | ui/webui/resources/css/chrome_shared.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/base/webui/web_ui_util.h" 5 #include "ui/base/webui/web_ui_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 pos + 1, stripped_path.length() - pos - 1), &factor)) { 118 pos + 1, stripped_path.length() - pos - 1), &factor)) {
119 // Strip scale factor specification from path. 119 // Strip scale factor specification from path.
120 stripped_path.remove_suffix(stripped_path.length() - pos); 120 stripped_path.remove_suffix(stripped_path.length() - pos);
121 stripped_path.CopyToString(path); 121 stripped_path.CopyToString(path);
122 } 122 }
123 if (scale_factor) 123 if (scale_factor)
124 *scale_factor = factor; 124 *scale_factor = factor;
125 } 125 }
126 } 126 }
127 127
128 // static 128 std::string GetFontFamily() {
129 void SetFontAndTextDirection(base::DictionaryValue* localized_strings) { 129 std::string font_family = l10n_util::GetStringUTF8(
130 int web_font_family_id = IDS_WEB_FONT_FAMILY;
131 int web_font_size_id = IDS_WEB_FONT_SIZE;
132 #if defined(OS_WIN) 130 #if defined(OS_WIN)
133 // Vary font settings for Windows XP. 131 base::win::GetVersion() < base::win::VERSION_VISTA ?
134 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 132 IDS_WEB_FONT_FAMILY_XP :
135 web_font_family_id = IDS_WEB_FONT_FAMILY_XP;
136 web_font_size_id = IDS_WEB_FONT_SIZE_XP;
137 }
138 #endif 133 #endif
139 134 IDS_WEB_FONT_FAMILY);
140 std::string font_family = l10n_util::GetStringUTF8(web_font_family_id);
141 135
142 // TODO(dnicoara) Remove Ozone check when PlatformFont support is introduced 136 // TODO(dnicoara) Remove Ozone check when PlatformFont support is introduced
143 // into Ozone: crbug.com/320050 137 // into Ozone: crbug.com/320050
144 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(USE_OZONE) 138 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(USE_OZONE)
145 font_family = ui::ResourceBundle::GetSharedInstance().GetFont( 139 font_family = ui::ResourceBundle::GetSharedInstance().GetFont(
146 ui::ResourceBundle::BaseFont).GetFontName() + ", " + font_family; 140 ui::ResourceBundle::BaseFont).GetFontName() + ", " + font_family;
147 #endif 141 #endif
148 142
149 localized_strings->SetString("fontfamily", font_family); 143 return font_family;
150 localized_strings->SetString("fontsize", 144 }
151 l10n_util::GetStringUTF8(web_font_size_id)); 145
152 localized_strings->SetString("textdirection", 146 std::string GetFontSize() {
153 base::i18n::IsRTL() ? "rtl" : "ltr"); 147 return l10n_util::GetStringUTF8(
148 #if defined(OS_WIN)
149 base::win::GetVersion() < base::win::VERSION_VISTA ?
150 IDS_WEB_FONT_SIZE_XP :
151 #endif
152 IDS_WEB_FONT_SIZE);
153 }
154
155 std::string GetTextDirection() {
156 return base::i18n::IsRTL() ? "rtl" : "ltr";
157 }
158
159 void SetFontAndTextDirection(base::DictionaryValue* localized_strings) {
160 localized_strings->SetString("fontfamily", GetFontFamily());
161 localized_strings->SetString("fontsize", GetFontSize());
162 localized_strings->SetString("textdirection", GetTextDirection());
154 } 163 }
155 164
156 } // namespace webui 165 } // namespace webui
OLDNEW
« no previous file with comments | « ui/base/webui/web_ui_util.h ('k') | ui/webui/resources/css/chrome_shared.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698