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

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: Fix gesture fling 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 void WebViewImpl::populateGestureScrollEventFromFling(WebInputEvent::Type type, WebGestureDevice sourceDevice, WebGestureEvent* gestureEvent)
tdresser 2016/03/29 19:16:03 Why not just return a WebGestureEvent?
dtapuska 2016/03/29 19:42:05 Done.
647 {
648 gestureEvent->type = type;
649 gestureEvent->sourceDevice = sourceDevice;
650 gestureEvent->timeStampSeconds = WTF::monotonicallyIncreasingTime();
651 gestureEvent->x = m_positionOnFlingStart.x;
652 gestureEvent->y = m_positionOnFlingStart.y;
653 gestureEvent->globalX = m_globalPositionOnFlingStart.x;
654 gestureEvent->globalY = m_globalPositionOnFlingStart.y;
655 gestureEvent->modifiers = m_flingModifier;
656 }
657
646 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci ty) 658 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci ty)
647 { 659 {
648 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); 660 ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized);
661 if (!m_page || !m_page->mainFrame() || !m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFrame()->view())
662 return false;
663
649 if (m_flingSourceDevice == WebGestureDeviceTouchpad) { 664 if (m_flingSourceDevice == WebGestureDeviceTouchpad) {
650 WebMouseWheelEvent syntheticWheel; 665 WebMouseWheelEvent syntheticWheel;
651 const float tickDivisor = WheelEvent::TickMultiplier; 666 const float tickDivisor = WheelEvent::TickMultiplier;
652 667
653 syntheticWheel.type = WebInputEvent::MouseWheel; 668 syntheticWheel.type = WebInputEvent::MouseWheel;
654 syntheticWheel.timeStampSeconds = WTF::monotonicallyIncreasingTime(); 669 syntheticWheel.timeStampSeconds = WTF::monotonicallyIncreasingTime();
655 syntheticWheel.deltaX = delta.width; 670 syntheticWheel.deltaX = delta.width;
656 syntheticWheel.deltaY = delta.height; 671 syntheticWheel.deltaY = delta.height;
657 syntheticWheel.wheelTicksX = delta.width / tickDivisor; 672 syntheticWheel.wheelTicksX = delta.width / tickDivisor;
658 syntheticWheel.wheelTicksY = delta.height / tickDivisor; 673 syntheticWheel.wheelTicksY = delta.height / tickDivisor;
659 syntheticWheel.hasPreciseScrollingDeltas = true; 674 syntheticWheel.hasPreciseScrollingDeltas = true;
660 syntheticWheel.x = m_positionOnFlingStart.x; 675 syntheticWheel.x = m_positionOnFlingStart.x;
661 syntheticWheel.y = m_positionOnFlingStart.y; 676 syntheticWheel.y = m_positionOnFlingStart.y;
662 syntheticWheel.globalX = m_globalPositionOnFlingStart.x; 677 syntheticWheel.globalX = m_globalPositionOnFlingStart.x;
663 syntheticWheel.globalY = m_globalPositionOnFlingStart.y; 678 syntheticWheel.globalY = m_globalPositionOnFlingStart.y;
664 syntheticWheel.modifiers = m_flingModifier; 679 syntheticWheel.modifiers = m_flingModifier;
665 680
666 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() && m_page->deprecatedLocalMainFrame()->view()) 681 if (handleMouseWheel(*m_page->deprecatedLocalMainFrame(), syntheticWheel ) != WebInputEventResult::NotHandled)
667 return handleMouseWheel(*m_page->deprecatedLocalMainFrame(), synthet icWheel) != WebInputEventResult::NotHandled; 682 return true;
683 if (!m_webSettings->wheelGesturesEnabled())
684 return false;
685
686 WebGestureEvent syntheticScrollBegin;
687 populateGestureScrollEventFromFling(WebInputEvent::GestureScrollBegin,
688 WebGestureDeviceTouchpad,
689 &syntheticScrollBegin);
690 syntheticScrollBegin.data.scrollBegin.deltaXHint = delta.width;
691 syntheticScrollBegin.data.scrollBegin.deltaYHint = delta.height;
692 syntheticScrollBegin.data.scrollBegin.inertial = true;
693 handleGestureEvent(syntheticScrollBegin);
694
695 WebGestureEvent syntheticScrollUpdate;
696 populateGestureScrollEventFromFling(WebInputEvent::GestureScrollUpdate,
697 WebGestureDeviceTouchpad,
698 &syntheticScrollUpdate);
699 syntheticScrollUpdate.data.scrollUpdate.deltaX = delta.width;
700 syntheticScrollUpdate.data.scrollUpdate.deltaY = delta.height;
701 syntheticScrollUpdate.data.scrollUpdate.velocityX = velocity.width;
702 syntheticScrollUpdate.data.scrollUpdate.velocityY = velocity.height;
703 syntheticScrollUpdate.data.scrollUpdate.inertial = true;
704 bool scrollUpdateHandled = handleGestureEvent(syntheticScrollUpdate) != WebInputEventResult::NotHandled;
705
706 WebGestureEvent syntheticScrollEnd;
707 populateGestureScrollEventFromFling(WebInputEvent::GestureScrollEnd,
708 WebGestureDeviceTouchpad,
709 &syntheticScrollUpdate);
tdresser 2016/03/29 19:16:03 We're passing in syntheticGestureScrollUpdate here
dtapuska 2016/03/29 19:42:05 Ugh; this should fail in a debug build bot.
710 syntheticScrollEnd.data.scrollEnd.inertial = true;
711 handleGestureEvent(syntheticScrollEnd);
712 return scrollUpdateHandled;
668 } else { 713 } else {
669 WebGestureEvent syntheticGestureEvent; 714 WebGestureEvent syntheticGestureEvent;
670 715 populateGestureScrollEventFromFling(WebInputEvent::GestureScrollUpdate,
671 syntheticGestureEvent.type = WebInputEvent::GestureScrollUpdate; 716 WebGestureDeviceTouchscreen,
672 syntheticGestureEvent.timeStampSeconds = WTF::monotonicallyIncreasingTim e(); 717 &syntheticGestureEvent);
673 syntheticGestureEvent.data.scrollUpdate.preventPropagation = true; 718 syntheticGestureEvent.data.scrollUpdate.preventPropagation = true;
674 syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width; 719 syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width;
675 syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height; 720 syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height;
676 syntheticGestureEvent.data.scrollUpdate.velocityX = velocity.width; 721 syntheticGestureEvent.data.scrollUpdate.velocityX = velocity.width;
677 syntheticGestureEvent.data.scrollUpdate.velocityY = velocity.height; 722 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; 723 syntheticGestureEvent.data.scrollUpdate.inertial = true;
685 724
686 if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() && m_page->deprecatedLocalMainFrame()->view()) 725 return handleGestureEvent(syntheticGestureEvent) != WebInputEventResult: :NotHandled;
687 return handleGestureEvent(syntheticGestureEvent) != WebInputEventRes ult::NotHandled;
688 } 726 }
689 return false;
690 } 727 }
691 728
692 WebInputEventResult WebViewImpl::handleGestureEvent(const WebGestureEvent& event ) 729 WebInputEventResult WebViewImpl::handleGestureEvent(const WebGestureEvent& event )
693 { 730 {
694 if (!m_client) 731 if (!m_client)
695 return WebInputEventResult::NotHandled; 732 return WebInputEventResult::NotHandled;
696 733
697 WebInputEventResult eventResult = WebInputEventResult::NotHandled; 734 WebInputEventResult eventResult = WebInputEventResult::NotHandled;
698 bool eventCancelled = false; // for disambiguation 735 bool eventCancelled = false; // for disambiguation
699 736
(...skipping 3864 matching lines...) Expand 10 before | Expand all | Expand 10 after
4564 { 4601 {
4565 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4602 // 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. 4603 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4567 if (!page()) 4604 if (!page())
4568 return 1; 4605 return 1;
4569 4606
4570 return page()->deviceScaleFactor(); 4607 return page()->deviceScaleFactor();
4571 } 4608 }
4572 4609
4573 } // namespace blink 4610 } // 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