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

Unified Diff: third_party/WebKit/Source/core/page/SpatialNavigation.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, 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/page/SpatialNavigation.cpp
diff --git a/third_party/WebKit/Source/core/page/SpatialNavigation.cpp b/third_party/WebKit/Source/core/page/SpatialNavigation.cpp
index 20a368546a230df214e924b5e7f83573341e8bda..52c1a5b4674369b304d0d63f7a446d859a596f30 100644
--- a/third_party/WebKit/Source/core/page/SpatialNavigation.cpp
+++ b/third_party/WebKit/Source/core/page/SpatialNavigation.cpp
@@ -29,6 +29,7 @@
#include "core/page/SpatialNavigation.h"
#include "core/HTMLNames.h"
+#include "core/dom/NodeTraversal.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
@@ -581,15 +582,15 @@ bool canBeScrolledIntoView(WebFocusType type, const FocusCandidate& candidate)
{
ASSERT(candidate.visibleNode && candidate.isOffscreen);
LayoutRect candidateRect = candidate.rect;
- for (Node* parentNode = candidate.visibleNode->parentNode(); parentNode; parentNode = parentNode->parentNode()) {
- LayoutRect parentRect = nodeRectInAbsoluteCoordinates(parentNode);
+ for (Node& parentNode : NodeTraversal::ancestorsOf(*candidate.visibleNode)) {
+ LayoutRect parentRect = nodeRectInAbsoluteCoordinates(&parentNode);
if (!candidateRect.intersects(parentRect)) {
- if (((type == WebFocusTypeLeft || type == WebFocusTypeRight) && parentNode->layoutObject()->style()->overflowX() == OverflowHidden)
- || ((type == WebFocusTypeUp || type == WebFocusTypeDown) && parentNode->layoutObject()->style()->overflowY() == OverflowHidden))
+ if (((type == WebFocusTypeLeft || type == WebFocusTypeRight) && parentNode.layoutObject()->style()->overflowX() == OverflowHidden)
+ || ((type == WebFocusTypeUp || type == WebFocusTypeDown) && parentNode.layoutObject()->style()->overflowY() == OverflowHidden))
return false;
}
if (parentNode == candidate.enclosingScrollableBox)
- return canScrollInDirection(parentNode, type);
+ return canScrollInDirection(&parentNode, type);
}
return true;
}

Powered by Google App Engine
This is Rietveld 408576698