Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: content/browser/accessibility/browser_accessibility_cocoa.mm

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
7 #include <stdint.h>
6 8
7 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 9 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
8 10
9 #include <map> 11 #include <map>
10 12
11 #include "base/basictypes.h"
12 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
13 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "content/app/strings/grit/content_strings.h" 16 #include "content/app/strings/grit/content_strings.h"
16 #include "content/browser/accessibility/browser_accessibility_manager.h" 17 #include "content/browser/accessibility/browser_accessibility_manager.h"
17 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" 18 #include "content/browser/accessibility/browser_accessibility_manager_mac.h"
18 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h" 19 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h"
19 #include "content/public/common/content_client.h" 20 #include "content/public/common/content_client.h"
20 #import "ui/accessibility/platform/ax_platform_node_mac.h" 21 #import "ui/accessibility/platform/ax_platform_node_mac.h"
21 22
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 459
459 - (NSNumber*)ariaSetSize { 460 - (NSNumber*)ariaSetSize {
460 return [NSNumber numberWithInt: 461 return [NSNumber numberWithInt:
461 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_SET_SIZE)]; 462 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_SET_SIZE)];
462 } 463 }
463 464
464 // Returns an array of BrowserAccessibilityCocoa objects, representing the 465 // Returns an array of BrowserAccessibilityCocoa objects, representing the
465 // accessibility children of this object. 466 // accessibility children of this object.
466 - (NSArray*)children { 467 - (NSArray*)children {
467 if (!children_) { 468 if (!children_) {
468 uint32 childCount = browserAccessibility_->PlatformChildCount(); 469 uint32_t childCount = browserAccessibility_->PlatformChildCount();
469 children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]); 470 children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]);
470 for (uint32 index = 0; index < childCount; ++index) { 471 for (uint32_t index = 0; index < childCount; ++index) {
471 BrowserAccessibilityCocoa* child = 472 BrowserAccessibilityCocoa* child =
472 browserAccessibility_->PlatformGetChild(index)-> 473 browserAccessibility_->PlatformGetChild(index)->
473 ToBrowserAccessibilityCocoa(); 474 ToBrowserAccessibilityCocoa();
474 if ([child isIgnored]) 475 if ([child isIgnored])
475 [children_ addObjectsFromArray:[child children]]; 476 [children_ addObjectsFromArray:[child children]];
476 else 477 else
477 [children_ addObject:child]; 478 [children_ addObject:child];
478 } 479 }
479 480
480 // Also, add indirect children (if any). 481 // Also, add indirect children (if any).
481 const std::vector<int32>& indirectChildIds = 482 const std::vector<int32_t>& indirectChildIds =
482 browserAccessibility_->GetIntListAttribute( 483 browserAccessibility_->GetIntListAttribute(
483 ui::AX_ATTR_INDIRECT_CHILD_IDS); 484 ui::AX_ATTR_INDIRECT_CHILD_IDS);
484 for (uint32 i = 0; i < indirectChildIds.size(); ++i) { 485 for (uint32_t i = 0; i < indirectChildIds.size(); ++i) {
485 int32 child_id = indirectChildIds[i]; 486 int32_t child_id = indirectChildIds[i];
486 BrowserAccessibility* child = 487 BrowserAccessibility* child =
487 browserAccessibility_->manager()->GetFromID(child_id); 488 browserAccessibility_->manager()->GetFromID(child_id);
488 489
489 // This only became necessary as a result of crbug.com/93095. It should be 490 // This only became necessary as a result of crbug.com/93095. It should be
490 // a DCHECK in the future. 491 // a DCHECK in the future.
491 if (child) { 492 if (child) {
492 BrowserAccessibilityCocoa* child_cocoa = 493 BrowserAccessibilityCocoa* child_cocoa =
493 child->ToBrowserAccessibilityCocoa(); 494 child->ToBrowserAccessibilityCocoa();
494 [children_ addObject:child_cocoa]; 495 [children_ addObject:child_cocoa];
495 } 496 }
(...skipping 11 matching lines...) Expand all
507 } 508 }
508 } 509 }
509 510
510 - (NSArray*)columnHeaders { 511 - (NSArray*)columnHeaders {
511 if ([self internalRole] != ui::AX_ROLE_TABLE && 512 if ([self internalRole] != ui::AX_ROLE_TABLE &&
512 [self internalRole] != ui::AX_ROLE_GRID) { 513 [self internalRole] != ui::AX_ROLE_GRID) {
513 return nil; 514 return nil;
514 } 515 }
515 516
516 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; 517 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease];
517 const std::vector<int32>& uniqueCellIds = 518 const std::vector<int32_t>& uniqueCellIds =
518 browserAccessibility_->GetIntListAttribute( 519 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
519 ui::AX_ATTR_UNIQUE_CELL_IDS);
520 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { 520 for (size_t i = 0; i < uniqueCellIds.size(); ++i) {
521 int id = uniqueCellIds[i]; 521 int id = uniqueCellIds[i];
522 BrowserAccessibility* cell = 522 BrowserAccessibility* cell =
523 browserAccessibility_->manager()->GetFromID(id); 523 browserAccessibility_->manager()->GetFromID(id);
524 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) 524 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER)
525 [ret addObject:cell->ToBrowserAccessibilityCocoa()]; 525 [ret addObject:cell->ToBrowserAccessibilityCocoa()];
526 } 526 }
527 return ret; 527 return ret;
528 } 528 }
529 529
(...skipping 21 matching lines...) Expand all
551 return ret; 551 return ret;
552 } 552 }
553 553
554 - (NSString*)description { 554 - (NSString*)description {
555 // Mac OS X wants static text exposed in AXValue. 555 // Mac OS X wants static text exposed in AXValue.
556 if ([self shouldExposeNameInAXValue]) 556 if ([self shouldExposeNameInAXValue])
557 return @""; 557 return @"";
558 558
559 // If the name came from a single related element and it's present in the 559 // If the name came from a single related element and it's present in the
560 // tree, it will be exposed in AXTitleUIElement. 560 // tree, it will be exposed in AXTitleUIElement.
561 std::vector<int32> labelledby_ids = 561 std::vector<int32_t> labelledby_ids =
562 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS); 562 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS);
563 ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>( 563 ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>(
564 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); 564 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM));
565 if (nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT && 565 if (nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT &&
566 labelledby_ids.size() == 1 && 566 labelledby_ids.size() == 1 &&
567 browserAccessibility_->manager()->GetFromID(labelledby_ids[0])) { 567 browserAccessibility_->manager()->GetFromID(labelledby_ids[0])) {
568 return @""; 568 return @"";
569 } 569 }
570 570
571 std::string name = browserAccessibility_->GetStringAttribute( 571 std::string name = browserAccessibility_->GetStringAttribute(
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 return NSStringForStringAttribute( 782 return NSStringForStringAttribute(
783 browserAccessibility_, ui::AX_ATTR_DESCRIPTION); 783 browserAccessibility_, ui::AX_ATTR_DESCRIPTION);
784 } 784 }
785 785
786 return NSStringForStringAttribute( 786 return NSStringForStringAttribute(
787 browserAccessibility_, ui::AX_ATTR_PLACEHOLDER); 787 browserAccessibility_, ui::AX_ATTR_PLACEHOLDER);
788 } 788 }
789 789
790 - (void)addLinkedUIElementsFromAttribute:(ui::AXIntListAttribute)attribute 790 - (void)addLinkedUIElementsFromAttribute:(ui::AXIntListAttribute)attribute
791 addTo:(NSMutableArray*)outArray { 791 addTo:(NSMutableArray*)outArray {
792 const std::vector<int32>& attributeValues = 792 const std::vector<int32_t>& attributeValues =
793 browserAccessibility_->GetIntListAttribute(attribute); 793 browserAccessibility_->GetIntListAttribute(attribute);
794 for (size_t i = 0; i < attributeValues.size(); ++i) { 794 for (size_t i = 0; i < attributeValues.size(); ++i) {
795 BrowserAccessibility* element = 795 BrowserAccessibility* element =
796 browserAccessibility_->manager()->GetFromID(attributeValues[i]); 796 browserAccessibility_->manager()->GetFromID(attributeValues[i]);
797 if (element) 797 if (element)
798 [outArray addObject:element->ToBrowserAccessibilityCocoa()]; 798 [outArray addObject:element->ToBrowserAccessibilityCocoa()];
799 } 799 }
800 } 800 }
801 801
802 - (NSArray*)linkedUIElements { 802 - (NSArray*)linkedUIElements {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 return NSAccessibilityRoleDescription(role, nil); 1070 return NSAccessibilityRoleDescription(role, nil);
1071 } 1071 }
1072 1072
1073 - (NSArray*)rowHeaders { 1073 - (NSArray*)rowHeaders {
1074 if ([self internalRole] != ui::AX_ROLE_TABLE && 1074 if ([self internalRole] != ui::AX_ROLE_TABLE &&
1075 [self internalRole] != ui::AX_ROLE_GRID) { 1075 [self internalRole] != ui::AX_ROLE_GRID) {
1076 return nil; 1076 return nil;
1077 } 1077 }
1078 1078
1079 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; 1079 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease];
1080 const std::vector<int32>& uniqueCellIds = 1080 const std::vector<int32_t>& uniqueCellIds =
1081 browserAccessibility_->GetIntListAttribute( 1081 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
1082 ui::AX_ATTR_UNIQUE_CELL_IDS);
1083 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { 1082 for (size_t i = 0; i < uniqueCellIds.size(); ++i) {
1084 int id = uniqueCellIds[i]; 1083 int id = uniqueCellIds[i];
1085 BrowserAccessibility* cell = 1084 BrowserAccessibility* cell =
1086 browserAccessibility_->manager()->GetFromID(id); 1085 browserAccessibility_->manager()->GetFromID(id);
1087 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) 1086 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER)
1088 [ret addObject:cell->ToBrowserAccessibilityCocoa()]; 1087 [ret addObject:cell->ToBrowserAccessibilityCocoa()];
1089 } 1088 }
1090 return ret; 1089 return ret;
1091 } 1090 }
1092 1091
(...skipping 15 matching lines...) Expand all
1108 - (NSArray*)rows { 1107 - (NSArray*)rows {
1109 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; 1108 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease];
1110 1109
1111 if ([self internalRole] == ui::AX_ROLE_TABLE|| 1110 if ([self internalRole] == ui::AX_ROLE_TABLE||
1112 [self internalRole] == ui::AX_ROLE_GRID) { 1111 [self internalRole] == ui::AX_ROLE_GRID) {
1113 for (BrowserAccessibilityCocoa* child in [self children]) { 1112 for (BrowserAccessibilityCocoa* child in [self children]) {
1114 if ([[child role] isEqualToString:NSAccessibilityRowRole]) 1113 if ([[child role] isEqualToString:NSAccessibilityRowRole])
1115 [ret addObject:child]; 1114 [ret addObject:child];
1116 } 1115 }
1117 } else if ([self internalRole] == ui::AX_ROLE_COLUMN) { 1116 } else if ([self internalRole] == ui::AX_ROLE_COLUMN) {
1118 const std::vector<int32>& indirectChildIds = 1117 const std::vector<int32_t>& indirectChildIds =
1119 browserAccessibility_->GetIntListAttribute( 1118 browserAccessibility_->GetIntListAttribute(
1120 ui::AX_ATTR_INDIRECT_CHILD_IDS); 1119 ui::AX_ATTR_INDIRECT_CHILD_IDS);
1121 for (uint32 i = 0; i < indirectChildIds.size(); ++i) { 1120 for (uint32_t i = 0; i < indirectChildIds.size(); ++i) {
1122 int id = indirectChildIds[i]; 1121 int id = indirectChildIds[i];
1123 BrowserAccessibility* rowElement = 1122 BrowserAccessibility* rowElement =
1124 browserAccessibility_->manager()->GetFromID(id); 1123 browserAccessibility_->manager()->GetFromID(id);
1125 if (rowElement) 1124 if (rowElement)
1126 [ret addObject:rowElement->ToBrowserAccessibilityCocoa()]; 1125 [ret addObject:rowElement->ToBrowserAccessibilityCocoa()];
1127 } 1126 }
1128 } 1127 }
1129 1128
1130 return ret; 1129 return ret;
1131 } 1130 }
(...skipping 21 matching lines...) Expand all
1153 if (activeDescendant) { 1152 if (activeDescendant) {
1154 [ret addObject:activeDescendant->ToBrowserAccessibilityCocoa()]; 1153 [ret addObject:activeDescendant->ToBrowserAccessibilityCocoa()];
1155 return ret; 1154 return ret;
1156 } 1155 }
1157 } 1156 }
1158 } 1157 }
1159 1158
1160 // If it's multiselectable or if the previous attempts failed, 1159 // If it's multiselectable or if the previous attempts failed,
1161 // return any children with the "selected" state, which may 1160 // return any children with the "selected" state, which may
1162 // come from aria-selected. 1161 // come from aria-selected.
1163 uint32 childCount = browserAccessibility_->PlatformChildCount(); 1162 uint32_t childCount = browserAccessibility_->PlatformChildCount();
1164 for (uint32 index = 0; index < childCount; ++index) { 1163 for (uint32_t index = 0; index < childCount; ++index) {
1165 BrowserAccessibility* child = 1164 BrowserAccessibility* child =
1166 browserAccessibility_->PlatformGetChild(index); 1165 browserAccessibility_->PlatformGetChild(index);
1167 if (child->HasState(ui::AX_STATE_SELECTED)) 1166 if (child->HasState(ui::AX_STATE_SELECTED))
1168 [ret addObject:child->ToBrowserAccessibilityCocoa()]; 1167 [ret addObject:child->ToBrowserAccessibilityCocoa()];
1169 } 1168 }
1170 1169
1171 // And if nothing's selected but one has focus, use the focused one. 1170 // And if nothing's selected but one has focus, use the focused one.
1172 if ([ret count] == 0 && 1171 if ([ret count] == 0 &&
1173 focusedChild && 1172 focusedChild &&
1174 focusedChild != browserAccessibility_) { 1173 focusedChild != browserAccessibility_) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 return tabSubtree; 1238 return tabSubtree;
1240 } 1239 }
1241 1240
1242 - (NSString*)title { 1241 - (NSString*)title {
1243 // Mac OS X wants static text exposed in AXValue. 1242 // Mac OS X wants static text exposed in AXValue.
1244 if ([self shouldExposeNameInAXValue]) 1243 if ([self shouldExposeNameInAXValue])
1245 return @""; 1244 return @"";
1246 1245
1247 // If the name came from a single related element and it's present in the 1246 // If the name came from a single related element and it's present in the
1248 // tree, it will be exposed in AXTitleUIElement. 1247 // tree, it will be exposed in AXTitleUIElement.
1249 std::vector<int32> labelledby_ids = 1248 std::vector<int32_t> labelledby_ids =
1250 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS); 1249 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS);
1251 ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>( 1250 ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>(
1252 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); 1251 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM));
1253 if (nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT && 1252 if (nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT &&
1254 labelledby_ids.size() == 1 && 1253 labelledby_ids.size() == 1 &&
1255 browserAccessibility_->manager()->GetFromID(labelledby_ids[0])) { 1254 browserAccessibility_->manager()->GetFromID(labelledby_ids[0])) {
1256 return @""; 1255 return @"";
1257 } 1256 }
1258 1257
1259 // On Mac OS X, the accessible name of an object is exposed as its 1258 // On Mac OS X, the accessible name of an object is exposed as its
1260 // title if it comes from visible text, and as its description 1259 // title if it comes from visible text, and as its description
1261 // otherwise, but never both. 1260 // otherwise, but never both.
1262 if (nameFrom == ui::AX_NAME_FROM_CONTENTS || 1261 if (nameFrom == ui::AX_NAME_FROM_CONTENTS ||
1263 nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT || 1262 nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT ||
1264 nameFrom == ui::AX_NAME_FROM_VALUE) { 1263 nameFrom == ui::AX_NAME_FROM_VALUE) {
1265 return NSStringForStringAttribute( 1264 return NSStringForStringAttribute(
1266 browserAccessibility_, ui::AX_ATTR_NAME); 1265 browserAccessibility_, ui::AX_ATTR_NAME);
1267 } 1266 }
1268 1267
1269 return nil; 1268 return nil;
1270 } 1269 }
1271 1270
1272 - (id)titleUIElement { 1271 - (id)titleUIElement {
1273 std::vector<int32> labelledby_ids = 1272 std::vector<int32_t> labelledby_ids =
1274 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS); 1273 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS);
1275 ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>( 1274 ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>(
1276 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); 1275 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM));
1277 if (nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT && 1276 if (nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT &&
1278 labelledby_ids.size() == 1) { 1277 labelledby_ids.size() == 1) {
1279 BrowserAccessibility* titleElement = 1278 BrowserAccessibility* titleElement =
1280 browserAccessibility_->manager()->GetFromID(labelledby_ids[0]); 1279 browserAccessibility_->manager()->GetFromID(labelledby_ids[0]);
1281 if (titleElement) 1280 if (titleElement)
1282 return titleElement->ToBrowserAccessibilityCocoa(); 1281 return titleElement->ToBrowserAccessibilityCocoa();
1283 } 1282 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 return nil; 1366 return nil;
1368 } 1367 }
1369 1368
1370 - (NSValue*)visibleCharacterRange { 1369 - (NSValue*)visibleCharacterRange {
1371 base::string16 value = browserAccessibility_->GetValue(); 1370 base::string16 value = browserAccessibility_->GetValue();
1372 return [NSValue valueWithRange:NSMakeRange(0, value.size())]; 1371 return [NSValue valueWithRange:NSMakeRange(0, value.size())];
1373 } 1372 }
1374 1373
1375 - (NSArray*)visibleCells { 1374 - (NSArray*)visibleCells {
1376 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; 1375 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease];
1377 const std::vector<int32>& uniqueCellIds = 1376 const std::vector<int32_t>& uniqueCellIds =
1378 browserAccessibility_->GetIntListAttribute( 1377 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
1379 ui::AX_ATTR_UNIQUE_CELL_IDS);
1380 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { 1378 for (size_t i = 0; i < uniqueCellIds.size(); ++i) {
1381 int id = uniqueCellIds[i]; 1379 int id = uniqueCellIds[i];
1382 BrowserAccessibility* cell = 1380 BrowserAccessibility* cell =
1383 browserAccessibility_->manager()->GetFromID(id); 1381 browserAccessibility_->manager()->GetFromID(id);
1384 if (cell) 1382 if (cell)
1385 [ret addObject:cell->ToBrowserAccessibilityCocoa()]; 1383 [ret addObject:cell->ToBrowserAccessibilityCocoa()];
1386 } 1384 }
1387 return ret; 1385 return ret;
1388 } 1386 }
1389 1387
1390 - (NSArray*)visibleChildren { 1388 - (NSArray*)visibleChildren {
1391 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; 1389 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease];
1392 uint32 childCount = browserAccessibility_->PlatformChildCount(); 1390 uint32_t childCount = browserAccessibility_->PlatformChildCount();
1393 for (uint32 index = 0; index < childCount; ++index) { 1391 for (uint32_t index = 0; index < childCount; ++index) {
1394 BrowserAccessibilityCocoa* child = 1392 BrowserAccessibilityCocoa* child =
1395 browserAccessibility_->PlatformGetChild(index)-> 1393 browserAccessibility_->PlatformGetChild(index)->
1396 ToBrowserAccessibilityCocoa(); 1394 ToBrowserAccessibilityCocoa();
1397 [ret addObject:child]; 1395 [ret addObject:child];
1398 } 1396 }
1399 return ret; 1397 return ret;
1400 } 1398 }
1401 1399
1402 - (NSArray*)visibleColumns { 1400 - (NSArray*)visibleColumns {
1403 return [self columns]; 1401 return [self columns];
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 int selStart, selEnd; 1458 int selStart, selEnd;
1461 if (browserAccessibility_->GetIntAttribute( 1459 if (browserAccessibility_->GetIntAttribute(
1462 ui::AX_ATTR_TEXT_SEL_START, &selStart) && 1460 ui::AX_ATTR_TEXT_SEL_START, &selStart) &&
1463 browserAccessibility_-> 1461 browserAccessibility_->
1464 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, &selEnd)) { 1462 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, &selEnd)) {
1465 if (selStart > selEnd) 1463 if (selStart > selEnd)
1466 std::swap(selStart, selEnd); 1464 std::swap(selStart, selEnd);
1467 int selLength = selEnd - selStart; 1465 int selLength = selEnd - selStart;
1468 if ([attribute isEqualToString: 1466 if ([attribute isEqualToString:
1469 NSAccessibilityInsertionPointLineNumberAttribute]) { 1467 NSAccessibilityInsertionPointLineNumberAttribute]) {
1470 const std::vector<int32>& line_breaks = 1468 const std::vector<int32_t>& line_breaks =
1471 browserAccessibility_->GetIntListAttribute( 1469 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS);
1472 ui::AX_ATTR_LINE_BREAKS);
1473 for (int i = 0; i < static_cast<int>(line_breaks.size()); ++i) { 1470 for (int i = 0; i < static_cast<int>(line_breaks.size()); ++i) {
1474 if (line_breaks[i] > selStart) 1471 if (line_breaks[i] > selStart)
1475 return [NSNumber numberWithInt:i]; 1472 return [NSNumber numberWithInt:i];
1476 } 1473 }
1477 return [NSNumber numberWithInt:static_cast<int>(line_breaks.size())]; 1474 return [NSNumber numberWithInt:static_cast<int>(line_breaks.size())];
1478 } 1475 }
1479 if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute]) { 1476 if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute]) {
1480 base::string16 value = browserAccessibility_->GetValue(); 1477 base::string16 value = browserAccessibility_->GetValue();
1481 return base::SysUTF16ToNSString(value.substr(selStart, selLength)); 1478 return base::SysUTF16ToNSString(value.substr(selStart, selLength));
1482 } 1479 }
1483 if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { 1480 if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) {
1484 return [NSValue valueWithRange:NSMakeRange(selStart, selLength)]; 1481 return [NSValue valueWithRange:NSMakeRange(selStart, selLength)];
1485 } 1482 }
1486 } 1483 }
1487 return nil; 1484 return nil;
1488 } 1485 }
1489 1486
1490 // Returns the accessibility value for the given attribute and parameter. If the 1487 // Returns the accessibility value for the given attribute and parameter. If the
1491 // value isn't supported this will return nil. 1488 // value isn't supported this will return nil.
1492 - (id)accessibilityAttributeValue:(NSString*)attribute 1489 - (id)accessibilityAttributeValue:(NSString*)attribute
1493 forParameter:(id)parameter { 1490 forParameter:(id)parameter {
1494 if (!browserAccessibility_) 1491 if (!browserAccessibility_)
1495 return nil; 1492 return nil;
1496 1493
1497 const std::vector<int32>& line_breaks = 1494 const std::vector<int32_t>& line_breaks =
1498 browserAccessibility_->GetIntListAttribute( 1495 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS);
1499 ui::AX_ATTR_LINE_BREAKS);
1500 base::string16 value = browserAccessibility_->GetValue(); 1496 base::string16 value = browserAccessibility_->GetValue();
1501 int len = static_cast<int>(value.size()); 1497 int len = static_cast<int>(value.size());
1502 1498
1503 if ([attribute isEqualToString: 1499 if ([attribute isEqualToString:
1504 NSAccessibilityStringForRangeParameterizedAttribute]) { 1500 NSAccessibilityStringForRangeParameterizedAttribute]) {
1505 return [self valueForRange:[(NSValue*)parameter rangeValue]]; 1501 return [self valueForRange:[(NSValue*)parameter rangeValue]];
1506 } 1502 }
1507 1503
1508 if ([attribute 1504 if ([attribute
1509 isEqualToString: 1505 isEqualToString:
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 if (!browserAccessibility_) 2082 if (!browserAccessibility_)
2087 return [super hash]; 2083 return [super hash];
2088 return browserAccessibility_->GetId(); 2084 return browserAccessibility_->GetId();
2089 } 2085 }
2090 2086
2091 - (BOOL)accessibilityShouldUseUniqueId { 2087 - (BOOL)accessibilityShouldUseUniqueId {
2092 return YES; 2088 return YES;
2093 } 2089 }
2094 2090
2095 @end 2091 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698