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

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: Refactored common code between AXNodeObject and AXRenderObject 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
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))
415 return PreRole; 331 return PreRole;
416 332
417 if (node && node->hasTagName(sectionTag)) 333 if (node && node->hasTagName(sectionTag))
418 return RegionRole; 334 return RegionRole;
419 335
420 if (node && node->hasTagName(addressTag)) 336 if (node && node->hasTagName(addressTag))
421 return ContentInfoRole; 337 return ContentInfoRole;
422 338
423 if (node && node->hasTagName(dialogTag)) 339 if (node && node->hasTagName(dialogTag))
424 return DialogRole; 340 return DialogRole;
425 341
426 // The HTML element should not be exposed as an element. That's what the Ren derView element does. 342 // The HTML element should not be exposed as an element. That's what the Ren derView element does.
427 if (isHTMLHtmlElement(node)) 343 if (isHTMLHtmlElement(node))
428 return IgnoredRole; 344 return IgnoredRole;
429 345
430 if (node && node->hasTagName(iframeTag))
431 return IframeRole;
432
433 if (isEmbeddedObject())
434 return EmbeddedObjectRole;
435
436 if (node && node->hasTagName(figcaptionTag))
437 return FigcaptionRole;
438
439 if (node && node->hasTagName(figureTag))
440 return FigureRole;
441 346
442 // There should only be one banner/contentInfo per page. If header/footer ar e being used within an article or section 347 // There should only be one banner/contentInfo per page. If header/footer ar e being used within an article or section
443 // then it should not be exposed as whole page's banner/contentInfo 348 // then it should not be exposed as whole page's banner/contentInfo
444 if (node && node->hasTagName(headerTag) && !isDescendantOfElementType(articl eTag) && !isDescendantOfElementType(sectionTag)) 349 if (node && node->hasTagName(headerTag) && !isDescendantOfElementType(articl eTag) && !isDescendantOfElementType(sectionTag))
445 return BannerRole; 350 return BannerRole;
446 if (node && node->hasTagName(footerTag) && !isDescendantOfElementType(articl eTag) && !isDescendantOfElementType(sectionTag)) 351 if (node && node->hasTagName(footerTag) && !isDescendantOfElementType(articl eTag) && !isDescendantOfElementType(sectionTag))
447 return FooterRole; 352 return FooterRole;
448 353
449 if (isHTMLAnchorElement(node) && isClickable()) 354 AccessibilityRole role = AXNodeObject::determineAccessibilityRoleUtil();
450 return LinkRole; 355 if (role != UnknownRole)
356 return role;
451 357
452 if (m_renderer->isRenderBlockFlow()) 358 if (m_renderer->isRenderBlockFlow())
453 return GroupRole; 359 return GroupRole;
454 360
455 // If the element does not have role, but it has ARIA attributes, accessibil ity should fallback to exposing it as a group. 361 // If the element does not have role, but it has ARIA attributes, accessibil ity should fallback to exposing it as a group.
456 if (supportsARIAAttributes()) 362 if (supportsARIAAttributes())
457 return GroupRole; 363 return GroupRole;
458 364
459 return UnknownRole; 365 return UnknownRole;
460 } 366 }
(...skipping 1996 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 if (label && label->renderer()) { 2363 if (label && label->renderer()) {
2458 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2364 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2459 result.unite(labelRect); 2365 result.unite(labelRect);
2460 } 2366 }
2461 } 2367 }
2462 2368
2463 return result; 2369 return result;
2464 } 2370 }
2465 2371
2466 } // namespace blink 2372 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698