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

Side by Side Diff: chrome/browser/android/vr_shell/textures/url_bar_texture.cc

Issue 2930783002: [vr] Exit to 2D when encountering URLs with strong RTL characters (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/textures/url_bar_texture_unittest.cc » ('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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/android/vr_shell/textures/url_bar_texture.h" 5 #include "chrome/browser/android/vr_shell/textures/url_bar_texture.h"
6 6
7 #include "base/i18n/rtl.h"
7 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
8 #include "cc/paint/skia_paint_canvas.h" 9 #include "cc/paint/skia_paint_canvas.h"
9 #include "chrome/browser/android/vr_shell/color_scheme.h" 10 #include "chrome/browser/android/vr_shell/color_scheme.h"
10 #include "chrome/browser/android/vr_shell/textures/render_text_wrapper.h" 11 #include "chrome/browser/android/vr_shell/textures/render_text_wrapper.h"
11 #include "components/toolbar/vector_icons.h" 12 #include "components/toolbar/vector_icons.h"
12 #include "components/url_formatter/url_formatter.h" 13 #include "components/url_formatter/url_formatter.h"
13 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/font.h" 15 #include "ui/gfx/font.h"
15 #include "ui/gfx/font_list.h" 16 #include "ui/gfx/font_list.h"
16 #include "ui/gfx/geometry/point_f.h" 17 #include "ui/gfx/geometry/point_f.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 253 }
253 } 254 }
254 255
255 void UrlBarTexture::RenderUrl(const gfx::Size& texture_size, 256 void UrlBarTexture::RenderUrl(const gfx::Size& texture_size,
256 const gfx::Rect& bounds) { 257 const gfx::Rect& bounds) {
257 url::Parsed parsed; 258 url::Parsed parsed;
258 const base::string16 text = url_formatter::FormatUrl( 259 const base::string16 text = url_formatter::FormatUrl(
259 gurl_, url_formatter::kFormatUrlOmitAll, net::UnescapeRule::NORMAL, 260 gurl_, url_formatter::kFormatUrlOmitAll, net::UnescapeRule::NORMAL,
260 &parsed, nullptr, nullptr); 261 &parsed, nullptr, nullptr);
261 262
263 if (base::i18n::StringContainsStrongRTLChars(text))
264 failure_callback_.Run(UiUnsupportedMode::kURLWithStrongRTLChars);
265
262 int pixel_font_height = texture_size.height() * kFontHeight / kHeight; 266 int pixel_font_height = texture_size.height() * kFontHeight / kHeight;
263 267
264 gfx::FontList font_list; 268 gfx::FontList font_list;
265 if (!GetFontList(pixel_font_height, text, &font_list)) 269 if (!GetFontList(pixel_font_height, text, &font_list))
266 failure_callback_.Run(UiUnsupportedMode::kUnhandledCodePoint); 270 failure_callback_.Run(UiUnsupportedMode::kUnhandledCodePoint);
267 271
268 std::unique_ptr<gfx::RenderText> render_text( 272 std::unique_ptr<gfx::RenderText> render_text(
269 gfx::RenderText::CreateInstance()); 273 gfx::RenderText::CreateInstance());
270 render_text->SetFontList(font_list); 274 render_text->SetFontList(font_list);
271 render_text->SetColor(SK_ColorBLACK); 275 render_text->SetColor(SK_ColorBLACK);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 367
364 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { 368 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const {
365 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); 369 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth);
366 } 370 }
367 371
368 gfx::SizeF UrlBarTexture::GetDrawnSize() const { 372 gfx::SizeF UrlBarTexture::GetDrawnSize() const {
369 return size_; 373 return size_;
370 } 374 }
371 375
372 } // namespace vr_shell 376 } // namespace vr_shell
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/textures/url_bar_texture_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698