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

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

Issue 1841053002: Fix mouse wheel scrolling on PDFs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Return WebGestureEvent Created 4 years, 8 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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 WebInputEventResult WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const W ebMouseWheelEvent& event) 636 WebInputEventResult WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const W ebMouseWheelEvent& event)
637 { 637 {
638 // Halt an in-progress fling on a wheel tick. 638 // Halt an in-progress fling on a wheel tick.
639 if (!event.hasPreciseScrollingDeltas) 639 if (!event.hasPreciseScrollingDeltas)
640 endActiveFlingAnimation(); 640 endActiveFlingAnimation();
641 641
642 hidePopups(); 642 hidePopups();
643 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); 643 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event);
644 } 644 }
645 645
646 WebGestureEvent WebViewImpl::createGestureScrollEventFromFling(WebInputEvent::Ty pe type, WebGestureDevice sourceDevice) const
647 {
648 WebGestureEvent gestureEvent;
649 gestureEvent.type = type;
650 gestureEvent.sourceDevice = sourceDevice;
651 gestureEvent.timeStampSeconds = WTF::monotonicallyIncreasingTime();
652 gestureEvent.x = m_positionOnFlingStart.x;
653 gestureEvent.y = m_positionOnFlingStart.y;
654 gestureEvent.globalX = m_globalPositionOnFlingStart.x;
655 gestureEvent.globalY = m_globalPositionOnFlingStart.y;
656 gestureEvent.modifiers = m_flingModifier;
657 return gestureEvent;
658 }
659
646 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci ty) 660 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci ty)
647 { 661 {
648 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); 662 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized);
663 if (!m_page || !m_page->mainFrame() || !m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFrame()->view())
664 return false;
665
649 if (m_flingSourceDevice == WebGestureDeviceTouchpad) { 666 if (m_flingSourceDevice == WebGestureDeviceTouchpad) {
650 WebMouseWheelEvent syntheticWheel; 667 WebMouseWheelEvent syntheticWheel;
651 const float tickDivisor = WheelEvent::TickMultiplier; 668 const float tickDivisor = WheelEvent::TickMultiplier;
652 669
653 syntheticWheel.type = WebInputEvent::MouseWheel; 670 syntheticWheel.type = WebInputEvent::MouseWheel;
654 syntheticWheel.timeStampSeconds = WTF::monotonicallyIncreasingTime(); 671 syntheticWheel.timeStampSeconds = WTF::monotonicallyIncreasingTime();
655 syntheticWheel.deltaX = delta.width; 672 syntheticWheel.deltaX = delta.width;
656 syntheticWheel.deltaY = delta.height; 673 syntheticWheel.deltaY = delta.height;
657 syntheticWheel.wheelTicksX = delta.width / tickDivisor; 674 syntheticWheel.wheelTicksX = delta.width / tickDivisor;
658 syntheticWheel.wheelTicksY = delta.height / tickDivisor; 675 syntheticWheel.wheelTicksY = delta.height / tickDivisor;
659 syntheticWheel.hasPreciseScrollingDeltas = true; 676 syntheticWheel.hasPreciseScrollingDeltas = true;
660 syntheticWheel.x = m_positionOnFlingStart.x; 677 syntheticWheel.x = m_positionOnFlingStart.x;
661 syntheticWheel.y = m_positionOnFlingStart.y; 678 syntheticWheel.y = m_positionOnFlingStart.y;
662 syntheticWheel.globalX = m_globalPositionOnFlingStart.x; 679 syntheticWheel.globalX = m_globalPositionOnFlingStart.x;
663 syntheticWheel.globalY = m_globalPositionOnFlingStart.y; 680 syntheticWheel.globalY = m_globalPositionOnFlingStart.y;
664 syntheticWheel.modifiers = m_flingModifier; 681 syntheticWheel.modifiers = m_flingModifier;
665 682
666 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() && m_page->deprecatedLocalMainFrame()->view()) 683 if (handleMouseWheel(*m_page->deprecatedLocalMainFrame(), syntheticWheel ) != WebInputEventResult::NotHandled)
667 return handleMouseWheel(*m_page->deprecatedLocalMainFrame(), synthet icWheel) != WebInputEventResult::NotHandled; 684 return true;
685 if (!m_webSettings->wheelGesturesEnabled())
686 return false;
687
688 WebGestureEvent syntheticScrollBegin = createGestureScrollEventFromFling (WebInputEvent::GestureScrollBegin, WebGestureDeviceTouchpad);
689 syntheticScrollBegin.data.scrollBegin.deltaXHint = delta.width;
690 syntheticScrollBegin.data.scrollBegin.deltaYHint = delta.height;
691 syntheticScrollBegin.data.scrollBegin.inertial = true;
692 handleGestureEvent(syntheticScrollBegin);
tdresser 2016/03/29 19:51:33 We should probably have a TODO here with a bug ref
dtapuska 2016/03/29 20:07:01 Done.
693
694 WebGestureEvent syntheticScrollUpdate = createGestureScrollEventFromFlin g(WebInputEvent::GestureScrollUpdate, WebGestureDeviceTouchpad);
695 syntheticScrollUpdate.data.scrollUpdate.deltaX = delta.width;
696 syntheticScrollUpdate.data.scrollUpdate.deltaY = delta.height;
697 syntheticScrollUpdate.data.scrollUpdate.velocityX = velocity.width;
698 syntheticScrollUpdate.data.scrollUpdate.velocityY = velocity.height;
699 syntheticScrollUpdate.data.scrollUpdate.inertial = true;
700 bool scrollUpdateHandled = handleGestureEvent(syntheticScrollUpdate) != WebInputEventResult::NotHandled;
701
702 WebGestureEvent syntheticScrollEnd = createGestureScrollEventFromFling(W ebInputEvent::GestureScrollEnd, WebGestureDeviceTouchpad);
703 syntheticScrollEnd.data.scrollEnd.inertial = true;
704 handleGestureEvent(syntheticScrollEnd);
705 return scrollUpdateHandled;
668 } else { 706 } else {
669 WebGestureEvent syntheticGestureEvent; 707 WebGestureEvent syntheticGestureEvent = createGestureScrollEventFromFlin g(WebInputEvent::GestureScrollUpdate, WebGestureDeviceTouchscreen);
670
671 syntheticGestureEvent.type = WebInputEvent::GestureScrollUpdate;
672 syntheticGestureEvent.timeStampSeconds = WTF::monotonicallyIncreasingTim e();
673 syntheticGestureEvent.data.scrollUpdate.preventPropagation = true; 708 syntheticGestureEvent.data.scrollUpdate.preventPropagation = true;
674 syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width; 709 syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width;
675 syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height; 710 syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height;
676 syntheticGestureEvent.data.scrollUpdate.velocityX = velocity.width; 711 syntheticGestureEvent.data.scrollUpdate.velocityX = velocity.width;
677 syntheticGestureEvent.data.scrollUpdate.velocityY = velocity.height; 712 syntheticGestureEvent.data.scrollUpdate.velocityY = velocity.height;
678 syntheticGestureEvent.x = m_positionOnFlingStart.x;
679 syntheticGestureEvent.y = m_positionOnFlingStart.y;
680 syntheticGestureEvent.globalX = m_globalPositionOnFlingStart.x;
681 syntheticGestureEvent.globalY = m_globalPositionOnFlingStart.y;
682 syntheticGestureEvent.modifiers = m_flingModifier;
683 syntheticGestureEvent.sourceDevice = WebGestureDeviceTouchscreen;
684 syntheticGestureEvent.data.scrollUpdate.inertial = true; 713 syntheticGestureEvent.data.scrollUpdate.inertial = true;
685 714
686 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() && m_page->deprecatedLocalMainFrame()->view()) 715 return handleGestureEvent(syntheticGestureEvent) != WebInputEventResult: :NotHandled;
687 return handleGestureEvent(syntheticGestureEvent) != WebInputEventRes ult::NotHandled;
688 } 716 }
689 return false;
690 } 717 }
691 718
692 WebInputEventResult WebViewImpl::handleGestureEvent(const WebGestureEvent& event ) 719 WebInputEventResult WebViewImpl::handleGestureEvent(const WebGestureEvent& event )
693 { 720 {
694 if (!m_client) 721 if (!m_client)
695 return WebInputEventResult::NotHandled; 722 return WebInputEventResult::NotHandled;
696 723
697 WebInputEventResult eventResult = WebInputEventResult::NotHandled; 724 WebInputEventResult eventResult = WebInputEventResult::NotHandled;
698 bool eventCancelled = false; // for disambiguation 725 bool eventCancelled = false; // for disambiguation
699 726
(...skipping 3864 matching lines...) Expand 10 before | Expand all | Expand 10 after
4564 { 4591 {
4565 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4592 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than
4566 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. 4593 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4567 if (!page()) 4594 if (!page())
4568 return 1; 4595 return 1;
4569 4596
4570 return page()->deviceScaleFactor(); 4597 return page()->deviceScaleFactor();
4571 } 4598 }
4572 4599
4573 } // namespace blink 4600 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebSettings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698