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

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

Issue 1039873002: AX presentation role should be inherited to its required owned elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moved code to AXNodeObject Created 5 years, 8 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 if (decision == IgnoreObject) 556 if (decision == IgnoreObject)
557 return true; 557 return true;
558 558
559 // If this element is within a parent that cannot have children, it should n ot be exposed. 559 // If this element is within a parent that cannot have children, it should n ot be exposed.
560 if (isDescendantOfBarrenParent()) 560 if (isDescendantOfBarrenParent())
561 return true; 561 return true;
562 562
563 if (roleValue() == IgnoredRole) 563 if (roleValue() == IgnoredRole)
564 return true; 564 return true;
565 565
566 if ((roleValue() == NoneRole || roleValue() == PresentationalRole) || inheri tsPresentationalRole()) 566 if (isPresentationRole(static_cast<const AXObject*>(this)))
dmazzoni 2015/03/31 16:35:23 Can you do this without the cast? If you do need
je_julie(Not used) 2015/04/01 12:51:28 Because |this| is AXLayoutObject and parameter typ
567 return true; 567 return true;
568 568
569 // An ARIA tree can only have tree items and static text as children. 569 // An ARIA tree can only have tree items and static text as children.
570 if (!isAllowedChildOfTree()) 570 if (!isAllowedChildOfTree())
571 return true; 571 return true;
572 572
573 // TODO: we should refactor this - but right now this is necessary to make 573 // TODO: we should refactor this - but right now this is necessary to make
574 // sure scroll areas stay in the tree. 574 // sure scroll areas stay in the tree.
575 if (isAttachment()) 575 if (isAttachment())
576 return false; 576 return false;
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 } 2285 }
2286 2286
2287 bool AXLayoutObject::elementAttributeValue(const QualifiedName& attributeName) c onst 2287 bool AXLayoutObject::elementAttributeValue(const QualifiedName& attributeName) c onst
2288 { 2288 {
2289 if (!m_layoutObject) 2289 if (!m_layoutObject)
2290 return false; 2290 return false;
2291 2291
2292 return equalIgnoringCase(getAttribute(attributeName), "true"); 2292 return equalIgnoringCase(getAttribute(attributeName), "true");
2293 } 2293 }
2294 2294
2295 bool AXLayoutObject::inheritsPresentationalRole() const
2296 {
2297 // ARIA states if an item can get focus, it should not be presentational.
2298 if (canSetFocusAttribute())
2299 return false;
2300
2301 // ARIA spec says that when a parent object is presentational, and it has re quired child elements,
2302 // those child elements are also presentational. For example, <li> becomes p resentational from <ul>.
2303 // http://www.w3.org/WAI/PF/aria/complete#presentation
2304 if (roleValue() != ListItemRole && roleValue() != ListMarkerRole)
2305 return false;
2306
2307 AXObject* parent = parentObject();
2308 if (!parent->isAXLayoutObject())
2309 return false;
2310
2311 Node* elementNode = toAXLayoutObject(parent)->node();
2312 if (!elementNode || !elementNode->isElementNode())
2313 return false;
2314
2315 QualifiedName tagName = toElement(elementNode)->tagQName();
2316 if (tagName != ulTag && tagName != olTag && tagName != dlTag)
2317 return false;
2318
2319 if (parent->roleValue() == NoneRole || parent->roleValue() == Presentational Role)
2320 return ariaRoleAttribute() == UnknownRole;
2321
2322 return false;
2323 }
2324
2325 LayoutRect AXLayoutObject::computeElementRect() const 2295 LayoutRect AXLayoutObject::computeElementRect() const
2326 { 2296 {
2327 LayoutObject* obj = m_layoutObject; 2297 LayoutObject* obj = m_layoutObject;
2328 2298
2329 if (!obj) 2299 if (!obj)
2330 return LayoutRect(); 2300 return LayoutRect();
2331 2301
2332 if (obj->node()) // If we are a continuation, we want to make sure to use th e primary layoutObject. 2302 if (obj->node()) // If we are a continuation, we want to make sure to use th e primary layoutObject.
2333 obj = obj->node()->layoutObject(); 2303 obj = obj->node()->layoutObject();
2334 2304
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 if (label && label->layoutObject()) { 2336 if (label && label->layoutObject()) {
2367 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2337 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2368 result.unite(labelRect); 2338 result.unite(labelRect);
2369 } 2339 }
2370 } 2340 }
2371 2341
2372 return result; 2342 return result;
2373 } 2343 }
2374 2344
2375 } // namespace blink 2345 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698