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

Side by Side Diff: Source/core/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 accessibilityDescription for figcaption 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
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 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 continue; 1174 continue;
1175 } 1175 }
1176 } 1176 }
1177 1177
1178 builder.append(child->textUnderElement()); 1178 builder.append(child->textUnderElement());
1179 } 1179 }
1180 1180
1181 return builder.toString(); 1181 return builder.toString();
1182 } 1182 }
1183 1183
1184 AXObject* AXNodeObject::searchAXObjectFromChild(const HTMLQualifiedName& node) c onst
dmazzoni 2014/11/12 06:03:03 The argument name should be tagName instead of nod
je_julie(Not used) 2014/11/12 13:07:04 You're right. I updated the parameter name.
1185 {
1186 for (AXObject* child = firstChild(); child; child = child->nextSibling()) {
1187 Node* childNode = child->node();
1188 if (childNode && childNode->hasTagName(node))
1189 return child;
1190 }
1191 return 0;
1192 }
1193
1184 String AXNodeObject::accessibilityDescription() const 1194 String AXNodeObject::accessibilityDescription() const
1185 { 1195 {
1186 // Static text should not have a description, it should only have a stringVa lue. 1196 // Static text should not have a description, it should only have a stringVa lue.
1187 if (roleValue() == StaticTextRole) 1197 if (roleValue() == StaticTextRole)
1188 return String(); 1198 return String();
1189 1199
1190 String ariaDescription = ariaAccessibilityDescription(); 1200 String ariaDescription = ariaAccessibilityDescription();
1191 if (!ariaDescription.isEmpty()) 1201 if (!ariaDescription.isEmpty())
1192 return ariaDescription; 1202 return ariaDescription;
1193 1203
1194 if (isImage() || isInputImage() || isNativeImage() || isCanvas()) { 1204 if (isImage() || isInputImage() || isNativeImage() || isCanvas()) {
1195 // Images should use alt as long as the attribute is present, even if em pty. 1205 // Images should use alt as long as the attribute is present, even if em pty.
1196 // Otherwise, it should fallback to other methods, like the title attrib ute. 1206 // Otherwise, it should fallback to other methods, like the title attrib ute.
1197 const AtomicString& alt = getAttribute(altAttr); 1207 const AtomicString& alt = getAttribute(altAttr);
1198 if (!alt.isNull()) 1208 if (!alt.isNull())
1199 return alt; 1209 return alt;
1200 } 1210 }
1201 1211
1202 // An element's descriptive text is comprised of title() (what's visible on the screen) and accessibilityDescription() (other descriptive text). 1212 // An element's descriptive text is comprised of title() (what's visible on the screen) and accessibilityDescription() (other descriptive text).
1203 // Both are used to generate what a screen reader speaks. 1213 // Both are used to generate what a screen reader speaks.
1204 // 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. 1214 // 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.
1205 // 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). 1215 // 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).
1206 if (title().isEmpty()) 1216 if (title().isEmpty())
1207 return getAttribute(titleAttr); 1217 return getAttribute(titleAttr);
1208 1218
1219 if (roleValue() == FigureRole) {
1220 AXObject* figcaption = searchAXObjectFromChild(figcaptionTag);
1221 if (figcaption)
1222 return figcaption->accessibilityDescription();
1223 }
1224
1209 return String(); 1225 return String();
1210 } 1226 }
1211 1227
1212 String AXNodeObject::title() const 1228 String AXNodeObject::title() const
1213 { 1229 {
1214 Node* node = this->node(); 1230 Node* node = this->node();
1215 if (!node) 1231 if (!node)
1216 return String(); 1232 return String();
1217 1233
1218 bool isInputElement = isHTMLInputElement(*node); 1234 bool isInputElement = isHTMLInputElement(*node);
(...skipping 25 matching lines...) Expand all
1244 case MenuButtonRole: 1260 case MenuButtonRole:
1245 case MenuItemRole: 1261 case MenuItemRole:
1246 case MenuItemCheckBoxRole: 1262 case MenuItemCheckBoxRole:
1247 case MenuItemRadioRole: 1263 case MenuItemRadioRole:
1248 case RadioButtonRole: 1264 case RadioButtonRole:
1249 case TabRole: 1265 case TabRole:
1250 return textUnderElement(); 1266 return textUnderElement();
1251 // SVGRoots should not use the text under itself as a title. That could incl ude the text of objects like <text>. 1267 // SVGRoots should not use the text under itself as a title. That could incl ude the text of objects like <text>.
1252 case SVGRootRole: 1268 case SVGRootRole:
1253 return String(); 1269 return String();
1270 case FigureRole: {
1271 AXObject* figcaption = searchAXObjectFromChild(figcaptionTag);
1272 if (figcaption)
1273 return figcaption->textUnderElement();
1274 }
1254 default: 1275 default:
1255 break; 1276 break;
1256 } 1277 }
1257 1278
1258 if (isHeading() || isLink()) 1279 if (isHeading() || isLink())
1259 return textUnderElement(); 1280 return textUnderElement();
1260 1281
1261 // If it's focusable but it's not content editable or a known control type, then it will appear to 1282 // If it's focusable but it's not content editable or a known control type, then it will appear to
1262 // the user as a single atomic object, so we should use its text as the defa ult title. 1283 // the user as a single atomic object, so we should use its text as the defa ult title.
1263 if (isGenericFocusableElement()) 1284 if (isGenericFocusableElement())
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 float range = maxValueForRange() - minValueForRange(); 1795 float range = maxValueForRange() - minValueForRange();
1775 float value = valueForRange(); 1796 float value = valueForRange();
1776 1797
1777 value += range * (percentChange / 100); 1798 value += range * (percentChange / 100);
1778 setValue(String::number(value)); 1799 setValue(String::number(value));
1779 1800
1780 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged, true); 1801 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged, true);
1781 } 1802 }
1782 1803
1783 } // namespace blink 1804 } // namespace blink
OLDNEW
« Source/core/accessibility/AXNodeObject.h ('K') | « Source/core/accessibility/AXNodeObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698