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..b623ea0c933c781bc495822638a3caf83d4e3cb2 100644 |
--- a/chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.mm |
+++ b/chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.mm |
@@ -8,74 +8,43 @@ |
#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 { |
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_]; |
+ AutofillPopupViewCocoa* view, AutofillPopupController* controller) |
Ilya Sherman
2014/05/09 21:51:28
nit: Please write one param per line if they don't
Patrick Dubroy
2014/05/12 14:13:39
Done.
|
+ : view_(view), controller_(controller) { |
Ilya Sherman
2014/05/09 21:51:28
nit: Likewise, please split this into two lines.
Patrick Dubroy
2014/05/12 14:13:39
Done.
|
} |
AutofillPopupViewBridge::~AutofillPopupViewBridge() { |
- [view_ controllerDestroyed]; |
- |
- // Remove the child window before closing, otherwise it can mess up |
- // display ordering. |
- [[window_ parentWindow] removeChildWindow:window_]; |
- |
- [window_ close]; |
} |
void AutofillPopupViewBridge::Hide() { |
- delete this; |
+ [view_ hidePopup]; |
Ilya Sherman
2014/05/09 21:51:28
There used to be a |delete this| call here. Who i
Patrick Dubroy
2014/05/12 14:13:39
Right, I screwed this up when I was refactoring. I
|
} |
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( |
AutofillPopupController* controller) { |
- return new AutofillPopupViewBridge(controller); |
+ AutofillPopupViewCocoa* view = |
+ [[[AutofillPopupViewCocoa alloc] |
+ initWithController:controller |
+ frame:NSZeroRect] autorelease]; |
Ilya Sherman
2014/05/09 21:51:28
Autorelease doesn't seem safe here. What prevents
Patrick Dubroy
2014/05/12 14:13:39
Hmmm, good point. I've moved this code into the co
|
+ return new AutofillPopupViewBridge(view, controller); |
} |
} // namespace autofill |