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 // static | |
38 int AutocompleteResultView::icon_size_ = 0; | |
39 | |
40 // This class is a utility class for calculations affected by whether the result | 37 // This class is a utility class for calculations affected by whether the result |
41 // view is horizontally mirrored. The drawing functions can be written as if | 38 // view is horizontally mirrored. The drawing functions can be written as if |
42 // all drawing occurs left-to-right, and then use this class to get the actual | 39 // all drawing occurs left-to-right, and then use this class to get the actual |
43 // coordinates to begin drawing onscreen. | 40 // coordinates to begin drawing onscreen. |
44 class AutocompleteResultView::MirroringContext { | 41 class AutocompleteResultView::MirroringContext { |
45 public: | 42 public: |
46 MirroringContext() : center_(0), right_(0) {} | 43 MirroringContext() : center_(0), right_(0) {} |
47 | 44 |
48 // Tells the mirroring context to use the provided range as the physical | 45 // Tells the mirroring context to use the provided range as the physical |
49 // bounds of the drawing region. When coordinate mirroring is needed, the | 46 // bounds of the drawing region. When coordinate mirroring is needed, the |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 const RunData& rhs) { | 209 const RunData& rhs) { |
213 return lhs.run_start < rhs.run_start; | 210 return lhs.run_start < rhs.run_start; |
214 } | 211 } |
215 | 212 |
216 // static | 213 // static |
217 bool AutocompleteResultView::SortRunsVisually(const RunData& lhs, | 214 bool AutocompleteResultView::SortRunsVisually(const RunData& lhs, |
218 const RunData& rhs) { | 215 const RunData& rhs) { |
219 return lhs.visual_order < rhs.visual_order; | 216 return lhs.visual_order < rhs.visual_order; |
220 } | 217 } |
221 | 218 |
| 219 // static |
| 220 int AutocompleteResultView::icon_size_ = 0; |
| 221 |
222 AutocompleteResultView::ResultViewState | 222 AutocompleteResultView::ResultViewState |
223 AutocompleteResultView::GetState() const { | 223 AutocompleteResultView::GetState() const { |
224 if (model_->IsSelectedIndex(model_index_)) | 224 if (model_->IsSelectedIndex(model_index_)) |
225 return SELECTED; | 225 return SELECTED; |
226 return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; | 226 return model_->IsHoveredIndex(model_index_) ? HOVERED : NORMAL; |
227 } | 227 } |
228 | 228 |
229 const SkBitmap* AutocompleteResultView::GetIcon() const { | 229 const SkBitmap* AutocompleteResultView::GetIcon() const { |
230 const SkBitmap* bitmap = model_->GetSpecialIcon(model_index_); | 230 const SkBitmap* bitmap = model_->GetSpecialIcon(model_index_); |
231 if (bitmap) | 231 if (bitmap) |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // * It's normal, and will be able to draw successfully with the | 467 // * It's normal, and will be able to draw successfully with the |
468 // ellipsis we'll append to it, or | 468 // ellipsis we'll append to it, or |
469 // * It is also bold, in which case we don't want to fall back | 469 // * It is also bold, in which case we don't want to fall back |
470 // to a normal ellipsis anyway (see comment above). | 470 // to a normal ellipsis anyway (see comment above). |
471 } | 471 } |
472 } | 472 } |
473 | 473 |
474 // We couldn't draw anything. | 474 // We couldn't draw anything. |
475 runs->clear(); | 475 runs->clear(); |
476 } | 476 } |
OLD | NEW |