Commit a0d07de0 authored by Avi Drissman's avatar Avi Drissman Committed by Chromium LUCI CQ

Update Mac New badge for 10.11

macOS 10.11 simplifies the NSTextAttachment API, so now
that Chromium requires 10.11, clean up the New badge code.

Bug: 1153883
Change-Id: I12f17b0c8da7f75346fac9ad9e6d4da12b04d8ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2572937
Commit-Queue: Avi Drissman <avi@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833496}
parent ed1921a6
...@@ -94,28 +94,6 @@ NSImage* NewTagImage() { ...@@ -94,28 +94,6 @@ NSImage* NewTagImage() {
} // namespace } // namespace
@interface NewTagAttachmentCell : NSTextAttachmentCell
@end
@implementation NewTagAttachmentCell
- (instancetype)init {
if (self = [super init]) {
self.image = NewTagImage();
}
return self;
}
- (NSPoint)cellBaselineOffset {
return NSMakePoint(0, views::NewBadge::kNewBadgeBaslineOffsetMac);
}
- (NSSize)cellSize {
return [self.image size];
}
@end
@interface MenuControllerDelegate : NSObject <MenuControllerCocoaDelegate> @interface MenuControllerDelegate : NSObject <MenuControllerCocoaDelegate>
@end @end
...@@ -129,13 +107,12 @@ NSImage* NewTagImage() { ...@@ -129,13 +107,12 @@ NSImage* NewTagImage() {
if (!feature_enabled || !model->IsNewFeatureAt(index)) if (!feature_enabled || !model->IsNewFeatureAt(index))
return; return;
// TODO(avi): When moving to 10.11 as the minimum macOS, switch to using NSTextAttachment* attachment =
// NSTextAttachment's |image| and |bounds| properties and avoid the whole [[[NSTextAttachment alloc] initWithData:nil ofType:nil] autorelease];
// NSTextAttachmentCell subclassing mishegas. attachment.image = NewTagImage();
base::scoped_nsobject<NSTextAttachment> attachment( NSSize newTagSize = attachment.image.size;
[[NSTextAttachment alloc] init]); attachment.bounds = NSMakeRect(0, views::NewBadge::kNewBadgeBaselineOffsetMac,
attachment.get().attachmentCell = newTagSize.width, newTagSize.height);
[[[NewTagAttachmentCell alloc] init] autorelease];
// Starting in 10.13, if an attributed string is set as a menu item title, and // Starting in 10.13, if an attributed string is set as a menu item title, and
// NSFontAttributeName is not specified for it, it is automatically rendered // NSFontAttributeName is not specified for it, it is automatically rendered
......
...@@ -67,7 +67,7 @@ class VIEWS_EXPORT NewBadge { ...@@ -67,7 +67,7 @@ class VIEWS_EXPORT NewBadge {
static constexpr int kNewBadgeInternalPaddingTopMac = 1; static constexpr int kNewBadgeInternalPaddingTopMac = 1;
// The baseline offset of the "new" badge image to the menu text baseline. // The baseline offset of the "new" badge image to the menu text baseline.
static constexpr int kNewBadgeBaslineOffsetMac = -4; static constexpr int kNewBadgeBaselineOffsetMac = -4;
// The corner radius of the rounded rect for the "new" badge. // The corner radius of the rounded rect for the "new" badge.
static constexpr int kNewBadgeCornerRadius = 3; static constexpr int kNewBadgeCornerRadius = 3;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment