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

Side by Side 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-28T16:44:17 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (!containerNode) 112 if (!containerNode)
113 continue; 113 continue;
114 if (!blackList.add(containerNode).isNewEntry) 114 if (!blackList.add(containerNode).isNewEntry)
115 break; 115 break;
116 } 116 }
117 } 117 }
118 118
119 HeapHashMap<Member<Node>, TouchTargetData> touchTargets; 119 HeapHashMap<Member<Node>, TouchTargetData> touchTargets;
120 float bestScore = 0; 120 float bestScore = 0;
121 for (const auto& hitResult : hitResults) { 121 for (const auto& hitResult : hitResults) {
122 for (Node* node = hitResult.get(); node; node = node->parentNode()) { 122 for (Node& node : NodeTraversal::ancestorsOrSelfOf(hitResult.get())) {
123 if (blackList.contains(node)) 123 if (blackList.contains(&node))
124 continue; 124 continue;
125 if (node->isDocumentNode() || isHTMLHtmlElement(*node) || isHTMLBody Element(*node)) 125 if (node.isDocumentNode() || isHTMLHtmlElement(node) || isHTMLBodyEl ement(node))
126 break; 126 break;
127 if (node->willRespondToMouseClickEvents()) { 127 if (node.willRespondToMouseClickEvents()) {
128 TouchTargetData& targetData = touchTargets.add(node, TouchTarget Data()).storedValue->value; 128 TouchTargetData& targetData = touchTargets.add(&node, TouchTarge tData()).storedValue->value;
129 targetData.windowBoundingBox = boundingBoxForEventNodes(node); 129 targetData.windowBoundingBox = boundingBoxForEventNodes(&node);
130 targetData.score = scoreTouchTarget(touchPoint, touchPointPaddin g, targetData.windowBoundingBox); 130 targetData.score = scoreTouchTarget(touchPoint, touchPointPaddin g, targetData.windowBoundingBox);
131 bestScore = std::max(bestScore, targetData.score); 131 bestScore = std::max(bestScore, targetData.score);
132 break; 132 break;
133 } 133 }
134 } 134 }
135 } 135 }
136 136
137 for (const auto& touchTarget : touchTargets) { 137 for (const auto& touchTarget : touchTargets) {
138 // Currently the scoring function uses the overlap area with the fat poi nt as the score. 138 // Currently the scoring function uses the overlap area with the fat poi nt as the score.
139 // We ignore the candidates that has less than 1/2 overlap (we consider not really ambiguous enough) than the best candidate to avoid excessive popups. 139 // We ignore the candidates that has less than 1/2 overlap (we consider not really ambiguous enough) than the best candidate to avoid excessive popups.
140 if (touchTarget.value.score < bestScore * 0.5) 140 if (touchTarget.value.score < bestScore * 0.5)
141 continue; 141 continue;
142 goodTargets.append(touchTarget.value.windowBoundingBox); 142 goodTargets.append(touchTarget.value.windowBoundingBox);
143 highlightNodes.append(touchTarget.key); 143 highlightNodes.append(touchTarget.key);
144 } 144 }
145 } 145 }
146 146
147 } // namespace blink 147 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698