OLD | NEW |
---|---|
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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
680 return handleGestureEvent(syntheticGestureEvent); | 680 return handleGestureEvent(syntheticGestureEvent); |
681 } | 681 } |
682 return false; | 682 return false; |
683 } | 683 } |
684 | 684 |
685 bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) | 685 bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) |
686 { | 686 { |
687 if (!m_client) | 687 if (!m_client) |
688 return false; | 688 return false; |
689 | 689 |
690 | |
690 bool eventSwallowed = false; | 691 bool eventSwallowed = false; |
691 bool eventCancelled = false; // for disambiguation | 692 bool eventCancelled = false; // for disambiguation |
692 | 693 |
693 // Special handling for slow-path fling gestures. | 694 // Special handling for slow-path fling gestures. |
694 switch (event.type) { | 695 switch (event.type) { |
695 case WebInputEvent::GestureFlingStart: { | 696 case WebInputEvent::GestureFlingStart: { |
696 if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures ()) | 697 if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures ()) |
697 break; | 698 break; |
698 endActiveFlingAnimation(); | 699 endActiveFlingAnimation(); |
699 m_client->cancelScheduledContentIntents(); | 700 m_client->cancelScheduledContentIntents(); |
700 m_positionOnFlingStart = WebPoint(event.x, event.y); | 701 m_positionOnFlingStart = WebPoint(event.x, event.y); |
701 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); | 702 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); |
702 m_flingModifier = event.modifiers; | 703 m_flingModifier = event.modifiers; |
703 m_flingSourceDevice = event.sourceDevice; | 704 m_flingSourceDevice = event.sourceDevice; |
704 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->creat eFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.vel ocityX, event.data.flingStart.velocityY), WebSize())); | 705 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->creat eFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.vel ocityX, event.data.flingStart.velocityY), WebSize())); |
705 ASSERT(flingCurve); | 706 ASSERT(flingCurve); |
706 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(f lingCurve.release(), this); | 707 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(f lingCurve.release(), this); |
707 scheduleAnimation(); | 708 scheduleAnimation(); |
708 eventSwallowed = true; | 709 eventSwallowed = true; |
709 | 710 |
711 // Plugins may need to see GestureFlingStart to balance | |
712 // GestureScrollBegin (since the former replaces GestureScrollEnd when | |
713 // transitioning to a fling). | |
714 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event); | |
715 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent(platfo rmEvent); | |
716 | |
710 m_client->didHandleGestureEvent(event, eventCancelled); | 717 m_client->didHandleGestureEvent(event, eventCancelled); |
711 return eventSwallowed; | 718 return eventSwallowed; |
712 } | 719 } |
713 case WebInputEvent::GestureFlingCancel: | 720 case WebInputEvent::GestureFlingCancel: |
714 if (endActiveFlingAnimation()) | 721 if (endActiveFlingAnimation()) |
715 eventSwallowed = true; | 722 eventSwallowed = true; |
716 | 723 |
717 m_client->didHandleGestureEvent(event, eventCancelled); | 724 m_client->didHandleGestureEvent(event, eventCancelled); |
718 return eventSwallowed; | 725 return eventSwallowed; |
719 default: | 726 default: |
(...skipping 18 matching lines...) Expand all Loading... | |
738 case WebInputEvent::GestureScrollBegin: | 745 case WebInputEvent::GestureScrollBegin: |
739 m_client->cancelScheduledContentIntents(); | 746 m_client->cancelScheduledContentIntents(); |
740 case WebInputEvent::GestureScrollEnd: | 747 case WebInputEvent::GestureScrollEnd: |
741 case WebInputEvent::GestureScrollUpdate: | 748 case WebInputEvent::GestureScrollUpdate: |
742 case WebInputEvent::GestureFlingStart: | 749 case WebInputEvent::GestureFlingStart: |
743 // Scrolling-related gesture events invoke EventHandler recursively for each frame down | 750 // Scrolling-related gesture events invoke EventHandler recursively for each frame down |
744 // the chain, doing a single-frame hit-test per frame. This matches hand leWheelEvent. | 751 // the chain, doing a single-frame hit-test per frame. This matches hand leWheelEvent. |
745 // Perhaps we could simplify things by rewriting scroll handling to work inner frame | 752 // Perhaps we could simplify things by rewriting scroll handling to work inner frame |
746 // out, and then unify with other gesture events. | 753 // out, and then unify with other gesture events. |
747 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureS crollEvent(platformEvent); | 754 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureS crollEvent(platformEvent); |
755 if (event.type == WebInputEvent::GestureFlingStart) | |
tdresser
2015/09/11 15:25:20
Is the indentation here a little off?
wjmaclean
2015/09/11 15:31:01
Ooops, you're right ... will fix this in the next
wjmaclean
2015/09/11 15:37:23
Actually, I don't think this should even be here .
| |
748 m_client->didHandleGestureEvent(event, eventCancelled); | 756 m_client->didHandleGestureEvent(event, eventCancelled); |
749 return eventSwallowed; | 757 return eventSwallowed; |
750 case WebInputEvent::GesturePinchBegin: | 758 case WebInputEvent::GesturePinchBegin: |
751 case WebInputEvent::GesturePinchEnd: | 759 case WebInputEvent::GesturePinchEnd: |
752 case WebInputEvent::GesturePinchUpdate: | 760 case WebInputEvent::GesturePinchUpdate: |
753 return false; | 761 return false; |
754 default: | 762 default: |
755 break; | 763 break; |
756 } | 764 } |
757 | 765 |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1857 // Create synthetic wheel events as necessary for fling. | 1865 // Create synthetic wheel events as necessary for fling. |
1858 if (m_gestureAnimation) { | 1866 if (m_gestureAnimation) { |
1859 if (m_gestureAnimation->animate(validFrameTime.lastFrameTimeMonotonic)) | 1867 if (m_gestureAnimation->animate(validFrameTime.lastFrameTimeMonotonic)) |
1860 scheduleAnimation(); | 1868 scheduleAnimation(); |
1861 else { | 1869 else { |
1862 endActiveFlingAnimation(); | 1870 endActiveFlingAnimation(); |
1863 | 1871 |
1864 PlatformGestureEvent endScrollEvent(PlatformEvent::GestureScrollEnd, | 1872 PlatformGestureEvent endScrollEvent(PlatformEvent::GestureScrollEnd, |
1865 m_positionOnFlingStart, m_globalPositionOnFlingStart, | 1873 m_positionOnFlingStart, m_globalPositionOnFlingStart, |
1866 IntSize(), 0, false, false, false, false); | 1874 IntSize(), 0, false, false, false, false); |
1867 endScrollEvent.setScrollGestureData(0, 0, 0, 0, true, false); | 1875 endScrollEvent.setScrollGestureData(0, 0, 0, 0, true, false, 0); |
1868 | 1876 |
1869 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEnd(endS crollEvent); | 1877 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEnd(endS crollEvent); |
1870 } | 1878 } |
1871 } | 1879 } |
1872 | 1880 |
1873 if (!m_page) | 1881 if (!m_page) |
1874 return; | 1882 return; |
1875 | 1883 |
1876 // FIXME: This should probably be using the local root? | 1884 // FIXME: This should probably be using the local root? |
1877 if (m_page->mainFrame()->isLocalFrame()) | 1885 if (m_page->mainFrame()->isLocalFrame()) |
(...skipping 2533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4411 if (m_pageColorOverlay) | 4419 if (m_pageColorOverlay) |
4412 m_pageColorOverlay->update(); | 4420 m_pageColorOverlay->update(); |
4413 if (InspectorOverlayImpl* overlay = inspectorOverlay()) { | 4421 if (InspectorOverlayImpl* overlay = inspectorOverlay()) { |
4414 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); | 4422 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); |
4415 if (inspectorPageOverlay) | 4423 if (inspectorPageOverlay) |
4416 inspectorPageOverlay->update(); | 4424 inspectorPageOverlay->update(); |
4417 } | 4425 } |
4418 } | 4426 } |
4419 | 4427 |
4420 } // namespace blink | 4428 } // namespace blink |
OLD | NEW |