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..c58d45b47bad08abf34e9d03a43c5cb4a978138c 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. |
dewittj
2014/06/12 21:02:27
This comment seems out of date?
Pete Williamson
2014/06/17 17:36:36
Hmm, not sure how to change this to make it better
dewittj
2014/06/17 17:45:01
The problem is partly that the comment is above th
|
@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 { |
+ // If we get a request for NSAccessibilityChildrenAttribute, return an empty |
+ // array to pretend we have no children. |
+ if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) |
+ return @[]; |
+ 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]]; |
dewittj
2014/06/12 21:02:27
Any reason you diverged from the prevailing style
Pete Williamson
2014/06/17 17:36:35
I was following the same pattern that the Icon vie
dewittj
2014/06/17 17:45:01
Okay I see better now why it's different. sounds
|
NSRect contentFrame = [self currentContentRect]; |
@@ -732,17 +745,33 @@ |
forAttribute:NSAccessibilityTitleAttribute]; |
} |
-- (void)configureSmallImageInFrame:(NSRect)rootFrame { |
+- (NSView*)createSmallImageInFrame:(NSRect)rootFrame { |
int smallImageXOffset = |
message_center::kSmallImagePadding + message_center::kSmallImageSize; |
- NSRect smallImageFrame = |
+ NSRect boxFrame = |
NSMakeRect(NSMaxX(rootFrame) - smallImageXOffset, |
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:boxFrame]); |
+ [self configureCustomBox:imageBox]; |
+ [imageBox setAutoresizingMask:NSViewMinYMargin]; |
+ |
+ NSRect smallImageFrame = |
+ NSMakeRect(0,0, |
Robert Sesek
2014/06/12 18:19:48
nit: space after first 0,
Pete Williamson
2014/06/17 17:36:35
Done.
|
+ message_center::kSmallImageSize, |
+ message_center::kSmallImageSize); |
+ |
smallImage_.reset([[NSImageView alloc] initWithFrame:smallImageFrame]); |
[smallImage_ setImageScaling:NSImageScaleProportionallyUpOrDown]; |
- [smallImage_ setAutoresizingMask:NSViewMinYMargin]; |
+ [imageBox setContentView:smallImage_]; |
+ |
+ return imageBox.autorelease(); |
} |
- (void)configureTitleInFrame:(NSRect)contentFrame { |