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

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: Cleaned up 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
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..2dce1d78ab380018af1b763d8ebb9bcbef60f487 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,52 @@ size_t CalculatePositionsInFrame(
[super drawInteriorWithFrame:cellFrame inView:controlView];
}
+- (BOOL)canDropAtLocationInWindow:(NSPoint)location
+ ofView:(AutocompleteTextField*)controlView {
+ NSRect cellFrame = [controlView bounds];
+ const BOOL flipped = [controlView isFlipped];
+ const NSPoint locationInView =
+ [controlView convertPoint:location fromView:nil];
+
+ // If we have decorations, the drop can't occur at their horizontal padding.
+ if (!leftDecorations_.empty()) {
+ NSRect leftPaddingFrame = cellFrame;
+ leftPaddingFrame.size.width = LeftDecorationXOffset();
+ if (NSMouseInRect(locationInView, leftPaddingFrame, flipped))
shrike 2016/09/16 18:28:41 You could also just say if (locationInView.x < Lef
spqchan 2016/09/20 21:00:00 Done.
+ return false;
+ }
+
+ if (!rightDecorations_.empty()) {
shrike 2016/09/16 18:28:41 Do you think we really need this check? Seems like
spqchan 2016/09/20 21:00:00 I think it's better to be consistent with the left
+ NSRect rightPaddingFrame = cellFrame;
+ rightPaddingFrame.origin.x = NSMaxX(cellFrame) - kRightDecorationXOffset;
+ rightPaddingFrame.size.width = kRightDecorationXOffset;
+ if (NSMouseInRect(locationInView, rightPaddingFrame, flipped))
+ 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 +478,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];
}

Powered by Google App Engine
This is Rietveld 408576698