| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 { | 528 { |
| 529 return isProgressIndicator() | 529 return isProgressIndicator() |
| 530 || isMeter() | 530 || isMeter() |
| 531 || isSlider() | 531 || isSlider() |
| 532 || isScrollbar() | 532 || isScrollbar() |
| 533 || isSpinButton(); | 533 || isSpinButton(); |
| 534 } | 534 } |
| 535 | 535 |
| 536 void AXObject::ariaTreeRows(AccessibilityChildrenVector& result) | 536 void AXObject::ariaTreeRows(AccessibilityChildrenVector& result) |
| 537 { | 537 { |
| 538 const AccessibilityChildrenVector& axChildren = children(); | 538 for (const auto& child : children()) { |
| 539 unsigned count = axChildren.size(); | |
| 540 for (unsigned k = 0; k < count; ++k) { | |
| 541 AXObject* obj = axChildren[k].get(); | |
| 542 | |
| 543 // Add tree items as the rows. | 539 // Add tree items as the rows. |
| 544 if (obj->roleValue() == TreeItemRole) | 540 if (child->roleValue() == TreeItemRole) |
| 545 result.append(obj); | 541 result.append(child); |
| 546 | 542 |
| 547 // Now see if this item also has rows hiding inside of it. | 543 // Now see if this item also has rows hiding inside of it. |
| 548 obj->ariaTreeRows(result); | 544 child->ariaTreeRows(result); |
| 549 } | 545 } |
| 550 } | 546 } |
| 551 | 547 |
| 552 bool AXObject::isLiveRegion() const | 548 bool AXObject::isLiveRegion() const |
| 553 { | 549 { |
| 554 const AtomicString& liveRegion = liveRegionStatus(); | 550 const AtomicString& liveRegion = liveRegionStatus(); |
| 555 return equalIgnoringCase(liveRegion, "polite") || equalIgnoringCase(liveRegi
on, "assertive"); | 551 return equalIgnoringCase(liveRegion, "polite") || equalIgnoringCase(liveRegi
on, "assertive"); |
| 556 } | 552 } |
| 557 | 553 |
| 558 const AXObject* AXObject::liveRegionRoot() const | 554 const AXObject* AXObject::liveRegionRoot() const |
| (...skipping 21 matching lines...) Expand all Loading... |
| 580 } | 576 } |
| 581 | 577 |
| 582 bool AXObject::containerLiveRegionBusy() const | 578 bool AXObject::containerLiveRegionBusy() const |
| 583 { | 579 { |
| 584 updateCachedAttributeValuesIfNeeded(); | 580 updateCachedAttributeValuesIfNeeded(); |
| 585 return m_cachedLiveRegionRoot ? m_cachedLiveRegionRoot->liveRegionBusy() : f
alse; | 581 return m_cachedLiveRegionRoot ? m_cachedLiveRegionRoot->liveRegionBusy() : f
alse; |
| 586 } | 582 } |
| 587 | 583 |
| 588 void AXObject::markCachedElementRectDirty() const | 584 void AXObject::markCachedElementRectDirty() const |
| 589 { | 585 { |
| 590 for (unsigned i = 0; i < m_children.size(); ++i) | 586 for (const auto& child : m_children) |
| 591 m_children[i].get()->markCachedElementRectDirty(); | 587 child->markCachedElementRectDirty(); |
| 592 } | 588 } |
| 593 | 589 |
| 594 IntPoint AXObject::clickPoint() | 590 IntPoint AXObject::clickPoint() |
| 595 { | 591 { |
| 596 LayoutRect rect = elementRect(); | 592 LayoutRect rect = elementRect(); |
| 597 return roundedIntPoint(LayoutPoint(rect.x() + rect.width() / 2, rect.y() + r
ect.height() / 2)); | 593 return roundedIntPoint(LayoutPoint(rect.x() + rect.width() / 2, rect.y() + r
ect.height() / 2)); |
| 598 } | 594 } |
| 599 | 595 |
| 600 IntRect AXObject::boundingBoxForQuads(LayoutObject* obj, const Vector<FloatQuad>
& quads) | 596 IntRect AXObject::boundingBoxForQuads(LayoutObject* obj, const Vector<FloatQuad>
& quads) |
| 601 { | 597 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 623 { | 619 { |
| 624 // Send the hit test back into the sub-frame if necessary. | 620 // Send the hit test back into the sub-frame if necessary. |
| 625 if (isAttachment()) { | 621 if (isAttachment()) { |
| 626 Widget* widget = widgetForAttachmentView(); | 622 Widget* widget = widgetForAttachmentView(); |
| 627 // Normalize the point for the widget's bounds. | 623 // Normalize the point for the widget's bounds. |
| 628 if (widget && widget->isFrameView()) | 624 if (widget && widget->isFrameView()) |
| 629 return axObjectCache()->getOrCreate(widget)->accessibilityHitTest(In
tPoint(point - widget->frameRect().location())); | 625 return axObjectCache()->getOrCreate(widget)->accessibilityHitTest(In
tPoint(point - widget->frameRect().location())); |
| 630 } | 626 } |
| 631 | 627 |
| 632 // Check if there are any mock elements that need to be handled. | 628 // Check if there are any mock elements that need to be handled. |
| 633 size_t count = m_children.size(); | 629 for (const auto& child : m_children) { |
| 634 for (size_t k = 0; k < count; k++) { | 630 if (child->isMockObject() && child->elementRect().contains(point)) |
| 635 if (m_children[k]->isMockObject() && m_children[k]->elementRect().contai
ns(point)) | 631 return child->elementAccessibilityHitTest(point); |
| 636 return m_children[k]->elementAccessibilityHitTest(point); | |
| 637 } | 632 } |
| 638 | 633 |
| 639 return const_cast<AXObject*>(this); | 634 return const_cast<AXObject*>(this); |
| 640 } | 635 } |
| 641 | 636 |
| 642 const AXObject::AccessibilityChildrenVector& AXObject::children() | 637 const AXObject::AccessibilityChildrenVector& AXObject::children() |
| 643 { | 638 { |
| 644 updateChildrenIfNecessary(); | 639 updateChildrenIfNecessary(); |
| 645 | 640 |
| 646 return m_children; | 641 return m_children; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 | 674 |
| 680 void AXObject::updateChildrenIfNecessary() | 675 void AXObject::updateChildrenIfNecessary() |
| 681 { | 676 { |
| 682 if (!hasChildren()) | 677 if (!hasChildren()) |
| 683 addChildren(); | 678 addChildren(); |
| 684 } | 679 } |
| 685 | 680 |
| 686 void AXObject::clearChildren() | 681 void AXObject::clearChildren() |
| 687 { | 682 { |
| 688 // Detach all weak pointers from objects to their parents. | 683 // Detach all weak pointers from objects to their parents. |
| 689 size_t length = m_children.size(); | 684 for (const auto& child : m_children) |
| 690 for (size_t i = 0; i < length; i++) | 685 child->detachFromParent(); |
| 691 m_children[i]->detachFromParent(); | |
| 692 | 686 |
| 693 m_children.clear(); | 687 m_children.clear(); |
| 694 m_haveChildren = false; | 688 m_haveChildren = false; |
| 695 } | 689 } |
| 696 | 690 |
| 697 AXObject* AXObject::focusedUIElement() const | 691 AXObject* AXObject::focusedUIElement() const |
| 698 { | 692 { |
| 699 Document* doc = document(); | 693 Document* doc = document(); |
| 700 if (!doc) | 694 if (!doc) |
| 701 return 0; | 695 return 0; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 | 1033 |
| 1040 AccessibilityRole AXObject::ariaRoleToWebCoreRole(const String& value) | 1034 AccessibilityRole AXObject::ariaRoleToWebCoreRole(const String& value) |
| 1041 { | 1035 { |
| 1042 ASSERT(!value.isEmpty()); | 1036 ASSERT(!value.isEmpty()); |
| 1043 | 1037 |
| 1044 static const ARIARoleMap* roleMap = createARIARoleMap(); | 1038 static const ARIARoleMap* roleMap = createARIARoleMap(); |
| 1045 | 1039 |
| 1046 Vector<String> roleVector; | 1040 Vector<String> roleVector; |
| 1047 value.split(' ', roleVector); | 1041 value.split(' ', roleVector); |
| 1048 AccessibilityRole role = UnknownRole; | 1042 AccessibilityRole role = UnknownRole; |
| 1049 unsigned size = roleVector.size(); | 1043 for (const auto& child : roleVector) { |
| 1050 for (unsigned i = 0; i < size; ++i) { | 1044 role = roleMap->get(child); |
| 1051 String roleName = roleVector[i]; | |
| 1052 role = roleMap->get(roleName); | |
| 1053 if (role) | 1045 if (role) |
| 1054 return role; | 1046 return role; |
| 1055 } | 1047 } |
| 1056 | 1048 |
| 1057 return role; | 1049 return role; |
| 1058 } | 1050 } |
| 1059 | 1051 |
| 1060 bool AXObject::isInsideFocusableElementOrARIAWidget(const Node& node) | 1052 bool AXObject::isInsideFocusableElementOrARIAWidget(const Node& node) |
| 1061 { | 1053 { |
| 1062 const Node* curNode = &node; | 1054 const Node* curNode = &node; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1086 } | 1078 } |
| 1087 return false; | 1079 return false; |
| 1088 } | 1080 } |
| 1089 | 1081 |
| 1090 bool AXObject::includesARIAWidgetRole(const String& role) | 1082 bool AXObject::includesARIAWidgetRole(const String& role) |
| 1091 { | 1083 { |
| 1092 static const HashSet<String, CaseFoldingHash>* roleSet = createARIARoleWidge
tSet(); | 1084 static const HashSet<String, CaseFoldingHash>* roleSet = createARIARoleWidge
tSet(); |
| 1093 | 1085 |
| 1094 Vector<String> roleVector; | 1086 Vector<String> roleVector; |
| 1095 role.split(' ', roleVector); | 1087 role.split(' ', roleVector); |
| 1096 unsigned size = roleVector.size(); | 1088 for (const auto& child : roleVector) { |
| 1097 for (unsigned i = 0; i < size; ++i) { | 1089 if (roleSet->contains(child)) |
| 1098 String roleName = roleVector[i]; | |
| 1099 if (roleSet->contains(roleName)) | |
| 1100 return true; | 1090 return true; |
| 1101 } | 1091 } |
| 1102 return false; | 1092 return false; |
| 1103 } | 1093 } |
| 1104 | 1094 |
| 1105 AccessibilityRole AXObject::buttonRoleType() const | 1095 AccessibilityRole AXObject::buttonRoleType() const |
| 1106 { | 1096 { |
| 1107 // If aria-pressed is present, then it should be exposed as a toggle button. | 1097 // If aria-pressed is present, then it should be exposed as a toggle button. |
| 1108 // http://www.w3.org/TR/wai-aria/states_and_properties#aria-pressed | 1098 // http://www.w3.org/TR/wai-aria/states_and_properties#aria-pressed |
| 1109 if (ariaPressedIsPresent()) | 1099 if (ariaPressedIsPresent()) |
| 1110 return ToggleButtonRole; | 1100 return ToggleButtonRole; |
| 1111 if (ariaHasPopup()) | 1101 if (ariaHasPopup()) |
| 1112 return PopUpButtonRole; | 1102 return PopUpButtonRole; |
| 1113 // We don't contemplate RadioButtonRole, as it depends on the input | 1103 // We don't contemplate RadioButtonRole, as it depends on the input |
| 1114 // type. | 1104 // type. |
| 1115 | 1105 |
| 1116 return ButtonRole; | 1106 return ButtonRole; |
| 1117 } | 1107 } |
| 1118 | 1108 |
| 1119 const AtomicString& AXObject::roleName(AccessibilityRole role) | 1109 const AtomicString& AXObject::roleName(AccessibilityRole role) |
| 1120 { | 1110 { |
| 1121 static const Vector<AtomicString>* roleNameVector = createRoleNameVector(); | 1111 static const Vector<AtomicString>* roleNameVector = createRoleNameVector(); |
| 1122 | 1112 |
| 1123 return roleNameVector->at(role); | 1113 return roleNameVector->at(role); |
| 1124 } | 1114 } |
| 1125 | 1115 |
| 1126 } // namespace blink | 1116 } // namespace blink |
| OLD | NEW |