Index: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm |
diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm |
index 54dabd7e16754fdf1a212e2dc9d5c4adebf71d33..c3f190231f8d328e44d5b30fcabc94565bab9a0c 100644 |
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm |
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm |
@@ -424,13 +424,44 @@ size_t CalculatePositionsInFrame( |
[super drawInteriorWithFrame:cellFrame inView:controlView]; |
} |
+- (BOOL)canDropAtLocationInWindow:(NSPoint)location |
+ ofView:(AutocompleteTextField*)controlView { |
+ NSRect cellFrame = [controlView bounds]; |
+ const NSPoint locationInView = |
+ [controlView convertPoint:location fromView:nil]; |
+ |
+ // If we have decorations, the drop can't occur at their horizontal padding. |
+ if (!leftDecorations_.empty() && locationInView.x < LeftDecorationXOffset()) |
+ return false; |
+ |
+ if (!rightDecorations_.empty() && |
+ locationInView.x > NSWidth(cellFrame) - kRightDecorationXOffset) { |
+ return false; |
+ } |
+ |
+ LocationBarDecoration* decoration = |
+ [self decorationForLocationInWindow:location |
+ inRect:cellFrame |
+ ofView:controlView]; |
+ return !decoration; |
+} |
+ |
- (LocationBarDecoration*)decorationForEvent:(NSEvent*)theEvent |
inRect:(NSRect)cellFrame |
ofView:(AutocompleteTextField*)controlView |
{ |
+ return [self decorationForLocationInWindow:[theEvent locationInWindow] |
+ inRect:cellFrame |
+ ofView:controlView]; |
+} |
+ |
+- (LocationBarDecoration*)decorationForLocationInWindow:(NSPoint)location |
+ inRect:(NSRect)cellFrame |
+ ofView:(AutocompleteTextField*) |
+ controlView { |
const BOOL flipped = [controlView isFlipped]; |
- const NSPoint location = |
- [controlView convertPoint:[theEvent locationInWindow] fromView:nil]; |
+ const NSPoint locationInView = |
+ [controlView convertPoint:location fromView:nil]; |
std::vector<LocationBarDecoration*> decorations; |
std::vector<NSRect> decorationFrames; |
@@ -439,7 +470,7 @@ size_t CalculatePositionsInFrame( |
&decorations, &decorationFrames, &textFrame); |
for (size_t i = 0; i < decorations.size(); ++i) { |
- if (NSMouseInRect(location, decorationFrames[i], flipped)) |
+ if (NSMouseInRect(locationInView, decorationFrames[i], flipped)) |
return decorations[i]; |
} |