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

Unified Diff: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp

Issue 2805493002: Boolean properties for Accessibility Object Model Phase 1 (Closed)
Patch Set: Address feedback Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
diff --git a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
index f86ae486d9f6e5ae378eafea59f848b3f3b88182..73346d38cbe7e2462c80b42c8e622153689482d0 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
@@ -263,18 +263,18 @@ AXObject* AXNodeObject::ActiveDescendant() {
}
bool AXNodeObject::ComputeAccessibilityIsIgnored(
- IgnoredReasons* ignored_reasons) const {
+ IgnoredReasons* ignoredReasons) const {
#if DCHECK_IS_ON()
// Double-check that an AXObject is never accessed before
// it's been initialized.
- DCHECK(initialized_);
+ DCHECK(m_initialized);
#endif
// If this element is within a parent that cannot have children, it should not
// be exposed.
if (IsDescendantOfLeafNode()) {
- if (ignored_reasons)
- ignored_reasons->push_back(
+ if (ignoredReasons)
+ ignoredReasons->push_back(
IgnoredReason(kAXAncestorIsLeafNode, LeafNodeAncestor()));
return true;
}
@@ -283,15 +283,15 @@ bool AXNodeObject::ComputeAccessibilityIsIgnored(
AXObject* control_object = CorrespondingControlForLabelElement();
if (control_object && control_object->IsCheckboxOrRadio() &&
control_object->NameFromLabelElement()) {
- if (ignored_reasons) {
+ if (ignoredReasons) {
HTMLLabelElement* label = LabelElementContainer();
if (label && label != GetNode()) {
AXObject* label_ax_object = AxObjectCache().GetOrCreate(label);
- ignored_reasons->push_back(
+ ignoredReasons->push_back(
IgnoredReason(kAXLabelContainer, label_ax_object));
}
- ignored_reasons->push_back(IgnoredReason(kAXLabelFor, control_object));
+ ignoredReasons->push_back(IgnoredReason(kAXLabelFor, control_object));
}
return true;
}
@@ -299,15 +299,15 @@ bool AXNodeObject::ComputeAccessibilityIsIgnored(
Element* element = GetNode()->IsElementNode() ? ToElement(GetNode())
: GetNode()->parentElement();
if (!GetLayoutObject() && (!element || !element->IsInCanvasSubtree()) &&
- !EqualIgnoringASCIICase(GetAttribute(aria_hiddenAttr), "false")) {
- if (ignored_reasons)
- ignored_reasons->push_back(IgnoredReason(kAXNotRendered));
+ !AOMPropertyOrARIAAttributeIsFalse(AOMBooleanProperty::kHidden)) {
+ if (ignoredReasons)
+ ignoredReasons->push_back(IgnoredReason(kAXNotRendered));
return true;
}
if (role_ == kUnknownRole) {
- if (ignored_reasons)
- ignored_reasons->push_back(IgnoredReason(kAXUninteresting));
+ if (ignoredReasons)
+ ignoredReasons->push_back(IgnoredReason(kAXUninteresting));
return true;
}
return false;
@@ -319,8 +319,8 @@ static bool IsListElement(Node* node) {
}
static bool IsPresentationalInTable(AXObject* parent,
- HTMLElement* current_element) {
- if (!current_element)
+ HTMLElement* currentElement) {
+ if (!currentElement)
return false;
Node* parent_node = parent->GetNode();
@@ -337,11 +337,11 @@ static bool IsPresentationalInTable(AXObject* parent,
// If table has presentation role, it will be like
// cell(group)-> tr(unknown) -> tfoot, tbody, thead(ignored) ->
// table(presentation).
- if (IsHTMLTableCellElement(*current_element) &&
+ if (IsHTMLTableCellElement(*currentElement) &&
isHTMLTableRowElement(*parent_node))
return parent->HasInheritedPresentationalRole();
- if (isHTMLTableRowElement(*current_element) &&
+ if (isHTMLTableRowElement(*currentElement) &&
IsHTMLTableSectionElement(ToHTMLElement(*parent_node))) {
// Because TableSections have ignored role, presentation should be checked
// with its parent node.
@@ -354,25 +354,25 @@ static bool IsPresentationalInTable(AXObject* parent,
}
static bool IsRequiredOwnedElement(AXObject* parent,
- AccessibilityRole current_role,
- HTMLElement* current_element) {
+ AccessibilityRole currentRole,
+ HTMLElement* currentElement) {
Node* parent_node = parent->GetNode();
if (!parent_node || !parent_node->IsHTMLElement())
return false;
- if (current_role == kListItemRole)
+ if (currentRole == kListItemRole)
return IsListElement(parent_node);
- if (current_role == kListMarkerRole)
+ if (currentRole == kListMarkerRole)
return isHTMLLIElement(*parent_node);
- if (current_role == kMenuItemCheckBoxRole || current_role == kMenuItemRole ||
- current_role == kMenuItemRadioRole)
+ if (currentRole == kMenuItemCheckBoxRole || currentRole == kMenuItemRole ||
+ currentRole == kMenuItemRadioRole)
return isHTMLMenuElement(*parent_node);
- if (!current_element)
+ if (!currentElement)
return false;
- if (IsHTMLTableCellElement(*current_element))
+ if (IsHTMLTableCellElement(*currentElement))
return isHTMLTableRowElement(*parent_node);
- if (isHTMLTableRowElement(*current_element))
+ if (isHTMLTableRowElement(*currentElement))
return IsHTMLTableSectionElement(ToHTMLElement(*parent_node));
// In case of ListboxRole and its child, ListBoxOptionRole, inheritance of
@@ -446,13 +446,13 @@ static HashSet<QualifiedName>& GetLandmarkRolesNotAllowed() {
}
bool AXNodeObject::IsDescendantOfElementType(
- HashSet<QualifiedName>& tag_names) const {
+ HashSet<QualifiedName>& tagNames) const {
if (!GetNode())
return false;
for (Element* parent = GetNode()->parentElement(); parent;
parent = parent->parentElement()) {
- if (tag_names.Contains(parent->TagQName()))
+ if (tagNames.Contains(parent->TagQName()))
return true;
}
return false;
@@ -904,8 +904,8 @@ AccessibilityRole AXNodeObject::RemapAriaRoleDueToParent(
void AXNodeObject::Init() {
#if DCHECK_IS_ON()
- DCHECK(!initialized_);
- initialized_ = true;
+ DCHECK(!m_initialized);
+ m_initialized = true;
#endif
role_ = DetermineAccessibilityRole();
}
@@ -1043,12 +1043,11 @@ bool AXNodeObject::IsMeter() const {
}
bool AXNodeObject::IsMultiSelectable() const {
- const AtomicString& aria_multi_selectable =
- GetAttribute(aria_multiselectableAttr);
- if (EqualIgnoringASCIICase(aria_multi_selectable, "true"))
- return true;
- if (EqualIgnoringASCIICase(aria_multi_selectable, "false"))
- return false;
+ bool multiselectable = false;
+ if (HasAOMPropertyOrARIAAttribute(AOMBooleanProperty::kMultiselectable,
+ multiselectable)) {
+ return multiselectable;
+ }
return isHTMLSelectElement(GetNode()) &&
toHTMLSelectElement(*GetNode()).IsMultiple();
@@ -1181,11 +1180,10 @@ AccessibilityExpanded AXNodeObject::IsExpanded() const {
: kExpandedCollapsed;
}
- const AtomicString& expanded = GetAttribute(aria_expandedAttr);
- if (EqualIgnoringASCIICase(expanded, "true"))
- return kExpandedExpanded;
- if (EqualIgnoringASCIICase(expanded, "false"))
- return kExpandedCollapsed;
+ bool expanded = false;
+ if (HasAOMPropertyOrARIAAttribute(AOMBooleanProperty::kExpanded, expanded)) {
+ return expanded ? kExpandedExpanded : kExpandedCollapsed;
+ }
return kExpandedUndefined;
}
@@ -1194,13 +1192,9 @@ bool AXNodeObject::IsModal() const {
if (RoleValue() != kDialogRole && RoleValue() != kAlertDialogRole)
return false;
- if (HasAttribute(aria_modalAttr)) {
- const AtomicString& modal = GetAttribute(aria_modalAttr);
- if (EqualIgnoringASCIICase(modal, "true"))
- return true;
- if (EqualIgnoringASCIICase(modal, "false"))
- return false;
- }
+ bool modal = false;
+ if (HasAOMPropertyOrARIAAttribute(AOMBooleanProperty::kModal, modal))
+ return modal;
if (GetNode() && isHTMLDialogElement(*GetNode()))
return ToElement(GetNode())->IsInTopLayer();
@@ -1251,7 +1245,7 @@ bool AXNodeObject::IsRequired() const {
HasAttribute(requiredAttr))
return ToHTMLFormControlElement(n)->IsRequired();
- if (EqualIgnoringASCIICase(GetAttribute(aria_requiredAttr), "true"))
+ if (AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kRequired))
return true;
return false;
@@ -1281,7 +1275,7 @@ bool AXNodeObject::CanSetFocusAttribute() const {
}
bool AXNodeObject::CanSetValueAttribute() const {
- if (EqualIgnoringASCIICase(GetAttribute(aria_readonlyAttr), "true"))
+ if (AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kReadOnly))
return false;
if (IsProgressIndicator() || IsSlider())
@@ -1952,7 +1946,7 @@ String AXNodeObject::TextFromDescendants(AXObjectSet& visited,
// true if any ancestor is hidden, but we need to be able to compute the
// accessible name of object inside hidden subtrees (for example, if
// aria-labelledby points to an object that's hidden).
- if (EqualIgnoringASCIICase(child->GetAttribute(aria_hiddenAttr), "true"))
+ if (child->AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kHidden))
continue;
// If we're going between two layoutObjects that are in separate

Powered by Google App Engine
This is Rietveld 408576698