| 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 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 return ElementTraversal::FirstChild(*node); | 1327 return ElementTraversal::FirstChild(*node); |
| 1328 } | 1328 } |
| 1329 | 1329 |
| 1330 int AXNodeObject::HeadingLevel() const { | 1330 int AXNodeObject::HeadingLevel() const { |
| 1331 // headings can be in block flow and non-block flow | 1331 // headings can be in block flow and non-block flow |
| 1332 Node* node = this->GetNode(); | 1332 Node* node = this->GetNode(); |
| 1333 if (!node) | 1333 if (!node) |
| 1334 return 0; | 1334 return 0; |
| 1335 | 1335 |
| 1336 if (RoleValue() == kHeadingRole) { | 1336 if (RoleValue() == kHeadingRole) { |
| 1337 String level_str = GetAttribute(aria_levelAttr); | 1337 uint32_t level; |
| 1338 if (!level_str.IsEmpty()) { | 1338 if (HasAOMPropertyOrARIAAttribute(AOMUIntProperty::kLevel, level)) { |
| 1339 int level = level_str.ToInt(); | |
| 1340 if (level >= 1 && level <= 9) | 1339 if (level >= 1 && level <= 9) |
| 1341 return level; | 1340 return level; |
| 1342 return 1; | 1341 return 1; |
| 1343 } | 1342 } |
| 1344 } | 1343 } |
| 1345 | 1344 |
| 1346 if (!node->IsHTMLElement()) | 1345 if (!node->IsHTMLElement()) |
| 1347 return 0; | 1346 return 0; |
| 1348 | 1347 |
| 1349 HTMLElement& element = ToHTMLElement(*node); | 1348 HTMLElement& element = ToHTMLElement(*node); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1362 if (element.HasTagName(h5Tag)) | 1361 if (element.HasTagName(h5Tag)) |
| 1363 return 5; | 1362 return 5; |
| 1364 | 1363 |
| 1365 if (element.HasTagName(h6Tag)) | 1364 if (element.HasTagName(h6Tag)) |
| 1366 return 6; | 1365 return 6; |
| 1367 | 1366 |
| 1368 return 0; | 1367 return 0; |
| 1369 } | 1368 } |
| 1370 | 1369 |
| 1371 unsigned AXNodeObject::HierarchicalLevel() const { | 1370 unsigned AXNodeObject::HierarchicalLevel() const { |
| 1372 Node* node = this->GetNode(); | 1371 Element* element = GetElement(); |
| 1373 if (!node || !node->IsElementNode()) | 1372 if (!element) |
| 1374 return 0; | 1373 return 0; |
| 1375 | 1374 |
| 1376 Element* element = ToElement(node); | 1375 uint32_t level; |
| 1377 String level_str = element->getAttribute(aria_levelAttr); | 1376 if (HasAOMPropertyOrARIAAttribute(AOMUIntProperty::kLevel, level)) { |
| 1378 if (!level_str.IsEmpty()) { | 1377 if (level >= 1 && level <= 9) |
| 1379 int level = level_str.ToInt(); | |
| 1380 if (level > 0) | |
| 1381 return level; | 1378 return level; |
| 1382 return 1; | 1379 return 1; |
| 1383 } | 1380 } |
| 1384 | 1381 |
| 1385 // Only tree item will calculate its level through the DOM currently. | 1382 // Only tree item will calculate its level through the DOM currently. |
| 1386 if (RoleValue() != kTreeItemRole) | 1383 if (RoleValue() != kTreeItemRole) |
| 1387 return 0; | 1384 return 0; |
| 1388 | 1385 |
| 1389 // Hierarchy leveling starts at 1, to match the aria-level spec. | 1386 // Hierarchy leveling starts at 1, to match the aria-level spec. |
| 1390 // We measure tree hierarchy by the number of groups that the item is within. | 1387 // We measure tree hierarchy by the number of groups that the item is within. |
| 1391 unsigned level = 1; | 1388 level = 1; |
| 1392 for (AXObjectImpl* parent = ParentObject(); parent; | 1389 for (AXObjectImpl* parent = ParentObject(); parent; |
| 1393 parent = parent->ParentObject()) { | 1390 parent = parent->ParentObject()) { |
| 1394 AccessibilityRole parent_role = parent->RoleValue(); | 1391 AccessibilityRole parent_role = parent->RoleValue(); |
| 1395 if (parent_role == kGroupRole) | 1392 if (parent_role == kGroupRole) |
| 1396 level++; | 1393 level++; |
| 1397 else if (parent_role == kTreeRole) | 1394 else if (parent_role == kTreeRole) |
| 1398 break; | 1395 break; |
| 1399 } | 1396 } |
| 1400 | 1397 |
| 1401 return level; | 1398 return level; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 bool is_invalid = !element->checkValidity(&invalid_controls, | 1649 bool is_invalid = !element->checkValidity(&invalid_controls, |
| 1653 kCheckValidityDispatchNoEvent); | 1650 kCheckValidityDispatchNoEvent); |
| 1654 return is_invalid ? kInvalidStateTrue : kInvalidStateFalse; | 1651 return is_invalid ? kInvalidStateTrue : kInvalidStateFalse; |
| 1655 } | 1652 } |
| 1656 | 1653 |
| 1657 return AXObjectImpl::GetInvalidState(); | 1654 return AXObjectImpl::GetInvalidState(); |
| 1658 } | 1655 } |
| 1659 | 1656 |
| 1660 int AXNodeObject::PosInSet() const { | 1657 int AXNodeObject::PosInSet() const { |
| 1661 if (SupportsSetSizeAndPosInSet()) { | 1658 if (SupportsSetSizeAndPosInSet()) { |
| 1662 String pos_in_set_str = GetAttribute(aria_posinsetAttr); | 1659 uint32_t pos_in_set; |
| 1663 if (!pos_in_set_str.IsEmpty()) { | 1660 if (HasAOMPropertyOrARIAAttribute(AOMUIntProperty::kPosInSet, pos_in_set)) |
| 1664 int pos_in_set = pos_in_set_str.ToInt(); | 1661 return pos_in_set; |
| 1665 if (pos_in_set > 0) | |
| 1666 return pos_in_set; | |
| 1667 return 1; | |
| 1668 } | |
| 1669 | 1662 |
| 1670 return AXObjectImpl::IndexInParent() + 1; | 1663 return AXObjectImpl::IndexInParent() + 1; |
| 1671 } | 1664 } |
| 1672 | 1665 |
| 1673 return 0; | 1666 return 0; |
| 1674 } | 1667 } |
| 1675 | 1668 |
| 1676 int AXNodeObject::SetSize() const { | 1669 int AXNodeObject::SetSize() const { |
| 1677 if (SupportsSetSizeAndPosInSet()) { | 1670 if (SupportsSetSizeAndPosInSet()) { |
| 1678 String set_size_str = GetAttribute(aria_setsizeAttr); | 1671 int32_t set_size; |
| 1679 if (!set_size_str.IsEmpty()) { | 1672 if (HasAOMPropertyOrARIAAttribute(AOMIntProperty::kSetSize, set_size)) |
| 1680 int set_size = set_size_str.ToInt(); | 1673 return set_size; |
| 1681 if (set_size > 0) | |
| 1682 return set_size; | |
| 1683 return 1; | |
| 1684 } | |
| 1685 | 1674 |
| 1686 if (ParentObject()) { | 1675 if (ParentObject()) { |
| 1687 const auto& siblings = ParentObject()->Children(); | 1676 const auto& siblings = ParentObject()->Children(); |
| 1688 return siblings.size(); | 1677 return siblings.size(); |
| 1689 } | 1678 } |
| 1690 } | 1679 } |
| 1691 | 1680 |
| 1692 return 0; | 1681 return 0; |
| 1693 } | 1682 } |
| 1694 | 1683 |
| 1695 String AXNodeObject::AriaInvalidValue() const { | 1684 String AXNodeObject::AriaInvalidValue() const { |
| 1696 if (GetInvalidState() == kInvalidStateOther) | 1685 if (GetInvalidState() == kInvalidStateOther) |
| 1697 return GetAOMPropertyOrARIAAttribute(AOMStringProperty::kInvalid); | 1686 return GetAOMPropertyOrARIAAttribute(AOMStringProperty::kInvalid); |
| 1698 | 1687 |
| 1699 return String(); | 1688 return String(); |
| 1700 } | 1689 } |
| 1701 | 1690 |
| 1702 String AXNodeObject::ValueDescription() const { | 1691 String AXNodeObject::ValueDescription() const { |
| 1703 if (!SupportsRangeValue()) | 1692 if (!SupportsRangeValue()) |
| 1704 return String(); | 1693 return String(); |
| 1705 | 1694 |
| 1706 return GetAOMPropertyOrARIAAttribute(AOMStringProperty::kValueText) | 1695 return GetAOMPropertyOrARIAAttribute(AOMStringProperty::kValueText) |
| 1707 .GetString(); | 1696 .GetString(); |
| 1708 } | 1697 } |
| 1709 | 1698 |
| 1710 float AXNodeObject::ValueForRange() const { | 1699 float AXNodeObject::ValueForRange() const { |
| 1711 if (HasAttribute(aria_valuenowAttr)) | 1700 float value_now; |
| 1712 return GetAttribute(aria_valuenowAttr).ToFloat(); | 1701 if (HasAOMPropertyOrARIAAttribute(AOMFloatProperty::kValueNow, value_now)) |
| 1702 return value_now; |
| 1713 | 1703 |
| 1714 if (IsNativeSlider()) | 1704 if (IsNativeSlider()) |
| 1715 return toHTMLInputElement(*GetNode()).valueAsNumber(); | 1705 return toHTMLInputElement(*GetNode()).valueAsNumber(); |
| 1716 | 1706 |
| 1717 if (isHTMLMeterElement(GetNode())) | 1707 if (isHTMLMeterElement(GetNode())) |
| 1718 return toHTMLMeterElement(*GetNode()).value(); | 1708 return toHTMLMeterElement(*GetNode()).value(); |
| 1719 | 1709 |
| 1720 return 0.0; | 1710 return 0.0; |
| 1721 } | 1711 } |
| 1722 | 1712 |
| 1723 float AXNodeObject::MaxValueForRange() const { | 1713 float AXNodeObject::MaxValueForRange() const { |
| 1724 if (HasAttribute(aria_valuemaxAttr)) | 1714 float value_max; |
| 1725 return GetAttribute(aria_valuemaxAttr).ToFloat(); | 1715 if (HasAOMPropertyOrARIAAttribute(AOMFloatProperty::kValueMax, value_max)) |
| 1716 return value_max; |
| 1726 | 1717 |
| 1727 if (IsNativeSlider()) | 1718 if (IsNativeSlider()) |
| 1728 return toHTMLInputElement(*GetNode()).Maximum(); | 1719 return toHTMLInputElement(*GetNode()).Maximum(); |
| 1729 | 1720 |
| 1730 if (isHTMLMeterElement(GetNode())) | 1721 if (isHTMLMeterElement(GetNode())) |
| 1731 return toHTMLMeterElement(*GetNode()).max(); | 1722 return toHTMLMeterElement(*GetNode()).max(); |
| 1732 | 1723 |
| 1733 return 0.0; | 1724 return 0.0; |
| 1734 } | 1725 } |
| 1735 | 1726 |
| 1736 float AXNodeObject::MinValueForRange() const { | 1727 float AXNodeObject::MinValueForRange() const { |
| 1737 if (HasAttribute(aria_valueminAttr)) | 1728 float value_min; |
| 1738 return GetAttribute(aria_valueminAttr).ToFloat(); | 1729 if (HasAOMPropertyOrARIAAttribute(AOMFloatProperty::kValueMin, value_min)) |
| 1730 return value_min; |
| 1739 | 1731 |
| 1740 if (IsNativeSlider()) | 1732 if (IsNativeSlider()) |
| 1741 return toHTMLInputElement(*GetNode()).Minimum(); | 1733 return toHTMLInputElement(*GetNode()).Minimum(); |
| 1742 | 1734 |
| 1743 if (isHTMLMeterElement(GetNode())) | 1735 if (isHTMLMeterElement(GetNode())) |
| 1744 return toHTMLMeterElement(*GetNode()).min(); | 1736 return toHTMLMeterElement(*GetNode()).min(); |
| 1745 | 1737 |
| 1746 return 0.0; | 1738 return 0.0; |
| 1747 } | 1739 } |
| 1748 | 1740 |
| (...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3229 return String(); | 3221 return String(); |
| 3230 return ToTextControlElement(node)->StrippedPlaceholder(); | 3222 return ToTextControlElement(node)->StrippedPlaceholder(); |
| 3231 } | 3223 } |
| 3232 | 3224 |
| 3233 DEFINE_TRACE(AXNodeObject) { | 3225 DEFINE_TRACE(AXNodeObject) { |
| 3234 visitor->Trace(node_); | 3226 visitor->Trace(node_); |
| 3235 AXObjectImpl::Trace(visitor); | 3227 AXObjectImpl::Trace(visitor); |
| 3236 } | 3228 } |
| 3237 | 3229 |
| 3238 } // namespace blink | 3230 } // namespace blink |
| OLD | NEW |