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

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: 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 | « no previous file | 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 5283ca6577fc1e479ddb42604c9d786928a3ba7c..60ef84ef2c8c15eddd560c2030382f8e1731698c 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -1170,6 +1170,22 @@ void WebViewImpl::computeScaleAndScrollForBlockRect(const WebPoint& hitPoint, co
scroll = clampOffsetAtScale(scroll, scale);
}
+static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame)
+{
+ // Go up the tree to find the node that defines a mouse cursor style
+ while (node) {
+ // If the current node has an attached renderer, check the cursor. Otherwise, go up.
+ if (node->renderer()) {
+ ECursor cursor = node->renderer()->style()->cursor();
+ if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(node, node->isLink()))
+ break;
+ }
+ node = node->parentNode();
+ }
+
+ return node;
+}
+
static bool invokesHandCursor(Node* node, LocalFrame* frame)
{
if (!node || !node->renderer())
@@ -1187,28 +1203,28 @@ 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();
+ GestureEventWithHitTestResults targetedEvent =
+ m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(tapEvent, true);
+ Node* 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();
- // 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();
-
- if (!bestTouchNode)
+ Node* cursorDefiningAncestor =
+ findCursorDefiningAncestor(bestTouchNode, m_page->deprecatedLocalMainFrame());
+ // We show a highlight on tap only when the current node shows a hand cursor
+ if (!cursorDefiningAncestor || !invokesHandCursor(cursorDefiningAncestor, m_page->deprecatedLocalMainFrame())) {
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();
+ // We should pick the largest enclosing node with hand cursor set
+ do {
+ bestTouchNode = cursorDefiningAncestor;
wjmaclean 2014/07/22 20:34:12 The logic may be correct, but the back-and-forth b
mustaq 2014/07/23 21:12:10 Done.
+ cursorDefiningAncestor = findCursorDefiningAncestor(bestTouchNode->parentNode(), m_page->deprecatedLocalMainFrame());
+ } while (cursorDefiningAncestor && invokesHandCursor(cursorDefiningAncestor, m_page->deprecatedLocalMainFrame()));
return bestTouchNode;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698