Index: chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.mm |
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.mm b/chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.mm |
index d173e32b084ca2887c8a68aaff78eb52ba0a0c04..2638d712d8d2cf823d770b970e45c00aa3835a7b 100644 |
--- a/chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.mm |
+++ b/chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.mm |
@@ -8,8 +8,8 @@ |
#include "base/logging.h" |
#include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
+#include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h" |
#import "chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.h" |
-#include "ui/base/cocoa/window_size_constants.h" |
#include "ui/gfx/rect.h" |
namespace autofill { |
@@ -17,28 +17,14 @@ namespace autofill { |
AutofillPopupViewBridge::AutofillPopupViewBridge( |
AutofillPopupController* controller) |
: controller_(controller) { |
- window_ = |
- [[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater |
- styleMask:NSBorderlessWindowMask |
- backing:NSBackingStoreBuffered |
- defer:YES]; |
- // Telling Cocoa that the window is opaque enables some drawing optimizations. |
- [window_ setOpaque:YES]; |
- |
- view_ = [[[AutofillPopupViewCocoa alloc] |
- initWithController:controller_ |
- frame:NSZeroRect] autorelease]; |
- [window_ setContentView:view_]; |
+ view_.reset( |
+ [[AutofillPopupViewCocoa alloc] initWithController:controller |
+ frame:NSZeroRect]); |
} |
AutofillPopupViewBridge::~AutofillPopupViewBridge() { |
[view_ controllerDestroyed]; |
- |
- // Remove the child window before closing, otherwise it can mess up |
- // display ordering. |
- [[window_ parentWindow] removeChildWindow:window_]; |
- |
- [window_ close]; |
+ [view_ hidePopup]; |
} |
void AutofillPopupViewBridge::Hide() { |
@@ -46,31 +32,15 @@ void AutofillPopupViewBridge::Hide() { |
} |
void AutofillPopupViewBridge::Show() { |
- UpdateBoundsAndRedrawPopup(); |
- [[controller_->container_view() window] addChildWindow:window_ |
- ordered:NSWindowAbove]; |
+ [view_ showPopup]; |
} |
void AutofillPopupViewBridge::InvalidateRow(size_t row) { |
- NSRect dirty_rect = |
- NSRectFromCGRect(controller_->GetRowBounds(row).ToCGRect()); |
- [view_ setNeedsDisplayInRect:dirty_rect]; |
+ [view_ invalidateRow:row]; |
} |
void AutofillPopupViewBridge::UpdateBoundsAndRedrawPopup() { |
- NSRect frame = NSRectFromCGRect(controller_->popup_bounds().ToCGRect()); |
- |
- // Flip coordinates back into Cocoa-land. The controller's platform-neutral |
- // coordinate space places the origin at the top-left of the first screen, |
- // whereas Cocoa's coordinate space expects the origin to be at the |
- // bottom-left of this same screen. |
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; |
- frame.origin.y = NSMaxY([screen frame]) - NSMaxY(frame); |
- |
- // TODO(isherman): The view should support scrolling if the popup gets too |
- // big to fit on the screen. |
- [window_ setFrame:frame display:YES]; |
- [view_ setNeedsDisplay:YES]; |
+ [view_ updateBoundsAndRedrawPopup]; |
} |
AutofillPopupView* AutofillPopupView::Create( |