Changeset 128757 in webkit
- Timestamp:
- Sep 17, 2012 8:02:41 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r128753 r128757 1 2012-09-17 Allan Sandfeld Jensen <allan.jensen@nokia.com> 2 3 [TouchAdjustment] Adjusted point outside bounds for non-rectilinear targets 4 https://bugs.webkit.org/show_bug.cgi?id=96098 5 6 Reviewed by Antonio Gomes. 7 8 Expands the test of rotated nodes to also perform checks of the validity of the adjusted points. 9 10 * touchadjustment/resources/touchadjustment.js: 11 (adjustTouchPoint): 12 * touchadjustment/rotated-node-expected.txt: 13 * touchadjustment/rotated-node.html: 14 1 15 2012-09-17 Christophe Dumez <christophe.dumez@intel.com> 2 16 -
trunk/LayoutTests/touchadjustment/resources/touchadjustment.js
r126284 r128757 65 65 } 66 66 67 68 67 function testTouchPoint(touchpoint, targetNode, allowTextNodes) 69 68 { … … 80 79 adjustedNode = adjustedNode.parentNode; 81 80 shouldBeNode(adjustedNode, targetNode); 81 } 82 83 function adjustTouchPoint(touchpoint) 84 { 85 var adjustedPoint = internals.touchPositionAdjustedToBestClickableNode(touchpoint.left, touchpoint.top, touchpoint.width, touchpoint.height, document); 86 return adjustedPoint; 82 87 } 83 88 -
trunk/LayoutTests/touchadjustment/rotated-node-expected.txt
r124351 r128757 21 21 PASS adjusted node was DIV#container. 22 22 PASS adjusted node was DIV#container. 23 24 Adjusted point within bounds 25 PASS adjusted point was within (0,-20)x(40,40) 26 PASS adjusted point was within (40,40)x(40,40) 27 PASS adjusted point was within (-40,40)x(80,40) 28 PASS adjusted point was within (50,-20)x(40,80) 23 29 PASS successfullyParsed is true 24 30 -
trunk/LayoutTests/touchadjustment/rotated-node.html
r124351 r128757 47 47 { 48 48 debug('Direct Touches'); 49 49 50 50 testTouchPoint(touchPoint(30, 30, 20), e.rotated); 51 51 testTouchPoint(touchPoint(20, 30, 20), e.rotated); … … 76 76 } 77 77 78 function testAdjustedPoints() 79 { 80 debug('\nAdjusted point within bounds'); 81 var adjustedPoint = adjustTouchPoint(touchPoint(20, 0, 20)) 82 shouldBeWithin(adjustedPoint, touchPoint(20, 0, 20)); 83 84 adjustedPoint = adjustTouchPoint(touchPoint(60, 60, 20)) 85 shouldBeWithin(adjustedPoint, touchPoint(60, 60, 20)); 86 87 adjustedPoint = adjustTouchPoint(touchPoint(0, 60, 40, 20)) 88 shouldBeWithin(adjustedPoint, touchPoint(0, 60, 40, 20)); 89 90 adjustedPoint = adjustTouchPoint(touchPoint(70, 20, 20, 40)) 91 shouldBeWithin(adjustedPoint, touchPoint(70, 20, 20, 40)); 92 } 93 78 94 function runTests() 79 95 { … … 83 99 testDirectTouches(); 84 100 testAdjustedTouches(); 101 testAdjustedPoints() 85 102 e.container.style.display = 'none'; 86 103 } -
trunk/Source/WebCore/ChangeLog
r128754 r128757 1 2012-09-17 Allan Sandfeld Jensen <allan.jensen@nokia.com> 2 3 [TouchAdjustment] Adjusted point outside bounds for non-rectilinear targets 4 https://bugs.webkit.org/show_bug.cgi?id=96098 5 6 Reviewed by Antonio Gomes. 7 8 Simplifies how snapTo tries to restrict the adjustment to the touch-area, and 9 at the same fix it to give better guarantees. 10 11 Test: touchadjustment/rotated-node.html 12 13 * page/TouchAdjustment.cpp: 14 (WebCore::TouchAdjustment::snapTo): 15 1 16 2012-09-17 Yury Semikhatsky <yurys@chromium.org> 2 17 -
trunk/Source/WebCore/page/TouchAdjustment.cpp
r128222 r128757 358 358 } 359 359 360 // Adjusts 'point' to the nearest point inside rect, and leaves it unchanged if already inside. 361 void adjustPointToRect(FloatPoint& point, const FloatRect& rect) 362 { 363 if (point.x() < rect.x()) 364 point.setX(rect.x()); 365 else if (point.x() > rect.maxX()) 366 point.setX(rect.maxX()); 367 368 if (point.y() < rect.y()) 369 point.setY(rect.y()); 370 else if (point.y() > rect.maxY()) 371 point.setY(rect.maxY()); 372 } 373 360 374 bool snapTo(const SubtargetGeometry& geom, const IntPoint& touchPoint, const IntRect& touchArea, IntPoint& adjustedPoint) 361 375 { … … 379 393 } 380 394 381 // Non-rectilinear element. 395 // The following code tries to adjust the point to place inside a both the touchArea and the non-rectilinear quad. 396 // FIXME: This will return the point inside the touch area that is the closest to the quad center, but does not 397 // guarantee that the point will be inside the quad. Corner-cases exist where the quad will intersect but this 398 // will fail to adjust the point to somewhere in the intersection. 399 382 400 // Convert quad from content to window coordinates. 383 401 FloatPoint p1 = contentsToWindow(view, quad.p1()); … … 393 411 394 412 // Pull point towards the center of the element. 395 float cx = 0.25 * (p1.x() + p2.x() + p3.x() + p4.x()); 396 float cy = 0.25 * (p1.y() + p2.y() + p3.y() + p4.y()); 397 FloatPoint center = FloatPoint(cx, cy); 398 399 FloatSize pullDirection = center - touchPoint; 400 float distanceToCenter = pullDirection.diagonalLength(); 401 402 // Use distance from center to corner of touch area to limit adjustment distance. 403 float dx = 0.5f * touchArea.width(); 404 float dy = 0.5f * touchArea.height(); 405 float touchRadius = sqrt(dx * dx + dy * dy); 406 407 float scaleFactor = touchRadius / distanceToCenter; 408 if (scaleFactor > 1) 409 scaleFactor = 1; 410 pullDirection.scale(scaleFactor); 411 412 int x = static_cast<int>(touchPoint.x() + pullDirection.width()); 413 int y = static_cast<int>(touchPoint.y() + pullDirection.height()); 414 IntPoint point(x, y); 415 416 if (quad.containsPoint(point)) { 417 adjustedPoint = point; 418 return true; 419 } 420 return false; 413 FloatPoint center = quad.center(); 414 415 adjustPointToRect(center, touchArea); 416 adjustedPoint = roundedIntPoint(center); 417 418 return quad.containsPoint(adjustedPoint); 421 419 } 422 420
Note: See TracChangeset
for help on using the changeset viewer.