OLD | NEW |
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 touch_targets.insert(&node, TouchTargetData()).stored_value->value; | 145 touch_targets.insert(&node, TouchTargetData()).stored_value->value; |
146 target_data.window_bounding_box = BoundingBoxForEventNodes(&node); | 146 target_data.window_bounding_box = BoundingBoxForEventNodes(&node); |
147 target_data.score = ScoreTouchTarget(touch_point, touch_point_padding, | 147 target_data.score = ScoreTouchTarget(touch_point, touch_point_padding, |
148 target_data.window_bounding_box); | 148 target_data.window_bounding_box); |
149 best_score = std::max(best_score, target_data.score); | 149 best_score = std::max(best_score, target_data.score); |
150 break; | 150 break; |
151 } | 151 } |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
| 155 // The scoring function uses the overlap area with the fat point as the score. |
| 156 // We ignore the candidates that have less than this (empirically tuned) |
| 157 // fraction of overlap than the best candidate to avoid excessive popups. |
| 158 // |
| 159 // If this value were 1, then the disambiguation feature would only be seen |
| 160 // when two nodes have precisely the same overlap with the touch radius. If |
| 161 // it were 0, then any miniscule overlap with the edge of another node would |
| 162 // trigger it. |
| 163 const float kRelativeAmbiguityThreshold = 0.75f; |
| 164 |
155 for (const auto& touch_target : touch_targets) { | 165 for (const auto& touch_target : touch_targets) { |
156 // Currently the scoring function uses the overlap area with the fat point | 166 if (touch_target.value.score < best_score * kRelativeAmbiguityThreshold) |
157 // as the score. We ignore the candidates that has less than 1/2 overlap | |
158 // (we consider not really ambiguous enough) than the best candidate to | |
159 // avoid excessive popups. | |
160 if (touch_target.value.score < best_score * 0.5) | |
161 continue; | 167 continue; |
162 good_targets.push_back(touch_target.value.window_bounding_box); | 168 good_targets.push_back(touch_target.value.window_bounding_box); |
163 highlight_nodes.push_back(touch_target.key); | 169 highlight_nodes.push_back(touch_target.key); |
164 } | 170 } |
165 } | 171 } |
166 | 172 |
167 } // namespace blink | 173 } // namespace blink |
OLD | NEW |