OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 7 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
8 | 8 |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // content view. | 312 // content view. |
313 if (popup_ && [[[popup_ contentView] subviews] count]) { | 313 if (popup_ && [[[popup_ contentView] subviews] count]) { |
314 NSArray* subviews = [[popup_ contentView] subviews]; | 314 NSArray* subviews = [[popup_ contentView] subviews]; |
315 DCHECK_GE([subviews count], 0U); | 315 DCHECK_GE([subviews count], 0U); |
316 return (AutocompleteMatrix*)[subviews objectAtIndex:0]; | 316 return (AutocompleteMatrix*)[subviews objectAtIndex:0]; |
317 } | 317 } |
318 return nil; | 318 return nil; |
319 } | 319 } |
320 | 320 |
321 bool AutocompletePopupViewMac::IsOpen() const { | 321 bool AutocompletePopupViewMac::IsOpen() const { |
322 return [popup_ isVisible] ? true : false; | 322 return popup_ != nil; |
323 } | 323 } |
324 | 324 |
325 void AutocompletePopupViewMac::CreatePopupIfNeeded() { | 325 void AutocompletePopupViewMac::CreatePopupIfNeeded() { |
326 if (!popup_) { | 326 if (!popup_) { |
327 popup_.reset([[NSWindow alloc] initWithContentRect:NSZeroRect | 327 popup_.reset([[NSWindow alloc] initWithContentRect:NSZeroRect |
328 styleMask:NSBorderlessWindowMask | 328 styleMask:NSBorderlessWindowMask |
329 backing:NSBackingStoreBuffered | 329 backing:NSBackingStoreBuffered |
330 defer:YES]); | 330 defer:YES]); |
331 [popup_ setMovableByWindowBackground:NO]; | 331 [popup_ setMovableByWindowBackground:NO]; |
332 // The window shape is determined by the content view (OmniboxPopupView). | 332 // The window shape is determined by the content view (OmniboxPopupView). |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 [[NSAnimationContext currentContext] setDuration:kShrinkAnimationDuration]; | 402 [[NSAnimationContext currentContext] setDuration:kShrinkAnimationDuration]; |
403 [[popup_ animator] setFrame:popupFrame display:YES]; | 403 [[popup_ animator] setFrame:popupFrame display:YES]; |
404 [NSAnimationContext endGrouping]; | 404 [NSAnimationContext endGrouping]; |
405 | 405 |
406 if (!animate) { | 406 if (!animate) { |
407 // Restore the original animations dictionary. This does not reinstate any | 407 // Restore the original animations dictionary. This does not reinstate any |
408 // previously running animations. | 408 // previously running animations. |
409 [popup_ setAnimations:savedAnimations]; | 409 [popup_ setAnimations:savedAnimations]; |
410 } | 410 } |
411 | 411 |
412 if (!IsOpen()) | 412 if (![popup_ isVisible]) |
413 [[field_ window] addChildWindow:popup_ ordered:NSWindowAbove]; | 413 [[field_ window] addChildWindow:popup_ ordered:NSWindowAbove]; |
414 } | 414 } |
415 | 415 |
416 NSImage* AutocompletePopupViewMac::ImageForMatch( | 416 NSImage* AutocompletePopupViewMac::ImageForMatch( |
417 const AutocompleteMatch& match) { | 417 const AutocompleteMatch& match) { |
418 const SkBitmap* bitmap = model_->GetSpecialIconForMatch(match); | 418 const SkBitmap* bitmap = model_->GetSpecialIconForMatch(match); |
419 if (bitmap) | 419 if (bitmap) |
420 return gfx::SkBitmapToNSImage(*bitmap); | 420 return gfx::SkBitmapToNSImage(*bitmap); |
421 | 421 |
422 const int resource_id = match.starred ? | 422 const int resource_id = match.starred ? |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 bottomRightCornerRadius:kPopupRoundingRadius]; | 821 bottomRightCornerRadius:kPopupRoundingRadius]; |
822 | 822 |
823 // Draw the matrix clipped to our border. | 823 // Draw the matrix clipped to our border. |
824 [NSGraphicsContext saveGraphicsState]; | 824 [NSGraphicsContext saveGraphicsState]; |
825 [path addClip]; | 825 [path addClip]; |
826 [super drawRect:rect]; | 826 [super drawRect:rect]; |
827 [NSGraphicsContext restoreGraphicsState]; | 827 [NSGraphicsContext restoreGraphicsState]; |
828 } | 828 } |
829 | 829 |
830 @end | 830 @end |
OLD | NEW |