[Qt] Entire page highlighted on panning.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Apr 2012 15:52:11 +0000 (15:52 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Apr 2012 15:52:11 +0000 (15:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83158

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

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::highlightPotentialActivation):

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 9e86315..d51a28b 100644 (file)
@@ -1,3 +1,13 @@
+2012-04-04  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
+
+        [Qt] Entire page highlighted on panning.
+        https://bugs.webkit.org/show_bug.cgi?id=83158
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::highlightPotentialActivation):
+
 2012-04-04  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
 
         [Qt][WK2] QtWebKit2 should support Page Visibility API
index 9c37347..ca37426 100644 (file)
@@ -1455,19 +1455,25 @@ void WebPage::highlightPotentialActivation(const IntPoint& point, const IntSize&
     IntPoint adjustedPoint;
 
     if (point != IntPoint::zero()) {
+        Node* adjustedNode = 0;
 #if ENABLE(TOUCH_ADJUSTMENT)
-        mainframe->eventHandler()->bestClickableNodeForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), adjustedPoint, activationNode);
+        mainframe->eventHandler()->bestClickableNodeForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), adjustedPoint, adjustedNode);
 #else
         HitTestResult result = mainframe->eventHandler()->hitTestResultAtPoint(mainframe->view()->windowToContents(point), /*allowShadowContent*/ false, /*ignoreClipping*/ true);
-        activationNode = result.innerNode();
-#endif
-        if (activationNode && !activationNode->isFocusable()) {
-            for (Node* node = activationNode; node; node = node->parentOrHostNode()) {
-                if (node->isFocusable()) {
-                    activationNode = node;
-                    break;
-                }
+        adjustedNode = result.innerNode();
+#endif
+        // Find the node to highlight. This is not the same as the node responding the tap gesture, because many
+        // pages has a global click handler and we do not want to highlight the body.
+        // Instead find the enclosing link or focusable element, or the last enclosing inline element.
+        for (Node* node = adjustedNode; node; node = node->parentOrHostNode()) {
+            if (node->isMouseFocusable() || node->isLink()) {
+                activationNode = node;
+                break;
             }
+            if (node->renderer() && node->renderer()->isInline())
+                activationNode = node;
+            else if (activationNode)
+                break;
         }
     }