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

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

Issue 1932523003: Introduce NodeTraversal::ancestorsOf() and inclusiveAncestors() for range-based for loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-04-28T18:38:12 Created 4 years, 7 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 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 } 1700 }
1701 } 1701 }
1702 1702
1703 // bail if none found 1703 // bail if none found
1704 if (!currLayoutObject) 1704 if (!currLayoutObject)
1705 return 0; 1705 return 0;
1706 1706
1707 // search up the DOM tree for an anchor element 1707 // search up the DOM tree for an anchor element
1708 // NOTE: this assumes that any non-image with an anchor is an HTMLAnchorElem ent 1708 // NOTE: this assumes that any non-image with an anchor is an HTMLAnchorElem ent
1709 Node* node = currLayoutObject->node(); 1709 Node* node = currLayoutObject->node();
1710 for ( ; node; node = node->parentNode()) { 1710 if (!node)
1711 if (isHTMLAnchorElement(*node) || (node->layoutObject() && cache.getOrCr eate(node->layoutObject())->isAnchor())) 1711 return nullptr;
1712 return toElement(node); 1712 for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) {
1713 if (isHTMLAnchorElement(runner) || (runner.layoutObject() && cache.getOr Create(runner.layoutObject())->isAnchor()))
1714 return toElement(&runner);
1713 } 1715 }
1714 1716
1715 return 0; 1717 return 0;
1716 } 1718 }
1717 1719
1718 // 1720 //
1719 // Functions that retrieve the current selection. 1721 // Functions that retrieve the current selection.
1720 // 1722 //
1721 1723
1722 AXObject::AXRange AXLayoutObject::selection() const 1724 AXObject::AXRange AXLayoutObject::selection() const
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 if (label && label->layoutObject()) { 2467 if (label && label->layoutObject()) {
2466 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct(); 2468 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct();
2467 result.unite(labelRect); 2469 result.unite(labelRect);
2468 } 2470 }
2469 } 2471 }
2470 2472
2471 return result; 2473 return result;
2472 } 2474 }
2473 2475
2474 } // namespace blink 2476 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGElement.cpp ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698