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

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

Issue 2694903010: AX checked state changes (Closed)
Patch Set: Remove whitespace change Created 3 years, 10 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 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 if (isNativeTextControl() && 1427 if (isNativeTextControl() &&
1456 (isHTMLTextAreaElement(*node) || isHTMLInputElement(*node))) 1428 (isHTMLTextAreaElement(*node) || isHTMLInputElement(*node)))
1457 return toTextControlElement(*node).value(); 1429 return toTextControlElement(*node).value();
1458 1430
1459 if (!node->isElementNode()) 1431 if (!node->isElementNode())
1460 return String(); 1432 return String();
1461 1433
1462 return toElement(node)->innerText(); 1434 return toElement(node)->innerText();
1463 } 1435 }
1464 1436
1465 AccessibilityButtonState AXNodeObject::checkboxOrRadioValue() const {
1466 if (isNativeCheckboxInMixedState())
1467 return ButtonStateMixed;
1468
1469 if (isNativeCheckboxOrRadio())
1470 return isChecked() ? ButtonStateOn : ButtonStateOff;
1471
1472 return AXObject::checkboxOrRadioValue();
1473 }
1474
1475 RGBA32 AXNodeObject::colorValue() const { 1437 RGBA32 AXNodeObject::colorValue() const {
1476 if (!isHTMLInputElement(getNode()) || !isColorWell()) 1438 if (!isHTMLInputElement(getNode()) || !isColorWell())
1477 return AXObject::colorValue(); 1439 return AXObject::colorValue();
1478 1440
1479 HTMLInputElement* input = toHTMLInputElement(getNode()); 1441 HTMLInputElement* input = toHTMLInputElement(getNode());
1480 const AtomicString& type = input->getAttribute(typeAttr); 1442 const AtomicString& type = input->getAttribute(typeAttr);
1481 if (!equalIgnoringCase(type, "color")) 1443 if (!equalIgnoringCase(type, "color"))
1482 return AXObject::colorValue(); 1444 return AXObject::colorValue();
1483 1445
1484 // HTMLInputElement::value always returns a string parseable by Color. 1446 // HTMLInputElement::value always returns a string parseable by Color.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 static bool isInSameNonInlineBlockFlow(LayoutObject* r1, LayoutObject* r2) { 1665 static bool isInSameNonInlineBlockFlow(LayoutObject* r1, LayoutObject* r2) {
1704 if (!r1 || !r2) 1666 if (!r1 || !r2)
1705 return false; 1667 return false;
1706 if (!r1->isInline() || !r2->isInline()) 1668 if (!r1->isInline() || !r2->isInline())
1707 return false; 1669 return false;
1708 LayoutBlockFlow* b1 = nonInlineBlockFlow(r1); 1670 LayoutBlockFlow* b1 = nonInlineBlockFlow(r1);
1709 LayoutBlockFlow* b2 = nonInlineBlockFlow(r2); 1671 LayoutBlockFlow* b2 = nonInlineBlockFlow(r2);
1710 return b1 && b2 && b1 == b2; 1672 return b1 && b2 && b1 == b2;
1711 } 1673 }
1712 1674
1713 bool AXNodeObject::isNativeCheckboxInMixedState() const {
1714 if (!isHTMLInputElement(m_node))
1715 return false;
1716
1717 HTMLInputElement* input = toHTMLInputElement(m_node);
1718 return input->type() == InputTypeNames::checkbox &&
1719 input->shouldAppearIndeterminate();
1720 }
1721
1722 // 1675 //
1723 // New AX name calculation. 1676 // New AX name calculation.
1724 // 1677 //
1725 1678
1726 String AXNodeObject::textAlternative(bool recursive, 1679 String AXNodeObject::textAlternative(bool recursive,
1727 bool inAriaLabelledByTraversal, 1680 bool inAriaLabelledByTraversal,
1728 AXObjectSet& visited, 1681 AXObjectSet& visited,
1729 AXNameFrom& nameFrom, 1682 AXNameFrom& nameFrom,
1730 AXRelatedObjectVector* relatedObjects, 1683 AXRelatedObjectVector* relatedObjects,
1731 NameSources* nameSources) const { 1684 NameSources* nameSources) const {
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after
3115 return String(); 3068 return String();
3116 return toTextControlElement(node)->strippedPlaceholder(); 3069 return toTextControlElement(node)->strippedPlaceholder();
3117 } 3070 }
3118 3071
3119 DEFINE_TRACE(AXNodeObject) { 3072 DEFINE_TRACE(AXNodeObject) {
3120 visitor->trace(m_node); 3073 visitor->trace(m_node);
3121 AXObject::trace(visitor); 3074 AXObject::trace(visitor);
3122 } 3075 }
3123 3076
3124 } // namespace blink 3077 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698