OLD | NEW |
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 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 Node* node = this->getNode(); | 1083 Node* node = this->getNode(); |
1084 if (!node) | 1084 if (!node) |
1085 return false; | 1085 return false; |
1086 | 1086 |
1087 if (!isHTMLInputElement(node)) | 1087 if (!isHTMLInputElement(node)) |
1088 return false; | 1088 return false; |
1089 | 1089 |
1090 return toHTMLInputElement(node)->type() == InputTypeNames::range; | 1090 return toHTMLInputElement(node)->type() == InputTypeNames::range; |
1091 } | 1091 } |
1092 | 1092 |
1093 bool AXNodeObject::isChecked() const { | |
1094 Node* node = this->getNode(); | |
1095 if (!node) | |
1096 return false; | |
1097 | |
1098 // First test for native checkedness semantics | |
1099 if (isHTMLInputElement(*node)) | |
1100 return toHTMLInputElement(*node).shouldAppearChecked(); | |
1101 | |
1102 // Else, if this is an ARIA role checkbox or radio or menuitemcheckbox | |
1103 // or menuitemradio or switch, respect the aria-checked attribute | |
1104 switch (ariaRoleAttribute()) { | |
1105 case CheckBoxRole: | |
1106 case MenuItemCheckBoxRole: | |
1107 case MenuItemRadioRole: | |
1108 case RadioButtonRole: | |
1109 case SwitchRole: | |
1110 if (equalIgnoringCase(getAttribute(aria_checkedAttr), "true")) | |
1111 return true; | |
1112 return false; | |
1113 default: | |
1114 break; | |
1115 } | |
1116 | |
1117 // Otherwise it's not checked | |
1118 return false; | |
1119 } | |
1120 | |
1121 bool AXNodeObject::isClickable() const { | 1093 bool AXNodeObject::isClickable() const { |
1122 if (getNode()) { | 1094 if (getNode()) { |
1123 if (getNode()->isElementNode() && | 1095 if (getNode()->isElementNode() && |
1124 toElement(getNode())->isDisabledFormControl()) | 1096 toElement(getNode())->isDisabledFormControl()) |
1125 return false; | 1097 return false; |
1126 | 1098 |
1127 // Note: we can't call getNode()->willRespondToMouseClickEvents() because | 1099 // Note: we can't call getNode()->willRespondToMouseClickEvents() because |
1128 // that triggers a style recalc and can delete this. | 1100 // that triggers a style recalc and can delete this. |
1129 if (getNode()->hasEventListeners(EventTypeNames::mouseup) || | 1101 if (getNode()->hasEventListeners(EventTypeNames::mouseup) || |
1130 getNode()->hasEventListeners(EventTypeNames::mousedown) || | 1102 getNode()->hasEventListeners(EventTypeNames::mousedown) || |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 if (isNativeTextControl() && | 1426 if (isNativeTextControl() && |
1455 (isHTMLTextAreaElement(*node) || isHTMLInputElement(*node))) | 1427 (isHTMLTextAreaElement(*node) || isHTMLInputElement(*node))) |
1456 return toTextControlElement(*node).value(); | 1428 return toTextControlElement(*node).value(); |
1457 | 1429 |
1458 if (!node->isElementNode()) | 1430 if (!node->isElementNode()) |
1459 return String(); | 1431 return String(); |
1460 | 1432 |
1461 return toElement(node)->innerText(); | 1433 return toElement(node)->innerText(); |
1462 } | 1434 } |
1463 | 1435 |
1464 AccessibilityButtonState AXNodeObject::checkboxOrRadioValue() const { | |
1465 if (isNativeCheckboxInMixedState()) | |
1466 return ButtonStateMixed; | |
1467 | |
1468 if (isNativeCheckboxOrRadio()) | |
1469 return isChecked() ? ButtonStateOn : ButtonStateOff; | |
1470 | |
1471 return AXObject::checkboxOrRadioValue(); | |
1472 } | |
1473 | |
1474 RGBA32 AXNodeObject::colorValue() const { | 1436 RGBA32 AXNodeObject::colorValue() const { |
1475 if (!isHTMLInputElement(getNode()) || !isColorWell()) | 1437 if (!isHTMLInputElement(getNode()) || !isColorWell()) |
1476 return AXObject::colorValue(); | 1438 return AXObject::colorValue(); |
1477 | 1439 |
1478 HTMLInputElement* input = toHTMLInputElement(getNode()); | 1440 HTMLInputElement* input = toHTMLInputElement(getNode()); |
1479 const AtomicString& type = input->getAttribute(typeAttr); | 1441 const AtomicString& type = input->getAttribute(typeAttr); |
1480 if (!equalIgnoringCase(type, "color")) | 1442 if (!equalIgnoringCase(type, "color")) |
1481 return AXObject::colorValue(); | 1443 return AXObject::colorValue(); |
1482 | 1444 |
1483 // HTMLInputElement::value always returns a string parseable by Color. | 1445 // HTMLInputElement::value always returns a string parseable by Color. |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1702 static bool isInSameNonInlineBlockFlow(LayoutObject* r1, LayoutObject* r2) { | 1664 static bool isInSameNonInlineBlockFlow(LayoutObject* r1, LayoutObject* r2) { |
1703 if (!r1 || !r2) | 1665 if (!r1 || !r2) |
1704 return false; | 1666 return false; |
1705 if (!r1->isInline() || !r2->isInline()) | 1667 if (!r1->isInline() || !r2->isInline()) |
1706 return false; | 1668 return false; |
1707 LayoutBlockFlow* b1 = nonInlineBlockFlow(r1); | 1669 LayoutBlockFlow* b1 = nonInlineBlockFlow(r1); |
1708 LayoutBlockFlow* b2 = nonInlineBlockFlow(r2); | 1670 LayoutBlockFlow* b2 = nonInlineBlockFlow(r2); |
1709 return b1 && b2 && b1 == b2; | 1671 return b1 && b2 && b1 == b2; |
1710 } | 1672 } |
1711 | 1673 |
1712 bool AXNodeObject::isNativeCheckboxInMixedState() const { | |
1713 if (!isHTMLInputElement(m_node)) | |
1714 return false; | |
1715 | |
1716 HTMLInputElement* input = toHTMLInputElement(m_node); | |
1717 return input->type() == InputTypeNames::checkbox && | |
1718 input->shouldAppearIndeterminate(); | |
1719 } | |
1720 | |
1721 // | 1674 // |
1722 // New AX name calculation. | 1675 // New AX name calculation. |
1723 // | 1676 // |
1724 | 1677 |
1725 String AXNodeObject::textAlternative(bool recursive, | 1678 String AXNodeObject::textAlternative(bool recursive, |
1726 bool inAriaLabelledByTraversal, | 1679 bool inAriaLabelledByTraversal, |
1727 AXObjectSet& visited, | 1680 AXObjectSet& visited, |
1728 AXNameFrom& nameFrom, | 1681 AXNameFrom& nameFrom, |
1729 AXRelatedObjectVector* relatedObjects, | 1682 AXRelatedObjectVector* relatedObjects, |
1730 NameSources* nameSources) const { | 1683 NameSources* nameSources) const { |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 return String(); | 3067 return String(); |
3115 return toTextControlElement(node)->strippedPlaceholder(); | 3068 return toTextControlElement(node)->strippedPlaceholder(); |
3116 } | 3069 } |
3117 | 3070 |
3118 DEFINE_TRACE(AXNodeObject) { | 3071 DEFINE_TRACE(AXNodeObject) { |
3119 visitor->trace(m_node); | 3072 visitor->trace(m_node); |
3120 AXObject::trace(visitor); | 3073 AXObject::trace(visitor); |
3121 } | 3074 } |
3122 | 3075 |
3123 } // namespace blink | 3076 } // namespace blink |
OLD | NEW |