Select best target for tap gesture.
https://bugs.webkit.org/show_bug.cgi?id=78801

Source/WebCore:

Patch by Allan Sandfeld Jensen <allan.jensen@nokia.com> on 2012-03-19
Reviewed by Kenneth Rohde Christiansen.
IntRect changes reviewed by Dave Hyatt.

The new API is available through EventHandler::bestClickableNodeForTouchPoint, but
implementation details have been placed in page/TouchAdjustment.

The default hit detection is performed by measuring the distance to the center
lines of the absolute rects of the hit nodes. Absolute rects are used instead
of bounding rects to make hit-detecting against links over line breaks. Distance
to center line is used to make it easier to hit small links next to large links.
For line-rects the distance to the center-line is a better expression of the distance
to a rectangles center than the distance to the center-point.

Tests: touchadjustment/event-triggered-widgets.html
       touchadjustment/html-label.html
       touchadjustment/nested-touch.html
       touchadjustment/touch-inlines.html

* Target.pri:
* page/EventHandler.cpp:
(WebCore::EventHandler::handleGestureTap):
(WebCore::EventHandler::bestClickableNodeForTouchPoint):
* page/EventHandler.h:
* page/TouchAdjustment.cpp: Added.
(WebCore::TouchAdjustment::QuadForHitTest::QuadForHitTest):
(WebCore::TouchAdjustment::QuadForHitTest::node):
(WebCore::TouchAdjustment::QuadForHitTest::quad):
(WebCore::TouchAdjustment::QuadForHitTest::boundingBox):
(WebCore::TouchAdjustment::nodeRespondsToTapGesture):
(WebCore::TouchAdjustment::appendAbsoluteQuadsForNodeToHitTestList):
(WebCore::TouchAdjustment::compileQuadsForHitTesting):
(WebCore::TouchAdjustment::distanceSquaredToQuadCenterLine):
(WebCore::TouchAdjustment::findNodeWithLowestMetric):
(WebCore::findBestClickableCandidate):
* page/TouchAdjustment.h: Added.
* platform/graphics/FloatQuad.h:
(WebCore::FloatQuad::center):
* platform/graphics/IntPoint.h:
(WebCore::IntPoint::distanceSquaredToPoint):
* platform/graphics/IntRect.cpp:
(WebCore::distanceToInterval):
(WebCore::IntRect::differenceToPoint):
(WebCore::IntRect::differenceFromCenterLineToPoint):
* platform/graphics/IntRect.h:
(WebCore::IntRect::distanceSquaredToPoint):
(WebCore::IntRect::distanceSquaredFromCenterLineToPoint):
* platform/graphics/IntSize.h:
(WebCore::IntSize::diagonalLengthSquared):
* testing/Internals.cpp:
(WebCore::Internals::touchPositionAdjustedToBestClickableNode):
(WebCore::Internals::touchNodeAdjustedToBestClickableNode):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit2:

Patch by Allan Sandfeld Jensen <allan.jensen@nokia.com> on 2012-03-19
Reviewed by Kenneth Rohde Christiansen.

Send radius to handlePotentialSingleTapEvent so it can do the same hit
detection the tap gesture later does.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::handlePotentialActivation):
* UIProcess/WebPageProxy.h:
* UIProcess/qt/QtWebPageEventHandler.cpp:
(QtWebPageEventHandler::handlePotentialSingleTapEvent):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::highlightPotentialActivation):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

Patch by Allan Sandfeld Jensen <allan.jensen@nokia.com> on 2012-03-19
Reviewed by Kenneth Rohde Christiansen.

Add TOUCH_ADJUSTMENT to enabled features.

* qmake/mkspecs/features/features.prf:

LayoutTests:

Patch by Allan Sandfeld Jensen <allan.jensen@nokia.com> on 2012-03-19
Reviewed by Kenneth Rohde Christiansen.

Test of touch adjustments. Tests several both normal and tricky cases.

* platform/chromium/test_expectations.txt:
* platform/efl/Skipped:
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/win/Skipped:
* touchadjustment/event-triggered-widgets-expected.txt: Added.
* touchadjustment/event-triggered-widgets.html: Added.
* touchadjustment/html-label-expected.txt: Added.
* touchadjustment/html-label.html: Added.
* touchadjustment/nested-touch-expected.txt: Added.
* touchadjustment/nested-touch.html: Added.
* touchadjustment/touch-inlines-expected.txt: Added.
* touchadjustment/touch-inlines.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@111185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/touchadjustment/html-label-expected.txt b/LayoutTests/touchadjustment/html-label-expected.txt
new file mode 100644
index 0000000..f969fdb
--- /dev/null
+++ b/LayoutTests/touchadjustment/html-label-expected.txt
@@ -0,0 +1,22 @@
+Do not click here
+Click here, but not here. 
+
+
+
+Tests if labels are treated as clickable if the input they control is.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing small direct hits.
+PASS adjustedNode.id is "mylink"
+PASS adjustedNode.id is "mylabel"
+PASS adjustedNode.id is "myinput"
+Testing indirect hits.
+PASS adjustedNode.id is "mylink"
+PASS adjustedNode.id is "mylabel"
+PASS adjustedNode.id is "myinput"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+