OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autocomplete/autocomplete_result_view.h" | 5 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h" |
6 | 6 |
7 #include "base/i18n/bidi_line_iterator.h" | 7 #include "base/i18n/bidi_line_iterator.h" |
8 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view_model.h" | 8 #include "chrome/browser/ui/views/autocomplete/autocomplete_result_view_model.h" |
9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 // The minimum distance between the top and bottom of the {icon|text} and the | 27 // The minimum distance between the top and bottom of the {icon|text} and the |
28 // top or bottom of the row. | 28 // top or bottom of the row. |
29 const int kMinimumIconVerticalPadding = 2; | 29 const int kMinimumIconVerticalPadding = 2; |
30 const int kMinimumTextVerticalPadding = 3; | 30 const int kMinimumTextVerticalPadding = 3; |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 //////////////////////////////////////////////////////////////////////////////// | 34 //////////////////////////////////////////////////////////////////////////////// |
35 // AutocompleteResultView, public: | 35 // AutocompleteResultView, public: |
36 | 36 |
37 // Precalculated data used to draw the portion of a match classification that | |
38 // fits entirely within one run. | |
39 struct AutocompleteResultView::ClassificationData { | |
40 string16 text; | |
41 const gfx::Font* font; | |
42 SkColor color; | |
43 int pixel_width; | |
44 }; | |
45 | |
46 // Precalculated data used to draw a complete visual run within the match. | |
47 // This will include all or part of at leasdt one, and possibly several, | |
48 // classifications. | |
49 struct AutocompleteResultView::RunData { | |
50 size_t run_start; // Offset within the match text where this run begins. | |
51 int visual_order; // Where this run occurs in visual order. The earliest | |
52 // run drawn is run 0. | |
53 bool is_rtl; | |
54 int pixel_width; | |
55 Classifications classifications; // Classification pieces within this run, | |
56 // in logical order. | |
Nico
2011/03/04 22:53:02
align with // on prev line
| |
57 }; | |
58 | |
37 // This class is a utility class for calculations affected by whether the result | 59 // This class is a utility class for calculations affected by whether the result |
38 // view is horizontally mirrored. The drawing functions can be written as if | 60 // view is horizontally mirrored. The drawing functions can be written as if |
39 // all drawing occurs left-to-right, and then use this class to get the actual | 61 // all drawing occurs left-to-right, and then use this class to get the actual |
40 // coordinates to begin drawing onscreen. | 62 // coordinates to begin drawing onscreen. |
41 class AutocompleteResultView::MirroringContext { | 63 class AutocompleteResultView::MirroringContext { |
42 public: | 64 public: |
43 MirroringContext() : center_(0), right_(0) {} | 65 MirroringContext() : center_(0), right_(0) {} |
44 | 66 |
45 // Tells the mirroring context to use the provided range as the physical | 67 // Tells the mirroring context to use the provided range as the physical |
46 // bounds of the drawing region. When coordinate mirroring is needed, the | 68 // bounds of the drawing region. When coordinate mirroring is needed, the |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 // * It's normal, and will be able to draw successfully with the | 489 // * It's normal, and will be able to draw successfully with the |
468 // ellipsis we'll append to it, or | 490 // ellipsis we'll append to it, or |
469 // * It is also bold, in which case we don't want to fall back | 491 // * It is also bold, in which case we don't want to fall back |
470 // to a normal ellipsis anyway (see comment above). | 492 // to a normal ellipsis anyway (see comment above). |
471 } | 493 } |
472 } | 494 } |
473 | 495 |
474 // We couldn't draw anything. | 496 // We couldn't draw anything. |
475 runs->clear(); | 497 runs->clear(); |
476 } | 498 } |
OLD | NEW |