OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #import "ui/app_list/cocoa/apps_search_results_controller.h" | 5 #import "ui/app_list/cocoa/apps_search_results_controller.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
10 #include "skia/ext/skia_utils_mac.h" | 11 #include "skia/ext/skia_utils_mac.h" |
11 #include "ui/app_list/app_list_constants.h" | 12 #include "ui/app_list/app_list_constants.h" |
12 #include "ui/app_list/app_list_model.h" | 13 #include "ui/app_list/app_list_model.h" |
13 #import "ui/app_list/cocoa/apps_search_results_model_bridge.h" | 14 #import "ui/app_list/cocoa/apps_search_results_model_bridge.h" |
14 #include "ui/app_list/search_result.h" | 15 #include "ui/app_list/search_result.h" |
15 #import "ui/base/cocoa/flipped_view.h" | 16 #import "ui/base/cocoa/flipped_view.h" |
16 #include "ui/gfx/image/image_skia_util_mac.h" | 17 #include "ui/gfx/image/image_skia_util_mac.h" |
17 | 18 |
18 namespace { | 19 namespace { |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 395 |
395 @end | 396 @end |
396 | 397 |
397 @implementation AppsSearchResultsTableView | 398 @implementation AppsSearchResultsTableView |
398 | 399 |
399 - (AppsSearchResultsController*)controller { | 400 - (AppsSearchResultsController*)controller { |
400 return base::mac::ObjCCastStrict<AppsSearchResultsController>( | 401 return base::mac::ObjCCastStrict<AppsSearchResultsController>( |
401 [self delegate]); | 402 [self delegate]); |
402 } | 403 } |
403 | 404 |
| 405 - (BOOL)canDraw { |
| 406 // AppKit doesn't call -[NSView canDrawConcurrently] which would have told it |
| 407 // that this is unsafe. Returning true from canDraw only if there is a message |
| 408 // loop ensures that no drawing occurs on a background thread. Without this, |
| 409 // ImageSkia can assert when trying to get bitmaps. http://crbug.com/417148. |
| 410 // This means unit tests will always return 'NO', but that's OK. |
| 411 return !!base::MessageLoop::current() && [super canDraw]; |
| 412 } |
| 413 |
404 - (void)mouseDown:(NSEvent*)theEvent { | 414 - (void)mouseDown:(NSEvent*)theEvent { |
405 [[self controller] mouseDown:theEvent]; | 415 [[self controller] mouseDown:theEvent]; |
406 [super mouseDown:theEvent]; | 416 [super mouseDown:theEvent]; |
407 } | 417 } |
408 | 418 |
409 - (NSMenu*)menuForEvent:(NSEvent*)theEvent { | 419 - (NSMenu*)menuForEvent:(NSEvent*)theEvent { |
410 NSPoint pointInView = [self convertPoint:[theEvent locationInWindow] | 420 NSPoint pointInView = [self convertPoint:[theEvent locationInWindow] |
411 fromView:nil]; | 421 fromView:nil]; |
412 return [[self controller] contextMenuForRow:[self rowAtPoint:pointInView]]; | 422 return [[self controller] contextMenuForRow:[self rowAtPoint:pointInView]]; |
413 } | 423 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 std::min(iconSize.height, kIconDimension)); | 464 std::min(iconSize.height, kIconDimension)); |
455 [resultIcon drawInRect:iconRect | 465 [resultIcon drawInRect:iconRect |
456 fromRect:NSZeroRect | 466 fromRect:NSZeroRect |
457 operation:NSCompositeSourceOver | 467 operation:NSCompositeSourceOver |
458 fraction:1.0 | 468 fraction:1.0 |
459 respectFlipped:YES | 469 respectFlipped:YES |
460 hints:nil]; | 470 hints:nil]; |
461 } | 471 } |
462 | 472 |
463 @end | 473 @end |
OLD | NEW |