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

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

Issue 713873002: Add the case for figure in title() and accessibilityDescription(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update code on the latest source tree Created 6 years, 1 month 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
« no previous file with comments | « Source/modules/accessibility/AXNodeObject.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 continue; 1181 continue;
1182 } 1182 }
1183 } 1183 }
1184 1184
1185 builder.append(child->textUnderElement()); 1185 builder.append(child->textUnderElement());
1186 } 1186 }
1187 1187
1188 return builder.toString(); 1188 return builder.toString();
1189 } 1189 }
1190 1190
1191 AXObject* AXNodeObject::findChildWithTagName(const HTMLQualifiedName& tagName) c onst
1192 {
1193 for (AXObject* child = firstChild(); child; child = child->nextSibling()) {
1194 Node* childNode = child->node();
1195 if (childNode && childNode->hasTagName(tagName))
1196 return child;
1197 }
1198 return 0;
1199 }
1200
1191 String AXNodeObject::accessibilityDescription() const 1201 String AXNodeObject::accessibilityDescription() const
1192 { 1202 {
1193 // Static text should not have a description, it should only have a stringVa lue. 1203 // Static text should not have a description, it should only have a stringVa lue.
1194 if (roleValue() == StaticTextRole) 1204 if (roleValue() == StaticTextRole)
1195 return String(); 1205 return String();
1196 1206
1197 String ariaDescription = ariaAccessibilityDescription(); 1207 String ariaDescription = ariaAccessibilityDescription();
1198 if (!ariaDescription.isEmpty()) 1208 if (!ariaDescription.isEmpty())
1199 return ariaDescription; 1209 return ariaDescription;
1200 1210
1201 if (isImage() || isInputImage() || isNativeImage() || isCanvas()) { 1211 if (isImage() || isInputImage() || isNativeImage() || isCanvas()) {
1202 // Images should use alt as long as the attribute is present, even if em pty. 1212 // Images should use alt as long as the attribute is present, even if em pty.
1203 // Otherwise, it should fallback to other methods, like the title attrib ute. 1213 // Otherwise, it should fallback to other methods, like the title attrib ute.
1204 const AtomicString& alt = getAttribute(altAttr); 1214 const AtomicString& alt = getAttribute(altAttr);
1205 if (!alt.isNull()) 1215 if (!alt.isNull())
1206 return alt; 1216 return alt;
1207 } 1217 }
1208 1218
1209 // An element's descriptive text is comprised of title() (what's visible on the screen) and accessibilityDescription() (other descriptive text). 1219 // An element's descriptive text is comprised of title() (what's visible on the screen) and accessibilityDescription() (other descriptive text).
1210 // Both are used to generate what a screen reader speaks. 1220 // Both are used to generate what a screen reader speaks.
1211 // If this point is reached (i.e. there's no accessibilityDescription) and t here's no title(), we should fallback to using the title attribute. 1221 // If this point is reached (i.e. there's no accessibilityDescription) and t here's no title(), we should fallback to using the title attribute.
1212 // The title attribute is normally used as help text (because it is a toolti p), but if there is nothing else available, this should be used (according to AR IA). 1222 // The title attribute is normally used as help text (because it is a toolti p), but if there is nothing else available, this should be used (according to AR IA).
1213 if (title().isEmpty()) 1223 if (title().isEmpty())
1214 return getAttribute(titleAttr); 1224 return getAttribute(titleAttr);
1215 1225
1226 if (roleValue() == FigureRole) {
1227 AXObject* figcaption = findChildWithTagName(figcaptionTag);
1228 if (figcaption)
1229 return figcaption->accessibilityDescription();
1230 }
1231
1216 return String(); 1232 return String();
1217 } 1233 }
1218 1234
1219 String AXNodeObject::title() const 1235 String AXNodeObject::title() const
1220 { 1236 {
1221 Node* node = this->node(); 1237 Node* node = this->node();
1222 if (!node) 1238 if (!node)
1223 return String(); 1239 return String();
1224 1240
1225 bool isInputElement = isHTMLInputElement(*node); 1241 bool isInputElement = isHTMLInputElement(*node);
(...skipping 26 matching lines...) Expand all
1252 case MenuButtonRole: 1268 case MenuButtonRole:
1253 case MenuItemRole: 1269 case MenuItemRole:
1254 case MenuItemCheckBoxRole: 1270 case MenuItemCheckBoxRole:
1255 case MenuItemRadioRole: 1271 case MenuItemRadioRole:
1256 case RadioButtonRole: 1272 case RadioButtonRole:
1257 case TabRole: 1273 case TabRole:
1258 return textUnderElement(); 1274 return textUnderElement();
1259 // SVGRoots should not use the text under itself as a title. That could incl ude the text of objects like <text>. 1275 // SVGRoots should not use the text under itself as a title. That could incl ude the text of objects like <text>.
1260 case SVGRootRole: 1276 case SVGRootRole:
1261 return String(); 1277 return String();
1278 case FigureRole: {
1279 AXObject* figcaption = findChildWithTagName(figcaptionTag);
1280 if (figcaption)
1281 return figcaption->textUnderElement();
1282 }
1262 default: 1283 default:
1263 break; 1284 break;
1264 } 1285 }
1265 1286
1266 if (isHeading() || isLink()) 1287 if (isHeading() || isLink())
1267 return textUnderElement(); 1288 return textUnderElement();
1268 1289
1269 // If it's focusable but it's not content editable or a known control type, then it will appear to 1290 // If it's focusable but it's not content editable or a known control type, then it will appear to
1270 // the user as a single atomic object, so we should use its text as the defa ult title. 1291 // the user as a single atomic object, so we should use its text as the defa ult title.
1271 if (isGenericFocusableElement()) 1292 if (isGenericFocusableElement())
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 float range = maxValueForRange() - minValueForRange(); 1803 float range = maxValueForRange() - minValueForRange();
1783 float value = valueForRange(); 1804 float value = valueForRange();
1784 1805
1785 value += range * (percentChange / 100); 1806 value += range * (percentChange / 100);
1786 setValue(String::number(value)); 1807 setValue(String::number(value));
1787 1808
1788 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged, true); 1809 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged, true);
1789 } 1810 }
1790 1811
1791 } // namespace blink 1812 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXNodeObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698