OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <execinfo.h> | 5 #include <execinfo.h> |
6 | 6 |
7 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 7 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "content/browser/accessibility/browser_accessibility_mac.h" | |
16 #include "content/browser/accessibility/browser_accessibility_manager.h" | 15 #include "content/browser/accessibility/browser_accessibility_manager.h" |
17 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
18 #include "grit/webkit_strings.h" | 17 #include "grit/webkit_strings.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
20 | 19 |
21 // See http://openradar.appspot.com/9896491. This SPI has been tested on 10.5, | 20 // See http://openradar.appspot.com/9896491. This SPI has been tested on 10.5, |
22 // 10.6, and 10.7. It allows accessibility clients to observe events posted on | 21 // 10.6, and 10.7. It allows accessibility clients to observe events posted on |
23 // this object. | 22 // this object. |
24 extern "C" void NSAccessibilityUnregisterUniqueIdForUIElement(id element); | 23 extern "C" void NSAccessibilityUnregisterUniqueIdForUIElement(id element); |
25 | 24 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // Returns an array of BrowserAccessibilityCocoa objects, representing the | 336 // Returns an array of BrowserAccessibilityCocoa objects, representing the |
338 // accessibility children of this object. | 337 // accessibility children of this object. |
339 - (NSArray*)children { | 338 - (NSArray*)children { |
340 if (!children_.get()) { | 339 if (!children_.get()) { |
341 children_.reset([[NSMutableArray alloc] | 340 children_.reset([[NSMutableArray alloc] |
342 initWithCapacity:browserAccessibility_->child_count()] ); | 341 initWithCapacity:browserAccessibility_->child_count()] ); |
343 for (uint32 index = 0; | 342 for (uint32 index = 0; |
344 index < browserAccessibility_->child_count(); | 343 index < browserAccessibility_->child_count(); |
345 ++index) { | 344 ++index) { |
346 BrowserAccessibilityCocoa* child = | 345 BrowserAccessibilityCocoa* child = |
347 browserAccessibility_->GetChild(index)-> | 346 browserAccessibility_->GetChild(index)->toBrowserAccessibilityCocoa(); |
348 ToBrowserAccessibilityMac()->native_view(); | |
349 if ([child isIgnored]) | 347 if ([child isIgnored]) |
350 [children_ addObjectsFromArray:[child children]]; | 348 [children_ addObjectsFromArray:[child children]]; |
351 else | 349 else |
352 [children_ addObject:child]; | 350 [children_ addObject:child]; |
353 } | 351 } |
354 | 352 |
355 // Also, add indirect children (if any). | 353 // Also, add indirect children (if any). |
356 for (uint32 i = 0; | 354 for (uint32 i = 0; |
357 i < browserAccessibility_->indirect_child_ids().size(); | 355 i < browserAccessibility_->indirect_child_ids().size(); |
358 ++i) { | 356 ++i) { |
359 int32 child_id = browserAccessibility_->indirect_child_ids()[i]; | 357 int32 child_id = browserAccessibility_->indirect_child_ids()[i]; |
360 BrowserAccessibility* child = | 358 BrowserAccessibility* child = |
361 browserAccessibility_->manager()->GetFromRendererID(child_id); | 359 browserAccessibility_->manager()->GetFromRendererID(child_id); |
362 | 360 |
363 // This only became necessary as a result of crbug.com/93095. It should be | 361 // This only became necessary as a result of crbug.com/93095. It should be |
364 // a DCHECK in the future. | 362 // a DCHECK in the future. |
365 if (child) { | 363 if (child) { |
366 BrowserAccessibilityCocoa* child_cocoa = | 364 BrowserAccessibilityCocoa* child_cocoa = |
367 child->ToBrowserAccessibilityMac()->native_view(); | 365 child->toBrowserAccessibilityCocoa(); |
368 [children_ addObject:child_cocoa]; | 366 [children_ addObject:child_cocoa]; |
369 } | 367 } |
370 } | 368 } |
371 } | 369 } |
372 return children_; | 370 return children_; |
373 } | 371 } |
374 | 372 |
375 - (void)childrenChanged { | 373 - (void)childrenChanged { |
376 if (![self isIgnored]) { | 374 if (![self isIgnored]) { |
377 children_.reset(); | 375 children_.reset(); |
378 } else if (browserAccessibility_->parent()) { | 376 } else { |
379 [browserAccessibility_->parent()->ToBrowserAccessibilityMac()->native_view() | 377 [browserAccessibility_->parent()->toBrowserAccessibilityCocoa() |
380 childrenChanged]; | 378 childrenChanged]; |
381 } | 379 } |
382 } | 380 } |
383 | 381 |
384 - (NSArray*)columns { | 382 - (NSArray*)columns { |
385 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 383 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
386 for (BrowserAccessibilityCocoa* child in [self children]) { | 384 for (BrowserAccessibilityCocoa* child in [self children]) { |
387 if ([[child role] isEqualToString:NSAccessibilityColumnRole]) | 385 if ([[child role] isEqualToString:NSAccessibilityColumnRole]) |
388 [ret addObject:child]; | 386 [ret addObject:child]; |
389 } | 387 } |
390 return ret; | 388 return ret; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 // bottom-left origin. | 481 // bottom-left origin. |
484 - (NSPoint)origin { | 482 - (NSPoint)origin { |
485 gfx::Rect bounds = browserAccessibility_->GetLocalBoundsRect(); | 483 gfx::Rect bounds = browserAccessibility_->GetLocalBoundsRect(); |
486 return NSMakePoint(bounds.x(), bounds.y()); | 484 return NSMakePoint(bounds.x(), bounds.y()); |
487 } | 485 } |
488 | 486 |
489 - (id)parent { | 487 - (id)parent { |
490 // A nil parent means we're the root. | 488 // A nil parent means we're the root. |
491 if (browserAccessibility_->parent()) { | 489 if (browserAccessibility_->parent()) { |
492 return NSAccessibilityUnignoredAncestor( | 490 return NSAccessibilityUnignoredAncestor( |
493 browserAccessibility_->parent()->ToBrowserAccessibilityMac()-> | 491 browserAccessibility_->parent()->toBrowserAccessibilityCocoa()); |
494 native_view()); | |
495 } else { | 492 } else { |
496 // Hook back up to RenderWidgetHostViewCocoa. | 493 // Hook back up to RenderWidgetHostViewCocoa. |
497 return browserAccessibility_->manager()->GetParentView(); | 494 return browserAccessibility_->manager()->GetParentView(); |
498 } | 495 } |
499 } | 496 } |
500 | 497 |
501 - (NSValue*)position { | 498 - (NSValue*)position { |
502 return [NSValue valueWithPoint:[delegate_ accessibilityPointInScreen:self]]; | 499 return [NSValue valueWithPoint:[delegate_ accessibilityPointInScreen:self]]; |
503 } | 500 } |
504 | 501 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 return base::SysUTF16ToNSString(browserAccessibility_->name()); | 625 return base::SysUTF16ToNSString(browserAccessibility_->name()); |
629 } | 626 } |
630 | 627 |
631 - (id)titleUIElement { | 628 - (id)titleUIElement { |
632 int titleElementId; | 629 int titleElementId; |
633 if (browserAccessibility_->GetIntAttribute( | 630 if (browserAccessibility_->GetIntAttribute( |
634 WebAccessibility::ATTR_TITLE_UI_ELEMENT, &titleElementId)) { | 631 WebAccessibility::ATTR_TITLE_UI_ELEMENT, &titleElementId)) { |
635 BrowserAccessibility* titleElement = | 632 BrowserAccessibility* titleElement = |
636 browserAccessibility_->manager()->GetFromRendererID(titleElementId); | 633 browserAccessibility_->manager()->GetFromRendererID(titleElementId); |
637 if (titleElement) | 634 if (titleElement) |
638 return titleElement->ToBrowserAccessibilityMac()->native_view(); | 635 return titleElement->toBrowserAccessibilityCocoa(); |
639 } | 636 } |
640 return nil; | 637 return nil; |
641 } | 638 } |
642 | 639 |
643 - (NSString*)url { | 640 - (NSString*)url { |
644 StringAttribute urlAttribute = | 641 StringAttribute urlAttribute = |
645 [[self role] isEqualToString:@"AXWebArea"] ? | 642 [[self role] isEqualToString:@"AXWebArea"] ? |
646 WebAccessibility::ATTR_DOC_URL : | 643 WebAccessibility::ATTR_DOC_URL : |
647 WebAccessibility::ATTR_URL; | 644 WebAccessibility::ATTR_URL; |
648 return NSStringForStringAttribute( | 645 return NSStringForStringAttribute( |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 return [super hash]; | 1043 return [super hash]; |
1047 return browserAccessibility_->renderer_id(); | 1044 return browserAccessibility_->renderer_id(); |
1048 } | 1045 } |
1049 | 1046 |
1050 - (BOOL)accessibilityShouldUseUniqueId { | 1047 - (BOOL)accessibilityShouldUseUniqueId { |
1051 return YES; | 1048 return YES; |
1052 } | 1049 } |
1053 | 1050 |
1054 @end | 1051 @end |
1055 | 1052 |
OLD | NEW |