Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 // focusable. Check instead if the frame's selection controller is focused | 450 // focusable. Check instead if the frame's selection controller is focused |
| 451 if (focused_object == this || | 451 if (focused_object == this || |
| 452 (RoleValue() == kWebAreaRole && | 452 (RoleValue() == kWebAreaRole && |
| 453 GetDocument()->GetFrame()->Selection().FrameIsFocusedAndActive())) | 453 GetDocument()->GetFrame()->Selection().FrameIsFocusedAndActive())) |
| 454 return true; | 454 return true; |
| 455 | 455 |
| 456 return false; | 456 return false; |
| 457 } | 457 } |
| 458 | 458 |
| 459 bool AXLayoutObject::IsSelected() const { | 459 bool AXLayoutObject::IsSelected() const { |
| 460 if (!GetLayoutObject() || !GetNode()) | 460 if (!GetLayoutObject() || !GetNode() || !CanSetSelectedAttribute()) |
| 461 return false; | 461 return false; |
| 462 | 462 |
| 463 if (AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kSelected)) | 463 // aria-selected overrides automatic behaviors |
|
David Tseng
2017/06/06 20:58:30
Note that this doesn't actually happen because the
| |
| 464 return true; | 464 bool is_selected; |
| 465 if (HasAOMPropertyOrARIAAttribute(AOMBooleanProperty::kSelected, is_selected)) | |
| 466 return is_selected; | |
| 465 | 467 |
| 466 AXObjectImpl* focused_object = AxObjectCache().FocusedObject(); | 468 // Tab item with focus in the associated tab |
| 467 if (AriaRoleAttribute() == kListBoxOptionRole && focused_object && | |
| 468 focused_object->ActiveDescendant() == this) { | |
| 469 return true; | |
| 470 } | |
| 471 | |
| 472 if (IsTabItem() && IsTabItemSelected()) | 469 if (IsTabItem() && IsTabItemSelected()) |
| 473 return true; | 470 return true; |
| 474 | 471 |
| 475 return false; | 472 // Selection follows focus, but ONLY in single selection containers, |
| 473 // and only if aria-selected was not present to override | |
| 474 | |
| 475 AXObjectImpl* container = ContainerWidget(); | |
| 476 if (!container || container->IsMultiSelectable()) | |
| 477 return false; | |
| 478 | |
| 479 AXObjectImpl* focused_object = AxObjectCache().FocusedObject(); | |
| 480 return focused_object == this || | |
| 481 (focused_object && focused_object->ActiveDescendant() == this); | |
| 476 } | 482 } |
| 477 | 483 |
| 478 // | 484 // |
| 479 // Whether objects are ignored, i.e. not included in the tree. | 485 // Whether objects are ignored, i.e. not included in the tree. |
| 480 // | 486 // |
| 481 | 487 |
| 482 AXObjectInclusion AXLayoutObject::DefaultObjectInclusion( | 488 AXObjectInclusion AXLayoutObject::DefaultObjectInclusion( |
| 483 IgnoredReasons* ignored_reasons) const { | 489 IgnoredReasons* ignored_reasons) const { |
| 484 // The following cases can apply to any element that's a subclass of | 490 // The following cases can apply to any element that's a subclass of |
| 485 // AXLayoutObject. | 491 // AXLayoutObject. |
| (...skipping 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2524 | 2530 |
| 2525 bool AXLayoutObject::ElementAttributeValue( | 2531 bool AXLayoutObject::ElementAttributeValue( |
| 2526 const QualifiedName& attribute_name) const { | 2532 const QualifiedName& attribute_name) const { |
| 2527 if (!layout_object_) | 2533 if (!layout_object_) |
| 2528 return false; | 2534 return false; |
| 2529 | 2535 |
| 2530 return EqualIgnoringASCIICase(GetAttribute(attribute_name), "true"); | 2536 return EqualIgnoringASCIICase(GetAttribute(attribute_name), "true"); |
| 2531 } | 2537 } |
| 2532 | 2538 |
| 2533 } // namespace blink | 2539 } // namespace blink |
| OLD | NEW |