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

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

Issue 762783002: Adding a11y support for HTML5 <datalist> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding support to expose link element which is inside a label element Created 6 years 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.cpp ('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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 { 257 {
258 if (!m_renderer) 258 if (!m_renderer)
259 return UnknownRole; 259 return UnknownRole;
260 260
261 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) 261 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole)
262 return m_ariaRole; 262 return m_ariaRole;
263 263
264 Node* node = m_renderer->node(); 264 Node* node = m_renderer->node();
265 RenderBoxModelObject* cssBox = renderBoxModelObject(); 265 RenderBoxModelObject* cssBox = renderBoxModelObject();
266 266
267 if (node && node->isLink()) {
268 if (cssBox && cssBox->isImage())
269 return ImageMapRole;
270 return LinkRole;
271 }
272 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node)) 267 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node))
273 return ListItemRole; 268 return ListItemRole;
274 if (m_renderer->isListMarker()) 269 if (m_renderer->isListMarker())
275 return ListMarkerRole; 270 return ListMarkerRole;
276 if (isHTMLButtonElement(node))
277 return buttonRoleType();
278 if (isHTMLDetailsElement(node))
279 return DetailsRole;
280 if (isHTMLSummaryElement(node)) {
281 if (node->parentElement() && isHTMLDetailsElement(node->parentElement()) )
282 return DisclosureTriangleRole;
283 return UnknownRole;
284 }
285 if (isHTMLLegendElement(node)) 271 if (isHTMLLegendElement(node))
286 return LegendRole; 272 return LegendRole;
287 if (m_renderer->isText()) 273 if (m_renderer->isText())
288 return StaticTextRole; 274 return StaticTextRole;
289 if (cssBox && cssBox->isImage()) { 275 if (cssBox && cssBox->isImage()) {
276 if (node && node->isLink())
277 return ImageMapRole;
290 if (isHTMLInputElement(node)) 278 if (isHTMLInputElement(node))
291 return ariaHasPopup() ? PopUpButtonRole : ButtonRole; 279 return ariaHasPopup() ? PopUpButtonRole : ButtonRole;
292 if (isSVGImage()) 280 if (isSVGImage())
293 return SVGRootRole; 281 return SVGRootRole;
294 return ImageRole; 282 return ImageRole;
295 } 283 }
296
297 // Note: if JavaScript is disabled, the renderer won't be a RenderHTMLCanvas . 284 // Note: if JavaScript is disabled, the renderer won't be a RenderHTMLCanvas .
298 if (isHTMLCanvasElement(node) && m_renderer->isCanvas()) 285 if (isHTMLCanvasElement(node) && m_renderer->isCanvas())
299 return CanvasRole; 286 return CanvasRole;
300 287
301 if (cssBox && cssBox->isRenderView()) 288 if (cssBox && cssBox->isRenderView())
302 return WebAreaRole; 289 return WebAreaRole;
303 290
304 if (cssBox && cssBox->isTextArea())
305 return TextAreaRole;
306
307 if (isHTMLInputElement(node)) {
308 HTMLInputElement& input = toHTMLInputElement(*node);
309 const AtomicString& type = input.type();
310 if (type == InputTypeNames::button) {
311 if ((node->parentNode() && isHTMLMenuElement(node->parentNode())) || (parentObject() && parentObject()->roleValue() == MenuRole))
312 return MenuItemRole;
313 return buttonRoleType();
314 }
315 if (type == InputTypeNames::checkbox) {
316 if ((node->parentNode() && isHTMLMenuElement(node->parentNode())) || (parentObject() && parentObject()->roleValue() == MenuRole))
317 return MenuItemCheckBoxRole;
318 return CheckBoxRole;
319 }
320 if (type == InputTypeNames::date)
321 return DateRole;
322 if (type == InputTypeNames::datetime
323 || type == InputTypeNames::datetime_local
324 || type == InputTypeNames::month
325 || type == InputTypeNames::week)
326 return DateTimeRole;
327 if (type == InputTypeNames::radio) {
328 if ((node->parentNode() && isHTMLMenuElement(node->parentNode())) || (parentObject() && parentObject()->roleValue() == MenuRole))
329 return MenuItemRadioRole;
330 return RadioButtonRole;
331 }
332 if (type == InputTypeNames::file)
333 return ButtonRole;
334 if (type == InputTypeNames::number)
335 return SpinButtonRole;
336 if (input.isTextButton())
337 return buttonRoleType();
338 if (type == InputTypeNames::color)
339 return ColorWellRole;
340 if (type == InputTypeNames::time)
341 return TimeRole;
342 return TextFieldRole;
343 }
344
345 if (cssBox && cssBox->isMenuList())
346 return PopUpButtonRole;
347
348 if (headingLevel())
349 return HeadingRole;
350
351 if (m_renderer->isSVGImage()) 291 if (m_renderer->isSVGImage())
352 return ImageRole; 292 return ImageRole;
353 if (m_renderer->isSVGRoot()) 293 if (m_renderer->isSVGRoot())
354 return SVGRootRole; 294 return SVGRootRole;
355 295
356 if (node && node->hasTagName(ddTag)) 296 if (node && node->hasTagName(ddTag))
357 return DescriptionListDetailRole; 297 return DescriptionListDetailRole;
358 298
359 if (node && node->hasTagName(dlTag))
360 return DescriptionListRole;
361
362 if (node && node->hasTagName(dtTag)) 299 if (node && node->hasTagName(dtTag))
363 return DescriptionListTermRole; 300 return DescriptionListTermRole;
364 301
365 if (node && (node->nodeName() == "math")) 302 if (node && (node->nodeName() == "math"))
366 return MathRole; 303 return MathRole;
367 304
368 if (node && (node->hasTagName(rpTag) || node->hasTagName(rtTag))) 305 if (node && (node->hasTagName(rpTag) || node->hasTagName(rtTag)))
369 return AnnotationRole; 306 return AnnotationRole;
370 307
371 // Table sections should be ignored. 308 // Table sections should be ignored.
372 if (m_renderer->isTableSection()) 309 if (m_renderer->isTableSection())
373 return IgnoredRole; 310 return IgnoredRole;
374 311
375 if (m_renderer->isHR()) 312 if (m_renderer->isHR())
376 return SplitterRole; 313 return SplitterRole;
377 314
378 if (isHTMLOutputElement(node))
379 return StatusRole;
380
381 if (isHTMLParagraphElement(node))
382 return ParagraphRole;
383
384 if (isHTMLLabelElement(node))
385 return LabelRole;
386
387 if (isHTMLRubyElement(node))
388 return RubyRole;
389
390 if (isHTMLDivElement(node))
391 return DivRole;
392
393 if (isHTMLMeterElement(node))
394 return MeterRole;
395
396 if (isHTMLFormElement(node)) 315 if (isHTMLFormElement(node))
397 return FormRole; 316 return FormRole;
398 317
399 if (node && node->hasTagName(articleTag)) 318 if (node && node->hasTagName(articleTag))
400 return ArticleRole; 319 return ArticleRole;
401 320
402 if (node && node->hasTagName(blockquoteTag))
403 return BlockquoteRole;
404
405 if (node && node->hasTagName(mainTag)) 321 if (node && node->hasTagName(mainTag))
406 return MainRole; 322 return MainRole;
407 323
408 if (node && node->hasTagName(navTag)) 324 if (node && node->hasTagName(navTag))
409 return NavigationRole; 325 return NavigationRole;
410 326
411 if (node && node->hasTagName(asideTag)) 327 if (node && node->hasTagName(asideTag))
412 return ComplementaryRole; 328 return ComplementaryRole;
413 329
414 if (node && node->hasTagName(preTag)) 330 if (node && node->hasTagName(preTag))
(...skipping 12 matching lines...) Expand all
427 if (isHTMLHtmlElement(node)) 343 if (isHTMLHtmlElement(node))
428 return IgnoredRole; 344 return IgnoredRole;
429 345
430 if (node && node->hasTagName(iframeTag)) { 346 if (node && node->hasTagName(iframeTag)) {
431 const AtomicString& ariaRole = getAttribute(roleAttr); 347 const AtomicString& ariaRole = getAttribute(roleAttr);
432 if (ariaRole == "none" || ariaRole == "presentation") 348 if (ariaRole == "none" || ariaRole == "presentation")
433 return IframePresentationalRole; 349 return IframePresentationalRole;
434 return IframeRole; 350 return IframeRole;
435 } 351 }
436 352
437 if (isEmbeddedObject())
438 return EmbeddedObjectRole;
439
440 if (node && node->hasTagName(figcaptionTag))
441 return FigcaptionRole;
442
443 if (node && node->hasTagName(figureTag))
444 return FigureRole;
445
446 // There should only be one banner/contentInfo per page. If header/footer ar e being used within an article or section 353 // There should only be one banner/contentInfo per page. If header/footer ar e being used within an article or section
447 // then it should not be exposed as whole page's banner/contentInfo 354 // then it should not be exposed as whole page's banner/contentInfo
448 if (node && node->hasTagName(headerTag) && !isDescendantOfElementType(articl eTag) && !isDescendantOfElementType(sectionTag)) 355 if (node && node->hasTagName(headerTag) && !isDescendantOfElementType(articl eTag) && !isDescendantOfElementType(sectionTag))
449 return BannerRole; 356 return BannerRole;
450 if (node && node->hasTagName(footerTag) && !isDescendantOfElementType(articl eTag) && !isDescendantOfElementType(sectionTag)) 357 if (node && node->hasTagName(footerTag) && !isDescendantOfElementType(articl eTag) && !isDescendantOfElementType(sectionTag))
451 return FooterRole; 358 return FooterRole;
452 359
453 if (isHTMLAnchorElement(node) && isClickable()) 360 AccessibilityRole role = AXNodeObject::determineAccessibilityRoleUtil();
454 return LinkRole; 361 if (role != UnknownRole)
362 return role;
455 363
456 if (m_renderer->isRenderBlockFlow()) 364 if (m_renderer->isRenderBlockFlow())
457 return GroupRole; 365 return GroupRole;
458 366
459 // If the element does not have role, but it has ARIA attributes, accessibil ity should fallback to exposing it as a group. 367 // If the element does not have role, but it has ARIA attributes, accessibil ity should fallback to exposing it as a group.
460 if (supportsARIAAttributes()) 368 if (supportsARIAAttributes())
461 return GroupRole; 369 return GroupRole;
462 370
463 return UnknownRole; 371 return UnknownRole;
464 } 372 }
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 if (label && label->renderer()) { 2397 if (label && label->renderer()) {
2490 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2398 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2491 result.unite(labelRect); 2399 result.unite(labelRect);
2492 } 2400 }
2493 } 2401 }
2494 2402
2495 return result; 2403 return result;
2496 } 2404 }
2497 2405
2498 } // namespace blink 2406 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXNodeObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698