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

Side by Side Diff: Source/core/testing/Internals.cpp

Issue 338543003: Gesture event hit test refactoring and reduction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix release build Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/HitTestResult.cpp ('k') | Source/platform/PlatformGestureEvent.h » ('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 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 String Internals::rangeAsText(const Range* range, ExceptionState& exceptionState ) 1091 String Internals::rangeAsText(const Range* range, ExceptionState& exceptionState )
1092 { 1092 {
1093 if (!range) { 1093 if (!range) {
1094 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages:: argumentNullOrIncorrectType(1, "Range")); 1094 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages:: argumentNullOrIncorrectType(1, "Range"));
1095 return String(); 1095 return String();
1096 } 1096 }
1097 1097
1098 return range->text(); 1098 return range->text();
1099 } 1099 }
1100 1100
1101 // FIXME: The next four functions are very similar - combine them once
1102 // bestClickableNode/bestContextMenuNode have been combined..
1103
1101 PassRefPtrWillBeRawPtr<DOMPoint> Internals::touchPositionAdjustedToBestClickable Node(long x, long y, long width, long height, Document* document, ExceptionState & exceptionState) 1104 PassRefPtrWillBeRawPtr<DOMPoint> Internals::touchPositionAdjustedToBestClickable Node(long x, long y, long width, long height, Document* document, ExceptionState & exceptionState)
1102 { 1105 {
1103 if (!document || !document->frame()) { 1106 if (!document || !document->frame()) {
1104 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc ument's frame cannot be retrieved." : "The document provided is invalid."); 1107 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc ument's frame cannot be retrieved." : "The document provided is invalid.");
1105 return nullptr; 1108 return nullptr;
1106 } 1109 }
1107 1110
1108 document->updateLayout(); 1111 document->updateLayout();
1109 1112
1110 IntSize radius(width / 2, height / 2); 1113 IntSize radius(width / 2, height / 2);
1111 IntPoint point(x + radius.width(), y + radius.height()); 1114 IntPoint point(x + radius.width(), y + radius.height());
1112 1115
1116 EventHandler& eventHandler = document->frame()->eventHandler();
1117 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point);
1118 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe stRequest::ReadOnly | HitTestRequest::Active, radius);
1119
1113 Node* targetNode; 1120 Node* targetNode;
1114 IntPoint adjustedPoint; 1121 IntPoint adjustedPoint;
1115 1122
1116 bool foundNode = document->frame()->eventHandler().bestClickableNodeForTouch Point(point, radius, adjustedPoint, targetNode); 1123 bool foundNode = eventHandler.bestClickableNodeForHitTestResult(result, adju stedPoint, targetNode);
1117 if (foundNode) 1124 if (foundNode)
1118 return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y()); 1125 return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y());
1119 1126
1120 return nullptr; 1127 return nullptr;
1121 } 1128 }
1122 1129
1123 Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width , long height, Document* document, ExceptionState& exceptionState) 1130 Node* Internals::touchNodeAdjustedToBestClickableNode(long x, long y, long width , long height, Document* document, ExceptionState& exceptionState)
1124 { 1131 {
1125 if (!document || !document->frame()) { 1132 if (!document || !document->frame()) {
1126 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc ument's frame cannot be retrieved." : "The document provided is invalid."); 1133 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc ument's frame cannot be retrieved." : "The document provided is invalid.");
1127 return 0; 1134 return 0;
1128 } 1135 }
1129 1136
1130 document->updateLayout(); 1137 document->updateLayout();
1131 1138
1132 IntSize radius(width / 2, height / 2); 1139 IntSize radius(width / 2, height / 2);
1133 IntPoint point(x + radius.width(), y + radius.height()); 1140 IntPoint point(x + radius.width(), y + radius.height());
1134 1141
1142 EventHandler& eventHandler = document->frame()->eventHandler();
1143 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point);
1144 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe stRequest::ReadOnly | HitTestRequest::Active, radius);
1145
1135 Node* targetNode; 1146 Node* targetNode;
1136 IntPoint adjustedPoint; 1147 IntPoint adjustedPoint;
1137 document->frame()->eventHandler().bestClickableNodeForTouchPoint(point, radi us, adjustedPoint, targetNode); 1148 document->frame()->eventHandler().bestClickableNodeForHitTestResult(result, adjustedPoint, targetNode);
1138 return targetNode; 1149 return targetNode;
1139 } 1150 }
1140 1151
1141 PassRefPtrWillBeRawPtr<DOMPoint> Internals::touchPositionAdjustedToBestContextMe nuNode(long x, long y, long width, long height, Document* document, ExceptionSta te& exceptionState) 1152 PassRefPtrWillBeRawPtr<DOMPoint> Internals::touchPositionAdjustedToBestContextMe nuNode(long x, long y, long width, long height, Document* document, ExceptionSta te& exceptionState)
1142 { 1153 {
1143 if (!document || !document->frame()) { 1154 if (!document || !document->frame()) {
1144 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc ument's frame cannot be retrieved." : "The document provided is invalid."); 1155 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc ument's frame cannot be retrieved." : "The document provided is invalid.");
1145 return nullptr; 1156 return nullptr;
1146 } 1157 }
1147 1158
1148 document->updateLayout(); 1159 document->updateLayout();
1149 1160
1150 IntSize radius(width / 2, height / 2); 1161 IntSize radius(width / 2, height / 2);
1151 IntPoint point(x + radius.width(), y + radius.height()); 1162 IntPoint point(x + radius.width(), y + radius.height());
1152 1163
1164 EventHandler& eventHandler = document->frame()->eventHandler();
1165 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point);
1166 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe stRequest::ReadOnly | HitTestRequest::Active, radius);
1167
1153 Node* targetNode = 0; 1168 Node* targetNode = 0;
1154 IntPoint adjustedPoint; 1169 IntPoint adjustedPoint;
1155 1170
1156 bool foundNode = document->frame()->eventHandler().bestContextMenuNodeForTou chPoint(point, radius, adjustedPoint, targetNode); 1171 bool foundNode = eventHandler.bestContextMenuNodeForHitTestResult(result, ad justedPoint, targetNode);
1157 if (foundNode) 1172 if (foundNode)
1158 return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y()); 1173 return DOMPoint::create(adjustedPoint.x(), adjustedPoint.y());
1159 1174
1160 return DOMPoint::create(x, y); 1175 return DOMPoint::create(x, y);
1161 } 1176 }
1162 1177
1163 Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long wid th, long height, Document* document, ExceptionState& exceptionState) 1178 Node* Internals::touchNodeAdjustedToBestContextMenuNode(long x, long y, long wid th, long height, Document* document, ExceptionState& exceptionState)
1164 { 1179 {
1165 if (!document || !document->frame()) { 1180 if (!document || !document->frame()) {
1166 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc ument's frame cannot be retrieved." : "The document provided is invalid."); 1181 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc ument's frame cannot be retrieved." : "The document provided is invalid.");
1167 return 0; 1182 return 0;
1168 } 1183 }
1169 1184
1170 document->updateLayout(); 1185 document->updateLayout();
1171 1186
1172 IntSize radius(width / 2, height / 2); 1187 IntSize radius(width / 2, height / 2);
1173 IntPoint point(x + radius.width(), y + radius.height()); 1188 IntPoint point(x + radius.width(), y + radius.height());
1174 1189
1190 EventHandler& eventHandler = document->frame()->eventHandler();
1191 IntPoint hitTestPoint = document->frame()->view()->windowToContents(point);
1192 HitTestResult result = eventHandler.hitTestResultAtPoint(hitTestPoint, HitTe stRequest::ReadOnly | HitTestRequest::Active, radius);
1193
1175 Node* targetNode = 0; 1194 Node* targetNode = 0;
1176 IntPoint adjustedPoint; 1195 IntPoint adjustedPoint;
1177 document->frame()->eventHandler().bestContextMenuNodeForTouchPoint(point, ra dius, adjustedPoint, targetNode); 1196 eventHandler.bestContextMenuNodeForHitTestResult(result, adjustedPoint, targ etNode);
1178 return targetNode; 1197 return targetNode;
1179 } 1198 }
1180 1199
1181 PassRefPtrWillBeRawPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document* document, ExceptionState& excepti onState) 1200 PassRefPtrWillBeRawPtr<ClientRect> Internals::bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document* document, ExceptionState& excepti onState)
1182 { 1201 {
1183 if (!document || !document->frame()) { 1202 if (!document || !document->frame()) {
1184 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc ument's frame cannot be retrieved." : "The document provided is invalid."); 1203 exceptionState.throwDOMException(InvalidAccessError, document ? "The doc ument's frame cannot be retrieved." : "The document provided is invalid.");
1185 return nullptr; 1204 return nullptr;
1186 } 1205 }
1187 1206
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 } 2353 }
2335 networkStateNotifier().setWebConnectionTypeForTest(webtype); 2354 networkStateNotifier().setWebConnectionTypeForTest(webtype);
2336 } 2355 }
2337 2356
2338 unsigned Internals::countHitRegions(CanvasRenderingContext2D* context) 2357 unsigned Internals::countHitRegions(CanvasRenderingContext2D* context)
2339 { 2358 {
2340 return context->hitRegionsCount(); 2359 return context->hitRegionsCount();
2341 } 2360 }
2342 2361
2343 } // namespace WebCore 2362 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/HitTestResult.cpp ('k') | Source/platform/PlatformGestureEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698