| 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 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 Node* node = this->GetNode(); | 1136 Node* node = this->GetNode(); |
| 1137 if (!node) | 1137 if (!node) |
| 1138 return false; | 1138 return false; |
| 1139 | 1139 |
| 1140 if (!isHTMLInputElement(node)) | 1140 if (!isHTMLInputElement(node)) |
| 1141 return false; | 1141 return false; |
| 1142 | 1142 |
| 1143 return toHTMLInputElement(node)->type() == InputTypeNames::range; | 1143 return toHTMLInputElement(node)->type() == InputTypeNames::range; |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 bool AXNodeObject::IsChecked() const { | |
| 1147 Node* node = this->GetNode(); | |
| 1148 if (!node) | |
| 1149 return false; | |
| 1150 | |
| 1151 // First test for native checkedness semantics | |
| 1152 if (isHTMLInputElement(*node)) | |
| 1153 return toHTMLInputElement(*node).ShouldAppearChecked(); | |
| 1154 | |
| 1155 // Else, if this is an ARIA role checkbox or radio or menuitemcheckbox | |
| 1156 // or menuitemradio or switch, respect the aria-checked attribute | |
| 1157 switch (AriaRoleAttribute()) { | |
| 1158 case kCheckBoxRole: | |
| 1159 case kMenuItemCheckBoxRole: | |
| 1160 case kMenuItemRadioRole: | |
| 1161 case kRadioButtonRole: | |
| 1162 case kSwitchRole: | |
| 1163 if (EqualIgnoringASCIICase( | |
| 1164 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kChecked), | |
| 1165 "true")) | |
| 1166 return true; | |
| 1167 return false; | |
| 1168 default: | |
| 1169 break; | |
| 1170 } | |
| 1171 | |
| 1172 // Otherwise it's not checked | |
| 1173 return false; | |
| 1174 } | |
| 1175 | |
| 1176 bool AXNodeObject::IsClickable() const { | 1146 bool AXNodeObject::IsClickable() const { |
| 1177 if (GetNode()) { | 1147 if (GetNode()) { |
| 1178 if (GetNode()->IsElementNode() && | 1148 if (GetNode()->IsElementNode() && |
| 1179 ToElement(GetNode())->IsDisabledFormControl()) | 1149 ToElement(GetNode())->IsDisabledFormControl()) |
| 1180 return false; | 1150 return false; |
| 1181 | 1151 |
| 1182 // Note: we can't call getNode()->willRespondToMouseClickEvents() because | 1152 // Note: we can't call getNode()->willRespondToMouseClickEvents() because |
| 1183 // that triggers a style recalc and can delete this. | 1153 // that triggers a style recalc and can delete this. |
| 1184 if (GetNode()->HasEventListeners(EventTypeNames::mouseup) || | 1154 if (GetNode()->HasEventListeners(EventTypeNames::mouseup) || |
| 1185 GetNode()->HasEventListeners(EventTypeNames::mousedown) || | 1155 GetNode()->HasEventListeners(EventTypeNames::mousedown) || |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 if (IsNativeTextControl() && | 1570 if (IsNativeTextControl() && |
| 1601 (isHTMLTextAreaElement(*node) || isHTMLInputElement(*node))) | 1571 (isHTMLTextAreaElement(*node) || isHTMLInputElement(*node))) |
| 1602 return ToTextControlElement(*node).value(); | 1572 return ToTextControlElement(*node).value(); |
| 1603 | 1573 |
| 1604 if (!node->IsElementNode()) | 1574 if (!node->IsElementNode()) |
| 1605 return String(); | 1575 return String(); |
| 1606 | 1576 |
| 1607 return ToElement(node)->innerText(); | 1577 return ToElement(node)->innerText(); |
| 1608 } | 1578 } |
| 1609 | 1579 |
| 1610 AccessibilityButtonState AXNodeObject::CheckboxOrRadioValue() const { | |
| 1611 if (IsNativeCheckboxInMixedState()) | |
| 1612 return kButtonStateMixed; | |
| 1613 | |
| 1614 if (IsNativeCheckboxOrRadio()) | |
| 1615 return IsChecked() ? kButtonStateOn : kButtonStateOff; | |
| 1616 | |
| 1617 return AXObject::CheckboxOrRadioValue(); | |
| 1618 } | |
| 1619 | |
| 1620 RGBA32 AXNodeObject::ColorValue() const { | 1580 RGBA32 AXNodeObject::ColorValue() const { |
| 1621 if (!isHTMLInputElement(GetNode()) || !IsColorWell()) | 1581 if (!isHTMLInputElement(GetNode()) || !IsColorWell()) |
| 1622 return AXObject::ColorValue(); | 1582 return AXObject::ColorValue(); |
| 1623 | 1583 |
| 1624 HTMLInputElement* input = toHTMLInputElement(GetNode()); | 1584 HTMLInputElement* input = toHTMLInputElement(GetNode()); |
| 1625 const AtomicString& type = input->getAttribute(typeAttr); | 1585 const AtomicString& type = input->getAttribute(typeAttr); |
| 1626 if (!EqualIgnoringASCIICase(type, "color")) | 1586 if (!EqualIgnoringASCIICase(type, "color")) |
| 1627 return AXObject::ColorValue(); | 1587 return AXObject::ColorValue(); |
| 1628 | 1588 |
| 1629 // HTMLInputElement::value always returns a string parseable by Color. | 1589 // HTMLInputElement::value always returns a string parseable by Color. |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 static bool IsInSameNonInlineBlockFlow(LayoutObject* r1, LayoutObject* r2) { | 1809 static bool IsInSameNonInlineBlockFlow(LayoutObject* r1, LayoutObject* r2) { |
| 1850 if (!r1 || !r2) | 1810 if (!r1 || !r2) |
| 1851 return false; | 1811 return false; |
| 1852 if (!r1->IsInline() || !r2->IsInline()) | 1812 if (!r1->IsInline() || !r2->IsInline()) |
| 1853 return false; | 1813 return false; |
| 1854 LayoutBlockFlow* b1 = NonInlineBlockFlow(r1); | 1814 LayoutBlockFlow* b1 = NonInlineBlockFlow(r1); |
| 1855 LayoutBlockFlow* b2 = NonInlineBlockFlow(r2); | 1815 LayoutBlockFlow* b2 = NonInlineBlockFlow(r2); |
| 1856 return b1 && b2 && b1 == b2; | 1816 return b1 && b2 && b1 == b2; |
| 1857 } | 1817 } |
| 1858 | 1818 |
| 1859 bool AXNodeObject::IsNativeCheckboxInMixedState() const { | |
| 1860 if (!isHTMLInputElement(node_)) | |
| 1861 return false; | |
| 1862 | |
| 1863 HTMLInputElement* input = toHTMLInputElement(node_); | |
| 1864 return input->type() == InputTypeNames::checkbox && | |
| 1865 input->ShouldAppearIndeterminate(); | |
| 1866 } | |
| 1867 | |
| 1868 // | 1819 // |
| 1869 // New AX name calculation. | 1820 // New AX name calculation. |
| 1870 // | 1821 // |
| 1871 | 1822 |
| 1872 String AXNodeObject::TextAlternative(bool recursive, | 1823 String AXNodeObject::TextAlternative(bool recursive, |
| 1873 bool in_aria_labelled_by_traversal, | 1824 bool in_aria_labelled_by_traversal, |
| 1874 AXObjectSet& visited, | 1825 AXObjectSet& visited, |
| 1875 AXNameFrom& name_from, | 1826 AXNameFrom& name_from, |
| 1876 AXRelatedObjectVector* related_objects, | 1827 AXRelatedObjectVector* related_objects, |
| 1877 NameSources* name_sources) const { | 1828 NameSources* name_sources) const { |
| (...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3268 return String(); | 3219 return String(); |
| 3269 return ToTextControlElement(node)->StrippedPlaceholder(); | 3220 return ToTextControlElement(node)->StrippedPlaceholder(); |
| 3270 } | 3221 } |
| 3271 | 3222 |
| 3272 DEFINE_TRACE(AXNodeObject) { | 3223 DEFINE_TRACE(AXNodeObject) { |
| 3273 visitor->Trace(node_); | 3224 visitor->Trace(node_); |
| 3274 AXObject::Trace(visitor); | 3225 AXObject::Trace(visitor); |
| 3275 } | 3226 } |
| 3276 | 3227 |
| 3277 } // namespace blink | 3228 } // namespace blink |
| OLD | NEW |