Changeset 143783 in webkit


Ignore:
Timestamp:
Feb 22, 2013 1:24:22 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry]Adjust fatfinger detection rect size
https://bugs.webkit.org/show_bug.cgi?id=108678.

Patch by Tiancheng Jiang <tijiang@rim.com> on 2013-02-22
Reviewed by Antonio Gomes.

Changing HitTestRequest::IgnoreClipping does not solve the problem that
FatFinger rect detect the element out of the viewport. We have to clip
the fatfinger rect according to the current viewport size to avoid picking
the element out of the viewport.

  • WebKitSupport/FatFingers.cpp:

(BlackBerry::WebKit::FatFingers::fingerRectForPoint):
(BlackBerry::WebKit::FatFingers::findBestPoint):
(BlackBerry::WebKit::FatFingers::getAdjustedPaddings):
(BlackBerry::WebKit::FatFingers::getNodesFromRect):

  • WebKitSupport/FatFingers.h:
Location:
trunk/Source/WebKit/blackberry
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/ChangeLog

    r143767 r143783  
     12013-02-22  Tiancheng Jiang  <tijiang@rim.com>
     2
     3        [BlackBerry]Adjust fatfinger detection rect size
     4        https://bugs.webkit.org/show_bug.cgi?id=108678.
     5
     6        Reviewed by Antonio Gomes.
     7
     8        Changing HitTestRequest::IgnoreClipping does not solve the problem that
     9        FatFinger rect detect the element out of the viewport. We have to clip
     10        the fatfinger rect according to the current viewport size to avoid picking
     11        the element out of the viewport.
     12
     13        * WebKitSupport/FatFingers.cpp:
     14        (BlackBerry::WebKit::FatFingers::fingerRectForPoint):
     15        (BlackBerry::WebKit::FatFingers::findBestPoint):
     16        (BlackBerry::WebKit::FatFingers::getAdjustedPaddings):
     17        (BlackBerry::WebKit::FatFingers::getNodesFromRect):
     18        * WebKitSupport/FatFingers.h:
     19
    1202013-02-22  Mike Fenton  <mifenton@rim.com>
    221
  • trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.cpp

    r141797 r143783  
    6767{
    6868    unsigned topPadding, rightPadding, bottomPadding, leftPadding;
    69     getPaddings(topPadding, rightPadding, bottomPadding, leftPadding);
     69    IntPoint contentViewportPos = m_webPage->mapFromContentsToViewport(point);
     70    getAdjustedPaddings(contentViewportPos, topPadding, rightPadding, bottomPadding, leftPadding);
    7071
    7172    return HitTestResult::rectForPoint(point, topPadding, rightPadding, bottomPadding, leftPadding);
     
    151152    ASSERT(m_webPage);
    152153    ASSERT(m_webPage->m_mainFrame);
     154
     155    // Even though we have clamped the point in libwebview to viewport, but there might be a rounding difference for viewport rect.
     156    // Clamp position to viewport to ensure we are inside viewport.
     157    IntRect viewportRect = m_webPage->mainFrame()->view()->visibleContentRect();
     158    m_contentPos = Platform::pointClampedToRect(m_contentPos, viewportRect);
    153159
    154160    m_cachedRectHitTestResults.clear();
     
    429435}
    430436
    431 void FatFingers::getPaddings(unsigned& top, unsigned& right, unsigned& bottom, unsigned& left) const
     437void FatFingers::getAdjustedPaddings(const IntPoint& contentViewportPos, unsigned& top, unsigned& right, unsigned& bottom, unsigned& left) const
    432438{
    433439    static unsigned topPadding = Platform::Settings::instance()->topFatFingerPadding();
     
    441447    bottom = bottomPadding / currentScale;
    442448    left = leftPadding / currentScale;
     449
     450    IntRect viewportRect = m_webPage->mainFrame()->view()->visibleContentRect();
     451    // We clamp the event position inside the viewport. We should not expand the fat finger rect to the edge again.
     452    top = std::min(unsigned(std::max(contentViewportPos.y() - 1, 0)), top);
     453    left = std::min(unsigned(std::max(contentViewportPos.x() - 1, 0)), left);
     454    bottom = std::min(unsigned(std::max(viewportRect.height() - contentViewportPos.y() - 1, 0)), bottom);
     455    right = std::min(unsigned(std::max(viewportRect.width() - contentViewportPos.x() - 1, 0)), right);
    443456}
    444457
     
    446459{
    447460    unsigned topPadding, rightPadding, bottomPadding, leftPadding;
    448     getPaddings(topPadding, rightPadding, bottomPadding, leftPadding);
     461    IntPoint contentViewportPos = m_webPage->mapFromContentsToViewport(m_contentPos);
     462    // Do not allow fat fingers detect anything not visible(ie outside of the viewport)
     463    adjustPaddings(contentViewportPos, topPadding, rightPadding, bottomPadding, leftPadding);
    449464
    450465    // The user functions checkForText() and findIntersectingRegions() uses the Node.wholeText() to checkFingerIntersection()
  • trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.h

    r140541 r143783  
    104104
    105105    inline WebCore::IntRect fingerRectForPoint(const WebCore::IntPoint&) const;
    106     void getPaddings(unsigned& top, unsigned& right, unsigned& bottom, unsigned& left) const;
     106    void getAdjustedPaddings(const WebCore::IntPoint&, unsigned& top, unsigned& right, unsigned& bottom, unsigned& left) const;
    107107
    108108    WebPagePrivate* m_webPage;
Note: See TracChangeset for help on using the changeset viewer.