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

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

Issue 2967193003: Relation list properties for Accessibility Object Model phase 1 (Closed)
Patch Set: Get rid of accidental duplication in inspector output Created 3 years, 5 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) 2008, 2009, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2011 Apple 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 AOMRelationProperty property) const { 385 AOMRelationProperty property) const {
386 Element* element = this->GetElement(); 386 Element* element = this->GetElement();
387 if (!element) 387 if (!element)
388 return nullptr; 388 return nullptr;
389 389
390 AccessibleNode* target = 390 AccessibleNode* target =
391 AccessibleNode::GetPropertyOrARIAAttribute(element, property); 391 AccessibleNode::GetPropertyOrARIAAttribute(element, property);
392 return target ? target->element() : nullptr; 392 return target ? target->element() : nullptr;
393 } 393 }
394 394
395 bool AXObject::HasAOMProperty(AOMRelationListProperty property,
396 HeapVector<Member<Element>>& result) const {
397 Element* element = this->GetElement();
398 if (!element)
399 return false;
400
401 return AccessibleNode::GetProperty(element, property, result);
402 }
403
404 bool AXObject::HasAOMPropertyOrARIAAttribute(
405 AOMRelationListProperty property,
406 HeapVector<Member<Element>>& result) const {
407 Element* element = this->GetElement();
408 if (!element)
409 return false;
410
411 return AccessibleNode::GetPropertyOrARIAAttribute(element, property, result);
412 }
413
395 bool AXObject::HasAOMPropertyOrARIAAttribute(AOMBooleanProperty property, 414 bool AXObject::HasAOMPropertyOrARIAAttribute(AOMBooleanProperty property,
396 bool& result) const { 415 bool& result) const {
397 Element* element = this->GetElement(); 416 Element* element = this->GetElement();
398 if (!element) 417 if (!element)
399 return false; 418 return false;
400 419
401 bool is_null = true; 420 bool is_null = true;
402 result = 421 result =
403 AccessibleNode::GetPropertyOrARIAAttribute(element, property, is_null); 422 AccessibleNode::GetPropertyOrARIAAttribute(element, property, is_null);
404 return !is_null; 423 return !is_null;
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 // If you change this logic, update AXNodeObject::nameFromLabelElement, too. 989 // If you change this logic, update AXNodeObject::nameFromLabelElement, too.
971 if (!in_aria_labelled_by_traversal && 990 if (!in_aria_labelled_by_traversal &&
972 IsHiddenForTextAlternativeCalculation()) { 991 IsHiddenForTextAlternativeCalculation()) {
973 *found_text_alternative = true; 992 *found_text_alternative = true;
974 return String(); 993 return String();
975 } 994 }
976 995
977 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 996 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1
978 // If you change this logic, update AXNodeObject::nameFromLabelElement, too. 997 // If you change this logic, update AXNodeObject::nameFromLabelElement, too.
979 if (!in_aria_labelled_by_traversal && !already_visited) { 998 if (!in_aria_labelled_by_traversal && !already_visited) {
980 const QualifiedName& attr =
981 HasAttribute(aria_labeledbyAttr) && !HasAttribute(aria_labelledbyAttr)
982 ? aria_labeledbyAttr
983 : aria_labelledbyAttr;
984 name_from = kAXNameFromRelatedElement; 999 name_from = kAXNameFromRelatedElement;
985 if (name_sources) {
986 name_sources->push_back(NameSource(*found_text_alternative, attr));
987 name_sources->back().type = name_from;
988 }
989 1000
990 const AtomicString& aria_labelledby = GetAttribute(attr); 1001 // Check AOM property first.
991 if (!aria_labelledby.IsNull()) { 1002 HeapVector<Member<Element>> elements;
992 if (name_sources) 1003 if (HasAOMProperty(AOMRelationListProperty::kLabeledBy, elements)) {
993 name_sources->back().attribute_value = aria_labelledby; 1004 if (name_sources) {
1005 name_sources->push_back(
1006 NameSource(*found_text_alternative, aria_labelledbyAttr));
1007 name_sources->back().type = name_from;
1008 }
994 1009
995 // Operate on a copy of |visited| so that if |nameSources| is not null, 1010 // Operate on a copy of |visited| so that if |nameSources| is not null,
996 // the set of visited objects is preserved unmodified for future 1011 // the set of visited objects is preserved unmodified for future
997 // calculations. 1012 // calculations.
998 AXObjectSet visited_copy = visited; 1013 AXObjectSet visited_copy = visited;
999 text_alternative = TextFromAriaLabelledby(visited_copy, related_objects); 1014 text_alternative =
1015 TextFromElements(true, visited_copy, elements, related_objects);
1000 if (!text_alternative.IsNull()) { 1016 if (!text_alternative.IsNull()) {
1001 if (name_sources) { 1017 if (name_sources) {
1002 NameSource& source = name_sources->back(); 1018 NameSource& source = name_sources->back();
1003 source.type = name_from; 1019 source.type = name_from;
1004 source.related_objects = *related_objects; 1020 source.related_objects = *related_objects;
1005 source.text = text_alternative; 1021 source.text = text_alternative;
1006 *found_text_alternative = true; 1022 *found_text_alternative = true;
1007 } else { 1023 } else {
1008 *found_text_alternative = true; 1024 *found_text_alternative = true;
1009 return text_alternative; 1025 return text_alternative;
1010 } 1026 }
1011 } else if (name_sources) { 1027 } else if (name_sources) {
1012 name_sources->back().invalid = true; 1028 name_sources->back().invalid = true;
1013 } 1029 }
1030 } else {
1031 // Now check ARIA attribute
1032 const QualifiedName& attr =
1033 HasAttribute(aria_labeledbyAttr) && !HasAttribute(aria_labelledbyAttr)
1034 ? aria_labeledbyAttr
1035 : aria_labelledbyAttr;
1036
1037 if (name_sources) {
1038 name_sources->push_back(NameSource(*found_text_alternative, attr));
1039 name_sources->back().type = name_from;
1040 }
1041
1042 const AtomicString& aria_labelledby = GetAttribute(attr);
1043 if (!aria_labelledby.IsNull()) {
1044 if (name_sources)
1045 name_sources->back().attribute_value = aria_labelledby;
1046
1047 // Operate on a copy of |visited| so that if |nameSources| is not null,
1048 // the set of visited objects is preserved unmodified for future
1049 // calculations.
1050 AXObjectSet visited_copy = visited;
1051 text_alternative =
1052 TextFromAriaLabelledby(visited_copy, related_objects);
1053 if (!text_alternative.IsNull()) {
1054 if (name_sources) {
1055 NameSource& source = name_sources->back();
1056 source.type = name_from;
1057 source.related_objects = *related_objects;
1058 source.text = text_alternative;
1059 *found_text_alternative = true;
1060 } else {
1061 *found_text_alternative = true;
1062 return text_alternative;
1063 }
1064 } else if (name_sources) {
1065 name_sources->back().invalid = true;
1066 }
1067 }
1014 } 1068 }
1015 } 1069 }
1016 1070
1017 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1 1071 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1
1018 // If you change this logic, update AXNodeObject::nameFromLabelElement, too. 1072 // If you change this logic, update AXNodeObject::nameFromLabelElement, too.
1019 name_from = kAXNameFromAttribute; 1073 name_from = kAXNameFromAttribute;
1020 if (name_sources) { 1074 if (name_sources) {
1021 name_sources->push_back( 1075 name_sources->push_back(
1022 NameSource(*found_text_alternative, aria_labelAttr)); 1076 NameSource(*found_text_alternative, aria_labelAttr));
1023 name_sources->back().type = name_from; 1077 name_sources->back().type = name_from;
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 } 2153 }
2100 2154
2101 DEFINE_TRACE(AXObject) { 2155 DEFINE_TRACE(AXObject) {
2102 visitor->Trace(children_); 2156 visitor->Trace(children_);
2103 visitor->Trace(parent_); 2157 visitor->Trace(parent_);
2104 visitor->Trace(cached_live_region_root_); 2158 visitor->Trace(cached_live_region_root_);
2105 visitor->Trace(ax_object_cache_); 2159 visitor->Trace(ax_object_cache_);
2106 } 2160 }
2107 2161
2108 } // namespace blink 2162 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698