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

Unified Diff: Source/WebKit/chromium/src/WebViewImpl.cpp

Issue 12315056: Merge 142913 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 10 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 | « Source/WebKit/chromium/src/WebViewImpl.h ('k') | Source/WebKit/chromium/tests/LinkHighlightTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebKit/chromium/src/WebViewImpl.cpp
===================================================================
--- Source/WebKit/chromium/src/WebViewImpl.cpp (revision 143774)
+++ Source/WebKit/chromium/src/WebViewImpl.cpp (working copy)
@@ -697,6 +697,42 @@
bool eventSwallowed = false;
bool eventCancelled = false; // for disambiguation
+ // Special handling for slow-path fling gestures, which have no PlatformGestureEvent equivalent.
+ switch (event.type) {
+ case WebInputEvent::GestureFlingStart: {
+ if (mainFrameImpl()->frame()->eventHandler()->isScrollbarHandlingGestures()) {
+ m_client->didHandleGestureEvent(event, eventCancelled);
+ return eventSwallowed;
+ }
+ m_client->cancelScheduledContentIntents();
+ m_positionOnFlingStart = WebPoint(event.x / pageScaleFactor(), event.y / pageScaleFactor());
+ m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);
+ m_flingModifier = event.modifiers;
+ m_flingSourceDevice = event.sourceDevice;
+ OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->createFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY), WebSize()));
+ m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(flingCurve.release(), this);
+ scheduleAnimation();
+ eventSwallowed = true;
+
+ m_client->didHandleGestureEvent(event, eventCancelled);
+ return eventSwallowed;
+ }
+ case WebInputEvent::GestureFlingCancel:
+ if (m_gestureAnimation) {
+ m_gestureAnimation.clear();
+ if (m_layerTreeView)
+ m_layerTreeView->didStopFlinging();
+ eventSwallowed = true;
+ }
+
+ m_client->didHandleGestureEvent(event, eventCancelled);
+ return eventSwallowed;
+ default:
+ break;
+ }
+
+ PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
+
// Handle link highlighting outside the main switch to avoid getting lost in the
// complicated set of cases handled below.
switch (event.type) {
@@ -704,7 +740,7 @@
// Queue a highlight animation, then hand off to regular handler.
#if OS(LINUX)
if (settingsImpl()->gestureTapHighlightEnabled())
- enableTouchHighlight(event);
+ enableTapHighlight(platformEvent);
#endif
break;
case WebInputEvent::GestureTapCancel:
@@ -718,31 +754,9 @@
}
switch (event.type) {
- case WebInputEvent::GestureFlingStart: {
- if (mainFrameImpl()->frame()->eventHandler()->isScrollbarHandlingGestures())
- break;
- m_client->cancelScheduledContentIntents();
- m_positionOnFlingStart = WebPoint(event.x, event.y);
- m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);
- m_flingModifier = event.modifiers;
- m_flingSourceDevice = event.sourceDevice;
- OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->createFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY), WebSize()));
- m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(flingCurve.release(), this);
- scheduleAnimation();
- eventSwallowed = true;
- break;
- }
- case WebInputEvent::GestureFlingCancel:
- if (m_gestureAnimation) {
- m_gestureAnimation.clear();
- if (m_layerTreeView)
- m_layerTreeView->didStopFlinging();
- eventSwallowed = true;
- }
- break;
case WebInputEvent::GestureTap: {
m_client->cancelScheduledContentIntents();
- if (detectContentOnTouch(WebPoint(event.x, event.y))) {
+ if (detectContentOnTouch(platformEvent.position())) {
eventSwallowed = true;
break;
}
@@ -757,7 +771,7 @@
if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds()) {
// FIXME: didTapMultipleTargets should just take a rect instead of
// an event.
- WebGestureEvent scaledEvent;
+ WebGestureEvent scaledEvent = event;
scaledEvent.x = event.x / pageScaleFactor();
scaledEvent.y = event.y / pageScaleFactor();
scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor();
@@ -774,7 +788,6 @@
}
}
- PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
if (m_selectPopup && m_selectPopup == selectPopup) {
@@ -796,7 +809,6 @@
m_client->cancelScheduledContentIntents();
m_page->contextMenuController()->clearContextMenu();
m_contextMenuAllowed = true;
- PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
m_contextMenuAllowed = false;
@@ -804,14 +816,13 @@
}
case WebInputEvent::GestureTapDown: {
m_client->cancelScheduledContentIntents();
- PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
break;
}
case WebInputEvent::GestureDoubleTap:
if (m_webSettings->doubleTapToZoomEnabled() && m_minimumPageScaleFactor != m_maximumPageScaleFactor) {
m_client->cancelScheduledContentIntents();
- animateZoomAroundPoint(WebPoint(event.x, event.y), DoubleTap);
+ animateZoomAroundPoint(platformEvent.position(), DoubleTap);
eventSwallowed = true;
break;
}
@@ -824,7 +835,6 @@
case WebInputEvent::GestureTapCancel:
case WebInputEvent::GesturePinchEnd:
case WebInputEvent::GesturePinchUpdate: {
- PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
eventSwallowed = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent);
break;
}
@@ -1271,17 +1281,16 @@
|| (cursor == CURSOR_AUTO && frame->eventHandler()->useHandCursor(node, node->isLink(), shiftKey));
}
-Node* WebViewImpl::bestTouchLinkNode(const WebGestureEvent& touchEvent)
+Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
{
if (!m_page || !m_page->mainFrame())
return 0;
Node* bestTouchNode = 0;
- IntSize touchEventSearchRegionSize(touchEvent.data.tapDown.width / 2, touchEvent.data.tapDown.height / 2);
- IntPoint touchEventLocation(touchEvent.x, touchEvent.y);
+ IntPoint touchEventLocation(tapEvent.position());
#if ENABLE(TOUCH_ADJUSTMENT)
- m_page->mainFrame()->eventHandler()->adjustGesturePosition(PlatformGestureEventBuilder(mainFrameImpl()->frameView(), touchEvent), touchEventLocation);
+ m_page->mainFrame()->eventHandler()->adjustGesturePosition(tapEvent, touchEventLocation);
#endif
IntPoint hitTestPoint = m_page->mainFrame()->view()->windowToContents(touchEventLocation);
@@ -1291,23 +1300,22 @@
// Make sure our highlight candidate uses a hand cursor as a heuristic to
// choose appropriate targets.
- bool shiftKey = touchEvent.modifiers & WebGestureEvent::ShiftKey;
- while (bestTouchNode && !invokesHandCursor(bestTouchNode, shiftKey, m_page->mainFrame()))
+ while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mainFrame()))
bestTouchNode = bestTouchNode->parentNode();
// We should pick the largest enclosing node with hand cursor set.
- while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), shiftKey, m_page->mainFrame()))
+ while (bestTouchNode && bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), false, m_page->mainFrame()))
bestTouchNode = bestTouchNode->parentNode();
return bestTouchNode;
}
-void WebViewImpl::enableTouchHighlight(const WebGestureEvent& touchEvent)
+void WebViewImpl::enableTapHighlight(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 = bestTouchLinkNode(touchEvent);
+ Node* touchNode = bestTapNode(tapEvent);
if (!touchNode || !touchNode->renderer() || !touchNode->renderer()->enclosingLayer())
return;
« no previous file with comments | « Source/WebKit/chromium/src/WebViewImpl.h ('k') | Source/WebKit/chromium/tests/LinkHighlightTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698