OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" | 5 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 | 8 |
9 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" | 9 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" |
10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 static SkBitmap* icon_url_selected_; | 128 static SkBitmap* icon_url_selected_; |
129 static SkBitmap* icon_history_; | 129 static SkBitmap* icon_history_; |
130 static SkBitmap* icon_history_selected_; | 130 static SkBitmap* icon_history_selected_; |
131 static SkBitmap* icon_search_; | 131 static SkBitmap* icon_search_; |
132 static SkBitmap* icon_search_selected_; | 132 static SkBitmap* icon_search_selected_; |
133 static SkBitmap* icon_more_; | 133 static SkBitmap* icon_more_; |
134 static SkBitmap* icon_more_selected_; | 134 static SkBitmap* icon_more_selected_; |
135 static SkBitmap* icon_star_; | 135 static SkBitmap* icon_star_; |
136 static SkBitmap* icon_star_selected_; | 136 static SkBitmap* icon_star_selected_; |
137 static int icon_size_; | 137 static int icon_size_; |
138 | 138 |
139 static bool initialized_; | 139 static bool initialized_; |
140 static void InitClass(); | 140 static void InitClass(); |
141 | 141 |
142 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); | 142 DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView); |
143 }; | 143 }; |
144 | 144 |
145 // static | 145 // static |
146 SkBitmap* AutocompleteResultView::icon_url_ = NULL; | 146 SkBitmap* AutocompleteResultView::icon_url_ = NULL; |
147 SkBitmap* AutocompleteResultView::icon_url_selected_ = NULL; | 147 SkBitmap* AutocompleteResultView::icon_url_selected_ = NULL; |
148 SkBitmap* AutocompleteResultView::icon_history_ = NULL; | 148 SkBitmap* AutocompleteResultView::icon_history_ = NULL; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // Split this run with the given classifications and draw the fragments | 407 // Split this run with the given classifications and draw the fragments |
408 // into the local display context. | 408 // into the local display context. |
409 for (ACMatchClassifications::const_iterator i = classifications.begin(); | 409 for (ACMatchClassifications::const_iterator i = classifications.begin(); |
410 i != classifications.end(); ++i) { | 410 i != classifications.end(); ++i) { |
411 const int text_start = std::max(run_start, static_cast<int>(i->offset)); | 411 const int text_start = std::max(run_start, static_cast<int>(i->offset)); |
412 const int text_end = std::min(run_end, (i != classifications.end() - 1) ? | 412 const int text_end = std::min(run_end, (i != classifications.end() - 1) ? |
413 static_cast<int>((i + 1)->offset) : run_end); | 413 static_cast<int>((i + 1)->offset) : run_end); |
414 int style = i->style; | 414 int style = i->style; |
415 if (force_dim) | 415 if (force_dim) |
416 style |= ACMatchClassification::DIM; | 416 style |= ACMatchClassification::DIM; |
417 x += DrawStringFragment(canvas, | 417 if (text_start < text_end) { |
418 text.substr(text_start, text_end - text_start), | 418 x += DrawStringFragment(canvas, |
419 style, x, y); | 419 text.substr(text_start, text_end - text_start), |
| 420 style, x, y); |
| 421 } |
420 } | 422 } |
421 } | 423 } |
422 return x; | 424 return x; |
423 } | 425 } |
424 | 426 |
425 int AutocompleteResultView::DrawStringFragment( | 427 int AutocompleteResultView::DrawStringFragment( |
426 ChromeCanvas* canvas, | 428 ChromeCanvas* canvas, |
427 const std::wstring& text, | 429 const std::wstring& text, |
428 int style, | 430 int style, |
429 int x, | 431 int x, |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 void AutocompletePopupContentsView::MakeCanvasTransparent( | 794 void AutocompletePopupContentsView::MakeCanvasTransparent( |
793 ChromeCanvas* canvas) { | 795 ChromeCanvas* canvas) { |
794 // Allow the window blur effect to show through the popup background. | 796 // Allow the window blur effect to show through the popup background. |
795 SkPaint paint; | 797 SkPaint paint; |
796 paint.setColor(SkColorSetARGB(kPopupTransparency, 255, 255, 255)); | 798 paint.setColor(SkColorSetARGB(kPopupTransparency, 255, 255, 255)); |
797 paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode); | 799 paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode); |
798 paint.setStyle(SkPaint::kFill_Style); | 800 paint.setStyle(SkPaint::kFill_Style); |
799 canvas->FillRectInt(0, 0, canvas->getDevice()->width(), | 801 canvas->FillRectInt(0, 0, canvas->getDevice()->width(), |
800 canvas->getDevice()->height(), paint); | 802 canvas->getDevice()->height(), paint); |
801 } | 803 } |
802 | |
OLD | NEW |