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

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

Issue 2925053004: [vr] Exit to 2D when encountering URLs with strong RTL characters (Closed)
Patch Set: rebaes 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 264 }
264 } 265 }
265 266
266 void UrlBarTexture::RenderUrl(const gfx::Size& texture_size, 267 void UrlBarTexture::RenderUrl(const gfx::Size& texture_size,
267 const gfx::Rect& bounds) { 268 const gfx::Rect& bounds) {
268 url::Parsed parsed; 269 url::Parsed parsed;
269 const base::string16 text = url_formatter::FormatUrl( 270 const base::string16 text = url_formatter::FormatUrl(
270 gurl_, url_formatter::kFormatUrlOmitAll, net::UnescapeRule::NORMAL, 271 gurl_, url_formatter::kFormatUrlOmitAll, net::UnescapeRule::NORMAL,
271 &parsed, nullptr, nullptr); 272 &parsed, nullptr, nullptr);
272 273
274 if (base::i18n::StringContainsStrongRTLChars(text))
275 failure_callback_.Run(UiUnsupportedMode::kURLWithStrongRTLChars);
276
273 int pixel_font_height = texture_size.height() * kFontHeight / kHeight; 277 int pixel_font_height = texture_size.height() * kFontHeight / kHeight;
274 278
275 gfx::FontList font_list; 279 gfx::FontList font_list;
276 if (!GetFontList(pixel_font_height, text, &font_list)) 280 if (!GetFontList(pixel_font_height, text, &font_list))
277 failure_callback_.Run(UiUnsupportedMode::kUnhandledCodePoint); 281 failure_callback_.Run(UiUnsupportedMode::kUnhandledCodePoint);
278 282
279 std::unique_ptr<gfx::RenderText> render_text( 283 std::unique_ptr<gfx::RenderText> render_text(
280 gfx::RenderText::CreateInstance()); 284 gfx::RenderText::CreateInstance());
281 render_text->SetFontList(font_list); 285 render_text->SetFontList(font_list);
282 render_text->SetColor(SK_ColorBLACK); 286 render_text->SetColor(SK_ColorBLACK);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 378
375 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { 379 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const {
376 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); 380 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth);
377 } 381 }
378 382
379 gfx::SizeF UrlBarTexture::GetDrawnSize() const { 383 gfx::SizeF UrlBarTexture::GetDrawnSize() const {
380 return size_; 384 return size_;
381 } 385 }
382 386
383 } // namespace vr_shell 387 } // 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