Make Document::nodesFromRect more flexible
authorAdemar de Souza Reis Jr <ademar.reis@openbossa.org>
Thu, 11 Nov 2010 19:48:22 +0000 (16:48 -0300)
committerAdemar de Souza Reis Jr <ademar.reis@openbossa.org>
Thu, 11 Nov 2010 20:41:21 +0000 (17:41 -0300)
commit848c9ed7159870e76bca25b0e2d8926ced12e0f8
tree2dc527dba3c489c0a74e57e4388d959371e11db4
parentc49afb42cbd1bdbd07d9dd99ba822d059a56a43a
Make Document::nodesFromRect more flexible
https://bugs.webkit.org/show_bug.cgi?id=46336

Patch by Antonio Gomes <agomes@rim.com> on 2010-09-23
Reviewed by Kenneth Christiansen.

The patch changes the API for the Document::nodesFromRect() method as follows:

from
- RefPtf<NodeList> nodesFromRect(int x, int y, unsigned horizontalPadding, unsigned verticalPadding, bool ignoreClipping)

to
- RefPtf<NodeList> nodesFromRect(int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding,
                                 unsigned leftPadding, bool ignoreClipping)

Previously the method was receiving as parameter horizontal and vertical padding values.
In practice, the horizontal padding was being used to expand a given center point in both
right and left directions, while vertical padding was expanding it to the top and bottom directions.

Although this design makes it possible to improve the touch experience on mobile devices
(Document::nodesFromRect exposes the rect based hit testing system), empirical experiments
showed that, specially in capacitive touch screens, users tend to tap below elements. So
for even more accurate results (which means here the possibility of pleasant tapping experience),
it makes sense to use a region that is offset more above the touch point, favoring elements
above the touch point.

The patch basically implements that, increasing the API flexible and power by making it possible
to specify different padding values for each direction in a given orientation.

Changes were made accordingly to the HitTestResult, RenderLayer, RenderImage and RenderLineBoxList
classes.

WebCore:

* WebCore.exp.in:
* dom/Document.cpp:
(WebCore::Document::nodesFromRect):
* dom/Document.h:
* page/EventHandler.cpp:
(WebCore::EventHandler::hitTestResultAtPoint): For simplicity, I did not change the signature
    but the way the padding value passed in as parameter is being used to construct a HitTestResult.
* rendering/HitTestResult.cpp: Changed the rect-based bits from using IntSize (padding) to separated paddings
    for each direction.
(WebCore::HitTestResult::HitTestResult): Ditto.
(WebCore::HitTestResult::operator=): Ditto.
(WebCore::HitTestResult::rectFromPoint): Ditton.
* rendering/HitTestResult.h:
(WebCore::HitTestResult::topPadding): getter for the top padding.
(WebCore::HitTestResult::rightPadding): getter for the right padding.
(WebCore::HitTestResult::bottomPadding): getter for the bottom padding.
(WebCore::HitTestResult::leftPadding): getter for the left padding.
(WebCore::HitTestResult::rectFromPoint): Added a static method that given a center point and padding values for
    each direction, returns the rect that is going to be used in WebCore's hit testing processing.
* rendering/RenderImage.cpp: Changed the rect-based bits from using IntSize (padding) to separated paddings for each direction.
(WebCore::RenderImage::nodeAtPoint): Ditto.
* rendering/RenderLayer.cpp: Ditto.
(WebCore::RenderLayer::hitTestLayer): Ditto.
(WebCore::RenderLayer::hitTestList): Ditto.
* rendering/RenderLineBoxList.cpp: Ditto.
(WebCore::RenderLineBoxList::hitTest): Ditto.

LayoutTests:

* fast/dom/nodesFromRect-basic-expected.txt:
* fast/dom/nodesFromRect-basic.html:
* fast/dom/resources/nodesFromRect.js:
(check):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68475 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:

WebCore/WebCore.exp.in
22 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/nodesFromRect-basic-expected.txt
LayoutTests/fast/dom/nodesFromRect-basic.html
LayoutTests/fast/dom/resources/nodesFromRect.js
WebCore/ChangeLog
WebCore/WebCore.exp.in
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/page/EventHandler.cpp
WebCore/rendering/HitTestResult.cpp
WebCore/rendering/HitTestResult.h
WebCore/rendering/RenderImage.cpp
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderLineBoxList.cpp
WebKit/mac/WebView/WebView.mm
WebKit/mac/WebView/WebViewPrivate.h
WebKitTools/DumpRenderTree/LayoutTestController.cpp
WebKitTools/DumpRenderTree/LayoutTestController.h
WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp