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

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 1403893003: Plumb gesture source value through Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Convert more tests (related to CL) to use Touchscreen. Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 , m_isTransparent(false) 430 , m_isTransparent(false)
431 , m_tabsToLinks(false) 431 , m_tabsToLinks(false)
432 , m_layerTreeView(nullptr) 432 , m_layerTreeView(nullptr)
433 , m_rootLayer(nullptr) 433 , m_rootLayer(nullptr)
434 , m_rootGraphicsLayer(nullptr) 434 , m_rootGraphicsLayer(nullptr)
435 , m_rootTransformLayer(nullptr) 435 , m_rootTransformLayer(nullptr)
436 , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium(this))) 436 , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium(this)))
437 , m_matchesHeuristicsForGpuRasterization(false) 437 , m_matchesHeuristicsForGpuRasterization(false)
438 , m_recreatingGraphicsContext(false) 438 , m_recreatingGraphicsContext(false)
439 , m_flingModifier(0) 439 , m_flingModifier(0)
440 , m_flingSourceDevice(false) 440 , m_flingSourceDevice(WebGestureDeviceUninitialized)
441 , m_fullscreenController(FullscreenController::create(this)) 441 , m_fullscreenController(FullscreenController::create(this))
442 , m_showFPSCounter(false) 442 , m_showFPSCounter(false)
443 , m_baseBackgroundColor(Color::white) 443 , m_baseBackgroundColor(Color::white)
444 , m_backgroundColorOverride(Color::transparent) 444 , m_backgroundColorOverride(Color::transparent)
445 , m_zoomFactorOverride(0) 445 , m_zoomFactorOverride(0)
446 , m_userGestureObserved(false) 446 , m_userGestureObserved(false)
447 , m_shouldDispatchFirstVisuallyNonEmptyLayout(false) 447 , m_shouldDispatchFirstVisuallyNonEmptyLayout(false)
448 , m_shouldDispatchFirstLayoutAfterFinishedParsing(false) 448 , m_shouldDispatchFirstLayoutAfterFinishedParsing(false)
449 , m_shouldDispatchFirstLayoutAfterFinishedLoading(false) 449 , m_shouldDispatchFirstLayoutAfterFinishedLoading(false)
450 , m_displayMode(WebDisplayModeBrowser) 450 , m_displayMode(WebDisplayModeBrowser)
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 } 637 }
638 638
639 bool WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const WebMouseWheelEve nt& event) 639 bool WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const WebMouseWheelEve nt& event)
640 { 640 {
641 hidePopups(); 641 hidePopups();
642 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); 642 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event);
643 } 643 }
644 644
645 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci ty) 645 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci ty)
646 { 646 {
647 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized);
647 if (m_flingSourceDevice == WebGestureDeviceTouchpad) { 648 if (m_flingSourceDevice == WebGestureDeviceTouchpad) {
648 WebMouseWheelEvent syntheticWheel; 649 WebMouseWheelEvent syntheticWheel;
649 const float tickDivisor = WheelEvent::TickMultiplier; 650 const float tickDivisor = WheelEvent::TickMultiplier;
650 651
651 syntheticWheel.deltaX = delta.width; 652 syntheticWheel.deltaX = delta.width;
652 syntheticWheel.deltaY = delta.height; 653 syntheticWheel.deltaY = delta.height;
653 syntheticWheel.wheelTicksX = delta.width / tickDivisor; 654 syntheticWheel.wheelTicksX = delta.width / tickDivisor;
654 syntheticWheel.wheelTicksY = delta.height / tickDivisor; 655 syntheticWheel.wheelTicksY = delta.height / tickDivisor;
655 syntheticWheel.hasPreciseScrollingDeltas = true; 656 syntheticWheel.hasPreciseScrollingDeltas = true;
656 syntheticWheel.x = m_positionOnFlingStart.x; 657 syntheticWheel.x = m_positionOnFlingStart.x;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 switch (event.type) { 697 switch (event.type) {
697 case WebInputEvent::GestureFlingStart: { 698 case WebInputEvent::GestureFlingStart: {
698 if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures ()) 699 if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures ())
699 break; 700 break;
700 endActiveFlingAnimation(); 701 endActiveFlingAnimation();
701 m_client->cancelScheduledContentIntents(); 702 m_client->cancelScheduledContentIntents();
702 m_positionOnFlingStart = WebPoint(event.x, event.y); 703 m_positionOnFlingStart = WebPoint(event.x, event.y);
703 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); 704 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);
704 m_flingModifier = event.modifiers; 705 m_flingModifier = event.modifiers;
705 m_flingSourceDevice = event.sourceDevice; 706 m_flingSourceDevice = event.sourceDevice;
707 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized);
706 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->creat eFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.vel ocityX, event.data.flingStart.velocityY), WebSize())); 708 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->creat eFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.vel ocityX, event.data.flingStart.velocityY), WebSize()));
707 ASSERT(flingCurve); 709 ASSERT(flingCurve);
708 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(f lingCurve.release(), this); 710 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(f lingCurve.release(), this);
709 scheduleAnimation(); 711 scheduleAnimation();
710 eventSwallowed = true; 712 eventSwallowed = true;
711 713
712 // Plugins may need to see GestureFlingStart to balance 714 // Plugins may need to see GestureFlingStart to balance
713 // GestureScrollBegin (since the former replaces GestureScrollEnd when 715 // GestureScrollBegin (since the former replaces GestureScrollEnd when
714 // transitioning to a fling). 716 // transitioning to a fling).
715 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event); 717 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingPar ameters& parameters) 910 void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingPar ameters& parameters)
909 { 911 {
910 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation"); 912 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation");
911 ASSERT(!m_gestureAnimation); 913 ASSERT(!m_gestureAnimation);
912 m_positionOnFlingStart = parameters.point; 914 m_positionOnFlingStart = parameters.point;
913 m_globalPositionOnFlingStart = parameters.globalPoint; 915 m_globalPositionOnFlingStart = parameters.globalPoint;
914 m_flingModifier = parameters.modifiers; 916 m_flingModifier = parameters.modifiers;
915 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll)); 917 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll));
916 ASSERT(curve); 918 ASSERT(curve);
917 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime); 919 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime);
920 ASSERT(parameters.sourceDevice != WebGestureDeviceUninitialized);
921 m_flingSourceDevice = parameters.sourceDevice;
918 scheduleAnimation(); 922 scheduleAnimation();
919 } 923 }
920 924
921 bool WebViewImpl::endActiveFlingAnimation() 925 bool WebViewImpl::endActiveFlingAnimation()
922 { 926 {
923 if (m_gestureAnimation) { 927 if (m_gestureAnimation) {
924 m_gestureAnimation.clear(); 928 m_gestureAnimation.clear();
929 m_flingSourceDevice = WebGestureDeviceUninitialized;
925 if (m_layerTreeView) 930 if (m_layerTreeView)
926 m_layerTreeView->didStopFlinging(); 931 m_layerTreeView->didStopFlinging();
927 return true; 932 return true;
928 } 933 }
929 return false; 934 return false;
930 } 935 }
931 936
932 bool WebViewImpl::startPageScaleAnimation(const IntPoint& targetPosition, bool u seAnchor, float newScale, double durationInSeconds) 937 bool WebViewImpl::startPageScaleAnimation(const IntPoint& targetPosition, bool u seAnchor, float newScale, double durationInSeconds)
933 { 938 {
934 VisualViewport& visualViewport = page()->frameHost().visualViewport(); 939 VisualViewport& visualViewport = page()->frameHost().visualViewport();
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 void WebViewImpl::beginFrame(double lastFrameTimeMonotonic) 1876 void WebViewImpl::beginFrame(double lastFrameTimeMonotonic)
1872 { 1877 {
1873 TRACE_EVENT1("blink", "WebViewImpl::beginFrame", "frameTime", lastFrameTimeM onotonic); 1878 TRACE_EVENT1("blink", "WebViewImpl::beginFrame", "frameTime", lastFrameTimeM onotonic);
1874 ASSERT(lastFrameTimeMonotonic); 1879 ASSERT(lastFrameTimeMonotonic);
1875 1880
1876 // Create synthetic wheel events as necessary for fling. 1881 // Create synthetic wheel events as necessary for fling.
1877 if (m_gestureAnimation) { 1882 if (m_gestureAnimation) {
1878 if (m_gestureAnimation->animate(lastFrameTimeMonotonic)) 1883 if (m_gestureAnimation->animate(lastFrameTimeMonotonic))
1879 scheduleAnimation(); 1884 scheduleAnimation();
1880 else { 1885 else {
1886 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized);
1887 WebGestureDevice lastFlingSourceDevice = m_flingSourceDevice;
1881 endActiveFlingAnimation(); 1888 endActiveFlingAnimation();
1882 1889
1883 PlatformGestureEvent endScrollEvent(PlatformEvent::GestureScrollEnd, 1890 PlatformGestureEvent endScrollEvent(PlatformEvent::GestureScrollEnd,
1884 m_positionOnFlingStart, m_globalPositionOnFlingStart, 1891 m_positionOnFlingStart, m_globalPositionOnFlingStart,
1885 IntSize(), 0, PlatformEvent::NoModifiers); 1892 IntSize(), 0, PlatformEvent::NoModifiers, lastFlingSourceDevice == WebGestureDeviceTouchpad ? PlatformGestureSourceTouchpad : PlatformGestureSou rceTouchscreen);
1886 endScrollEvent.setScrollGestureData(0, 0, 0, 0, true, false, -1 /* n ull plugin id */); 1893 endScrollEvent.setScrollGestureData(0, 0, 0, 0, true, false, -1 /* n ull plugin id */);
1887 1894
1888 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEnd(endS crollEvent); 1895 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEnd(endS crollEvent);
1889 } 1896 }
1890 } 1897 }
1891 1898
1892 if (!m_page) 1899 if (!m_page)
1893 return; 1900 return;
1894 1901
1895 PageWidgetDelegate::animate(*m_page, lastFrameTimeMonotonic); 1902 PageWidgetDelegate::animate(*m_page, lastFrameTimeMonotonic);
(...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after
4078 4085
4079 WebHitTestResult WebViewImpl::hitTestResultForTap(const WebPoint& tapPointWindow Pos, const WebSize& tapArea) 4086 WebHitTestResult WebViewImpl::hitTestResultForTap(const WebPoint& tapPointWindow Pos, const WebSize& tapArea)
4080 { 4087 {
4081 if (!m_page->mainFrame()->isLocalFrame()) 4088 if (!m_page->mainFrame()->isLocalFrame())
4082 return HitTestResult(); 4089 return HitTestResult();
4083 4090
4084 WebGestureEvent tapEvent; 4091 WebGestureEvent tapEvent;
4085 tapEvent.x = tapPointWindowPos.x; 4092 tapEvent.x = tapPointWindowPos.x;
4086 tapEvent.y = tapPointWindowPos.y; 4093 tapEvent.y = tapPointWindowPos.y;
4087 tapEvent.type = WebInputEvent::GestureTap; 4094 tapEvent.type = WebInputEvent::GestureTap;
4095 // GestureTap is only ever from a touchscreen.
4096 tapEvent.sourceDevice = WebGestureDeviceTouchscreen;
4088 tapEvent.data.tap.tapCount = 1; 4097 tapEvent.data.tap.tapCount = 1;
4089 tapEvent.data.tap.width = tapArea.width; 4098 tapEvent.data.tap.width = tapArea.width;
4090 tapEvent.data.tap.height = tapArea.height; 4099 tapEvent.data.tap.height = tapArea.height;
4091 4100
4092 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), tapE vent); 4101 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), tapE vent);
4093 4102
4094 HitTestResult result = m_page->deprecatedLocalMainFrame()->eventHandler().hi tTestResultForGestureEvent(platformEvent, HitTestRequest::ReadOnly | HitTestRequ est::Active).hitTestResult(); 4103 HitTestResult result = m_page->deprecatedLocalMainFrame()->eventHandler().hi tTestResultForGestureEvent(platformEvent, HitTestRequest::ReadOnly | HitTestRequ est::Active).hitTestResult();
4095 4104
4096 result.setToShadowHostIfInUserAgentShadowRoot(); 4105 result.setToShadowHostIfInUserAgentShadowRoot();
4097 return result; 4106 return result;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
4432 if (m_pageColorOverlay) 4441 if (m_pageColorOverlay)
4433 m_pageColorOverlay->update(); 4442 m_pageColorOverlay->update();
4434 if (InspectorOverlay* overlay = inspectorOverlay()) { 4443 if (InspectorOverlay* overlay = inspectorOverlay()) {
4435 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); 4444 PageOverlay* inspectorPageOverlay = overlay->pageOverlay();
4436 if (inspectorPageOverlay) 4445 if (inspectorPageOverlay)
4437 inspectorPageOverlay->update(); 4446 inspectorPageOverlay->update();
4438 } 4447 }
4439 } 4448 }
4440 4449
4441 } // namespace blink 4450 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/Source/web/tests/ImeOnFocusTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698