Chromium Code Reviews| 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; |
| } |