Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4335)

Unified Diff: chrome/browser/ui/cocoa/autofill/autofill_popup_view_mac.mm

Issue 11740033: [Autofill] Add Mac implementation for the in-browser process popup view. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Flipped view, broken out mouse events, style fixes. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_popup_view_mac.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/autofill/autofill_popup_view_mac.mm
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_popup_view_mac.mm b/chrome/browser/ui/cocoa/autofill/autofill_popup_view_mac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..20e8988d586a26ec76e259d2e80486a4d6f87ced
--- /dev/null
+++ b/chrome/browser/ui/cocoa/autofill/autofill_popup_view_mac.mm
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Cocoa/Cocoa.h>
+
+#include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_mac.h"
+
+#include "base/logging.h"
+#include "chrome/browser/ui/autofill/autofill_popup_controller.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"
+
+AutofillPopupViewMac::AutofillPopupViewMac(
+ 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:[[window_ contentView] frame]] autorelease];
+ [window_ setContentView:view_];
+}
+
+AutofillPopupViewMac::~AutofillPopupViewMac() {
+ [view_ controllerDestroyed];
+ controller_->ViewDestroyed();
+
+ [window_ close];
+}
+
+void AutofillPopupViewMac::Hide() {
+ delete this;
+}
+
+void AutofillPopupViewMac::Show() {
+ SetInitialBounds();
+ UpdateBoundsAndRedrawPopup();
+ [[controller_->container_view() window] addChildWindow:window_
+ ordered:NSWindowAbove];
+}
+
+void AutofillPopupViewMac::InvalidateRow(size_t row) {
+ NSRect dirty_rect =
+ NSRectFromCGRect(controller_->GetRowBounds(row).ToCGRect());
+ [view_ setNeedsDisplayInRect:dirty_rect];
+}
+
+void AutofillPopupViewMac::UpdateBoundsAndRedrawPopup() {
+ NSRect frame = NSRectFromCGRect(controller_->popup_bounds().ToCGRect());
+
+ // Flip coordinates back into Cocoa-land.
+ // TODO(isherman): Does this handle multi-monitor setups correctly?
+ NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ frame.origin.y =
+ [screen frame].size.height - frame.origin.y - frame.size.height;
Scott Hess - ex-Googler 2013/01/10 22:02:57 This could be more compactly phrased as: frame.o
Ilya Sherman 2013/01/11 05:08:33 Done.
+
+ // TODO(isherman): The view should support scrolling if the popup gets too
+ // big to fit on the screen.
+ [window_ setFrame:frame display:YES];
+}
+
+void AutofillPopupViewMac::SetInitialBounds() {
+ // The bounds rect in Chrome's screen coordinates. The popup should be
+ // positioned just below the element which initiated it.
+ gfx::Rect bounds(controller_->element_bounds().x(),
+ controller_->element_bounds().bottom(),
+ controller_->GetPopupRequiredWidth(),
+ controller_->GetPopupRequiredHeight());
Scott Hess - ex-Googler 2013/01/10 22:02:57 I like all this better than before.
+
+ // TODO(isherman): Position the popup correctly if it can't fit below the text
+ // field: http://crbug.com/164603
+
+ controller_->SetPopupBounds(bounds);
+}
+
+AutofillPopupView* AutofillPopupView::Create(
+ AutofillPopupController* controller) {
+ return new AutofillPopupViewMac(controller);
+}
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_popup_view_mac.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698