Chromium Code Reviews| Index: ui/message_center/cocoa/notification_controller.mm |
| diff --git a/ui/message_center/cocoa/notification_controller.mm b/ui/message_center/cocoa/notification_controller.mm |
| index d2c8bf387c78655c690a77bcf9826822d38d9dc8..cd56b84ca249e8a34e9fabeda274a86b691e270e 100644 |
| --- a/ui/message_center/cocoa/notification_controller.mm |
| +++ b/ui/message_center/cocoa/notification_controller.mm |
| @@ -203,10 +203,24 @@ |
| @interface AccessibilityIgnoredBox : NSBox |
| @end |
| +// Ignore this element, but expose its children to accessibility. |
| @implementation AccessibilityIgnoredBox |
| - (BOOL)accessibilityIsIgnored { |
| return YES; |
| } |
| + |
| +// Pretend this element has no children. |
| +// TODO(petewil): Until we have alt text available, we will hide the children of |
| +// the box also. Remove this override once alt text is set (by using |
| +// NSAccessibilityDescriptionAttribute). |
| +-(id) accessibilityAttributeValue:(NSString*) attribute { |
|
Robert Sesek
2014/06/11 21:37:04
nit: space after - but not after )
Robert Sesek
2014/06/11 21:37:04
nit: no space after ) in arguments
Pete Williamson
2014/06/11 22:12:54
Done.
Pete Williamson
2014/06/11 22:12:54
Done.
|
| + // If we get a request for NSAccessibilityChildrenAttribute, return an empty |
| + // array to pretend we have no children. |
| + if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) |
| + return [[[NSMutableArray alloc] init] autorelease]; |
|
Robert Sesek
2014/06/11 21:37:04
nit: use [NSMutableArray array], or if it does not
Pete Williamson
2014/06/11 22:12:54
Done.
|
| + else |
| + return [super accessibilityAttributeValue:attribute]; |
| +} |
| @end |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -297,8 +311,7 @@ |
| [rootView addSubview:closeButton_]; |
| // Create the small image. |
| - [self configureSmallImageInFrame:rootFrame]; |
| - [[self view] addSubview:smallImage_]; |
| + [rootView addSubview:[self createSmallImageInFrame:rootFrame]]; |
| NSRect contentFrame = [self currentContentRect]; |
| @@ -732,7 +745,7 @@ |
| forAttribute:NSAccessibilityTitleAttribute]; |
| } |
| -- (void)configureSmallImageInFrame:(NSRect)rootFrame { |
| +- (NSView*)createSmallImageInFrame:(NSRect)rootFrame { |
| int smallImageXOffset = |
| message_center::kSmallImagePadding + message_center::kSmallImageSize; |
| NSRect smallImageFrame = |
| @@ -740,9 +753,19 @@ |
| NSMinY(rootFrame) + message_center::kSmallImagePadding, |
| message_center::kSmallImageSize, |
| message_center::kSmallImageSize); |
| + |
| + // Put the smallImage inside another box which can hide it from accessibility |
| + // until we have some alt text to go with it. Once we have alt text, remove |
| + // the box, and set NSAccessibilityDescriptionAttribute with it. |
| + base::scoped_nsobject<NSBox> imageBox( |
| + [[AccessibilityIgnoredBox alloc] initWithFrame:smallImageFrame]); |
| + [self configureCustomBox:imageBox]; |
| + [imageBox setAutoresizingMask:NSViewMinYMargin]; |
| smallImage_.reset([[NSImageView alloc] initWithFrame:smallImageFrame]); |
|
Robert Sesek
2014/06/11 21:37:04
Is this frame still correct? Since it's no longer
Pete Williamson
2014/06/11 22:12:54
The imageBox is supposed to be the same size and p
Robert Sesek
2014/06/12 13:31:10
Unless I'm misreading the code, it's not quite the
Pete Williamson
2014/06/12 17:29:04
Ah, I see. The code I cut and pasted worked since
|
| [smallImage_ setImageScaling:NSImageScaleProportionallyUpOrDown]; |
| - [smallImage_ setAutoresizingMask:NSViewMinYMargin]; |
| + [imageBox setContentView:smallImage_]; |
| + |
| + return imageBox.autorelease(); |
| } |
| - (void)configureTitleInFrame:(NSRect)contentFrame { |