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

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp

Issue 2893683002: Selection follows focus/activedescendant in single selection containers (Closed)
Patch Set: Last test to fix we hope 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 /* 1 /*
2 * Copyright (C) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 if (type == InputTypeNames::time) 533 if (type == InputTypeNames::time)
534 return kInputTimeRole; 534 return kInputTimeRole;
535 return kTextFieldRole; 535 return kTextFieldRole;
536 } 536 }
537 537
538 if (isHTMLSelectElement(*GetNode())) { 538 if (isHTMLSelectElement(*GetNode())) {
539 HTMLSelectElement& select_element = toHTMLSelectElement(*GetNode()); 539 HTMLSelectElement& select_element = toHTMLSelectElement(*GetNode());
540 return select_element.IsMultiple() ? kListBoxRole : kPopUpButtonRole; 540 return select_element.IsMultiple() ? kListBoxRole : kPopUpButtonRole;
541 } 541 }
542 542
543 if (isHTMLOptionElement(*GetNode())) {
544 HTMLSelectElement* select_element =
545 toHTMLOptionElement(GetNode())->OwnerSelectElement();
546 return select_element->IsMultiple() ? kListBoxOptionRole
547 : kMenuListOptionRole;
548 }
549
543 if (isHTMLTextAreaElement(*GetNode())) 550 if (isHTMLTextAreaElement(*GetNode()))
544 return kTextFieldRole; 551 return kTextFieldRole;
545 552
546 if (HeadingLevel()) 553 if (HeadingLevel())
547 return kHeadingRole; 554 return kHeadingRole;
548 555
549 if (isHTMLDivElement(*GetNode())) 556 if (isHTMLDivElement(*GetNode()))
550 return kGenericContainerRole; 557 return kGenericContainerRole;
551 558
552 if (isHTMLMeterElement(*GetNode())) 559 if (isHTMLMeterElement(*GetNode()))
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 if (!IsPresentational() && AriaRoleAttribute() != kUnknownRole && 1289 if (!IsPresentational() && AriaRoleAttribute() != kUnknownRole &&
1283 AncestorExposesActiveDescendant()) 1290 AncestorExposesActiveDescendant())
1284 return true; 1291 return true;
1285 1292
1286 // NOTE: It would be more accurate to ask the document whether 1293 // NOTE: It would be more accurate to ask the document whether
1287 // setFocusedNode() would do anything. For example, setFocusedNode() will do 1294 // setFocusedNode() would do anything. For example, setFocusedNode() will do
1288 // nothing if the current focused node will not relinquish the focus. 1295 // nothing if the current focused node will not relinquish the focus.
1289 if (IsDisabledFormControl(node)) 1296 if (IsDisabledFormControl(node))
1290 return false; 1297 return false;
1291 1298
1299 // Check for options here because AXListBoxOption and AXMenuListOption
1300 // don't help when the <option> is canvas fallback, and because
1301 // a common case for aria-owns from a textbox that points to a list
1302 // does not change the hierarchy (textboxes don't suport children)
1303 if ((RoleValue() == kListBoxOptionRole ||
1304 RoleValue() == kMenuListOptionRole) &&
1305 IsEnabled())
1306 return true;
1307
1292 return node->IsElementNode() && ToElement(node)->SupportsFocus(); 1308 return node->IsElementNode() && ToElement(node)->SupportsFocus();
1293 } 1309 }
1294 1310
1295 bool AXNodeObject::CanSetValueAttribute() const { 1311 bool AXNodeObject::CanSetValueAttribute() const {
1296 if (AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kReadOnly)) 1312 if (AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kReadOnly))
1297 return false; 1313 return false;
1298 1314
1299 if (IsProgressIndicator() || IsSlider()) 1315 if (IsProgressIndicator() || IsSlider())
1300 return true; 1316 return true;
1301 1317
1302 if (IsTextControl() && !IsNativeTextControl()) 1318 if (IsTextControl() && !IsNativeTextControl())
1303 return true; 1319 return true;
1304 1320
1305 // Any node could be contenteditable, so isReadOnly should be relied upon 1321 // Any node could be contenteditable, so isReadOnly should be relied upon
1306 // for this information for all elements. 1322 // for this information for all elements.
1307 return !IsReadOnly(); 1323 return !IsReadOnly();
1308 } 1324 }
1309 1325
1310 bool AXNodeObject::CanSetSelectedAttribute() const { 1326 bool AXNodeObject::CanSetSelectedAttribute() const {
1311 // ARIA list box options can be selected if they are children of an element 1327 const AccessibilityRole role = AriaRoleAttribute();
1312 // with an aria-activedescendant attribute. 1328 // These elements can be selected if not disabled (native or ARIA)
1313 if (AriaRoleAttribute() == kListBoxOptionRole && 1329 if ((role == kListBoxOptionRole || role == kMenuListOptionRole ||
1314 AncestorExposesActiveDescendant()) 1330 role == kTreeItemRole || role == kCellRole || role == kTabRole) &&
David Tseng 2017/06/06 21:28:47 The spec includes the roles: gridcell option row
1331 IsEnabled() && CanSetFocusAttribute()) {
1315 return true; 1332 return true;
1333 }
1316 return AXObjectImpl::CanSetSelectedAttribute(); 1334 return AXObjectImpl::CanSetSelectedAttribute();
1317 } 1335 }
1318 1336
1319 bool AXNodeObject::CanvasHasFallbackContent() const { 1337 bool AXNodeObject::CanvasHasFallbackContent() const {
1320 Node* node = this->GetNode(); 1338 Node* node = this->GetNode();
1321 if (!isHTMLCanvasElement(node)) 1339 if (!isHTMLCanvasElement(node))
1322 return false; 1340 return false;
1323 1341
1324 // If it has any children that are elements, we'll assume it might be fallback 1342 // If it has any children that are elements, we'll assume it might be fallback
1325 // content. If it has no children or its only children are not elements 1343 // content. If it has no children or its only children are not elements
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 // If an element has an ARIA role of presentation, we need to consider the 2250 // If an element has an ARIA role of presentation, we need to consider the
2233 // native role when deciding whether it can have children or not - otherwise 2251 // native role when deciding whether it can have children or not - otherwise
2234 // giving something a role of presentation could expose inner implementation 2252 // giving something a role of presentation could expose inner implementation
2235 // details. 2253 // details.
2236 if (IsPresentational()) 2254 if (IsPresentational())
2237 role = NativeAccessibilityRoleIgnoringAria(); 2255 role = NativeAccessibilityRoleIgnoringAria();
2238 2256
2239 switch (role) { 2257 switch (role) {
2240 case kImageRole: 2258 case kImageRole:
2241 case kButtonRole: 2259 case kButtonRole:
2242 case kPopUpButtonRole:
2243 case kCheckBoxRole: 2260 case kCheckBoxRole:
2244 case kRadioButtonRole: 2261 case kRadioButtonRole:
2245 case kSwitchRole: 2262 case kSwitchRole:
2246 case kTabRole: 2263 case kTabRole:
2247 case kToggleButtonRole: 2264 case kToggleButtonRole:
2248 case kListBoxOptionRole: 2265 case kListBoxOptionRole:
2266 case kMenuButtonRole:
2267 case kMenuListOptionRole:
2249 case kScrollBarRole: 2268 case kScrollBarRole:
2250 return false; 2269 return false;
2270 case kPopUpButtonRole:
2271 return isHTMLSelectElement(GetNode());
2251 case kStaticTextRole: 2272 case kStaticTextRole:
2252 if (!AxObjectCache().InlineTextBoxAccessibilityEnabled()) 2273 if (!AxObjectCache().InlineTextBoxAccessibilityEnabled())
2253 return false; 2274 return false;
2254 default: 2275 default:
2255 return true; 2276 return true;
2256 } 2277 }
2257 } 2278 }
2258 2279
2259 Element* AXNodeObject::ActionElement() const { 2280 Element* AXNodeObject::ActionElement() const {
2260 Node* node = this->GetNode(); 2281 Node* node = this->GetNode();
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
3229 return String(); 3250 return String();
3230 return ToTextControlElement(node)->StrippedPlaceholder(); 3251 return ToTextControlElement(node)->StrippedPlaceholder();
3231 } 3252 }
3232 3253
3233 DEFINE_TRACE(AXNodeObject) { 3254 DEFINE_TRACE(AXNodeObject) {
3234 visitor->Trace(node_); 3255 visitor->Trace(node_);
3235 AXObjectImpl::Trace(visitor); 3256 AXObjectImpl::Trace(visitor);
3236 } 3257 }
3237 3258
3238 } // namespace blink 3259 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698