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

Unified Diff: chrome/browser/cocoa/location_bar/page_action_decoration.mm

Issue 3017055: Merge 54767 - [Mac] M6 Omnibox positioning changes.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 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/cocoa/location_bar/page_action_decoration.mm
===================================================================
--- chrome/browser/cocoa/location_bar/page_action_decoration.mm (revision 54837)
+++ chrome/browser/cocoa/location_bar/page_action_decoration.mm (working copy)
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <cmath>
+
#import "chrome/browser/cocoa/location_bar/page_action_decoration.h"
#include "base/sys_string_conversions.h"
@@ -16,6 +18,16 @@
#include "chrome/common/extensions/extension_resource.h"
#include "skia/ext/skia_utils_mac.h"
+namespace {
+
+// Distance to offset the bubble pointer from the bottom of the max
+// icon area of the decoration. This makes the popup's upper border
+// 2px away from the omnibox's lower border (matches omnibox popup
+// upper border).
+const CGFloat kBubblePointYOffset = 2.0;
+
+} // namespace
+
PageActionDecoration::PageActionDecoration(
LocationBarViewMac* owner,
Profile* profile,
@@ -51,8 +63,14 @@
PageActionDecoration::~PageActionDecoration() {
}
-// Overridden from LocationBarImageView. Either notify listeners or show a
-// popup depending on the Page Action.
+// Always |kPageActionIconMaxSize| wide. |ImageDecoration| draws the
+// image centered.
+CGFloat PageActionDecoration::GetWidthForSpace(CGFloat width) {
+ return Extension::kPageActionIconMaxSize;
+}
+
+// Either notify listeners or show a popup depending on the Page
+// Action.
bool PageActionDecoration::OnMousePressed(NSRect frame) {
if (current_tab_id_ < 0) {
NOTREACHED() << "No current tab.";
@@ -175,8 +193,19 @@
}
NSPoint PageActionDecoration::GetBubblePointInFrame(NSRect frame) {
- frame = GetDrawRectInFrame(frame);
- return NSMakePoint(NSMidX(frame), NSMaxY(frame));
+ // This is similar to |ImageDecoration::GetDrawRectInFrame()|,
+ // except that code centers the image, which can differ in size
+ // between actions. This centers the maximum image size, so the
+ // point will consistently be at the same y position. x position is
+ // easier (the middle of the centered image is the middle of the
+ // frame).
+ const CGFloat delta_height =
+ NSHeight(frame) - Extension::kPageActionIconMaxSize;
+ const CGFloat bottom_inset = std::ceil(delta_height / 2.0);
+
+ // Return a point just below the bottom of the maximal drawing area.
+ return NSMakePoint(NSMidX(frame),
+ NSMaxY(frame) - bottom_inset + kBubblePointYOffset);
}
NSMenu* PageActionDecoration::GetMenu() {
« no previous file with comments | « chrome/browser/cocoa/location_bar/page_action_decoration.h ('k') | chrome/browser/cocoa/location_bar/star_decoration.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698