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

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

Issue 588653003: Adding support for ARIA 1.1 role="none" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 if (decision == IgnoreObject) 591 if (decision == IgnoreObject)
592 return true; 592 return true;
593 593
594 // If this element is within a parent that cannot have children, it should n ot be exposed. 594 // If this element is within a parent that cannot have children, it should n ot be exposed.
595 if (isDescendantOfBarrenParent()) 595 if (isDescendantOfBarrenParent())
596 return true; 596 return true;
597 597
598 if (roleValue() == IgnoredRole) 598 if (roleValue() == IgnoredRole)
599 return true; 599 return true;
600 600
601 if (roleValue() == PresentationalRole || inheritsPresentationalRole()) 601 if ((roleValue() == NoneRole || roleValue() == PresentationalRole) || inheri tsNoneOrPresentationalRole())
602 return true; 602 return true;
603 603
604 // An ARIA tree can only have tree items and static text as children. 604 // An ARIA tree can only have tree items and static text as children.
605 if (!isAllowedChildOfTree()) 605 if (!isAllowedChildOfTree())
606 return true; 606 return true;
607 607
608 // TODO: we should refactor this - but right now this is necessary to make 608 // TODO: we should refactor this - but right now this is necessary to make
609 // sure scroll areas stay in the tree. 609 // sure scroll areas stay in the tree.
610 if (isAttachment()) 610 if (isAttachment())
611 return false; 611 return false;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 void AXRenderObject::ariaOwnsElements(AccessibilityChildrenVector& owns) const 989 void AXRenderObject::ariaOwnsElements(AccessibilityChildrenVector& owns) const
990 { 990 {
991 accessibilityChildrenFromAttribute(aria_ownsAttr, owns); 991 accessibilityChildrenFromAttribute(aria_ownsAttr, owns);
992 } 992 }
993 993
994 bool AXRenderObject::ariaHasPopup() const 994 bool AXRenderObject::ariaHasPopup() const
995 { 995 {
996 return elementAttributeValue(aria_haspopupAttr); 996 return elementAttributeValue(aria_haspopupAttr);
997 } 997 }
998 998
999 bool AXRenderObject::ariaRoleHasPresentationalChildren() const 999 bool AXRenderObject::ariaRoleHasNoneOrPresentationalChildren() const
shreeramk 2014/09/20 12:39:36 Same query as AXObject.h
1000 { 1000 {
1001 switch (m_ariaRole) { 1001 switch (m_ariaRole) {
1002 case ButtonRole: 1002 case ButtonRole:
1003 case SliderRole: 1003 case SliderRole:
1004 case ImageRole: 1004 case ImageRole:
1005 case ProgressIndicatorRole: 1005 case ProgressIndicatorRole:
1006 case SpinButtonRole: 1006 case SpinButtonRole:
1007 // case SeparatorRole: 1007 // case SeparatorRole:
1008 return true; 1008 return true;
1009 default: 1009 default:
1010 return false; 1010 return false;
1011 } 1011 }
1012 } 1012 }
1013 1013
1014 bool AXRenderObject::isPresentationalChildOfAriaRole() const 1014 bool AXRenderObject::isNoneOrPresentationalChildOfAriaRole() const
1015 { 1015 {
1016 // Walk the parent chain looking for a parent that has presentational childr en 1016 // Walk the parent chain looking for a parent that has presentational childr en
1017 AXObject* parent; 1017 AXObject* parent;
1018 for (parent = parentObject(); parent && !parent->ariaRoleHasPresentationalCh ildren(); parent = parent->parentObject()) 1018 for (parent = parentObject(); parent && !parent->ariaRoleHasNoneOrPresentati onalChildren(); parent = parent->parentObject())
1019 { } 1019 { }
1020 1020
1021 return parent; 1021 return parent;
1022 } 1022 }
1023 1023
1024 bool AXRenderObject::shouldFocusActiveDescendant() const 1024 bool AXRenderObject::shouldFocusActiveDescendant() const
1025 { 1025 {
1026 switch (ariaRoleAttribute()) { 1026 switch (ariaRoleAttribute()) {
1027 case ComboBoxRole: 1027 case ComboBoxRole:
1028 case GridRole: 1028 case GridRole:
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 } 2267 }
2268 2268
2269 bool AXRenderObject::elementAttributeValue(const QualifiedName& attributeName) c onst 2269 bool AXRenderObject::elementAttributeValue(const QualifiedName& attributeName) c onst
2270 { 2270 {
2271 if (!m_renderer) 2271 if (!m_renderer)
2272 return false; 2272 return false;
2273 2273
2274 return equalIgnoringCase(getAttribute(attributeName), "true"); 2274 return equalIgnoringCase(getAttribute(attributeName), "true");
2275 } 2275 }
2276 2276
2277 bool AXRenderObject::inheritsPresentationalRole() const 2277 bool AXRenderObject::inheritsNoneOrPresentationalRole() const
shreeramk 2014/09/20 12:39:36 Same query as AXRenderObject.h
2278 { 2278 {
2279 // ARIA states if an item can get focus, it should not be presentational. 2279 // ARIA states if an item can get focus, it should not be none or presentati onal.
2280 if (canSetFocusAttribute()) 2280 if (canSetFocusAttribute())
2281 return false; 2281 return false;
2282 2282
2283 // ARIA spec says that when a parent object is presentational, and it has re quired child elements, 2283 // ARIA spec says that when a parent object is none or presentational, and i t has required child elements,
2284 // those child elements are also presentational. For example, <li> becomes p resentational from <ul>. 2284 // those child elements are also none or presentational. For example, <li> b ecomes presentational from <ul>.
2285 // http://www.w3.org/WAI/PF/aria/complete#presentation 2285 // http://www.w3.org/WAI/PF/aria/complete#presentation
2286 if (roleValue() != ListItemRole && roleValue() != ListMarkerRole) 2286 if (roleValue() != ListItemRole && roleValue() != ListMarkerRole)
2287 return false; 2287 return false;
2288 2288
2289 AXObject* parent = parentObject(); 2289 AXObject* parent = parentObject();
2290 if (!parent->isAXRenderObject()) 2290 if (!parent->isAXRenderObject())
2291 return false; 2291 return false;
2292 2292
2293 Node* elementNode = toAXRenderObject(parent)->node(); 2293 Node* elementNode = toAXRenderObject(parent)->node();
2294 if (!elementNode || !elementNode->isElementNode()) 2294 if (!elementNode || !elementNode->isElementNode())
2295 return false; 2295 return false;
2296 2296
2297 QualifiedName tagName = toElement(elementNode)->tagQName(); 2297 QualifiedName tagName = toElement(elementNode)->tagQName();
2298 if (tagName == ulTag || tagName == olTag || tagName == dlTag) 2298 if (tagName == ulTag || tagName == olTag || tagName == dlTag)
2299 return parent->roleValue() == PresentationalRole; 2299 return (parent->roleValue() == NoneRole || parent->roleValue() == Presen tationalRole);
2300 2300
2301 return false; 2301 return false;
2302 } 2302 }
2303 2303
2304 LayoutRect AXRenderObject::computeElementRect() const 2304 LayoutRect AXRenderObject::computeElementRect() const
2305 { 2305 {
2306 RenderObject* obj = m_renderer; 2306 RenderObject* obj = m_renderer;
2307 2307
2308 if (!obj) 2308 if (!obj)
2309 return LayoutRect(); 2309 return LayoutRect();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 if (label && label->renderer()) { 2344 if (label && label->renderer()) {
2345 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2345 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2346 result.unite(labelRect); 2346 result.unite(labelRect);
2347 } 2347 }
2348 } 2348 }
2349 2349
2350 return result; 2350 return result;
2351 } 2351 }
2352 2352
2353 } // namespace blink 2353 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698