| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2373 // Create a paint context for drawing the antialiased stroke. | 2373 // Create a paint context for drawing the antialiased stroke. |
| 2374 SkPaint paint; | 2374 SkPaint paint; |
| 2375 paint.setAntiAlias(true); | 2375 paint.setAntiAlias(true); |
| 2376 paint.setStrokeWidth(kStrokeWidthPixels); | 2376 paint.setStrokeWidth(kStrokeWidthPixels); |
| 2377 paint.setStrokeCap(SkPaint::kRound_Cap); | 2377 paint.setStrokeCap(SkPaint::kRound_Cap); |
| 2378 | 2378 |
| 2379 // Create a canvas as large as |scheme_rect| to do our drawing, and initialize | 2379 // Create a canvas as large as |scheme_rect| to do our drawing, and initialize |
| 2380 // it to fully transparent so any antialiasing will look nice when painted | 2380 // it to fully transparent so any antialiasing will look nice when painted |
| 2381 // atop the edit. | 2381 // atop the edit. |
| 2382 gfx::Canvas canvas(gfx::Size(scheme_rect.Width(), scheme_rect.Height()), | 2382 gfx::Canvas canvas(gfx::Size(scheme_rect.Width(), scheme_rect.Height()), |
| 2383 false); | 2383 ui::SCALE_FACTOR_100P, false); |
| 2384 SkCanvas* sk_canvas = canvas.sk_canvas(); | 2384 SkCanvas* sk_canvas = canvas.sk_canvas(); |
| 2385 sk_canvas->getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0); | 2385 sk_canvas->getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0); |
| 2386 | 2386 |
| 2387 // Calculate the start and end of the stroke, which are just the lower left | 2387 // Calculate the start and end of the stroke, which are just the lower left |
| 2388 // and upper right corners of the canvas, inset by the radius of the endcap | 2388 // and upper right corners of the canvas, inset by the radius of the endcap |
| 2389 // so we don't clip the endcap off. | 2389 // so we don't clip the endcap off. |
| 2390 const SkScalar kEndCapRadiusPixels = kStrokeWidthPixels / SkIntToScalar(2); | 2390 const SkScalar kEndCapRadiusPixels = kStrokeWidthPixels / SkIntToScalar(2); |
| 2391 const SkPoint start_point = { | 2391 const SkPoint start_point = { |
| 2392 kEndCapRadiusPixels, | 2392 kEndCapRadiusPixels, |
| 2393 SkIntToScalar(scheme_rect.Height()) - kEndCapRadiusPixels }; | 2393 SkIntToScalar(scheme_rect.Height()) - kEndCapRadiusPixels }; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2666 // PosFromChar(i) might return 0 when i is greater than 1. | 2666 // PosFromChar(i) might return 0 when i is greater than 1. |
| 2667 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2667 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
| 2668 } | 2668 } |
| 2669 | 2669 |
| 2670 bool OmniboxViewWin::IsCaretAtEnd() const { | 2670 bool OmniboxViewWin::IsCaretAtEnd() const { |
| 2671 long length = GetTextLength(); | 2671 long length = GetTextLength(); |
| 2672 CHARRANGE sel; | 2672 CHARRANGE sel; |
| 2673 GetSelection(sel); | 2673 GetSelection(sel); |
| 2674 return sel.cpMin == sel.cpMax && sel.cpMin == length; | 2674 return sel.cpMin == sel.cpMax && sel.cpMin == length; |
| 2675 } | 2675 } |
| OLD | NEW |