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/message_loop/message_loop.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 395 |
396 @end | 396 @end |
397 | 397 |
398 @implementation AppsSearchResultsTableView | 398 @implementation AppsSearchResultsTableView |
399 | 399 |
400 - (AppsSearchResultsController*)controller { | 400 - (AppsSearchResultsController*)controller { |
401 return base::mac::ObjCCastStrict<AppsSearchResultsController>( | 401 return base::mac::ObjCCastStrict<AppsSearchResultsController>( |
402 [self delegate]); | 402 [self delegate]); |
403 } | 403 } |
404 | 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 | |
414 - (void)mouseDown:(NSEvent*)theEvent { | 405 - (void)mouseDown:(NSEvent*)theEvent { |
415 [[self controller] mouseDown:theEvent]; | 406 [[self controller] mouseDown:theEvent]; |
416 [super mouseDown:theEvent]; | 407 [super mouseDown:theEvent]; |
417 } | 408 } |
418 | 409 |
419 - (NSMenu*)menuForEvent:(NSEvent*)theEvent { | 410 - (NSMenu*)menuForEvent:(NSEvent*)theEvent { |
420 NSPoint pointInView = [self convertPoint:[theEvent locationInWindow] | 411 NSPoint pointInView = [self convertPoint:[theEvent locationInWindow] |
421 fromView:nil]; | 412 fromView:nil]; |
422 return [[self controller] contextMenuForRow:[self rowAtPoint:pointInView]]; | 413 return [[self controller] contextMenuForRow:[self rowAtPoint:pointInView]]; |
423 } | 414 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 std::min(iconSize.height, kIconDimension)); | 455 std::min(iconSize.height, kIconDimension)); |
465 [resultIcon drawInRect:iconRect | 456 [resultIcon drawInRect:iconRect |
466 fromRect:NSZeroRect | 457 fromRect:NSZeroRect |
467 operation:NSCompositeSourceOver | 458 operation:NSCompositeSourceOver |
468 fraction:1.0 | 459 fraction:1.0 |
469 respectFlipped:YES | 460 respectFlipped:YES |
470 hints:nil]; | 461 hints:nil]; |
471 } | 462 } |
472 | 463 |
473 @end | 464 @end |
OLD | NEW |