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() {
} // 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>
@end
......@@ -129,13 +107,12 @@ NSImage* NewTagImage() {
if (!feature_enabled || !model->IsNewFeatureAt(index))
return;
// TODO(avi): When moving to 10.11 as the minimum macOS, switch to using
// NSTextAttachment's |image| and |bounds| properties and avoid the whole
// NSTextAttachmentCell subclassing mishegas.
base::scoped_nsobject<NSTextAttachment> attachment(
[[NSTextAttachment alloc] init]);
attachment.get().attachmentCell =
[[[NewTagAttachmentCell alloc] init] autorelease];
NSTextAttachment* attachment =
[[[NSTextAttachment alloc] initWithData:nil ofType:nil] autorelease];
attachment.image = NewTagImage();
NSSize newTagSize = attachment.image.size;
attachment.bounds = NSMakeRect(0, views::NewBadge::kNewBadgeBaselineOffsetMac,
newTagSize.width, newTagSize.height);
// 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
......
......@@ -67,7 +67,7 @@ class VIEWS_EXPORT NewBadge {
static constexpr int kNewBadgeInternalPaddingTopMac = 1;
// 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.
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