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

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

Issue 2707263011: Test aria-pressed=mixed on windows (Closed)
Patch Set: git cl try Created 3 years, 6 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 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 5 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
6 6
7 #include <execinfo.h> 7 #include <execinfo.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 - (NSString*)role { 1361 - (NSString*)role {
1362 if (![self instanceActive]) 1362 if (![self instanceActive])
1363 return nil; 1363 return nil;
1364 1364
1365 ui::AXRole role = [self internalRole]; 1365 ui::AXRole role = [self internalRole];
1366 if (role == ui::AX_ROLE_CANVAS && 1366 if (role == ui::AX_ROLE_CANVAS &&
1367 browserAccessibility_->GetBoolAttribute( 1367 browserAccessibility_->GetBoolAttribute(
1368 ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { 1368 ui::AX_ATTR_CANVAS_HAS_FALLBACK)) {
1369 return NSAccessibilityGroupRole; 1369 return NSAccessibilityGroupRole;
1370 } 1370 }
1371 if (role == ui::AX_ROLE_BUTTON || role == ui::AX_ROLE_TOGGLE_BUTTON) { 1371
1372 bool isAriaPressedDefined; 1372 // TODO do we need these 2 lines? A basic role mapping should do it:
1373 bool isMixed; 1373 // if (role == ui::AX_ROLE_BUTTON)
1374 browserAccessibility_->GetAriaTristate("aria-pressed", 1374 // return NSAccessibilityButtonRole;
1375 &isAriaPressedDefined, 1375 // if (role == ui::AX_ROLE_TOGGLE_BUTTON)
1376 &isMixed); 1376 // return NSAccessibilityCheckBoxRole;
1377 if (isAriaPressedDefined) 1377
1378 return NSAccessibilityCheckBoxRole;
1379 else
1380 return NSAccessibilityButtonRole;
1381 }
1382 if ((browserAccessibility_->IsSimpleTextControl() && 1378 if ((browserAccessibility_->IsSimpleTextControl() &&
1383 browserAccessibility_->HasState(ui::AX_STATE_MULTILINE)) || 1379 browserAccessibility_->HasState(ui::AX_STATE_MULTILINE)) ||
1384 browserAccessibility_->IsRichTextControl()) { 1380 browserAccessibility_->IsRichTextControl()) {
1385 return NSAccessibilityTextAreaRole; 1381 return NSAccessibilityTextAreaRole;
1386 } 1382 }
1387 1383
1388 // If this is a web area for a presentational iframe, give it a role of 1384 // If this is a web area for a presentational iframe, give it a role of
1389 // something other than WebArea so that the fact that it's a separate doc 1385 // something other than WebArea so that the fact that it's a separate doc
1390 // is not exposed to AT. 1386 // is not exposed to AT.
1391 if (browserAccessibility_->IsWebAreaForPresentationalIframe()) 1387 if (browserAccessibility_->IsWebAreaForPresentationalIframe())
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 } else if ([role isEqualToString:@"AXHeading"]) { 1860 } else if ([role isEqualToString:@"AXHeading"]) {
1865 int level = 0; 1861 int level = 0;
1866 if (browserAccessibility_->GetIntAttribute( 1862 if (browserAccessibility_->GetIntAttribute(
1867 ui::AX_ATTR_HIERARCHICAL_LEVEL, &level)) { 1863 ui::AX_ATTR_HIERARCHICAL_LEVEL, &level)) {
1868 return [NSNumber numberWithInt:level]; 1864 return [NSNumber numberWithInt:level];
1869 } 1865 }
1870 } else if ([role isEqualToString:NSAccessibilityButtonRole]) { 1866 } else if ([role isEqualToString:NSAccessibilityButtonRole]) {
1871 // AXValue does not make sense for pure buttons. 1867 // AXValue does not make sense for pure buttons.
1872 return @""; 1868 return @"";
1873 } else if ([self internalRole] == ui::AX_ROLE_TOGGLE_BUTTON) { 1869 } else if ([self internalRole] == ui::AX_ROLE_TOGGLE_BUTTON) {
1874 int value = 0; 1870 const auto pressedState = static_cast<ui::AXButtonState>(
1875 bool isAriaPressedDefined; 1871 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_PRESSED_STATE));
1876 bool isMixed; 1872 switch (pressedState) {
1877 value = browserAccessibility_->GetAriaTristate( 1873 case ui::AX_BUTTON_STATE_TRUE:
1878 "aria-pressed", &isAriaPressedDefined, &isMixed) ? 1 : 0; 1874 value = 1;
1879 1875 break;
1880 if (isMixed) 1876 case ui::AX_BUTTON_STATE_MIXED:
1881 value = 2; 1877 value = 2;
1882 1878 break;
1879 default:
1880 value = 0;
1881 break;
1882 }
1883 return [NSNumber numberWithInt:value]; 1883 return [NSNumber numberWithInt:value];
1884
1885 } else if ([role isEqualToString:NSAccessibilityCheckBoxRole] || 1884 } else if ([role isEqualToString:NSAccessibilityCheckBoxRole] ||
1886 [role isEqualToString:NSAccessibilityRadioButtonRole] || 1885 [role isEqualToString:NSAccessibilityRadioButtonRole] ||
1887 [self internalRole] == ui::AX_ROLE_MENU_ITEM_CHECK_BOX || 1886 [self internalRole] == ui::AX_ROLE_MENU_ITEM_CHECK_BOX ||
1888 [self internalRole] == ui::AX_ROLE_MENU_ITEM_RADIO) { 1887 [self internalRole] == ui::AX_ROLE_MENU_ITEM_RADIO) {
1889 int value; 1888 int value;
1890 const auto checkedState = static_cast<ui::AXCheckedState>( 1889 const auto checkedState = static_cast<ui::AXButtonState>(
1891 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); 1890 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_CHECKED_STATE));
1892 switch (checkedState) { 1891 switch (checkedState) {
1893 case ui::AX_CHECKED_STATE_TRUE: 1892 case ui::AX_CHECKED_STATE_TRUE:
1894 value = 1; 1893 value = 1;
1895 break; 1894 break;
1896 case ui::AX_CHECKED_STATE_MIXED: 1895 case ui::AX_CHECKED_STATE_MIXED:
1897 value = 2; 1896 value = 2;
1898 break; 1897 break;
1899 default: 1898 default:
1900 value = GetState(browserAccessibility_, ui::AX_STATE_SELECTED) ? 1 : 0; 1899 value = GetState(browserAccessibility_, ui::AX_STATE_SELECTED) ? 1 : 0;
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
2902 } 2901 }
2903 2902
2904 - (BOOL)accessibilityNotifiesWhenDestroyed { 2903 - (BOOL)accessibilityNotifiesWhenDestroyed {
2905 // Indicate that BrowserAccessibilityCocoa will post a notification when it's 2904 // Indicate that BrowserAccessibilityCocoa will post a notification when it's
2906 // destroyed (see -detach). This allows VoiceOver to do some internal things 2905 // destroyed (see -detach). This allows VoiceOver to do some internal things
2907 // more efficiently. 2906 // more efficiently.
2908 return YES; 2907 return YES;
2909 } 2908 }
2910 2909
2911 @end 2910 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698