| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/autofill/autofill_tooltip_controller.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_tooltip_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #import "chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.h" | 8 #import "chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.h" |
| 9 #import "ui/base/cocoa/base_view.h" | 9 #import "ui/base/cocoa/base_view.h" |
| 10 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 10 #import "ui/base/cocoa/hover_image_button.h" | 11 #import "ui/base/cocoa/hover_image_button.h" |
| 11 | 12 |
| 12 // Delay time before tooltip shows/hides. | 13 // Delay time before tooltip shows/hides. |
| 13 const NSTimeInterval kTooltipDelay = 0.1; | 14 const NSTimeInterval kTooltipDelay = 0.1; |
| 14 | 15 |
| 15 // How far to inset tooltip contents. | 16 // How far to inset tooltip contents. |
| 16 CGFloat kTooltipInset = 10; | 17 CGFloat kTooltipInset = 10; |
| 17 | 18 |
| 18 #pragma mark AutofillTooltipController - private methods | 19 #pragma mark AutofillTooltipController - private methods |
| 19 | 20 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 [trackingView setAutoresizesSubviews:YES]; | 158 [trackingView setAutoresizesSubviews:YES]; |
| 158 [oldContentView setFrame:[trackingView bounds]]; | 159 [oldContentView setFrame:[trackingView bounds]]; |
| 159 [oldContentView | 160 [oldContentView |
| 160 setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; | 161 setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; |
| 161 [[bubbleController_ window] setContentView:trackingView]; | 162 [[bubbleController_ window] setContentView:trackingView]; |
| 162 [trackingView setSubviews:@[ oldContentView ]]; | 163 [trackingView setSubviews:@[ oldContentView ]]; |
| 163 | 164 |
| 164 // Compute anchor point (in window coords - views might be flipped). | 165 // Compute anchor point (in window coords - views might be flipped). |
| 165 NSRect viewRect = [view_ convertRect:[view_ bounds] toView:nil]; | 166 NSRect viewRect = [view_ convertRect:[view_ bounds] toView:nil]; |
| 166 NSPoint anchorPoint = NSMakePoint(NSMidX(viewRect), NSMinY(viewRect)); | 167 NSPoint anchorPoint = NSMakePoint(NSMidX(viewRect), NSMinY(viewRect)); |
| 167 [bubbleController_ setAnchorPoint: | 168 [bubbleController_ setAnchorPoint:ui::ConvertPointFromWindowToScreen( |
| 168 [[[self view] window] convertBaseToScreen:anchorPoint]]; | 169 [[self view] window], anchorPoint)]; |
| 169 [bubbleController_ showWindow:self]; | 170 [bubbleController_ showWindow:self]; |
| 170 } | 171 } |
| 171 | 172 |
| 172 - (void)hideHover { | 173 - (void)hideHover { |
| 173 [bubbleController_ close]; | 174 [bubbleController_ close]; |
| 174 } | 175 } |
| 175 | 176 |
| 176 - (void)setHoveringOnBubble:(BOOL)hoveringOnBubble { | 177 - (void)setHoveringOnBubble:(BOOL)hoveringOnBubble { |
| 177 isHoveringOnBubble_ = hoveringOnBubble; | 178 isHoveringOnBubble_ = hoveringOnBubble; |
| 178 [self updateTooltipDisplayState]; | 179 [self updateTooltipDisplayState]; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 192 // timer to change visibility. (Uses '!!' to force bool values) | 193 // timer to change visibility. (Uses '!!' to force bool values) |
| 193 if (!!bubbleController_ ^ !!shouldDisplayTooltip_) { | 194 if (!!bubbleController_ ^ !!shouldDisplayTooltip_) { |
| 194 SEL sel = shouldDisplayTooltip_ ? @selector(displayHover) | 195 SEL sel = shouldDisplayTooltip_ ? @selector(displayHover) |
| 195 : @selector(hideHover); | 196 : @selector(hideHover); |
| 196 [self performSelector:sel withObject:nil afterDelay:kTooltipDelay]; | 197 [self performSelector:sel withObject:nil afterDelay:kTooltipDelay]; |
| 197 } | 198 } |
| 198 } | 199 } |
| 199 } | 200 } |
| 200 | 201 |
| 201 @end | 202 @end |
| OLD | NEW |