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