| 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 "ui/app_list/search_result_view.h" | 5 #include "ui/app_list/search_result_view.h" |
| 6 | 6 |
| 7 #include "ui/app_list/search_result.h" | 7 #include "ui/app_list/search_result.h" |
| 8 #include "ui/app_list/search_result_list_view.h" | 8 #include "ui/app_list/search_result_list_view.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/font.h" | 10 #include "ui/gfx/font.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 void SearchResultView::OnIconChanged() { | 207 void SearchResultView::OnIconChanged() { |
| 208 gfx::ImageSkia image(result_ ? result_->icon() : gfx::ImageSkia()); | 208 gfx::ImageSkia image(result_ ? result_->icon() : gfx::ImageSkia()); |
| 209 // Note this might leave the view with an old icon. But it is needed to avoid | 209 // Note this might leave the view with an old icon. But it is needed to avoid |
| 210 // flash when a SearchResult's icon is loaded asynchronously. In this case, it | 210 // flash when a SearchResult's icon is loaded asynchronously. In this case, it |
| 211 // looks nicer to keep the stale icon for a little while on screen instead of | 211 // looks nicer to keep the stale icon for a little while on screen instead of |
| 212 // clearing it out. It should work correctly as long as the SearchResult does | 212 // clearing it out. It should work correctly as long as the SearchResult does |
| 213 // not forget to SetIcon when it's ready. | 213 // not forget to SetIcon when it's ready. |
| 214 if (image.empty()) | 214 if (image.isNull()) |
| 215 return; | 215 return; |
| 216 | 216 |
| 217 // Scales down big icons but leave small ones unchanged. | 217 // Scales down big icons but leave small ones unchanged. |
| 218 if (image.width() > kIconDimension || image.height() > kIconDimension) | 218 if (image.width() > kIconDimension || image.height() > kIconDimension) |
| 219 icon_->SetImageSize(gfx::Size(kIconDimension, kIconDimension)); | 219 icon_->SetImageSize(gfx::Size(kIconDimension, kIconDimension)); |
| 220 else | 220 else |
| 221 icon_->ResetImageSize(); | 221 icon_->ResetImageSize(); |
| 222 | 222 |
| 223 icon_->SetImage(image); | 223 icon_->SetImage(image); |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace app_list | 226 } // namespace app_list |
| OLD | NEW |