Title: [143783] trunk/Source/WebKit/blackberry
Revision
143783
Author
commit-qu...@webkit.org
Date
2013-02-22 13:24:22 -0800 (Fri, 22 Feb 2013)

Log Message

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

Patch by Tiancheng Jiang <tiji...@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:

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/ChangeLog (143782 => 143783)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-02-22 21:20:57 UTC (rev 143782)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-02-22 21:24:22 UTC (rev 143783)
@@ -1,3 +1,22 @@
+2013-02-22  Tiancheng Jiang  <tiji...@rim.com>
+
+        [BlackBerry]Adjust fatfinger detection rect size
+        https://bugs.webkit.org/show_bug.cgi?id=108678.
+
+        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:
+
 2013-02-22  Mike Fenton  <mifen...@rim.com>
 
         [BlackBerry] Accept key events even when composing region is active.

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.cpp (143782 => 143783)


--- trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.cpp	2013-02-22 21:20:57 UTC (rev 143782)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.cpp	2013-02-22 21:24:22 UTC (rev 143783)
@@ -66,7 +66,8 @@
 IntRect FatFingers::fingerRectForPoint(const IntPoint& point) const
 {
     unsigned topPadding, rightPadding, bottomPadding, leftPadding;
-    getPaddings(topPadding, rightPadding, bottomPadding, leftPadding);
+    IntPoint contentViewportPos = m_webPage->mapFromContentsToViewport(point);
+    getAdjustedPaddings(contentViewportPos, topPadding, rightPadding, bottomPadding, leftPadding);
 
     return HitTestResult::rectForPoint(point, topPadding, rightPadding, bottomPadding, leftPadding);
 }
@@ -151,6 +152,11 @@
     ASSERT(m_webPage);
     ASSERT(m_webPage->m_mainFrame);
 
+    // Even though we have clamped the point in libwebview to viewport, but there might be a rounding difference for viewport rect.
+    // Clamp position to viewport to ensure we are inside viewport.
+    IntRect viewportRect = m_webPage->mainFrame()->view()->visibleContentRect();
+    m_contentPos = Platform::pointClampedToRect(m_contentPos, viewportRect);
+
     m_cachedRectHitTestResults.clear();
 
     FatFingersResult result(m_contentPos);
@@ -428,7 +434,7 @@
     return false;
 }
 
-void FatFingers::getPaddings(unsigned& top, unsigned& right, unsigned& bottom, unsigned& left) const
+void FatFingers::getAdjustedPaddings(const IntPoint& contentViewportPos, unsigned& top, unsigned& right, unsigned& bottom, unsigned& left) const
 {
     static unsigned topPadding = Platform::Settings::instance()->topFatFingerPadding();
     static unsigned rightPadding = Platform::Settings::instance()->rightFatFingerPadding();
@@ -440,12 +446,21 @@
     right = rightPadding / currentScale;
     bottom = bottomPadding / currentScale;
     left = leftPadding / currentScale;
+
+    IntRect viewportRect = m_webPage->mainFrame()->view()->visibleContentRect();
+    // We clamp the event position inside the viewport. We should not expand the fat finger rect to the edge again.
+    top = std::min(unsigned(std::max(contentViewportPos.y() - 1, 0)), top);
+    left = std::min(unsigned(std::max(contentViewportPos.x() - 1, 0)), left);
+    bottom = std::min(unsigned(std::max(viewportRect.height() - contentViewportPos.y() - 1, 0)), bottom);
+    right = std::min(unsigned(std::max(viewportRect.width() - contentViewportPos.x() - 1, 0)), right);
 }
 
 void FatFingers::getNodesFromRect(Document* document, const IntPoint& contentPos, ListHashSet<RefPtr<Node> >& intersectedNodes)
 {
     unsigned topPadding, rightPadding, bottomPadding, leftPadding;
-    getPaddings(topPadding, rightPadding, bottomPadding, leftPadding);
+    IntPoint contentViewportPos = m_webPage->mapFromContentsToViewport(m_contentPos);
+    // Do not allow fat fingers detect anything not visible(ie outside of the viewport)
+    adjustPaddings(contentViewportPos, topPadding, rightPadding, bottomPadding, leftPadding);
 
     // The user functions checkForText() and findIntersectingRegions() uses the Node.wholeText() to checkFingerIntersection()
     // not the text in its shadow tree.

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.h (143782 => 143783)


--- trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.h	2013-02-22 21:20:57 UTC (rev 143782)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.h	2013-02-22 21:24:22 UTC (rev 143783)
@@ -103,7 +103,7 @@
     bool isElementClickable(WebCore::Element*) const;
 
     inline WebCore::IntRect fingerRectForPoint(const WebCore::IntPoint&) const;
-    void getPaddings(unsigned& top, unsigned& right, unsigned& bottom, unsigned& left) const;
+    void getAdjustedPaddings(const WebCore::IntPoint&, unsigned& top, unsigned& right, unsigned& bottom, unsigned& left) const;
 
     WebPagePrivate* m_webPage;
     WebCore::IntPoint m_contentPos;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to