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

Unified Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm

Issue 2324593002: [Mac] Fix for security indicator drag&drop navigation (Closed)
Patch Set: Fix for shrike Created 4 years, 3 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/location_bar/autocomplete_text_field_cell.h ('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/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];
}
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698