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

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

Issue 2569273002: Add constructors to WebInputEvents and setters so we can work at cleaning up these public structs. (Closed)
Patch Set: Fix mouse up event sender not modifying modifiers Created 4 years 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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 if (!event.hasPreciseScrollingDeltas) 603 if (!event.hasPreciseScrollingDeltas)
604 endActiveFlingAnimation(); 604 endActiveFlingAnimation();
605 605
606 hidePopups(); 606 hidePopups();
607 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); 607 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event);
608 } 608 }
609 609
610 WebGestureEvent WebViewImpl::createGestureScrollEventFromFling( 610 WebGestureEvent WebViewImpl::createGestureScrollEventFromFling(
611 WebInputEvent::Type type, 611 WebInputEvent::Type type,
612 WebGestureDevice sourceDevice) const { 612 WebGestureDevice sourceDevice) const {
613 WebGestureEvent gestureEvent; 613 WebGestureEvent gestureEvent(type, m_flingModifier,
614 gestureEvent.type = type; 614 WTF::monotonicallyIncreasingTime());
615 gestureEvent.sourceDevice = sourceDevice; 615 gestureEvent.sourceDevice = sourceDevice;
616 gestureEvent.timeStampSeconds = WTF::monotonicallyIncreasingTime();
617 gestureEvent.x = m_positionOnFlingStart.x; 616 gestureEvent.x = m_positionOnFlingStart.x;
618 gestureEvent.y = m_positionOnFlingStart.y; 617 gestureEvent.y = m_positionOnFlingStart.y;
619 gestureEvent.globalX = m_globalPositionOnFlingStart.x; 618 gestureEvent.globalX = m_globalPositionOnFlingStart.x;
620 gestureEvent.globalY = m_globalPositionOnFlingStart.y; 619 gestureEvent.globalY = m_globalPositionOnFlingStart.y;
621 gestureEvent.modifiers = m_flingModifier;
622 return gestureEvent; 620 return gestureEvent;
623 } 621 }
624 622
625 bool WebViewImpl::scrollBy(const WebFloatSize& delta, 623 bool WebViewImpl::scrollBy(const WebFloatSize& delta,
626 const WebFloatSize& velocity) { 624 const WebFloatSize& velocity) {
627 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); 625 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized);
628 if (!m_page || !m_page->mainFrame() || !m_page->mainFrame()->isLocalFrame() || 626 if (!m_page || !m_page->mainFrame() || !m_page->mainFrame()->isLocalFrame() ||
629 !m_page->deprecatedLocalMainFrame()->view()) 627 !m_page->deprecatedLocalMainFrame()->view())
630 return false; 628 return false;
631 629
632 if (m_flingSourceDevice == WebGestureDeviceTouchpad) { 630 if (m_flingSourceDevice == WebGestureDeviceTouchpad) {
633 WebMouseWheelEvent syntheticWheel; 631 WebMouseWheelEvent syntheticWheel(WebInputEvent::MouseWheel,
632 m_flingModifier,
633 WTF::monotonicallyIncreasingTime());
634 const float tickDivisor = WheelEvent::TickMultiplier; 634 const float tickDivisor = WheelEvent::TickMultiplier;
635 635
636 syntheticWheel.type = WebInputEvent::MouseWheel;
637 syntheticWheel.timeStampSeconds = WTF::monotonicallyIncreasingTime();
638 syntheticWheel.deltaX = delta.width; 636 syntheticWheel.deltaX = delta.width;
639 syntheticWheel.deltaY = delta.height; 637 syntheticWheel.deltaY = delta.height;
640 syntheticWheel.wheelTicksX = delta.width / tickDivisor; 638 syntheticWheel.wheelTicksX = delta.width / tickDivisor;
641 syntheticWheel.wheelTicksY = delta.height / tickDivisor; 639 syntheticWheel.wheelTicksY = delta.height / tickDivisor;
642 syntheticWheel.hasPreciseScrollingDeltas = true; 640 syntheticWheel.hasPreciseScrollingDeltas = true;
643 syntheticWheel.x = m_positionOnFlingStart.x; 641 syntheticWheel.x = m_positionOnFlingStart.x;
644 syntheticWheel.y = m_positionOnFlingStart.y; 642 syntheticWheel.y = m_positionOnFlingStart.y;
645 syntheticWheel.globalX = m_globalPositionOnFlingStart.x; 643 syntheticWheel.globalX = m_globalPositionOnFlingStart.x;
646 syntheticWheel.globalY = m_globalPositionOnFlingStart.y; 644 syntheticWheel.globalY = m_globalPositionOnFlingStart.y;
647 syntheticWheel.modifiers = m_flingModifier;
648 645
649 if (handleMouseWheel(*m_page->deprecatedLocalMainFrame(), syntheticWheel) != 646 if (handleMouseWheel(*m_page->deprecatedLocalMainFrame(), syntheticWheel) !=
650 WebInputEventResult::NotHandled) 647 WebInputEventResult::NotHandled)
651 return true; 648 return true;
652 649
653 // TODO(dtapuska): Remove these GSB/GSE sequences when trackpad latching is 650 // TODO(dtapuska): Remove these GSB/GSE sequences when trackpad latching is
654 // implemented; see crbug.com/526463. 651 // implemented; see crbug.com/526463.
655 WebGestureEvent syntheticScrollBegin = createGestureScrollEventFromFling( 652 WebGestureEvent syntheticScrollBegin = createGestureScrollEventFromFling(
656 WebInputEvent::GestureScrollBegin, WebGestureDeviceTouchpad); 653 WebInputEvent::GestureScrollBegin, WebGestureDeviceTouchpad);
657 syntheticScrollBegin.data.scrollBegin.deltaXHint = delta.width; 654 syntheticScrollBegin.data.scrollBegin.deltaXHint = delta.width;
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 } 928 }
932 929
933 WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent( 930 WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(
934 const WebGestureEvent& pinchEvent) { 931 const WebGestureEvent& pinchEvent) {
935 DCHECK_EQ(pinchEvent.type, WebInputEvent::GesturePinchUpdate); 932 DCHECK_EQ(pinchEvent.type, WebInputEvent::GesturePinchUpdate);
936 933
937 // For pinch gesture events, match typical trackpad behavior on Windows by 934 // For pinch gesture events, match typical trackpad behavior on Windows by
938 // sending fake wheel events with the ctrl modifier set when we see trackpad 935 // sending fake wheel events with the ctrl modifier set when we see trackpad
939 // pinch gestures. Ideally we'd someday get a platform 'pinch' event and 936 // pinch gestures. Ideally we'd someday get a platform 'pinch' event and
940 // send that instead. 937 // send that instead.
941 WebMouseWheelEvent wheelEvent; 938 WebMouseWheelEvent wheelEvent(
942 wheelEvent.type = WebInputEvent::MouseWheel; 939 WebInputEvent::MouseWheel,
943 wheelEvent.timeStampSeconds = pinchEvent.timeStampSeconds; 940 pinchEvent.modifiers | WebInputEvent::ControlKey,
941 pinchEvent.timeStampSeconds);
944 wheelEvent.windowX = wheelEvent.x = pinchEvent.x; 942 wheelEvent.windowX = wheelEvent.x = pinchEvent.x;
945 wheelEvent.windowY = wheelEvent.y = pinchEvent.y; 943 wheelEvent.windowY = wheelEvent.y = pinchEvent.y;
946 wheelEvent.globalX = pinchEvent.globalX; 944 wheelEvent.globalX = pinchEvent.globalX;
947 wheelEvent.globalY = pinchEvent.globalY; 945 wheelEvent.globalY = pinchEvent.globalY;
948 wheelEvent.modifiers = pinchEvent.modifiers | WebInputEvent::ControlKey;
949 wheelEvent.deltaX = 0; 946 wheelEvent.deltaX = 0;
950 947
951 // The function to convert scales to deltaY values is designed to be 948 // The function to convert scales to deltaY values is designed to be
952 // compatible with websites existing use of wheel events, and with existing 949 // compatible with websites existing use of wheel events, and with existing
953 // Windows trackpad behavior. In particular, we want: 950 // Windows trackpad behavior. In particular, we want:
954 // - deltas should accumulate via addition: f(s1*s2)==f(s1)+f(s2) 951 // - deltas should accumulate via addition: f(s1*s2)==f(s1)+f(s2)
955 // - deltas should invert via negation: f(1/s) == -f(s) 952 // - deltas should invert via negation: f(1/s) == -f(s)
956 // - zoom in should be positive: f(s) > 0 iff s > 1 953 // - zoom in should be positive: f(s) > 0 iff s > 1
957 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100 954 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100
958 // - a formula that's relatively easy to use from JavaScript 955 // - a formula that's relatively easy to use from JavaScript
(...skipping 2832 matching lines...) Expand 10 before | Expand all | Expand 10 after
3791 result.setToShadowHostIfInUserAgentShadowRoot(); 3788 result.setToShadowHostIfInUserAgentShadowRoot();
3792 return result; 3789 return result;
3793 } 3790 }
3794 3791
3795 WebHitTestResult WebViewImpl::hitTestResultForTap( 3792 WebHitTestResult WebViewImpl::hitTestResultForTap(
3796 const WebPoint& tapPointWindowPos, 3793 const WebPoint& tapPointWindowPos,
3797 const WebSize& tapArea) { 3794 const WebSize& tapArea) {
3798 if (!m_page->mainFrame()->isLocalFrame()) 3795 if (!m_page->mainFrame()->isLocalFrame())
3799 return HitTestResult(); 3796 return HitTestResult();
3800 3797
3801 WebGestureEvent tapEvent; 3798 WebGestureEvent tapEvent(WebInputEvent::GestureTap,
3799 WebInputEvent::NoModifiers,
3800 WTF::monotonicallyIncreasingTime());
3802 tapEvent.x = tapPointWindowPos.x; 3801 tapEvent.x = tapPointWindowPos.x;
3803 tapEvent.y = tapPointWindowPos.y; 3802 tapEvent.y = tapPointWindowPos.y;
3804 tapEvent.type = WebInputEvent::GestureTap;
3805 // GestureTap is only ever from a touchscreen. 3803 // GestureTap is only ever from a touchscreen.
3806 tapEvent.sourceDevice = WebGestureDeviceTouchscreen; 3804 tapEvent.sourceDevice = WebGestureDeviceTouchscreen;
3807 tapEvent.data.tap.tapCount = 1; 3805 tapEvent.data.tap.tapCount = 1;
3808 tapEvent.data.tap.width = tapArea.width; 3806 tapEvent.data.tap.width = tapArea.width;
3809 tapEvent.data.tap.height = tapArea.height; 3807 tapEvent.data.tap.height = tapArea.height;
3810 3808
3811 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), 3809 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(),
3812 tapEvent); 3810 tapEvent);
3813 3811
3814 HitTestResult result = 3812 HitTestResult result =
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
4214 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4212 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4215 return nullptr; 4213 return nullptr;
4216 return focusedFrame; 4214 return focusedFrame;
4217 } 4215 }
4218 4216
4219 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4217 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4220 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4218 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4221 } 4219 }
4222 4220
4223 } // namespace blink 4221 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698