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 "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 12 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
14 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 14 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
15 #include "chrome/browser/instant/instant_confirm_dialog.h" | 15 #include "chrome/browser/instant/instant_confirm_dialog.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/cocoa/event_utils.h" | 17 #include "chrome/browser/ui/cocoa/event_utils.h" |
18 #include "chrome/browser/ui/cocoa/image_utils.h" | 18 #include "chrome/browser/ui/cocoa/image_utils.h" |
19 #import "chrome/browser/ui/cocoa/location_bar/omnibox_popup_view.h" | 19 #import "chrome/browser/ui/cocoa/location_bar/omnibox_popup_view.h" |
20 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 20 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
21 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
22 #include "skia/ext/skia_utils_mac.h" | 22 #include "skia/ext/skia_utils_mac.h" |
23 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" | 23 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" |
24 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" | 24 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" |
| 25 #include "ui/base/cocoa/window_size_constants.h" |
25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/base/text/text_elider.h" | 27 #include "ui/base/text/text_elider.h" |
27 #include "ui/gfx/rect.h" | 28 #include "ui/gfx/rect.h" |
28 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 29 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 // The size delta between the font used for the edit and the result | 33 // The size delta between the font used for the edit and the result |
33 // rows. | 34 // rows. |
34 const int kEditFontAdjust = -1; | 35 const int kEditFontAdjust = -1; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 } | 316 } |
316 return nil; | 317 return nil; |
317 } | 318 } |
318 | 319 |
319 bool OmniboxPopupViewMac::IsOpen() const { | 320 bool OmniboxPopupViewMac::IsOpen() const { |
320 return popup_ != nil; | 321 return popup_ != nil; |
321 } | 322 } |
322 | 323 |
323 void OmniboxPopupViewMac::CreatePopupIfNeeded() { | 324 void OmniboxPopupViewMac::CreatePopupIfNeeded() { |
324 if (!popup_) { | 325 if (!popup_) { |
325 popup_.reset([[NSWindow alloc] initWithContentRect:NSZeroRect | 326 popup_.reset( |
326 styleMask:NSBorderlessWindowMask | 327 [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater |
327 backing:NSBackingStoreBuffered | 328 styleMask:NSBorderlessWindowMask |
328 defer:YES]); | 329 backing:NSBackingStoreBuffered |
| 330 defer:YES]); |
329 [popup_ setMovableByWindowBackground:NO]; | 331 [popup_ setMovableByWindowBackground:NO]; |
330 // The window shape is determined by the content view (OmniboxPopupView). | 332 // The window shape is determined by the content view (OmniboxPopupView). |
331 [popup_ setAlphaValue:1.0]; | 333 [popup_ setAlphaValue:1.0]; |
332 [popup_ setOpaque:NO]; | 334 [popup_ setOpaque:NO]; |
333 [popup_ setBackgroundColor:[NSColor clearColor]]; | 335 [popup_ setBackgroundColor:[NSColor clearColor]]; |
334 [popup_ setHasShadow:YES]; | 336 [popup_ setHasShadow:YES]; |
335 [popup_ setLevel:NSNormalWindowLevel]; | 337 [popup_ setLevel:NSNormalWindowLevel]; |
336 | 338 |
337 scoped_nsobject<AutocompleteMatrix> matrix( | 339 scoped_nsobject<AutocompleteMatrix> matrix( |
338 [[AutocompleteMatrix alloc] initWithPopupView:this]); | 340 [[AutocompleteMatrix alloc] initWithPopupView:this]); |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 bottomLeftCornerRadius:kPopupRoundingRadius | 788 bottomLeftCornerRadius:kPopupRoundingRadius |
787 bottomRightCornerRadius:kPopupRoundingRadius]; | 789 bottomRightCornerRadius:kPopupRoundingRadius]; |
788 | 790 |
789 // Draw the matrix clipped to our border. | 791 // Draw the matrix clipped to our border. |
790 gfx::ScopedNSGraphicsContextSaveGState scopedGState; | 792 gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
791 [path addClip]; | 793 [path addClip]; |
792 [super drawRect:rect]; | 794 [super drawRect:rect]; |
793 } | 795 } |
794 | 796 |
795 @end | 797 @end |
OLD | NEW |