OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 #include "platform/geometry/LayoutRect.h" | 76 #include "platform/geometry/LayoutRect.h" |
77 #include "platform/graphics/GraphicsContext.h" | 77 #include "platform/graphics/GraphicsContext.h" |
78 #include "platform/graphics/GraphicsLayer.h" | 78 #include "platform/graphics/GraphicsLayer.h" |
79 #include "platform/graphics/paint/CullRect.h" | 79 #include "platform/graphics/paint/CullRect.h" |
80 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" | 80 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" |
81 #include "platform/scroll/ScrollAnimatorBase.h" | 81 #include "platform/scroll/ScrollAnimatorBase.h" |
82 #include "platform/scroll/ScrollbarTheme.h" | 82 #include "platform/scroll/ScrollbarTheme.h" |
83 #include "platform/wtf/Assertions.h" | 83 #include "platform/wtf/Assertions.h" |
84 #include "public/platform/Platform.h" | 84 #include "public/platform/Platform.h" |
85 #include "public/platform/WebClipboard.h" | 85 #include "public/platform/WebClipboard.h" |
| 86 #include "public/platform/WebCoalescedInputEvent.h" |
86 #include "public/platform/WebCompositorSupport.h" | 87 #include "public/platform/WebCompositorSupport.h" |
87 #include "public/platform/WebCursorInfo.h" | 88 #include "public/platform/WebCursorInfo.h" |
88 #include "public/platform/WebDragData.h" | 89 #include "public/platform/WebDragData.h" |
89 #include "public/platform/WebExternalTextureLayer.h" | 90 #include "public/platform/WebExternalTextureLayer.h" |
90 #include "public/platform/WebInputEvent.h" | 91 #include "public/platform/WebInputEvent.h" |
91 #include "public/platform/WebRect.h" | 92 #include "public/platform/WebRect.h" |
92 #include "public/platform/WebString.h" | 93 #include "public/platform/WebString.h" |
93 #include "public/platform/WebURL.h" | 94 #include "public/platform/WebURL.h" |
94 #include "public/platform/WebURLError.h" | 95 #include "public/platform/WebURLError.h" |
95 #include "public/platform/WebURLRequest.h" | 96 #include "public/platform/WebURLRequest.h" |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 // in this class. | 710 // in this class. |
710 WebMouseEventBuilder transformed_event( | 711 WebMouseEventBuilder transformed_event( |
711 parent_, LayoutItem(element_->GetLayoutObject()), *event); | 712 parent_, LayoutItem(element_->GetLayoutObject()), *event); |
712 if (transformed_event.GetType() == WebInputEvent::kUndefined) | 713 if (transformed_event.GetType() == WebInputEvent::kUndefined) |
713 return; | 714 return; |
714 | 715 |
715 if (event->type() == EventTypeNames::mousedown) | 716 if (event->type() == EventTypeNames::mousedown) |
716 FocusPlugin(); | 717 FocusPlugin(); |
717 | 718 |
718 WebCursorInfo cursor_info; | 719 WebCursorInfo cursor_info; |
719 if (web_plugin_ && | 720 if (web_plugin_ && web_plugin_->HandleInputEvent( |
720 web_plugin_->HandleInputEvent(transformed_event, cursor_info) != | 721 WebCoalescedInputEvent(transformed_event), |
721 WebInputEventResult::kNotHandled) | 722 cursor_info) != WebInputEventResult::kNotHandled) |
722 event->SetDefaultHandled(); | 723 event->SetDefaultHandled(); |
723 | 724 |
724 // A windowless plugin can change the cursor in response to a mouse move | 725 // A windowless plugin can change the cursor in response to a mouse move |
725 // event. We need to reflect the changed cursor in the frame view as the | 726 // event. We need to reflect the changed cursor in the frame view as the |
726 // mouse is moved in the boundaries of the windowless plugin. | 727 // mouse is moved in the boundaries of the windowless plugin. |
727 Page* page = parent_view->GetFrame().GetPage(); | 728 Page* page = parent_view->GetFrame().GetPage(); |
728 if (!page) | 729 if (!page) |
729 return; | 730 return; |
730 ToChromeClientImpl(page->GetChromeClient()) | 731 ToChromeClientImpl(page->GetChromeClient()) |
731 .SetCursorForPlugin(cursor_info, | 732 .SetCursorForPlugin(cursor_info, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 absolute_location = parent_->RootFrameToContents(absolute_location); | 771 absolute_location = parent_->RootFrameToContents(absolute_location); |
771 } | 772 } |
772 | 773 |
773 IntPoint local_point = | 774 IntPoint local_point = |
774 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( | 775 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( |
775 absolute_location, kUseTransforms)); | 776 absolute_location, kUseTransforms)); |
776 WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform(); | 777 WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform(); |
777 translated_event.SetPositionInWidget(local_point.X(), local_point.Y()); | 778 translated_event.SetPositionInWidget(local_point.X(), local_point.Y()); |
778 | 779 |
779 WebCursorInfo cursor_info; | 780 WebCursorInfo cursor_info; |
780 if (web_plugin_->HandleInputEvent(translated_event, cursor_info) != | 781 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(translated_event), |
| 782 cursor_info) != |
781 WebInputEventResult::kNotHandled) | 783 WebInputEventResult::kNotHandled) |
782 event->SetDefaultHandled(); | 784 event->SetDefaultHandled(); |
783 } | 785 } |
784 | 786 |
785 void WebPluginContainerImpl::HandleKeyboardEvent(KeyboardEvent* event) { | 787 void WebPluginContainerImpl::HandleKeyboardEvent(KeyboardEvent* event) { |
786 WebKeyboardEventBuilder web_event(*event); | 788 WebKeyboardEventBuilder web_event(*event); |
787 if (web_event.GetType() == WebInputEvent::kUndefined) | 789 if (web_event.GetType() == WebInputEvent::kUndefined) |
788 return; | 790 return; |
789 | 791 |
790 if (web_event.GetType() == WebInputEvent::kKeyDown) { | 792 if (web_event.GetType() == WebInputEvent::kKeyDown) { |
(...skipping 16 matching lines...) Expand all Loading... |
807 } | 809 } |
808 } | 810 } |
809 | 811 |
810 // Give the client a chance to issue edit comamnds. | 812 // Give the client a chance to issue edit comamnds. |
811 WebLocalFrameImpl* web_frame = | 813 WebLocalFrameImpl* web_frame = |
812 WebLocalFrameImpl::FromFrame(element_->GetDocument().GetFrame()); | 814 WebLocalFrameImpl::FromFrame(element_->GetDocument().GetFrame()); |
813 if (web_plugin_->SupportsEditCommands()) | 815 if (web_plugin_->SupportsEditCommands()) |
814 web_frame->Client()->HandleCurrentKeyboardEvent(); | 816 web_frame->Client()->HandleCurrentKeyboardEvent(); |
815 | 817 |
816 WebCursorInfo cursor_info; | 818 WebCursorInfo cursor_info; |
817 if (web_plugin_->HandleInputEvent(web_event, cursor_info) != | 819 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(web_event), |
| 820 cursor_info) != |
818 WebInputEventResult::kNotHandled) | 821 WebInputEventResult::kNotHandled) |
819 event->SetDefaultHandled(); | 822 event->SetDefaultHandled(); |
820 } | 823 } |
821 | 824 |
| 825 WebTouchEvent WebPluginContainerImpl::TransformTouchEvent( |
| 826 const WebInputEvent& event) { |
| 827 DCHECK(blink::WebInputEvent::IsTouchEventType(event.GetType())); |
| 828 const WebTouchEvent* touch_event = static_cast<const WebTouchEvent*>(&event); |
| 829 WebTouchEvent transformed_event = touch_event->FlattenTransform(); |
| 830 |
| 831 for (unsigned i = 0; i < transformed_event.touches_length; ++i) { |
| 832 WebFloatPoint absolute_location = transformed_event.touches[i].position; |
| 833 |
| 834 // Translate the root frame position to content coordinates. |
| 835 if (parent_) { |
| 836 absolute_location = parent_->RootFrameToContents(absolute_location); |
| 837 } |
| 838 |
| 839 IntPoint local_point = |
| 840 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( |
| 841 absolute_location, kUseTransforms)); |
| 842 transformed_event.touches[i].position.x = local_point.X(); |
| 843 transformed_event.touches[i].position.y = local_point.Y(); |
| 844 } |
| 845 return transformed_event; |
| 846 } |
| 847 |
| 848 WebCoalescedInputEvent WebPluginContainerImpl::TransformCoalescedTouchEvent( |
| 849 const WebCoalescedInputEvent& coalesced_event) { |
| 850 WebCoalescedInputEvent transformed_event( |
| 851 TransformTouchEvent(coalesced_event.Event())); |
| 852 for (size_t i = 1; i < coalesced_event.CoalescedEventSize(); ++i) { |
| 853 transformed_event.AddCoalescedEvent( |
| 854 TransformTouchEvent(coalesced_event.CoalescedEvent(i))); |
| 855 } |
| 856 return transformed_event; |
| 857 } |
| 858 |
822 void WebPluginContainerImpl::HandleTouchEvent(TouchEvent* event) { | 859 void WebPluginContainerImpl::HandleTouchEvent(TouchEvent* event) { |
823 switch (touch_event_request_type_) { | 860 switch (touch_event_request_type_) { |
824 case kTouchEventRequestTypeNone: | 861 case kTouchEventRequestTypeNone: |
825 return; | 862 return; |
826 case kTouchEventRequestTypeRaw: { | 863 case kTouchEventRequestTypeRaw: { |
827 if (!event->NativeEvent()) | 864 if (!event->NativeEvent()) |
828 return; | 865 return; |
829 | 866 |
830 if (event->type() == EventTypeNames::touchstart) | 867 if (event->type() == EventTypeNames::touchstart) |
831 FocusPlugin(); | 868 FocusPlugin(); |
832 | 869 |
833 WebTouchEvent transformed_event = | 870 WebCoalescedInputEvent transformed_event = |
834 event->NativeEvent()->FlattenTransform(); | 871 TransformCoalescedTouchEvent(*event->NativeEvent()); |
835 | |
836 for (unsigned i = 0; i < transformed_event.touches_length; ++i) { | |
837 WebFloatPoint absolute_location = transformed_event.touches[i].position; | |
838 | |
839 // Translate the root frame position to content coordinates. | |
840 if (parent_) { | |
841 absolute_location = parent_->RootFrameToContents(absolute_location); | |
842 } | |
843 | |
844 IntPoint local_point = | |
845 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( | |
846 absolute_location, kUseTransforms)); | |
847 transformed_event.touches[i].position.x = local_point.X(); | |
848 transformed_event.touches[i].position.y = local_point.Y(); | |
849 } | |
850 | 872 |
851 WebCursorInfo cursor_info; | 873 WebCursorInfo cursor_info; |
852 if (web_plugin_->HandleInputEvent(transformed_event, cursor_info) != | 874 if (web_plugin_->HandleInputEvent(transformed_event, cursor_info) != |
853 WebInputEventResult::kNotHandled) | 875 WebInputEventResult::kNotHandled) |
854 event->SetDefaultHandled(); | 876 event->SetDefaultHandled(); |
855 // FIXME: Can a plugin change the cursor from a touch-event callback? | 877 // FIXME: Can a plugin change the cursor from a touch-event callback? |
856 return; | 878 return; |
857 } | 879 } |
858 case kTouchEventRequestTypeSynthesizedMouse: | 880 case kTouchEventRequestTypeSynthesizedMouse: |
859 SynthesizeMouseEventIfPossible(event); | 881 SynthesizeMouseEventIfPossible(event); |
(...skipping 13 matching lines...) Expand all Loading... |
873 WebFloatPoint absolute_root_frame_location = | 895 WebFloatPoint absolute_root_frame_location = |
874 event->NativeEvent().PositionInRootFrame(); | 896 event->NativeEvent().PositionInRootFrame(); |
875 IntPoint local_point = | 897 IntPoint local_point = |
876 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( | 898 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( |
877 absolute_root_frame_location, kUseTransforms)); | 899 absolute_root_frame_location, kUseTransforms)); |
878 translated_event.FlattenTransform(); | 900 translated_event.FlattenTransform(); |
879 translated_event.x = local_point.X(); | 901 translated_event.x = local_point.X(); |
880 translated_event.y = local_point.Y(); | 902 translated_event.y = local_point.Y(); |
881 | 903 |
882 WebCursorInfo cursor_info; | 904 WebCursorInfo cursor_info; |
883 if (web_plugin_->HandleInputEvent(translated_event, cursor_info) != | 905 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(translated_event), |
| 906 cursor_info) != |
884 WebInputEventResult::kNotHandled) { | 907 WebInputEventResult::kNotHandled) { |
885 event->SetDefaultHandled(); | 908 event->SetDefaultHandled(); |
886 return; | 909 return; |
887 } | 910 } |
888 | 911 |
889 // FIXME: Can a plugin change the cursor from a touch-event callback? | 912 // FIXME: Can a plugin change the cursor from a touch-event callback? |
890 } | 913 } |
891 | 914 |
892 void WebPluginContainerImpl::SynthesizeMouseEventIfPossible(TouchEvent* event) { | 915 void WebPluginContainerImpl::SynthesizeMouseEventIfPossible(TouchEvent* event) { |
893 WebMouseEventBuilder web_event( | 916 WebMouseEventBuilder web_event( |
894 parent_, LayoutItem(element_->GetLayoutObject()), *event); | 917 parent_, LayoutItem(element_->GetLayoutObject()), *event); |
895 if (web_event.GetType() == WebInputEvent::kUndefined) | 918 if (web_event.GetType() == WebInputEvent::kUndefined) |
896 return; | 919 return; |
897 | 920 |
898 WebCursorInfo cursor_info; | 921 WebCursorInfo cursor_info; |
899 if (web_plugin_->HandleInputEvent(web_event, cursor_info) != | 922 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(web_event), |
| 923 cursor_info) != |
900 WebInputEventResult::kNotHandled) | 924 WebInputEventResult::kNotHandled) |
901 event->SetDefaultHandled(); | 925 event->SetDefaultHandled(); |
902 } | 926 } |
903 | 927 |
904 void WebPluginContainerImpl::FocusPlugin() { | 928 void WebPluginContainerImpl::FocusPlugin() { |
905 LocalFrame& containing_frame = parent_->GetFrame(); | 929 LocalFrame& containing_frame = parent_->GetFrame(); |
906 if (Page* current_page = containing_frame.GetPage()) | 930 if (Page* current_page = containing_frame.GetPage()) |
907 current_page->GetFocusController().SetFocusedElement(element_, | 931 current_page->GetFocusController().SetFocusedElement(element_, |
908 &containing_frame); | 932 &containing_frame); |
909 else | 933 else |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 ComputeClipRectsForPlugin(element_, window_rect, clip_rect, | 1027 ComputeClipRectsForPlugin(element_, window_rect, clip_rect, |
1004 unobscured_rect); | 1028 unobscured_rect); |
1005 } | 1029 } |
1006 GetPluginOcclusions(element_, parent_, frame_rect_, cut_out_rects); | 1030 GetPluginOcclusions(element_, parent_, frame_rect_, cut_out_rects); |
1007 // Convert to the plugin position. | 1031 // Convert to the plugin position. |
1008 for (size_t i = 0; i < cut_out_rects.size(); i++) | 1032 for (size_t i = 0; i < cut_out_rects.size(); i++) |
1009 cut_out_rects[i].Move(-frame_rect_.X(), -frame_rect_.Y()); | 1033 cut_out_rects[i].Move(-frame_rect_.X(), -frame_rect_.Y()); |
1010 } | 1034 } |
1011 | 1035 |
1012 } // namespace blink | 1036 } // namespace blink |
OLD | NEW |