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 // For WinDDK ATL compatibility, these ATL headers must come first. | 5 // For WinDDK ATL compatibility, these ATL headers must come first. |
6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <atlbase.h> // NOLINT | 8 #include <atlbase.h> // NOLINT |
9 #include <atlwin.h> // NOLINT | 9 #include <atlwin.h> // NOLINT |
10 #endif | 10 #endif |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 private: | 99 private: |
100 int center_; | 100 int center_; |
101 int right_; | 101 int right_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(MirroringContext); | 103 DISALLOW_COPY_AND_ASSIGN(MirroringContext); |
104 }; | 104 }; |
105 | 105 |
106 OmniboxResultView::OmniboxResultView( | 106 OmniboxResultView::OmniboxResultView( |
107 OmniboxResultViewModel* model, | 107 OmniboxResultViewModel* model, |
108 int model_index, | 108 int model_index, |
109 views::View* location_bar, | 109 OmniboxViewDelegate* view_delegate, |
110 const gfx::Font& font) | 110 const gfx::Font& font) |
111 : edge_item_padding_(LocationBarView::GetItemPadding()), | 111 : edge_item_padding_(LocationBarView::GetItemPadding()), |
112 item_padding_(LocationBarView::GetItemPadding()), | 112 item_padding_(LocationBarView::GetItemPadding()), |
113 minimum_text_vertical_padding_(kMinimumTextVerticalPadding), | 113 minimum_text_vertical_padding_(kMinimumTextVerticalPadding), |
114 model_(model), | 114 model_(model), |
115 model_index_(model_index), | 115 model_index_(model_index), |
116 location_bar_(location_bar), | 116 view_delegate_(view_delegate), |
117 font_(font), | 117 font_(font), |
118 font_height_(std::max(font.GetHeight(), | 118 font_height_(std::max(font.GetHeight(), |
119 font.DeriveFont(0, gfx::BOLD).GetHeight())), | 119 font.DeriveFont(0, gfx::BOLD).GetHeight())), |
120 ellipsis_width_(font.GetStringWidth(string16(kEllipsis))), | 120 ellipsis_width_(font.GetStringWidth(string16(kEllipsis))), |
121 mirroring_context_(new MirroringContext()), | 121 mirroring_context_(new MirroringContext()), |
122 keyword_icon_(new views::ImageView()), | 122 keyword_icon_(new views::ImageView()), |
123 animation_(new ui::SlideAnimation(this)) { | 123 animation_(new ui::SlideAnimation(this)) { |
124 CHECK_GE(model_index, 0); | 124 CHECK_GE(model_index, 0); |
125 if (default_icon_size_ == 0) { | 125 if (default_icon_size_ == 0) { |
126 default_icon_size_ = | 126 default_icon_size_ = |
127 location_bar_->GetThemeProvider()->GetImageSkiaNamed( | 127 view_delegate_->GetThemeProviderForPopup()->GetImageSkiaNamed( |
128 AutocompleteMatch::TypeToIcon( | 128 AutocompleteMatch::TypeToIcon( |
129 AutocompleteMatchType::URL_WHAT_YOU_TYPED))->width(); | 129 AutocompleteMatchType::URL_WHAT_YOU_TYPED))->width(); |
130 } | 130 } |
131 keyword_icon_->set_owned_by_client(); | 131 keyword_icon_->set_owned_by_client(); |
132 keyword_icon_->EnableCanvasFlippingForRTLUI(true); | 132 keyword_icon_->EnableCanvasFlippingForRTLUI(true); |
133 keyword_icon_->SetImage(GetKeywordIcon()); | 133 keyword_icon_->SetImage(GetKeywordIcon()); |
134 keyword_icon_->SizeToPreferredSize(); | 134 keyword_icon_->SizeToPreferredSize(); |
135 } | 135 } |
136 | 136 |
137 OmniboxResultView::~OmniboxResultView() { | 137 OmniboxResultView::~OmniboxResultView() { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 classifications.push_back( | 240 classifications.push_back( |
241 ACMatchClassification(0, ACMatchClassification::NONE)); | 241 ACMatchClassification(0, ACMatchClassification::NONE)); |
242 x = DrawString(canvas, separator, classifications, true, x, | 242 x = DrawString(canvas, separator, classifications, true, x, |
243 text_bounds_.y()); | 243 text_bounds_.y()); |
244 | 244 |
245 DrawString(canvas, match.description, match.description_class, true, x, | 245 DrawString(canvas, match.description, match.description_class, true, x, |
246 text_bounds_.y()); | 246 text_bounds_.y()); |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 int OmniboxResultView::GetTextHeight() const { | 250 int OmniboxResultView::GetTextHeight() const { |
Peter Kasting
2013/06/06 18:52:16
Nit: Move this definition up to continue to match
| |
251 return font_height_; | 251 return font_height_; |
252 } | 252 } |
253 | 253 |
254 // static | 254 // static |
255 void OmniboxResultView::CommonInitColors(const ui::NativeTheme* theme, | 255 void OmniboxResultView::CommonInitColors(const ui::NativeTheme* theme, |
256 SkColor colors[][NUM_KINDS]) { | 256 SkColor colors[][NUM_KINDS]) { |
257 colors[HOVERED][BACKGROUND] = | 257 colors[HOVERED][BACKGROUND] = |
258 color_utils::AlphaBlend(colors[SELECTED][BACKGROUND], | 258 color_utils::AlphaBlend(colors[SELECTED][BACKGROUND], |
259 colors[NORMAL][BACKGROUND], 64); | 259 colors[NORMAL][BACKGROUND], 64); |
260 colors[HOVERED][TEXT] = colors[NORMAL][TEXT]; | 260 colors[HOVERED][TEXT] = colors[NORMAL][TEXT]; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 icon = IDR_OMNIBOX_SEARCH_SELECTED; | 318 icon = IDR_OMNIBOX_SEARCH_SELECTED; |
319 break; | 319 break; |
320 case IDR_OMNIBOX_STAR: | 320 case IDR_OMNIBOX_STAR: |
321 icon = IDR_OMNIBOX_STAR_SELECTED; | 321 icon = IDR_OMNIBOX_STAR_SELECTED; |
322 break; | 322 break; |
323 default: | 323 default: |
324 NOTREACHED(); | 324 NOTREACHED(); |
325 break; | 325 break; |
326 } | 326 } |
327 } | 327 } |
328 return *(location_bar_->GetThemeProvider()->GetImageSkiaNamed(icon)); | 328 return *(view_delegate_->GetThemeProviderForPopup()->GetImageSkiaNamed(icon)); |
329 } | 329 } |
330 | 330 |
331 const gfx::ImageSkia* OmniboxResultView::GetKeywordIcon() const { | 331 const gfx::ImageSkia* OmniboxResultView::GetKeywordIcon() const { |
332 // NOTE: If we ever begin returning icons of varying size, then callers need | 332 // NOTE: If we ever begin returning icons of varying size, then callers need |
333 // to ensure that |keyword_icon_| is resized each time its image is reset. | 333 // to ensure that |keyword_icon_| is resized each time its image is reset. |
334 return location_bar_->GetThemeProvider()->GetImageSkiaNamed( | 334 return view_delegate_->GetThemeProviderForPopup()->GetImageSkiaNamed( |
335 (GetState() == SELECTED) ? IDR_OMNIBOX_TTS_SELECTED : IDR_OMNIBOX_TTS); | 335 (GetState() == SELECTED) ? IDR_OMNIBOX_TTS_SELECTED : IDR_OMNIBOX_TTS); |
336 } | 336 } |
337 | 337 |
338 int OmniboxResultView::DrawString( | 338 int OmniboxResultView::DrawString( |
339 gfx::Canvas* canvas, | 339 gfx::Canvas* canvas, |
340 const string16& text, | 340 const string16& text, |
341 const ACMatchClassifications& classifications, | 341 const ACMatchClassifications& classifications, |
342 bool force_dim, | 342 bool force_dim, |
343 int x, | 343 int x, |
344 int y) { | 344 int y) { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
623 int x = GetMirroredXForRect(keyword_text_bounds_); | 623 int x = GetMirroredXForRect(keyword_text_bounds_); |
624 mirroring_context_->Initialize(x, keyword_text_bounds_.width()); | 624 mirroring_context_->Initialize(x, keyword_text_bounds_.width()); |
625 PaintMatch(canvas, *match_.associated_keyword.get(), x); | 625 PaintMatch(canvas, *match_.associated_keyword.get(), x); |
626 } | 626 } |
627 } | 627 } |
628 | 628 |
629 void OmniboxResultView::AnimationProgressed(const ui::Animation* animation) { | 629 void OmniboxResultView::AnimationProgressed(const ui::Animation* animation) { |
630 Layout(); | 630 Layout(); |
631 SchedulePaint(); | 631 SchedulePaint(); |
632 } | 632 } |
OLD | NEW |