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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 score *= max((padding - abs(distance.height())) * reciprocalPadding, 0.f); | 81 score *= max((padding - abs(distance.height())) * reciprocalPadding, 0.f); |
82 | 82 |
83 return score; | 83 return score; |
84 } | 84 } |
85 | 85 |
86 struct TouchTargetData { | 86 struct TouchTargetData { |
87 IntRect windowBoundingBox; | 87 IntRect windowBoundingBox; |
88 float score; | 88 float score; |
89 }; | 89 }; |
90 | 90 |
91 void findGoodTouchTargets(const IntRect& touchBox, Frame* mainFrame, Vector<IntR
ect>& goodTargets) | 91 void findGoodTouchTargets(const IntRect& touchBox, Frame* mainFrame, Vector<IntR
ect>& goodTargets, Vector<Node*>& highlightNodes) |
92 { | 92 { |
93 goodTargets.clear(); | 93 goodTargets.clear(); |
94 | 94 |
95 int touchPointPadding = ceil(max(touchBox.width(), touchBox.height()) * 0.5)
; | 95 int touchPointPadding = ceil(max(touchBox.width(), touchBox.height()) * 0.5)
; |
96 | 96 |
97 IntPoint touchPoint = touchBox.center(); | 97 IntPoint touchPoint = touchBox.center(); |
98 IntPoint contentsPoint = mainFrame->view()->windowToContents(touchPoint); | 98 IntPoint contentsPoint = mainFrame->view()->windowToContents(touchPoint); |
99 | 99 |
100 HitTestResult result = mainFrame->eventHandler()->hitTestResultAtPoint(conte
ntsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::Di
sallowShadowContent, IntSize(touchPointPadding, touchPointPadding)); | 100 HitTestResult result = mainFrame->eventHandler()->hitTestResultAtPoint(conte
ntsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::Di
sallowShadowContent, IntSize(touchPointPadding, touchPointPadding)); |
101 const ListHashSet<RefPtr<Node> >& hitResults = result.rectBasedTestResult(); | 101 const ListHashSet<RefPtr<Node> >& hitResults = result.rectBasedTestResult(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 137 } |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 for (HashMap<Node*, TouchTargetData>::iterator it = touchTargets.begin(); it
!= touchTargets.end(); ++it) { | 141 for (HashMap<Node*, TouchTargetData>::iterator it = touchTargets.begin(); it
!= touchTargets.end(); ++it) { |
142 // Currently the scoring function uses the overlap area with the fat poi
nt as the score. | 142 // Currently the scoring function uses the overlap area with the fat poi
nt as the score. |
143 // 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. | 143 // 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. |
144 if (it->value.score < bestScore * 0.5) | 144 if (it->value.score < bestScore * 0.5) |
145 continue; | 145 continue; |
146 goodTargets.append(it->value.windowBoundingBox); | 146 goodTargets.append(it->value.windowBoundingBox); |
| 147 highlightNodes.append(it->key); |
147 } | 148 } |
148 } | 149 } |
149 | 150 |
150 } // namespace WebCore | 151 } // namespace WebCore |
OLD | NEW |