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

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

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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 | Annotate | Revision Log
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "core/page/FrameView.h" 44 #include "core/page/FrameView.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; 48 using namespace std;
49 49
50 namespace WebCore { 50 namespace WebCore {
51 51
52 static IntRect boundingBoxForEventNodes(Node* eventNode) 52 static IntRect boundingBoxForEventNodes(Node* eventNode)
53 { 53 {
54 if (!eventNode->document()->view()) 54 if (!eventNode->document().view())
55 return IntRect(); 55 return IntRect();
56 56
57 IntRect result; 57 IntRect result;
58 Node* node = eventNode; 58 Node* node = eventNode;
59 while (node) { 59 while (node) {
60 // Skip the whole sub-tree if the node doesn't propagate events. 60 // Skip the whole sub-tree if the node doesn't propagate events.
61 if (node != eventNode && node->willRespondToMouseClickEvents()) { 61 if (node != eventNode && node->willRespondToMouseClickEvents()) {
62 node = NodeTraversal::nextSkippingChildren(node, eventNode); 62 node = NodeTraversal::nextSkippingChildren(node, eventNode);
63 continue; 63 continue;
64 } 64 }
65 result.unite(node->pixelSnappedBoundingBox()); 65 result.unite(node->pixelSnappedBoundingBox());
66 node = NodeTraversal::next(node, eventNode); 66 node = NodeTraversal::next(node, eventNode);
67 } 67 }
68 return eventNode->document()->view()->contentsToWindow(result); 68 return eventNode->document().view()->contentsToWindow(result);
69 } 69 }
70 70
71 static float scoreTouchTarget(IntPoint touchPoint, int padding, IntRect bounding Box) 71 static float scoreTouchTarget(IntPoint touchPoint, int padding, IntRect bounding Box)
72 { 72 {
73 if (boundingBox.isEmpty()) 73 if (boundingBox.isEmpty())
74 return 0; 74 return 0;
75 75
76 float reciprocalPadding = 1.f / padding; 76 float reciprocalPadding = 1.f / padding;
77 float score = 1; 77 float score = 1;
78 78
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 } 147 }
148 } 148 }
149 149
150 } // namespace WebCore 150 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/TouchAdjustment.cpp ('k') | Source/core/page/animation/AnimationController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698