OLD | NEW |
---|---|
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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "cc/paint/skia_paint_canvas.h" | 8 #include "cc/paint/skia_paint_canvas.h" |
9 #include "chrome/browser/android/vr_shell/textures/render_text_wrapper.h" | 9 #include "chrome/browser/android/vr_shell/textures/render_text_wrapper.h" |
10 #include "components/url_formatter/url_formatter.h" | 10 #include "components/url_formatter/url_formatter.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 &parsed, nullptr, nullptr); | 245 &parsed, nullptr, nullptr); |
246 | 246 |
247 int pixel_font_height = texture_size.height() * kFontHeight / kHeight; | 247 int pixel_font_height = texture_size.height() * kFontHeight / kHeight; |
248 | 248 |
249 gfx::FontList font_list; | 249 gfx::FontList font_list; |
250 if (!GetFontList(pixel_font_height, text, &font_list)) | 250 if (!GetFontList(pixel_font_height, text, &font_list)) |
251 failure_callback_.Run(UiUnsupportedMode::kUnhandledCodePoint); | 251 failure_callback_.Run(UiUnsupportedMode::kUnhandledCodePoint); |
252 | 252 |
253 std::unique_ptr<gfx::RenderText> render_text( | 253 std::unique_ptr<gfx::RenderText> render_text( |
254 gfx::RenderText::CreateInstance()); | 254 gfx::RenderText::CreateInstance()); |
255 render_text->SetText(text); | |
256 render_text->SetFontList(font_list); | 255 render_text->SetFontList(font_list); |
257 render_text->SetColor(SK_ColorBLACK); | 256 render_text->SetColor(SK_ColorBLACK); |
258 render_text->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 257 render_text->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
259 render_text->SetDisplayRect(bounds); | |
260 render_text->SetElideBehavior(gfx::TRUNCATE); | 258 render_text->SetElideBehavior(gfx::TRUNCATE); |
261 | 259 |
260 const base::string16 mandatory_prefix = text.substr(0, parsed.host.end()); | |
261 gfx::Rect expanded_bounds = bounds; | |
262 expanded_bounds.set_width(2 * bounds.width()); | |
263 render_text->SetDisplayRect(expanded_bounds); | |
264 render_text->SetText(mandatory_prefix); | |
265 | |
266 if (render_text->GetStringSize().width() > bounds.width()) { | |
267 failure_callback_.Run(UiUnsupportedMode::kCouldNotElideURL); | |
268 } | |
269 | |
270 render_text->SetText(text); | |
cjgrant
2017/05/29 15:17:13
Just checking that you still want to proceed and r
| |
271 render_text->SetDisplayRect(bounds); | |
262 vr_shell::RenderTextWrapper vr_render_text(render_text.get()); | 272 vr_shell::RenderTextWrapper vr_render_text(render_text.get()); |
263 ApplyUrlStyling(text, parsed, security_level_, &vr_render_text); | 273 ApplyUrlStyling(text, parsed, security_level_, &vr_render_text); |
264 | 274 |
265 url_render_text_ = std::move(render_text); | 275 url_render_text_ = std::move(render_text); |
266 } | 276 } |
267 | 277 |
268 // This method replicates behavior in OmniboxView::UpdateTextStyle(), and | 278 // This method replicates behavior in OmniboxView::UpdateTextStyle(), and |
269 // attempts to maintain similar code structure. | 279 // attempts to maintain similar code structure. |
270 void UrlBarTexture::ApplyUrlStyling( | 280 void UrlBarTexture::ApplyUrlStyling( |
271 const base::string16& formatted_url, | 281 const base::string16& formatted_url, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 | 341 |
332 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { | 342 gfx::Size UrlBarTexture::GetPreferredTextureSize(int maximum_width) const { |
333 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); | 343 return gfx::Size(maximum_width, maximum_width * kHeight / kWidth); |
334 } | 344 } |
335 | 345 |
336 gfx::SizeF UrlBarTexture::GetDrawnSize() const { | 346 gfx::SizeF UrlBarTexture::GetDrawnSize() const { |
337 return size_; | 347 return size_; |
338 } | 348 } |
339 | 349 |
340 } // namespace vr_shell | 350 } // namespace vr_shell |
OLD | NEW |