| 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 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 9 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 | 12 |
| 13 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
| 14 #include "base/mac/scoped_cftyperef.h" | 14 #include "base/mac/scoped_cftyperef.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "content/app/strings/grit/content_strings.h" | 18 #include "content/app/strings/grit/content_strings.h" |
| 19 #include "content/browser/accessibility/browser_accessibility_mac.h" |
| 19 #include "content/browser/accessibility/browser_accessibility_manager.h" | 20 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 20 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" | 21 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
| 21 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h" | 22 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h" |
| 22 #include "content/public/common/content_client.h" | 23 #include "content/public/common/content_client.h" |
| 23 #import "ui/accessibility/platform/ax_platform_node_mac.h" | 24 #import "ui/accessibility/platform/ax_platform_node_mac.h" |
| 24 | 25 |
| 25 using content::AXTreeIDRegistry; | 26 using content::AXTreeIDRegistry; |
| 26 using content::AccessibilityMatchPredicate; | 27 using content::AccessibilityMatchPredicate; |
| 27 using content::BrowserAccessibility; | 28 using content::BrowserAccessibility; |
| 28 using content::BrowserAccessibilityDelegate; | 29 using content::BrowserAccessibilityDelegate; |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 } | 533 } |
| 533 | 534 |
| 534 // Returns an array of BrowserAccessibilityCocoa objects, representing the | 535 // Returns an array of BrowserAccessibilityCocoa objects, representing the |
| 535 // accessibility children of this object. | 536 // accessibility children of this object. |
| 536 - (NSArray*)children { | 537 - (NSArray*)children { |
| 537 if (!children_) { | 538 if (!children_) { |
| 538 uint32_t childCount = browserAccessibility_->PlatformChildCount(); | 539 uint32_t childCount = browserAccessibility_->PlatformChildCount(); |
| 539 children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]); | 540 children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]); |
| 540 for (uint32_t index = 0; index < childCount; ++index) { | 541 for (uint32_t index = 0; index < childCount; ++index) { |
| 541 BrowserAccessibilityCocoa* child = | 542 BrowserAccessibilityCocoa* child = |
| 542 browserAccessibility_->PlatformGetChild(index)-> | 543 ToBrowserAccessibilityCocoa( |
| 543 ToBrowserAccessibilityCocoa(); | 544 browserAccessibility_->PlatformGetChild(index)); |
| 544 if ([child isIgnored]) | 545 if ([child isIgnored]) |
| 545 [children_ addObjectsFromArray:[child children]]; | 546 [children_ addObjectsFromArray:[child children]]; |
| 546 else | 547 else |
| 547 [children_ addObject:child]; | 548 [children_ addObject:child]; |
| 548 } | 549 } |
| 549 | 550 |
| 550 // Also, add indirect children (if any). | 551 // Also, add indirect children (if any). |
| 551 const std::vector<int32_t>& indirectChildIds = | 552 const std::vector<int32_t>& indirectChildIds = |
| 552 browserAccessibility_->GetIntListAttribute( | 553 browserAccessibility_->GetIntListAttribute( |
| 553 ui::AX_ATTR_INDIRECT_CHILD_IDS); | 554 ui::AX_ATTR_INDIRECT_CHILD_IDS); |
| 554 for (uint32_t i = 0; i < indirectChildIds.size(); ++i) { | 555 for (uint32_t i = 0; i < indirectChildIds.size(); ++i) { |
| 555 int32_t child_id = indirectChildIds[i]; | 556 int32_t child_id = indirectChildIds[i]; |
| 556 BrowserAccessibility* child = | 557 BrowserAccessibility* child = |
| 557 browserAccessibility_->manager()->GetFromID(child_id); | 558 browserAccessibility_->manager()->GetFromID(child_id); |
| 558 | 559 |
| 559 // This only became necessary as a result of crbug.com/93095. It should be | 560 // This only became necessary as a result of crbug.com/93095. It should be |
| 560 // a DCHECK in the future. | 561 // a DCHECK in the future. |
| 561 if (child) { | 562 if (child) { |
| 562 BrowserAccessibilityCocoa* child_cocoa = | 563 BrowserAccessibilityCocoa* child_cocoa = |
| 563 child->ToBrowserAccessibilityCocoa(); | 564 ToBrowserAccessibilityCocoa(child); |
| 564 [children_ addObject:child_cocoa]; | 565 [children_ addObject:child_cocoa]; |
| 565 } | 566 } |
| 566 } | 567 } |
| 567 } | 568 } |
| 568 return children_; | 569 return children_; |
| 569 } | 570 } |
| 570 | 571 |
| 571 - (void)childrenChanged { | 572 - (void)childrenChanged { |
| 572 if (![self isIgnored]) { | 573 if (![self isIgnored]) { |
| 573 children_.reset(); | 574 children_.reset(); |
| 574 } else { | 575 } else { |
| 575 [browserAccessibility_->GetParent()->ToBrowserAccessibilityCocoa() | 576 [ToBrowserAccessibilityCocoa(browserAccessibility_->GetParent()) |
| 576 childrenChanged]; | 577 childrenChanged]; |
| 577 } | 578 } |
| 578 } | 579 } |
| 579 | 580 |
| 580 - (NSArray*)columnHeaders { | 581 - (NSArray*)columnHeaders { |
| 581 if ([self internalRole] != ui::AX_ROLE_TABLE && | 582 if ([self internalRole] != ui::AX_ROLE_TABLE && |
| 582 [self internalRole] != ui::AX_ROLE_GRID) { | 583 [self internalRole] != ui::AX_ROLE_GRID) { |
| 583 return nil; | 584 return nil; |
| 584 } | 585 } |
| 585 | 586 |
| 586 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 587 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
| 587 const std::vector<int32_t>& uniqueCellIds = | 588 const std::vector<int32_t>& uniqueCellIds = |
| 588 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); | 589 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 589 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { | 590 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { |
| 590 int id = uniqueCellIds[i]; | 591 int id = uniqueCellIds[i]; |
| 591 BrowserAccessibility* cell = | 592 BrowserAccessibility* cell = |
| 592 browserAccessibility_->manager()->GetFromID(id); | 593 browserAccessibility_->manager()->GetFromID(id); |
| 593 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) | 594 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) |
| 594 [ret addObject:cell->ToBrowserAccessibilityCocoa()]; | 595 [ret addObject:ToBrowserAccessibilityCocoa(cell)]; |
| 595 } | 596 } |
| 596 return ret; | 597 return ret; |
| 597 } | 598 } |
| 598 | 599 |
| 599 - (NSValue*)columnIndexRange { | 600 - (NSValue*)columnIndexRange { |
| 600 if (!browserAccessibility_->IsCellOrTableHeaderRole()) | 601 if (!browserAccessibility_->IsCellOrTableHeaderRole()) |
| 601 return nil; | 602 return nil; |
| 602 | 603 |
| 603 int column = -1; | 604 int column = -1; |
| 604 int colspan = -1; | 605 int colspan = -1; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, &headerElementId); | 801 ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, &headerElementId); |
| 801 } else if ([self internalRole] == ui::AX_ROLE_ROW) { | 802 } else if ([self internalRole] == ui::AX_ROLE_ROW) { |
| 802 browserAccessibility_->GetIntAttribute( | 803 browserAccessibility_->GetIntAttribute( |
| 803 ui::AX_ATTR_TABLE_ROW_HEADER_ID, &headerElementId); | 804 ui::AX_ATTR_TABLE_ROW_HEADER_ID, &headerElementId); |
| 804 } | 805 } |
| 805 | 806 |
| 806 if (headerElementId > 0) { | 807 if (headerElementId > 0) { |
| 807 BrowserAccessibility* headerObject = | 808 BrowserAccessibility* headerObject = |
| 808 browserAccessibility_->manager()->GetFromID(headerElementId); | 809 browserAccessibility_->manager()->GetFromID(headerElementId); |
| 809 if (headerObject) | 810 if (headerObject) |
| 810 return headerObject->ToBrowserAccessibilityCocoa(); | 811 return ToBrowserAccessibilityCocoa(headerObject); |
| 811 } | 812 } |
| 812 return nil; | 813 return nil; |
| 813 } | 814 } |
| 814 | 815 |
| 815 - (NSString*)help { | 816 - (NSString*)help { |
| 816 return NSStringForStringAttribute( | 817 return NSStringForStringAttribute( |
| 817 browserAccessibility_, ui::AX_ATTR_DESCRIPTION); | 818 browserAccessibility_, ui::AX_ATTR_DESCRIPTION); |
| 818 } | 819 } |
| 819 | 820 |
| 820 - (NSNumber*)index { | 821 - (NSNumber*)index { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 } | 890 } |
| 890 | 891 |
| 891 - (void)addLinkedUIElementsFromAttribute:(ui::AXIntListAttribute)attribute | 892 - (void)addLinkedUIElementsFromAttribute:(ui::AXIntListAttribute)attribute |
| 892 addTo:(NSMutableArray*)outArray { | 893 addTo:(NSMutableArray*)outArray { |
| 893 const std::vector<int32_t>& attributeValues = | 894 const std::vector<int32_t>& attributeValues = |
| 894 browserAccessibility_->GetIntListAttribute(attribute); | 895 browserAccessibility_->GetIntListAttribute(attribute); |
| 895 for (size_t i = 0; i < attributeValues.size(); ++i) { | 896 for (size_t i = 0; i < attributeValues.size(); ++i) { |
| 896 BrowserAccessibility* element = | 897 BrowserAccessibility* element = |
| 897 browserAccessibility_->manager()->GetFromID(attributeValues[i]); | 898 browserAccessibility_->manager()->GetFromID(attributeValues[i]); |
| 898 if (element) | 899 if (element) |
| 899 [outArray addObject:element->ToBrowserAccessibilityCocoa()]; | 900 [outArray addObject:ToBrowserAccessibilityCocoa(element)]; |
| 900 } | 901 } |
| 901 } | 902 } |
| 902 | 903 |
| 903 - (NSArray*)linkedUIElements { | 904 - (NSArray*)linkedUIElements { |
| 904 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 905 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
| 905 [self addLinkedUIElementsFromAttribute:ui::AX_ATTR_CONTROLS_IDS addTo:ret]; | 906 [self addLinkedUIElementsFromAttribute:ui::AX_ATTR_CONTROLS_IDS addTo:ret]; |
| 906 [self addLinkedUIElementsFromAttribute:ui::AX_ATTR_FLOWTO_IDS addTo:ret]; | 907 [self addLinkedUIElementsFromAttribute:ui::AX_ATTR_FLOWTO_IDS addTo:ret]; |
| 907 if ([ret count] == 0) | 908 if ([ret count] == 0) |
| 908 return nil; | 909 return nil; |
| 909 return ret; | 910 return ret; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 // bottom-left origin. | 951 // bottom-left origin. |
| 951 - (NSPoint)origin { | 952 - (NSPoint)origin { |
| 952 gfx::Rect bounds = browserAccessibility_->GetLocalBoundsRect(); | 953 gfx::Rect bounds = browserAccessibility_->GetLocalBoundsRect(); |
| 953 return NSMakePoint(bounds.x(), bounds.y()); | 954 return NSMakePoint(bounds.x(), bounds.y()); |
| 954 } | 955 } |
| 955 | 956 |
| 956 - (id)parent { | 957 - (id)parent { |
| 957 // A nil parent means we're the root. | 958 // A nil parent means we're the root. |
| 958 if (browserAccessibility_->GetParent()) { | 959 if (browserAccessibility_->GetParent()) { |
| 959 return NSAccessibilityUnignoredAncestor( | 960 return NSAccessibilityUnignoredAncestor( |
| 960 browserAccessibility_->GetParent()->ToBrowserAccessibilityCocoa()); | 961 ToBrowserAccessibilityCocoa(browserAccessibility_->GetParent())); |
| 961 } else { | 962 } else { |
| 962 // Hook back up to RenderWidgetHostViewCocoa. | 963 // Hook back up to RenderWidgetHostViewCocoa. |
| 963 BrowserAccessibilityManagerMac* manager = | 964 BrowserAccessibilityManagerMac* manager = |
| 964 static_cast<BrowserAccessibilityManagerMac*>( | 965 static_cast<BrowserAccessibilityManagerMac*>( |
| 965 browserAccessibility_->manager()); | 966 browserAccessibility_->manager()); |
| 966 return manager->parent_view(); | 967 return manager->parent_view(); |
| 967 } | 968 } |
| 968 } | 969 } |
| 969 | 970 |
| 970 - (NSValue*)position { | 971 - (NSValue*)position { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 } | 1179 } |
| 1179 | 1180 |
| 1180 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 1181 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
| 1181 const std::vector<int32_t>& uniqueCellIds = | 1182 const std::vector<int32_t>& uniqueCellIds = |
| 1182 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); | 1183 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 1183 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { | 1184 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { |
| 1184 int id = uniqueCellIds[i]; | 1185 int id = uniqueCellIds[i]; |
| 1185 BrowserAccessibility* cell = | 1186 BrowserAccessibility* cell = |
| 1186 browserAccessibility_->manager()->GetFromID(id); | 1187 browserAccessibility_->manager()->GetFromID(id); |
| 1187 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) | 1188 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) |
| 1188 [ret addObject:cell->ToBrowserAccessibilityCocoa()]; | 1189 [ret addObject:ToBrowserAccessibilityCocoa(cell)]; |
| 1189 } | 1190 } |
| 1190 return ret; | 1191 return ret; |
| 1191 } | 1192 } |
| 1192 | 1193 |
| 1193 - (NSValue*)rowIndexRange { | 1194 - (NSValue*)rowIndexRange { |
| 1194 if (!browserAccessibility_->IsCellOrTableHeaderRole()) | 1195 if (!browserAccessibility_->IsCellOrTableHeaderRole()) |
| 1195 return nil; | 1196 return nil; |
| 1196 | 1197 |
| 1197 int row = -1; | 1198 int row = -1; |
| 1198 int rowspan = -1; | 1199 int rowspan = -1; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1216 } | 1217 } |
| 1217 } else if ([self internalRole] == ui::AX_ROLE_COLUMN) { | 1218 } else if ([self internalRole] == ui::AX_ROLE_COLUMN) { |
| 1218 const std::vector<int32_t>& indirectChildIds = | 1219 const std::vector<int32_t>& indirectChildIds = |
| 1219 browserAccessibility_->GetIntListAttribute( | 1220 browserAccessibility_->GetIntListAttribute( |
| 1220 ui::AX_ATTR_INDIRECT_CHILD_IDS); | 1221 ui::AX_ATTR_INDIRECT_CHILD_IDS); |
| 1221 for (uint32_t i = 0; i < indirectChildIds.size(); ++i) { | 1222 for (uint32_t i = 0; i < indirectChildIds.size(); ++i) { |
| 1222 int id = indirectChildIds[i]; | 1223 int id = indirectChildIds[i]; |
| 1223 BrowserAccessibility* rowElement = | 1224 BrowserAccessibility* rowElement = |
| 1224 browserAccessibility_->manager()->GetFromID(id); | 1225 browserAccessibility_->manager()->GetFromID(id); |
| 1225 if (rowElement) | 1226 if (rowElement) |
| 1226 [ret addObject:rowElement->ToBrowserAccessibilityCocoa()]; | 1227 [ret addObject:ToBrowserAccessibilityCocoa(rowElement)]; |
| 1227 } | 1228 } |
| 1228 } | 1229 } |
| 1229 | 1230 |
| 1230 return ret; | 1231 return ret; |
| 1231 } | 1232 } |
| 1232 | 1233 |
| 1233 - (NSArray*)selectedChildren { | 1234 - (NSArray*)selectedChildren { |
| 1234 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 1235 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
| 1235 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); | 1236 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
| 1236 BrowserAccessibility* focusedChild = manager->GetFocus(); | 1237 BrowserAccessibility* focusedChild = manager->GetFocus(); |
| 1237 if (!focusedChild->IsDescendantOf(browserAccessibility_)) | 1238 if (!focusedChild->IsDescendantOf(browserAccessibility_)) |
| 1238 focusedChild = nullptr; | 1239 focusedChild = nullptr; |
| 1239 | 1240 |
| 1240 // If it's not multiselectable, try to skip iterating over the | 1241 // If it's not multiselectable, try to skip iterating over the |
| 1241 // children. | 1242 // children. |
| 1242 if (!GetState(browserAccessibility_, ui::AX_STATE_MULTISELECTABLE)) { | 1243 if (!GetState(browserAccessibility_, ui::AX_STATE_MULTISELECTABLE)) { |
| 1243 // First try the focused child. | 1244 // First try the focused child. |
| 1244 if (focusedChild && focusedChild != browserAccessibility_) { | 1245 if (focusedChild && focusedChild != browserAccessibility_) { |
| 1245 [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()]; | 1246 [ret addObject:ToBrowserAccessibilityCocoa(focusedChild)]; |
| 1246 return ret; | 1247 return ret; |
| 1247 } | 1248 } |
| 1248 | 1249 |
| 1249 // Next try the active descendant. | 1250 // Next try the active descendant. |
| 1250 int activeDescendantId; | 1251 int activeDescendantId; |
| 1251 if (browserAccessibility_->GetIntAttribute( | 1252 if (browserAccessibility_->GetIntAttribute( |
| 1252 ui::AX_ATTR_ACTIVEDESCENDANT_ID, &activeDescendantId)) { | 1253 ui::AX_ATTR_ACTIVEDESCENDANT_ID, &activeDescendantId)) { |
| 1253 BrowserAccessibility* activeDescendant = | 1254 BrowserAccessibility* activeDescendant = |
| 1254 manager->GetFromID(activeDescendantId); | 1255 manager->GetFromID(activeDescendantId); |
| 1255 if (activeDescendant) { | 1256 if (activeDescendant) { |
| 1256 [ret addObject:activeDescendant->ToBrowserAccessibilityCocoa()]; | 1257 [ret addObject:ToBrowserAccessibilityCocoa(activeDescendant)]; |
| 1257 return ret; | 1258 return ret; |
| 1258 } | 1259 } |
| 1259 } | 1260 } |
| 1260 } | 1261 } |
| 1261 | 1262 |
| 1262 // If it's multiselectable or if the previous attempts failed, | 1263 // If it's multiselectable or if the previous attempts failed, |
| 1263 // return any children with the "selected" state, which may | 1264 // return any children with the "selected" state, which may |
| 1264 // come from aria-selected. | 1265 // come from aria-selected. |
| 1265 uint32_t childCount = browserAccessibility_->PlatformChildCount(); | 1266 uint32_t childCount = browserAccessibility_->PlatformChildCount(); |
| 1266 for (uint32_t index = 0; index < childCount; ++index) { | 1267 for (uint32_t index = 0; index < childCount; ++index) { |
| 1267 BrowserAccessibility* child = | 1268 BrowserAccessibility* child = |
| 1268 browserAccessibility_->PlatformGetChild(index); | 1269 browserAccessibility_->PlatformGetChild(index); |
| 1269 if (child->HasState(ui::AX_STATE_SELECTED)) | 1270 if (child->HasState(ui::AX_STATE_SELECTED)) |
| 1270 [ret addObject:child->ToBrowserAccessibilityCocoa()]; | 1271 [ret addObject:ToBrowserAccessibilityCocoa(child)]; |
| 1271 } | 1272 } |
| 1272 | 1273 |
| 1273 // And if nothing's selected but one has focus, use the focused one. | 1274 // And if nothing's selected but one has focus, use the focused one. |
| 1274 if ([ret count] == 0 && | 1275 if ([ret count] == 0 && |
| 1275 focusedChild && | 1276 focusedChild && |
| 1276 focusedChild != browserAccessibility_) { | 1277 focusedChild != browserAccessibility_) { |
| 1277 [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()]; | 1278 [ret addObject:ToBrowserAccessibilityCocoa(focusedChild)]; |
| 1278 } | 1279 } |
| 1279 | 1280 |
| 1280 return ret; | 1281 return ret; |
| 1281 } | 1282 } |
| 1282 | 1283 |
| 1283 - (id)selectedTextMarkerRange { | 1284 - (id)selectedTextMarkerRange { |
| 1284 if (!browserAccessibility_) | 1285 if (!browserAccessibility_) |
| 1285 return nil; | 1286 return nil; |
| 1286 | 1287 |
| 1287 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); | 1288 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 - (id)titleUIElement { | 1431 - (id)titleUIElement { |
| 1431 std::vector<int32_t> labelledby_ids = | 1432 std::vector<int32_t> labelledby_ids = |
| 1432 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS); | 1433 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS); |
| 1433 ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>( | 1434 ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>( |
| 1434 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); | 1435 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); |
| 1435 if (nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT && | 1436 if (nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT && |
| 1436 labelledby_ids.size() == 1) { | 1437 labelledby_ids.size() == 1) { |
| 1437 BrowserAccessibility* titleElement = | 1438 BrowserAccessibility* titleElement = |
| 1438 browserAccessibility_->manager()->GetFromID(labelledby_ids[0]); | 1439 browserAccessibility_->manager()->GetFromID(labelledby_ids[0]); |
| 1439 if (titleElement) | 1440 if (titleElement) |
| 1440 return titleElement->ToBrowserAccessibilityCocoa(); | 1441 return ToBrowserAccessibilityCocoa(titleElement); |
| 1441 } | 1442 } |
| 1442 | 1443 |
| 1443 return nil; | 1444 return nil; |
| 1444 } | 1445 } |
| 1445 | 1446 |
| 1446 - (NSURL*)url { | 1447 - (NSURL*)url { |
| 1447 std::string url; | 1448 std::string url; |
| 1448 if ([[self role] isEqualToString:@"AXWebArea"]) | 1449 if ([[self role] isEqualToString:@"AXWebArea"]) |
| 1449 url = browserAccessibility_->manager()->GetTreeData().url; | 1450 url = browserAccessibility_->manager()->GetTreeData().url; |
| 1450 else | 1451 else |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 | 1533 |
| 1533 - (NSArray*)visibleCells { | 1534 - (NSArray*)visibleCells { |
| 1534 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 1535 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
| 1535 const std::vector<int32_t>& uniqueCellIds = | 1536 const std::vector<int32_t>& uniqueCellIds = |
| 1536 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); | 1537 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 1537 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { | 1538 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { |
| 1538 int id = uniqueCellIds[i]; | 1539 int id = uniqueCellIds[i]; |
| 1539 BrowserAccessibility* cell = | 1540 BrowserAccessibility* cell = |
| 1540 browserAccessibility_->manager()->GetFromID(id); | 1541 browserAccessibility_->manager()->GetFromID(id); |
| 1541 if (cell) | 1542 if (cell) |
| 1542 [ret addObject:cell->ToBrowserAccessibilityCocoa()]; | 1543 [ret addObject:ToBrowserAccessibilityCocoa(cell)]; |
| 1543 } | 1544 } |
| 1544 return ret; | 1545 return ret; |
| 1545 } | 1546 } |
| 1546 | 1547 |
| 1547 - (NSArray*)visibleChildren { | 1548 - (NSArray*)visibleChildren { |
| 1548 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 1549 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
| 1549 uint32_t childCount = browserAccessibility_->PlatformChildCount(); | 1550 uint32_t childCount = browserAccessibility_->PlatformChildCount(); |
| 1550 for (uint32_t index = 0; index < childCount; ++index) { | 1551 for (uint32_t index = 0; index < childCount; ++index) { |
| 1551 BrowserAccessibilityCocoa* child = | 1552 BrowserAccessibilityCocoa* child = ToBrowserAccessibilityCocoa( |
| 1552 browserAccessibility_->PlatformGetChild(index)-> | 1553 browserAccessibility_->PlatformGetChild(index)); |
| 1553 ToBrowserAccessibilityCocoa(); | |
| 1554 [ret addObject:child]; | 1554 [ret addObject:child]; |
| 1555 } | 1555 } |
| 1556 return ret; | 1556 return ret; |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 - (NSArray*)visibleColumns { | 1559 - (NSArray*)visibleColumns { |
| 1560 return [self columns]; | 1560 return [self columns]; |
| 1561 } | 1561 } |
| 1562 | 1562 |
| 1563 - (NSArray*)visibleRows { | 1563 - (NSArray*)visibleRows { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 BrowserAccessibility* cell = child->PlatformGetChild(j); | 1730 BrowserAccessibility* cell = child->PlatformGetChild(j); |
| 1731 if (!cell->IsCellOrTableHeaderRole()) | 1731 if (!cell->IsCellOrTableHeaderRole()) |
| 1732 continue; | 1732 continue; |
| 1733 int colIndex; | 1733 int colIndex; |
| 1734 if (!cell->GetIntAttribute( | 1734 if (!cell->GetIntAttribute( |
| 1735 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, | 1735 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, |
| 1736 &colIndex)) { | 1736 &colIndex)) { |
| 1737 continue; | 1737 continue; |
| 1738 } | 1738 } |
| 1739 if (colIndex == column) | 1739 if (colIndex == column) |
| 1740 return cell->ToBrowserAccessibilityCocoa(); | 1740 return ToBrowserAccessibilityCocoa(cell); |
| 1741 if (colIndex > column) | 1741 if (colIndex > column) |
| 1742 break; | 1742 break; |
| 1743 } | 1743 } |
| 1744 } | 1744 } |
| 1745 return nil; | 1745 return nil; |
| 1746 } | 1746 } |
| 1747 | 1747 |
| 1748 if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) { | 1748 if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) { |
| 1749 BrowserAccessibility* object; | 1749 BrowserAccessibility* object; |
| 1750 int offset; | 1750 int offset; |
| 1751 if (GetTextMarkerData(parameter, &object, &offset)) | 1751 if (GetTextMarkerData(parameter, &object, &offset)) |
| 1752 return object->ToBrowserAccessibilityCocoa(); | 1752 return ToBrowserAccessibilityCocoa(object); |
| 1753 | 1753 |
| 1754 return nil; | 1754 return nil; |
| 1755 } | 1755 } |
| 1756 | 1756 |
| 1757 if ([attribute isEqualToString:@"AXTextMarkerRangeForUIElement"]) { | 1757 if ([attribute isEqualToString:@"AXTextMarkerRangeForUIElement"]) { |
| 1758 return CreateTextMarkerRange(*browserAccessibility_, 0, | 1758 return CreateTextMarkerRange(*browserAccessibility_, 0, |
| 1759 *browserAccessibility_, | 1759 *browserAccessibility_, |
| 1760 browserAccessibility_->GetText().length()); | 1760 browserAccessibility_->GetText().length()); |
| 1761 } | 1761 } |
| 1762 | 1762 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 return nil; | 1857 return nil; |
| 1858 } | 1858 } |
| 1859 | 1859 |
| 1860 if ([attribute isEqualToString:@"AXUIElementsForSearchPredicate"]) { | 1860 if ([attribute isEqualToString:@"AXUIElementsForSearchPredicate"]) { |
| 1861 OneShotAccessibilityTreeSearch search(browserAccessibility_); | 1861 OneShotAccessibilityTreeSearch search(browserAccessibility_); |
| 1862 if (InitializeAccessibilityTreeSearch(&search, parameter)) { | 1862 if (InitializeAccessibilityTreeSearch(&search, parameter)) { |
| 1863 size_t count = search.CountMatches(); | 1863 size_t count = search.CountMatches(); |
| 1864 NSMutableArray* result = [NSMutableArray arrayWithCapacity:count]; | 1864 NSMutableArray* result = [NSMutableArray arrayWithCapacity:count]; |
| 1865 for (size_t i = 0; i < count; ++i) { | 1865 for (size_t i = 0; i < count; ++i) { |
| 1866 BrowserAccessibility* match = search.GetMatchAtIndex(i); | 1866 BrowserAccessibility* match = search.GetMatchAtIndex(i); |
| 1867 [result addObject:match->ToBrowserAccessibilityCocoa()]; | 1867 [result addObject:ToBrowserAccessibilityCocoa(match)]; |
| 1868 } | 1868 } |
| 1869 return result; | 1869 return result; |
| 1870 } | 1870 } |
| 1871 return nil; | 1871 return nil; |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 return nil; | 1874 return nil; |
| 1875 } | 1875 } |
| 1876 | 1876 |
| 1877 // Returns an array of parameterized attributes names that this object will | 1877 // Returns an array of parameterized attributes names that this object will |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 if (!browserAccessibility_) | 2326 if (!browserAccessibility_) |
| 2327 return [super hash]; | 2327 return [super hash]; |
| 2328 return browserAccessibility_->GetId(); | 2328 return browserAccessibility_->GetId(); |
| 2329 } | 2329 } |
| 2330 | 2330 |
| 2331 - (BOOL)accessibilityShouldUseUniqueId { | 2331 - (BOOL)accessibilityShouldUseUniqueId { |
| 2332 return YES; | 2332 return YES; |
| 2333 } | 2333 } |
| 2334 | 2334 |
| 2335 @end | 2335 @end |
| OLD | NEW |