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

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

Issue 19098002: Introduce isHTMLHtmlElement and toHTMLHtmlElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 5 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
« no previous file with comments | « Source/core/page/FrameView.cpp ('k') | Source/core/rendering/RenderBox.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 20 matching lines...) Expand all
31 #include "config.h" 31 #include "config.h"
32 32
33 #include "core/page/TouchDisambiguation.h" 33 #include "core/page/TouchDisambiguation.h"
34 34
35 #include <algorithm> 35 #include <algorithm>
36 #include <cmath> 36 #include <cmath>
37 #include "HTMLNames.h" 37 #include "HTMLNames.h"
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/html/HTMLHtmlElement.h"
41 #include "core/page/EventHandler.h" 42 #include "core/page/EventHandler.h"
42 #include "core/page/Frame.h" 43 #include "core/page/Frame.h"
43 #include "core/page/FrameView.h" 44 #include "core/page/FrameView.h"
44 #include "core/rendering/HitTestResult.h" 45 #include "core/rendering/HitTestResult.h"
45 #include "core/rendering/RenderBlock.h" 46 #include "core/rendering/RenderBlock.h"
46 47
47 using namespace std; 48 using namespace std;
48 49
49 namespace WebCore { 50 namespace WebCore {
50 51
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 break; 119 break;
119 } 120 }
120 } 121 }
121 122
122 HashMap<Node*, TouchTargetData> touchTargets; 123 HashMap<Node*, TouchTargetData> touchTargets;
123 float bestScore = 0; 124 float bestScore = 0;
124 for (ListHashSet<RefPtr<Node> >::const_iterator it = hitResults.begin(); it != hitResults.end(); ++it) { 125 for (ListHashSet<RefPtr<Node> >::const_iterator it = hitResults.begin(); it != hitResults.end(); ++it) {
125 for (Node* node = it->get(); node; node = node->parentNode()) { 126 for (Node* node = it->get(); node; node = node->parentNode()) {
126 if (blackList.contains(node)) 127 if (blackList.contains(node))
127 continue; 128 continue;
128 if (node->isDocumentNode() || node->hasTagName(HTMLNames::htmlTag) | | node->hasTagName(HTMLNames::bodyTag)) 129 if (node->isDocumentNode() || isHTMLHtmlElement(node) || node->hasTa gName(HTMLNames::bodyTag))
129 break; 130 break;
130 if (node->willRespondToMouseClickEvents()) { 131 if (node->willRespondToMouseClickEvents()) {
131 TouchTargetData& targetData = touchTargets.add(node, TouchTarget Data()).iterator->value; 132 TouchTargetData& targetData = touchTargets.add(node, TouchTarget Data()).iterator->value;
132 targetData.windowBoundingBox = boundingBoxForEventNodes(node); 133 targetData.windowBoundingBox = boundingBoxForEventNodes(node);
133 targetData.score = scoreTouchTarget(touchPoint, touchPointPaddin g, targetData.windowBoundingBox); 134 targetData.score = scoreTouchTarget(touchPoint, touchPointPaddin g, targetData.windowBoundingBox);
134 bestScore = max(bestScore, targetData.score); 135 bestScore = max(bestScore, targetData.score);
135 break; 136 break;
136 } 137 }
137 } 138 }
138 } 139 }
139 140
140 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) {
141 // 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.
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 // 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) 144 if (it->value.score < bestScore * 0.5)
144 continue; 145 continue;
145 goodTargets.append(it->value.windowBoundingBox); 146 goodTargets.append(it->value.windowBoundingBox);
146 } 147 }
147 } 148 }
148 149
149 } // namespace WebCore 150 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/FrameView.cpp ('k') | Source/core/rendering/RenderBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698