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

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

Issue 82593002: [rAC, OSX] Align bubble arrow based on location. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More comment fixes. Created 7 years, 1 month 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_bubble_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/autofill/autofill_details_container.mm
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm
index ee4ee05773429ab1bbd2400f997e1dab892a649e..84be672f368208bc7c342324eb3eaf0837dcab15 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_details_container.mm
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.h"
#import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h"
+#import "chrome/browser/ui/cocoa/info_bubble_view.h"
@implementation AutofillDetailsContainer
@@ -157,14 +158,6 @@
}
}
-- (NSPoint)anchorPointFromView:(NSView*)view {
- // All math done in window coordinates, since views might be flipped.
- NSRect viewRect = [view convertRect:[view bounds] toView:nil];
- NSPoint anchorPoint =
- NSMakePoint(NSMidX(viewRect), NSMinY(viewRect));
- return [[view window] convertBaseToScreen:anchorPoint];
-}
-
- (void)errorBubbleWindowWillClose:(NSNotification*)notification {
DCHECK_EQ([notification object], [errorBubbleController_ window]);
@@ -195,7 +188,28 @@
// Compute anchor point (in window coords - views might be flipped).
NSRect viewRect = [field convertRect:[field bounds] toView:nil];
- NSPoint anchorPoint = NSMakePoint(NSMidX(viewRect), NSMinY(viewRect));
+
+ // If a bubble at maximum size with a left-aligned edge would exceed the
+ // window width, align the right edge of bubble and view. In all other
+ // cases, align the left edge of the bubble and the view.
+ // Alignment is based on maximum width to avoid the arrow changing positions
+ // if the validation bubble stays on the same field but gets a message of
+ // differing length. (E.g. "Field is required"/"Invalid Zip Code. Please
+ // check and try again" if an empty zip field gets changed to a bad zip).
+ NSPoint anchorPoint;
+ if ((NSMinX(viewRect) + [errorBubbleController_ maxWidth]) >
+ NSWidth([parentWindow frame])) {
+ anchorPoint = NSMakePoint(NSMaxX(viewRect), NSMinY(viewRect));
+ [[errorBubbleController_ bubble] setArrowLocation:info_bubble::kTopRight];
+ [[errorBubbleController_ bubble] setAlignment:
+ info_bubble::kAlignRightEdgeToAnchorEdge];
+
+ } else {
+ anchorPoint = NSMakePoint(NSMinX(viewRect), NSMinY(viewRect));
+ [[errorBubbleController_ bubble] setArrowLocation:info_bubble::kTopLeft];
+ [[errorBubbleController_ bubble] setAlignment:
+ info_bubble::kAlignLeftEdgeToAnchorEdge];
+ }
[errorBubbleController_ setAnchorPoint:
[parentWindow convertBaseToScreen:anchorPoint]];
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698