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