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

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: Created 7 years, 12 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
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..19052c2e09c8e4df1dad2a75bc7952837197f9a6
--- /dev/null
+++ b/chrome/browser/ui/cocoa/autofill/autofill_popup_view_mac.mm
@@ -0,0 +1,93 @@
+// 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];
+ // TODO(isherman): Should this be NSPopupMenuWindowLevel or perhaps
+ // NSFloatingWindowLevel or NSModalPanelWindowLevel instead?
Ilya Sherman 2013/01/04 01:24:29 Friendly Cocoa reviewers: Thoughts?
Scott Hess - ex-Googler 2013/01/05 01:06:49 Omnibox is at NSNormalWindowLevel. Levels are a b
Ilya Sherman 2013/01/05 03:14:10 Done.
+ [window_ setLevel:NSNormalWindowLevel];
+ // TODO(isherman): Are these explicit calls needed / recommended?
Ilya Sherman 2013/01/04 01:24:29 Friendly Cocoa reviewers: Thoughts?
Scott Hess - ex-Googler 2013/01/05 01:06:49 For borderless, you might need to disable moving b
Ilya Sherman 2013/01/05 03:14:10 It looks like everything works if I remove all of
+ [window_ setMovableByWindowBackground:NO];
+ [window_ setBackgroundColor:[NSColor clearColor]];
+ [window_ setAlphaValue:1.0];
+ [window_ setOpaque:YES];
+ [window_ setHasShadow:NO];
+ [window_ accessibilitySetOverrideValue:NSAccessibilityUnknownRole
+ forAttribute:NSAccessibilityRoleAttribute];
+
+ view_ = [[[AutofillPopupViewCocoa alloc]
+ initWithController:controller_
+ frame:[window_ frame]] autorelease];
+ [window_ setContentView:view_];
+}
+
+AutofillPopupViewMac::~AutofillPopupViewMac() {
+ [view_ controllerDestroyed];
Scott Hess - ex-Googler 2013/01/05 01:06:49 Since this is called from the destructor, you migh
Ilya Sherman 2013/01/05 03:14:10 Sorry, I'm confused -- document where?
Scott Hess - ex-Googler 2013/01/09 21:36:17 I mean that -controllerDestroyed cannot send any m
Ilya Sherman 2013/01/10 02:21:21 Done.
+ 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) {
+ gfx::Rect dirty_rect = controller_->GetRowBounds(row);
+ [view_ setNeedsDisplayInRect:[view_ flipRectToNSRect:dirty_rect]];
+}
+
+void AutofillPopupViewMac::UpdateBoundsAndRedrawPopup() {
+ [window_ setFrame:NSRectFromCGRect(controller_->popup_bounds().ToCGRect())
+ display:YES];
+}
+
+void AutofillPopupViewMac::SetInitialBounds() {
+ // The bounds rect in Chrome's screen coordinates.
+ // TODO(isherman): Does this handle Hi-DPI mode correctly? According to the
+ // docs, the origin should be in screen coordinates, whereas the size should
+ // be in view coordinates.
Ilya Sherman 2013/01/04 01:24:29 Friendly Cocoa reviewers: Thoughts?
Scott Hess - ex-Googler 2013/01/05 01:06:49 I think I'm going to need to patch this in and loo
Ilya Sherman 2013/01/05 03:14:10 As preconditions, you'll need to enable the flag f
Scott Hess - ex-Googler 2013/01/09 21:36:17 Weird. When I double-click a field, then click (e
Ilya Sherman 2013/01/10 02:21:21 Huh, I don't see that behavior. I guess this mean
Ilya Sherman 2013/01/10 04:17:15 According to the docs, the separators do indeed me
+ gfx::Rect bounds(controller_->element_bounds().x(),
+ controller_->element_bounds().bottom(),
+ controller_->GetPopupRequiredWidth(),
+ controller_->GetPopupRequiredHeight());
+
+ // Flip coordinates back into Cocoa-land.
+ // TODO(isherman): Does this handle multi-monitor setups correctly?
+ NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ bounds.set_y([screen frame].size.height - bounds.y() - bounds.height());
+
+ // 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);
+}

Powered by Google App Engine
This is Rietveld 408576698