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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 void findGoodTouchTargets(const IntRect& touchBox, LocalFrame* mainFrame, Vector
<IntRect>& goodTargets, WillBeHeapVector<RawPtrWillBeMember<Node>>& highlightNod
es) | 89 void findGoodTouchTargets(const IntRect& touchBox, LocalFrame* mainFrame, Vector
<IntRect>& goodTargets, WillBeHeapVector<RawPtrWillBeMember<Node>>& highlightNod
es) |
90 { | 90 { |
91 goodTargets.clear(); | 91 goodTargets.clear(); |
92 | 92 |
93 int touchPointPadding = ceil(std::max(touchBox.width(), touchBox.height()) *
0.5); | 93 int touchPointPadding = ceil(std::max(touchBox.width(), touchBox.height()) *
0.5); |
94 | 94 |
95 IntPoint touchPoint = touchBox.center(); | 95 IntPoint touchPoint = touchBox.center(); |
96 IntPoint contentsPoint = mainFrame->view()->windowToContents(touchPoint); | 96 IntPoint contentsPoint = mainFrame->view()->windowToContents(touchPoint); |
97 | 97 |
98 HitTestResult result = mainFrame->eventHandler().hitTestResultAtPoint(conten
tsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active, LayoutSize(touchPoin
tPadding, touchPointPadding)); | 98 HitTestResult result = mainFrame->eventHandler().hitTestResultAtPoint(conten
tsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::Lis
tBased, LayoutSize(touchPointPadding, touchPointPadding)); |
99 const WillBeHeapListHashSet<RefPtrWillBeMember<Node>>& hitResults = result.r
ectBasedTestResult(); | 99 const WillBeHeapListHashSet<RefPtrWillBeMember<Node>>& hitResults = result.l
istBasedTestResult(); |
100 | 100 |
101 // Blacklist nodes that are container of disambiguated nodes. | 101 // Blacklist nodes that are container of disambiguated nodes. |
102 // It is not uncommon to have a clickable <div> that contains other clickabl
e objects. | 102 // It is not uncommon to have a clickable <div> that contains other clickabl
e objects. |
103 // This heuristic avoids excessive disambiguation in that case. | 103 // This heuristic avoids excessive disambiguation in that case. |
104 WillBeHeapHashSet<RawPtrWillBeMember<Node>> blackList; | 104 WillBeHeapHashSet<RawPtrWillBeMember<Node>> blackList; |
105 for (const auto& hitResult : hitResults) { | 105 for (const auto& hitResult : hitResults) { |
106 // Ignore any Nodes that can't be clicked on. | 106 // Ignore any Nodes that can't be clicked on. |
107 LayoutObject* renderer = hitResult.get()->renderer(); | 107 LayoutObject* renderer = hitResult.get()->renderer(); |
108 if (!renderer || !hitResult.get()->willRespondToMouseClickEvents()) | 108 if (!renderer || !hitResult.get()->willRespondToMouseClickEvents()) |
109 continue; | 109 continue; |
(...skipping 30 matching lines...) Expand all Loading... |
140 // Currently the scoring function uses the overlap area with the fat poi
nt as the score. | 140 // Currently the scoring function uses the overlap area with the fat poi
nt as the score. |
141 // 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. | 141 // 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 if (touchTarget.value.score < bestScore * 0.5) | 142 if (touchTarget.value.score < bestScore * 0.5) |
143 continue; | 143 continue; |
144 goodTargets.append(touchTarget.value.windowBoundingBox); | 144 goodTargets.append(touchTarget.value.windowBoundingBox); |
145 highlightNodes.append(touchTarget.key); | 145 highlightNodes.append(touchTarget.key); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 } // namespace blink | 149 } // namespace blink |
OLD | NEW |