Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(753)

Unified Diff: Source/web/WebViewImpl.cpp

Issue 402603005: Disable touch highlight when the touched node has no hand-cursor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added another tests, handled image maps inside or outside of anchors. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/compositing/gestures/gesture-tapHighlight-nested-cursor3-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 662d48622052856ccd32e60a860c8120ce5359f1..d66b8f5d2cf5540d5018ecd0b7a23ddfb484980f 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -1168,14 +1168,14 @@ void WebViewImpl::computeScaleAndScrollForBlockRect(const WebPoint& hitPoint, co
scroll = clampOffsetAtScale(scroll, scale);
}
-static bool invokesHandCursor(Node* node, LocalFrame* frame)
+static bool showsHandCursor(Node* node, LocalFrame* frame, bool isOverLink)
{
if (!node || !node->renderer())
return false;
ECursor cursor = node->renderer()->style()->cursor();
return cursor == CURSOR_POINTER
- || (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, node->isLink()));
+ || (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, isOverLink));
}
Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
@@ -1185,29 +1185,54 @@ Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
if (!m_page || !m_page->mainFrame())
return 0;
- Node* bestTouchNode = 0;
-
// FIXME: Rely on earlier hit test instead of hit testing again.
- GestureEventWithHitTestResults targetedEvent = m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(tapEvent, true);
- bestTouchNode = targetedEvent.hitTestResult().targetNode();
-
- // We might hit something like an image map that has no renderer on it
- // Walk up the tree until we have a node with an attached renderer
- while (bestTouchNode && !bestTouchNode->renderer())
- bestTouchNode = bestTouchNode->parentNode();
+ GestureEventWithHitTestResults targetedEvent =
+ m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(tapEvent, true);
+ Node* bestTouchNode = targetedEvent.hitTestResult().targetNode();
+ bool tapIsOverLink = targetedEvent.hitTestResult().isOverLink();
- // Check if we're in the subtree of a node with a hand cursor
- // this is the heuristic we use to determine if we show a highlight on tap
- while (bestTouchNode && !invokesHandCursor(bestTouchNode, m_page->deprecatedLocalMainFrame()))
- bestTouchNode = bestTouchNode->parentNode();
+ // Walk up the tree until we have an element node with an attached renderer
+ while (bestTouchNode && (!bestTouchNode->isElementNode() || !bestTouchNode->renderer()))
+ bestTouchNode = NodeRenderingTraversal::parent(bestTouchNode);
- if (!bestTouchNode)
+ // We show a highlight on tap only when the current node shows a hand cursor
+ if (!showsHandCursor(bestTouchNode, m_page->deprecatedLocalMainFrame(), tapIsOverLink))
return 0;
- // We should pick the largest enclosing node with hand cursor set.
- while (bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), toLocalFrame(m_page->mainFrame())))
- bestTouchNode = bestTouchNode->parentNode();
+ // Find the largest enclosing node with a hand cursor set
+ Node* largestHandCursorNode = bestTouchNode;
+ Node* currentNode;
+ bool currentIsOverLink = tapIsOverLink;
+ while ((currentNode = NodeRenderingTraversal::parent(largestHandCursorNode))) {
Rick Byers 2014/07/31 20:15:10 d'oh - looks like my suggestion to remove the '!=
mustaq 2014/07/31 21:04:48 Yeah, the msvc failures plus the style requirement
+ if (largestHandCursorNode->isLink() && !currentNode->isLink())
+ currentIsOverLink = false;
+
+ if (!showsHandCursor(currentNode, toLocalFrame(m_page->mainFrame()), currentIsOverLink))
+ break;
Rick Byers 2014/07/31 20:15:10 nit: rather than break and test below, you can sim
mustaq 2014/07/31 21:04:48 Done, thanks.
+
+ largestHandCursorNode = currentNode;
+ }
+
+ if (currentNode)
+ return largestHandCursorNode;
+
+ // Otherwise, bestTouchNode is an image map w/o an enclosing anchor tag.
Rick Byers 2014/07/31 20:15:10 Ah, interesting. Doing another pass like this see
mustaq 2014/07/31 21:04:48 HitTestResult::isOverLink() returns true for both
+ largestHandCursorNode = bestTouchNode;
+ currentIsOverLink = tapIsOverLink;
+ while ((currentNode = NodeRenderingTraversal::parent(largestHandCursorNode))) {
+ if (isHTMLMapElement(largestHandCursorNode) && !isHTMLMapElement(currentNode))
+ currentIsOverLink = false;
+
+ if (!showsHandCursor(currentNode, toLocalFrame(m_page->mainFrame()), currentIsOverLink))
+ break;
Rick Byers 2014/07/31 20:15:10 same as above
mustaq 2014/07/31 21:04:48 Done.
+
+ largestHandCursorNode = currentNode;
+ }
+
+ if (currentNode)
+ return largestHandCursorNode;
+ // Couldn't find a parent with a hand cursor
Rick Byers 2014/07/31 20:15:10 nit: you mean 'without' not 'with', right?
mustaq 2014/07/31 21:04:48 Good catch!
return bestTouchNode;
}
« no previous file with comments | « LayoutTests/compositing/gestures/gesture-tapHighlight-nested-cursor3-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698