| 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 std::vector<const WebInputEvent*>()); |
| 853 for (size_t i = 0; i < coalesced_event.CoalescedEventSize(); ++i) { |
| 854 transformed_event.AddCoalescedEvent( |
| 855 TransformTouchEvent(coalesced_event.CoalescedEvent(i))); |
| 856 } |
| 857 return transformed_event; |
| 858 } |
| 859 |
| 822 void WebPluginContainerImpl::HandleTouchEvent(TouchEvent* event) { | 860 void WebPluginContainerImpl::HandleTouchEvent(TouchEvent* event) { |
| 823 switch (touch_event_request_type_) { | 861 switch (touch_event_request_type_) { |
| 824 case kTouchEventRequestTypeNone: | 862 case kTouchEventRequestTypeNone: |
| 825 return; | 863 return; |
| 826 case kTouchEventRequestTypeRaw: { | 864 case kTouchEventRequestTypeRaw: { |
| 827 if (!event->NativeEvent()) | 865 if (!event->NativeEvent()) |
| 828 return; | 866 return; |
| 829 | 867 |
| 830 if (event->type() == EventTypeNames::touchstart) | 868 if (event->type() == EventTypeNames::touchstart) |
| 831 FocusPlugin(); | 869 FocusPlugin(); |
| 832 | 870 |
| 833 WebTouchEvent transformed_event = | 871 WebCoalescedInputEvent transformed_event = |
| 834 event->NativeEvent()->FlattenTransform(); | 872 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 | 873 |
| 851 WebCursorInfo cursor_info; | 874 WebCursorInfo cursor_info; |
| 852 if (web_plugin_->HandleInputEvent(transformed_event, cursor_info) != | 875 if (web_plugin_->HandleInputEvent(transformed_event, cursor_info) != |
| 853 WebInputEventResult::kNotHandled) | 876 WebInputEventResult::kNotHandled) |
| 854 event->SetDefaultHandled(); | 877 event->SetDefaultHandled(); |
| 855 // FIXME: Can a plugin change the cursor from a touch-event callback? | 878 // FIXME: Can a plugin change the cursor from a touch-event callback? |
| 856 return; | 879 return; |
| 857 } | 880 } |
| 858 case kTouchEventRequestTypeSynthesizedMouse: | 881 case kTouchEventRequestTypeSynthesizedMouse: |
| 859 SynthesizeMouseEventIfPossible(event); | 882 SynthesizeMouseEventIfPossible(event); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 873 WebFloatPoint absolute_root_frame_location = | 896 WebFloatPoint absolute_root_frame_location = |
| 874 event->NativeEvent().PositionInRootFrame(); | 897 event->NativeEvent().PositionInRootFrame(); |
| 875 IntPoint local_point = | 898 IntPoint local_point = |
| 876 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( | 899 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( |
| 877 absolute_root_frame_location, kUseTransforms)); | 900 absolute_root_frame_location, kUseTransforms)); |
| 878 translated_event.FlattenTransform(); | 901 translated_event.FlattenTransform(); |
| 879 translated_event.x = local_point.X(); | 902 translated_event.x = local_point.X(); |
| 880 translated_event.y = local_point.Y(); | 903 translated_event.y = local_point.Y(); |
| 881 | 904 |
| 882 WebCursorInfo cursor_info; | 905 WebCursorInfo cursor_info; |
| 883 if (web_plugin_->HandleInputEvent(translated_event, cursor_info) != | 906 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(translated_event), |
| 907 cursor_info) != |
| 884 WebInputEventResult::kNotHandled) { | 908 WebInputEventResult::kNotHandled) { |
| 885 event->SetDefaultHandled(); | 909 event->SetDefaultHandled(); |
| 886 return; | 910 return; |
| 887 } | 911 } |
| 888 | 912 |
| 889 // FIXME: Can a plugin change the cursor from a touch-event callback? | 913 // FIXME: Can a plugin change the cursor from a touch-event callback? |
| 890 } | 914 } |
| 891 | 915 |
| 892 void WebPluginContainerImpl::SynthesizeMouseEventIfPossible(TouchEvent* event) { | 916 void WebPluginContainerImpl::SynthesizeMouseEventIfPossible(TouchEvent* event) { |
| 893 WebMouseEventBuilder web_event( | 917 WebMouseEventBuilder web_event( |
| 894 parent_, LayoutItem(element_->GetLayoutObject()), *event); | 918 parent_, LayoutItem(element_->GetLayoutObject()), *event); |
| 895 if (web_event.GetType() == WebInputEvent::kUndefined) | 919 if (web_event.GetType() == WebInputEvent::kUndefined) |
| 896 return; | 920 return; |
| 897 | 921 |
| 898 WebCursorInfo cursor_info; | 922 WebCursorInfo cursor_info; |
| 899 if (web_plugin_->HandleInputEvent(web_event, cursor_info) != | 923 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(web_event), |
| 924 cursor_info) != |
| 900 WebInputEventResult::kNotHandled) | 925 WebInputEventResult::kNotHandled) |
| 901 event->SetDefaultHandled(); | 926 event->SetDefaultHandled(); |
| 902 } | 927 } |
| 903 | 928 |
| 904 void WebPluginContainerImpl::FocusPlugin() { | 929 void WebPluginContainerImpl::FocusPlugin() { |
| 905 LocalFrame& containing_frame = parent_->GetFrame(); | 930 LocalFrame& containing_frame = parent_->GetFrame(); |
| 906 if (Page* current_page = containing_frame.GetPage()) | 931 if (Page* current_page = containing_frame.GetPage()) |
| 907 current_page->GetFocusController().SetFocusedElement(element_, | 932 current_page->GetFocusController().SetFocusedElement(element_, |
| 908 &containing_frame); | 933 &containing_frame); |
| 909 else | 934 else |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 ComputeClipRectsForPlugin(element_, window_rect, clip_rect, | 1028 ComputeClipRectsForPlugin(element_, window_rect, clip_rect, |
| 1004 unobscured_rect); | 1029 unobscured_rect); |
| 1005 } | 1030 } |
| 1006 GetPluginOcclusions(element_, parent_, frame_rect_, cut_out_rects); | 1031 GetPluginOcclusions(element_, parent_, frame_rect_, cut_out_rects); |
| 1007 // Convert to the plugin position. | 1032 // Convert to the plugin position. |
| 1008 for (size_t i = 0; i < cut_out_rects.size(); i++) | 1033 for (size_t i = 0; i < cut_out_rects.size(); i++) |
| 1009 cut_out_rects[i].Move(-frame_rect_.X(), -frame_rect_.Y()); | 1034 cut_out_rects[i].Move(-frame_rect_.X(), -frame_rect_.Y()); |
| 1010 } | 1035 } |
| 1011 | 1036 |
| 1012 } // namespace blink | 1037 } // namespace blink |
| OLD | NEW |