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

Side by Side Diff: third_party/WebKit/Source/core/page/TouchDisambiguation.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 score *= std::max((padding - abs(distance.height())) * reciprocalPadding, 0. f); 77 score *= std::max((padding - abs(distance.height())) * reciprocalPadding, 0. f);
78 78
79 return score; 79 return score;
80 } 80 }
81 81
82 struct TouchTargetData { 82 struct TouchTargetData {
83 IntRect windowBoundingBox; 83 IntRect windowBoundingBox;
84 float score; 84 float score;
85 }; 85 };
86 86
87 void findGoodTouchTargets(const IntRect& touchBoxInRootFrame, LocalFrame* mainFr ame, Vector<IntRect>& goodTargets, WillBeHeapVector<RawPtrWillBeMember<Node>>& h ighlightNodes) 87 void findGoodTouchTargets(const IntRect& touchBoxInRootFrame, LocalFrame* mainFr ame, Vector<IntRect>& goodTargets, HeapVector<Member<Node>>& highlightNodes)
88 { 88 {
89 goodTargets.clear(); 89 goodTargets.clear();
90 90
91 int touchPointPadding = ceil(std::max(touchBoxInRootFrame.width(), touchBoxI nRootFrame.height()) * 0.5); 91 int touchPointPadding = ceil(std::max(touchBoxInRootFrame.width(), touchBoxI nRootFrame.height()) * 0.5);
92 92
93 IntPoint touchPoint = touchBoxInRootFrame.center(); 93 IntPoint touchPoint = touchBoxInRootFrame.center();
94 IntPoint contentsPoint = mainFrame->view()->rootFrameToContents(touchPoint); 94 IntPoint contentsPoint = mainFrame->view()->rootFrameToContents(touchPoint);
95 95
96 HitTestResult result = mainFrame->eventHandler().hitTestResultAtPoint(conten tsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::Lis tBased, LayoutSize(touchPointPadding, touchPointPadding)); 96 HitTestResult result = mainFrame->eventHandler().hitTestResultAtPoint(conten tsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::Lis tBased, LayoutSize(touchPointPadding, touchPointPadding));
97 const WillBeHeapListHashSet<RefPtrWillBeMember<Node>>& hitResults = result.l istBasedTestResult(); 97 const HeapListHashSet<Member<Node>>& hitResults = result.listBasedTestResult ();
98 98
99 // Blacklist nodes that are container of disambiguated nodes. 99 // Blacklist nodes that are container of disambiguated nodes.
100 // It is not uncommon to have a clickable <div> that contains other clickabl e objects. 100 // It is not uncommon to have a clickable <div> that contains other clickabl e objects.
101 // This heuristic avoids excessive disambiguation in that case. 101 // This heuristic avoids excessive disambiguation in that case.
102 WillBeHeapHashSet<RawPtrWillBeMember<Node>> blackList; 102 HeapHashSet<Member<Node>> blackList;
103 for (const auto& hitResult : hitResults) { 103 for (const auto& hitResult : hitResults) {
104 // Ignore any Nodes that can't be clicked on. 104 // Ignore any Nodes that can't be clicked on.
105 LayoutObject* layoutObject = hitResult.get()->layoutObject(); 105 LayoutObject* layoutObject = hitResult.get()->layoutObject();
106 if (!layoutObject || !hitResult.get()->willRespondToMouseClickEvents()) 106 if (!layoutObject || !hitResult.get()->willRespondToMouseClickEvents())
107 continue; 107 continue;
108 108
109 // Blacklist all of the Node's containers. 109 // Blacklist all of the Node's containers.
110 for (LayoutBlock* container = layoutObject->containingBlock(); container ; container = container->containingBlock()) { 110 for (LayoutBlock* container = layoutObject->containingBlock(); container ; container = container->containingBlock()) {
111 Node* containerNode = container->node(); 111 Node* containerNode = container->node();
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 WillBeHeapHashMap<RawPtrWillBeMember<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 = hitResult.get(); node; node = node->parentNode()) {
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) || isHTMLBody Element(*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, TouchTarget Data()).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