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

Unified Diff: third_party/WebKit/Source/core/page/TouchDisambiguation.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/TouchDisambiguation.cpp
diff --git a/third_party/WebKit/Source/core/page/TouchDisambiguation.cpp b/third_party/WebKit/Source/core/page/TouchDisambiguation.cpp
index d19a86e90ee15e549f21efdc5f4949febb1979c3..a7d1cd90ef5285b7ef262aff8969351f650accec 100644
--- a/third_party/WebKit/Source/core/page/TouchDisambiguation.cpp
+++ b/third_party/WebKit/Source/core/page/TouchDisambiguation.cpp
@@ -119,14 +119,16 @@ void findGoodTouchTargets(const IntRect& touchBoxInRootFrame, LocalFrame* mainFr
HeapHashMap<Member<Node>, TouchTargetData> touchTargets;
float bestScore = 0;
for (const auto& hitResult : hitResults) {
- for (Node* node = hitResult.get(); node; node = node->parentNode()) {
- if (blackList.contains(node))
+ if (!hitResult)
+ continue;
+ for (Node& node : NodeTraversal::inclusiveAncestorsOf(*hitResult)) {
+ if (blackList.contains(&node))
continue;
- if (node->isDocumentNode() || isHTMLHtmlElement(*node) || isHTMLBodyElement(*node))
+ if (node.isDocumentNode() || isHTMLHtmlElement(node) || isHTMLBodyElement(node))
break;
- if (node->willRespondToMouseClickEvents()) {
- TouchTargetData& targetData = touchTargets.add(node, TouchTargetData()).storedValue->value;
- targetData.windowBoundingBox = boundingBoxForEventNodes(node);
+ if (node.willRespondToMouseClickEvents()) {
+ TouchTargetData& targetData = touchTargets.add(&node, TouchTargetData()).storedValue->value;
+ targetData.windowBoundingBox = boundingBoxForEventNodes(&node);
targetData.score = scoreTouchTarget(touchPoint, touchPointPadding, targetData.windowBoundingBox);
bestScore = std::max(bestScore, targetData.score);
break;

Powered by Google App Engine
This is Rietveld 408576698