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

Unified Diff: Source/web/WebViewImpl.cpp

Issue 15663005: Expand tap highlight to allow multiple highlights for touch disambiguation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index 1cdb62d6aa28f411514f57116393205350dad0ec..52db966dc9eb1dd9d32578d443430f69fae0b8c8 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -696,14 +696,14 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
// Queue a highlight animation, then hand off to regular handler.
#if OS(LINUX)
if (settingsImpl()->gestureTapHighlightEnabled())
- enableTapHighlight(platformEvent);
+ enableTapHighlightAtPoint(platformEvent);
#endif
break;
case WebInputEvent::GestureTapCancel:
case WebInputEvent::GestureTap:
case WebInputEvent::GestureLongPress:
- if (m_linkHighlight)
- m_linkHighlight->startHighlightAnimationIfNeeded();
+ for (size_t i = 0; i < m_linkHighlights.size(); i++)
+ m_linkHighlights[i]->startHighlightAnimationIfNeeded();
break;
default:
break;
@@ -734,10 +734,13 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
scaledEvent.data.tap.height = event.data.tap.height / pageScaleFactor();
IntRect boundingBox(scaledEvent.x - scaledEvent.data.tap.width / 2, scaledEvent.y - scaledEvent.data.tap.height / 2, scaledEvent.data.tap.width, scaledEvent.data.tap.height);
Vector<IntRect> goodTargets;
- findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTargets);
+ Vector<Node*> highlightNodes;
+ findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTargets, highlightNodes);
// FIXME: replace touch adjustment code when numberOfGoodTargets == 1?
// Single candidate case is currently handled by: https://bugs.webkit.org/show_bug.cgi?id=85101
if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(scaledEvent, goodTargets)) {
+ if (settingsImpl()->gestureTapHighlightEnabled())
+ enableTapHighlights(highlightNodes);
eventSwallowed = true;
eventCancelled = true;
break;
@@ -1231,24 +1234,37 @@ Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
return bestTouchNode;
}
-void WebViewImpl::enableTapHighlight(const PlatformGestureEvent& tapEvent)
+void WebViewImpl::enableTapHighlightAtPoint(const PlatformGestureEvent& tapEvent)
{
- // Always clear any existing highlight when this is invoked, even if we don't get a new target to highlight.
- m_linkHighlight.clear();
-
Node* touchNode = bestTapNode(tapEvent);
- if (!touchNode || !touchNode->renderer() || !touchNode->renderer()->enclosingLayer())
- return;
+ Vector<Node*> highlightNodes;
+ highlightNodes.append(touchNode);
- Color highlightColor = touchNode->renderer()->style()->tapHighlightColor();
- // Safari documentation for -webkit-tap-highlight-color says if the specified color has 0 alpha,
- // then tap highlighting is disabled.
- // http://developer.apple.com/library/safari/#documentation/appleapplications/reference/safaricssref/articles/standardcssproperties.html
- if (!highlightColor.alpha())
- return;
+ enableTapHighlights(highlightNodes);
+}
+
+void WebViewImpl::enableTapHighlights(Vector<Node*>& highlightNodes)
+{
+ // Always clear any existing highlight when this is invoked, even if we
+ // don't get a new target to highlight.
+ m_linkHighlights.clear();
+
+ for (size_t i = 0; i < highlightNodes.size(); i++) {
+ Node* node = highlightNodes[i];
+
+ if (!node || !node->renderer() || !node->renderer()->enclosingLayer())
+ continue;
- m_linkHighlight = LinkHighlight::create(touchNode, this);
+ Color highlightColor = node->renderer()->style()->tapHighlightColor();
+ // Safari documentation for -webkit-tap-highlight-color says if the specified color has 0 alpha,
+ // then tap highlighting is disabled.
+ // http://developer.apple.com/library/safari/#documentation/appleapplications/reference/safaricssref/articles/standardcssproperties.html
+ if (!highlightColor.alpha())
+ continue;
+
+ m_linkHighlights.append(LinkHighlight::create(node, this));
+ }
}
void WebViewImpl::animateDoubleTapZoom(const IntPoint& point)
@@ -1772,8 +1788,8 @@ void WebViewImpl::layout()
if (m_layerTreeView)
m_layerTreeView->setBackgroundColor(backgroundColor());
- if (m_linkHighlight)
- m_linkHighlight->updateGeometry();
+ for (size_t i = 0; i < m_linkHighlights.size(); i++)
+ m_linkHighlights[i]->updateGeometry();
}
void WebViewImpl::enterForceCompositingMode(bool enter)
@@ -3624,7 +3640,7 @@ void WebViewImpl::didCommitLoad(bool* isNewNavigation, bool isNavigationWithinPa
m_pageScaleConstraintsSet.setNeedsReset(true);
// Make sure link highlight from previous page is cleared.
- m_linkHighlight.clear();
+ m_linkHighlights.clear();
m_gestureAnimation.clear();
if (m_layerTreeView)
m_layerTreeView->didStopFlinging();

Powered by Google App Engine
This is Rietveld 408576698