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

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

Issue 2972593002: Mac: Fix up location bar decoration bubble anchoring. (Closed)
Patch Set: Created 3 years, 5 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/content_setting_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm b/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm
index 160f4ffff7c78ee092929603a6cfeefa36e95bf0..ed9a57af231f9199576e2d439558c19ae87310e1 100644
--- a/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm
@@ -17,6 +17,7 @@
#import "chrome/browser/ui/cocoa/l10n_util.h"
#include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
+#import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
#import "chrome/browser/ui/cocoa/themed_window.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
@@ -37,10 +38,6 @@ using content::WebContents;
namespace {
-// The bubble point should look like it points to the bottom of the respective
-// icon. The offset should be 2px.
-const CGFloat kPageBubblePointYOffset = 2.0;
-
// Duration of animation, 3 seconds. The ContentSettingAnimationState breaks
// this up into different states of varying lengths.
const NSTimeInterval kAnimationDuration = 3.0;
@@ -269,9 +266,9 @@ NSPoint ContentSettingDecoration::GetBubblePointInFrame(NSRect frame) {
if (!cocoa_l10n_util::ShouldDoExperimentalRTLLayout())
frame.origin.x += frame.size.width - image_size.width;
frame.size = image_size;
- const NSRect draw_frame = GetDrawRectInFrame(frame);
- return NSMakePoint(NSMidX(draw_frame),
- NSMaxY(draw_frame) + kPageBubblePointYOffset);
+
+ // Position the same way as the bookmark star.
+ return StarDecoration::GetStarBubblePointInFrame(GetDrawRectInFrame(frame));
}
bool ContentSettingDecoration::AcceptsMousePress() {
@@ -285,14 +282,8 @@ bool ContentSettingDecoration::OnMousePressed(NSRect frame, NSPoint location) {
if (!web_contents)
return true;
- // Find point for bubble's arrow in screen coordinates.
- // TODO(shess): |owner_| is only being used to fetch |field|.
- // Consider passing in |control_view|. Or refactoring to be
- // consistent with other decorations (which don't currently bring up
- // their bubble directly).
AutocompleteTextField* field = owner_->GetAutocompleteTextField();
- NSPoint anchor = GetBubblePointInFrame(frame);
- anchor = [field convertPoint:anchor toView:nil];
+ NSPoint anchor = [field bubblePointForDecoration:this];
anchor = ui::ConvertPointFromWindowToScreen([field window], anchor);
// Open bubble.

Powered by Google App Engine
This is Rietveld 408576698