| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/ui/views/omnibox/omnibox_view_win.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <locale> | 8 #include <locale> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 2496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 // Create a paint context for drawing the antialiased stroke. | 2507 // Create a paint context for drawing the antialiased stroke. |
| 2508 SkPaint paint; | 2508 SkPaint paint; |
| 2509 paint.setAntiAlias(true); | 2509 paint.setAntiAlias(true); |
| 2510 paint.setStrokeWidth(kStrokeWidthPixels); | 2510 paint.setStrokeWidth(kStrokeWidthPixels); |
| 2511 paint.setStrokeCap(SkPaint::kRound_Cap); | 2511 paint.setStrokeCap(SkPaint::kRound_Cap); |
| 2512 | 2512 |
| 2513 // Create a canvas as large as |scheme_rect| to do our drawing, and initialize | 2513 // Create a canvas as large as |scheme_rect| to do our drawing, and initialize |
| 2514 // it to fully transparent so any antialiasing will look nice when painted | 2514 // it to fully transparent so any antialiasing will look nice when painted |
| 2515 // atop the edit. | 2515 // atop the edit. |
| 2516 gfx::Canvas canvas(gfx::Size(scheme_rect.Width(), scheme_rect.Height()), | 2516 gfx::Canvas canvas(gfx::Size(scheme_rect.Width(), scheme_rect.Height()), |
| 2517 ui::SCALE_FACTOR_100P, false); | 2517 1.0f, false); |
| 2518 SkCanvas* sk_canvas = canvas.sk_canvas(); | 2518 SkCanvas* sk_canvas = canvas.sk_canvas(); |
| 2519 sk_canvas->getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0); | 2519 sk_canvas->getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0); |
| 2520 | 2520 |
| 2521 // Calculate the start and end of the stroke, which are just the lower left | 2521 // Calculate the start and end of the stroke, which are just the lower left |
| 2522 // and upper right corners of the canvas, inset by the radius of the endcap | 2522 // and upper right corners of the canvas, inset by the radius of the endcap |
| 2523 // so we don't clip the endcap off. | 2523 // so we don't clip the endcap off. |
| 2524 const SkScalar kEndCapRadiusPixels = kStrokeWidthPixels / SkIntToScalar(2); | 2524 const SkScalar kEndCapRadiusPixels = kStrokeWidthPixels / SkIntToScalar(2); |
| 2525 const SkPoint start_point = { | 2525 const SkPoint start_point = { |
| 2526 kEndCapRadiusPixels, | 2526 kEndCapRadiusPixels, |
| 2527 SkIntToScalar(scheme_rect.Height()) - kEndCapRadiusPixels }; | 2527 SkIntToScalar(scheme_rect.Height()) - kEndCapRadiusPixels }; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2802 } | 2802 } |
| 2803 | 2803 |
| 2804 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2804 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
| 2805 // Use font_list_.GetPrimaryFont().GetStringWidth() instead of | 2805 // Use font_list_.GetPrimaryFont().GetStringWidth() instead of |
| 2806 // PosFromChar(GetTextLength()) because PosFromChar() is apparently buggy. | 2806 // PosFromChar(GetTextLength()) because PosFromChar() is apparently buggy. |
| 2807 // In both LTR UI and RTL UI with left-to-right layout, PosFromChar(i) might | 2807 // In both LTR UI and RTL UI with left-to-right layout, PosFromChar(i) might |
| 2808 // return 0 when i is greater than 1. | 2808 // return 0 when i is greater than 1. |
| 2809 return font_list_.GetPrimaryFont().GetStringWidth(text) + | 2809 return font_list_.GetPrimaryFont().GetStringWidth(text) + |
| 2810 GetHorizontalMargin(); | 2810 GetHorizontalMargin(); |
| 2811 } | 2811 } |
| OLD | NEW |