Select best target for tap gesture.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2012 15:33:26 +0000 (15:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Mar 2012 15:33:26 +0000 (15:33 +0000)
commitb49009a51401630680fafc533af83aaa22f6a5d0
treeb51ead666ec3b36ee67c640b58a8d59c1897535d
parentf8d563f4fa6bf886adf0775f92ff00f80cb556f7
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: https://svn.webkit.org/repository/webkit/trunk@111185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
37 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/efl/Skipped
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/Skipped
LayoutTests/platform/win/Skipped
LayoutTests/touchadjustment/event-triggered-widgets-expected.txt [new file with mode: 0644]
LayoutTests/touchadjustment/event-triggered-widgets.html [new file with mode: 0644]
LayoutTests/touchadjustment/html-label-expected.txt [new file with mode: 0644]
LayoutTests/touchadjustment/html-label.html [new file with mode: 0644]
LayoutTests/touchadjustment/nested-touch-expected.txt [new file with mode: 0644]
LayoutTests/touchadjustment/nested-touch.html [new file with mode: 0644]
LayoutTests/touchadjustment/touch-inlines-expected.txt [new file with mode: 0644]
LayoutTests/touchadjustment/touch-inlines.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Target.pri
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/page/TouchAdjustment.cpp [new file with mode: 0644]
Source/WebCore/page/TouchAdjustment.h [new file with mode: 0644]
Source/WebCore/platform/graphics/FloatQuad.h
Source/WebCore/platform/graphics/IntPoint.h
Source/WebCore/platform/graphics/IntRect.cpp
Source/WebCore/platform/graphics/IntRect.h
Source/WebCore/platform/graphics/IntSize.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/qmake/mkspecs/features/features.prf