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

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

Issue 329183002: Removing "using" declarations that import names in the C++ Standard library. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed Trybot Errors Created 6 years, 6 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 27 matching lines...) Expand all
38 #include "core/dom/Document.h" 38 #include "core/dom/Document.h"
39 #include "core/dom/Element.h" 39 #include "core/dom/Element.h"
40 #include "core/dom/NodeTraversal.h" 40 #include "core/dom/NodeTraversal.h"
41 #include "core/frame/FrameView.h" 41 #include "core/frame/FrameView.h"
42 #include "core/frame/LocalFrame.h" 42 #include "core/frame/LocalFrame.h"
43 #include "core/html/HTMLHtmlElement.h" 43 #include "core/html/HTMLHtmlElement.h"
44 #include "core/page/EventHandler.h" 44 #include "core/page/EventHandler.h"
45 #include "core/rendering/HitTestResult.h" 45 #include "core/rendering/HitTestResult.h"
46 #include "core/rendering/RenderBlock.h" 46 #include "core/rendering/RenderBlock.h"
47 47
48 using namespace std;
49
50 namespace WebCore { 48 namespace WebCore {
51 49
52 static IntRect boundingBoxForEventNodes(Node* eventNode) 50 static IntRect boundingBoxForEventNodes(Node* eventNode)
53 { 51 {
54 if (!eventNode->document().view()) 52 if (!eventNode->document().view())
55 return IntRect(); 53 return IntRect();
56 54
57 IntRect result; 55 IntRect result;
58 Node* node = eventNode; 56 Node* node = eventNode;
59 while (node) { 57 while (node) {
(...skipping 10 matching lines...) Expand all
70 68
71 static float scoreTouchTarget(IntPoint touchPoint, int padding, IntRect bounding Box) 69 static float scoreTouchTarget(IntPoint touchPoint, int padding, IntRect bounding Box)
72 { 70 {
73 if (boundingBox.isEmpty()) 71 if (boundingBox.isEmpty())
74 return 0; 72 return 0;
75 73
76 float reciprocalPadding = 1.f / padding; 74 float reciprocalPadding = 1.f / padding;
77 float score = 1; 75 float score = 1;
78 76
79 IntSize distance = boundingBox.differenceToPoint(touchPoint); 77 IntSize distance = boundingBox.differenceToPoint(touchPoint);
80 score *= max((padding - abs(distance.width())) * reciprocalPadding, 0.f); 78 score *= std::max((padding - std::abs(distance.width())) * reciprocalPadding , 0.f);
81 score *= max((padding - abs(distance.height())) * reciprocalPadding, 0.f); 79 score *= std::max((padding - std::abs(distance.height())) * reciprocalPaddin g, 0.f);
82 80
83 return score; 81 return score;
84 } 82 }
85 83
86 struct TouchTargetData { 84 struct TouchTargetData {
87 IntRect windowBoundingBox; 85 IntRect windowBoundingBox;
88 float score; 86 float score;
89 }; 87 };
90 88
91 void findGoodTouchTargets(const IntRect& touchBox, LocalFrame* mainFrame, Vector <IntRect>& goodTargets, WillBeHeapVector<RawPtrWillBeMember<Node> >& highlightNo des) 89 void findGoodTouchTargets(const IntRect& touchBox, LocalFrame* mainFrame, Vector <IntRect>& goodTargets, WillBeHeapVector<RawPtrWillBeMember<Node> >& highlightNo des)
92 { 90 {
93 goodTargets.clear(); 91 goodTargets.clear();
94 92
95 int touchPointPadding = ceil(max(touchBox.width(), touchBox.height()) * 0.5) ; 93 int touchPointPadding = ceil(std::max(touchBox.width(), touchBox.height()) * 0.5);
96 94
97 IntPoint touchPoint = touchBox.center(); 95 IntPoint touchPoint = touchBox.center();
98 IntPoint contentsPoint = mainFrame->view()->windowToContents(touchPoint); 96 IntPoint contentsPoint = mainFrame->view()->windowToContents(touchPoint);
99 97
100 HitTestResult result = mainFrame->eventHandler().hitTestResultAtPoint(conten tsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::Con fusingAndOftenMisusedDisallowShadowContent, IntSize(touchPointPadding, touchPoin tPadding)); 98 HitTestResult result = mainFrame->eventHandler().hitTestResultAtPoint(conten tsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::Con fusingAndOftenMisusedDisallowShadowContent, IntSize(touchPointPadding, touchPoin tPadding));
101 const WillBeHeapListHashSet<RefPtrWillBeMember<Node> >& hitResults = result. rectBasedTestResult(); 99 const WillBeHeapListHashSet<RefPtrWillBeMember<Node> >& hitResults = result. rectBasedTestResult();
102 100
103 // Blacklist nodes that are container of disambiguated nodes. 101 // Blacklist nodes that are container of disambiguated nodes.
104 // 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.
105 // This heuristic avoids excessive disambiguation in that case. 103 // This heuristic avoids excessive disambiguation in that case.
(...skipping 19 matching lines...) Expand all
125 for (WillBeHeapListHashSet<RefPtrWillBeMember<Node> >::const_iterator it = h itResults.begin(); it != hitResults.end(); ++it) { 123 for (WillBeHeapListHashSet<RefPtrWillBeMember<Node> >::const_iterator it = h itResults.begin(); it != hitResults.end(); ++it) {
126 for (Node* node = it->get(); node; node = node->parentNode()) { 124 for (Node* node = it->get(); node; node = node->parentNode()) {
127 if (blackList.contains(node)) 125 if (blackList.contains(node))
128 continue; 126 continue;
129 if (node->isDocumentNode() || isHTMLHtmlElement(*node) || isHTMLBody Element(*node)) 127 if (node->isDocumentNode() || isHTMLHtmlElement(*node) || isHTMLBody Element(*node))
130 break; 128 break;
131 if (node->willRespondToMouseClickEvents()) { 129 if (node->willRespondToMouseClickEvents()) {
132 TouchTargetData& targetData = touchTargets.add(node, TouchTarget Data()).storedValue->value; 130 TouchTargetData& targetData = touchTargets.add(node, TouchTarget Data()).storedValue->value;
133 targetData.windowBoundingBox = boundingBoxForEventNodes(node); 131 targetData.windowBoundingBox = boundingBoxForEventNodes(node);
134 targetData.score = scoreTouchTarget(touchPoint, touchPointPaddin g, targetData.windowBoundingBox); 132 targetData.score = scoreTouchTarget(touchPoint, touchPointPaddin g, targetData.windowBoundingBox);
135 bestScore = max(bestScore, targetData.score); 133 bestScore = std::max(bestScore, targetData.score);
136 break; 134 break;
137 } 135 }
138 } 136 }
139 } 137 }
140 138
141 for (WillBeHeapHashMap<RawPtrWillBeMember<Node>, TouchTargetData>::iterator it = touchTargets.begin(); it != touchTargets.end(); ++it) { 139 for (WillBeHeapHashMap<RawPtrWillBeMember<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. 140 // 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. 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.
144 if (it->value.score < bestScore * 0.5) 142 if (it->value.score < bestScore * 0.5)
145 continue; 143 continue;
146 goodTargets.append(it->value.windowBoundingBox); 144 goodTargets.append(it->value.windowBoundingBox);
147 highlightNodes.append(it->key); 145 highlightNodes.append(it->key);
148 } 146 }
149 } 147 }
150 148
151 } // namespace WebCore 149 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/ScopedPageLoadDeferrer.cpp ('k') | Source/core/svg/animation/SMILTimeContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698