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

Unified Diff: chrome/browser/android/vr_shell/textures/ui_texture.cc

Issue 2914543002: [vr] Bail on unhandled code points. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/textures/ui_texture.cc
diff --git a/chrome/browser/android/vr_shell/textures/ui_texture.cc b/chrome/browser/android/vr_shell/textures/ui_texture.cc
index 63299889200a2d7158006602f20e6aa0b5441584..02eccd784a99356c6cb2eed3b7590619463c7761 100644
--- a/chrome/browser/android/vr_shell/textures/ui_texture.cc
+++ b/chrome/browser/android/vr_shell/textures/ui_texture.cc
@@ -29,6 +29,8 @@ namespace {
static constexpr char kDefaultFontFamily[] = "sans-serif";
+static bool force_font_fallback_failure_for_testing_ = false;
+
std::set<UChar32> CollectDifferentChars(base::string16 text) {
std::set<UChar32> characters;
for (base::i18n::UTF16CharIterator it(&text); !it.end(); it.Advance()) {
@@ -162,20 +164,33 @@ gfx::FontList UiTexture::GetDefaultFontList(int size) {
return gfx::FontList(gfx::Font(kDefaultFontFamily, size));
}
-gfx::FontList UiTexture::GetFontList(int size, base::string16 text) {
+bool UiTexture::GetFontList(int size,
+ base::string16 text,
+ gfx::FontList* font_list) {
+ if (force_font_fallback_failure_for_testing_)
+ return false;
+
gfx::Font default_font(kDefaultFontFamily, size);
std::vector<gfx::Font> fonts{default_font};
std::set<std::string> names;
// TODO(acondor): Query BrowserProcess to obtain the application locale.
for (UChar32 c : CollectDifferentChars(text)) {
- std::string name = GetFallbackFontNameForChar(default_font, c, "");
- if (!name.empty())
+ std::string name;
+ bool found_name = GetFallbackFontNameForChar(default_font, c, "", &name);
+ if (!found_name)
+ return false;
+ if (name.empty())
names.insert(name);
}
for (const auto& name : names)
fonts.push_back(gfx::Font(name, size));
- return gfx::FontList(fonts);
+ *font_list = gfx::FontList(fonts);
+ return true;
+}
+
+void UiTexture::SetForceFontFallbackFailureForTesting(bool force) {
+ force_font_fallback_failure_for_testing_ = force;
}
} // namespace vr_shell
« no previous file with comments | « chrome/browser/android/vr_shell/textures/ui_texture.h ('k') | chrome/browser/android/vr_shell/textures/url_bar_texture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698