| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #include "platform/geometry/LayoutRect.h" | 78 #include "platform/geometry/LayoutRect.h" |
| 79 #include "platform/graphics/GraphicsContext.h" | 79 #include "platform/graphics/GraphicsContext.h" |
| 80 #include "platform/graphics/GraphicsLayer.h" | 80 #include "platform/graphics/GraphicsLayer.h" |
| 81 #include "platform/graphics/paint/CullRect.h" | 81 #include "platform/graphics/paint/CullRect.h" |
| 82 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" | 82 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" |
| 83 #include "platform/scroll/ScrollAnimatorBase.h" | 83 #include "platform/scroll/ScrollAnimatorBase.h" |
| 84 #include "platform/scroll/ScrollbarTheme.h" | 84 #include "platform/scroll/ScrollbarTheme.h" |
| 85 #include "platform/wtf/Assertions.h" | 85 #include "platform/wtf/Assertions.h" |
| 86 #include "public/platform/Platform.h" | 86 #include "public/platform/Platform.h" |
| 87 #include "public/platform/WebClipboard.h" | 87 #include "public/platform/WebClipboard.h" |
| 88 #include "public/platform/WebCoalescedInputEvent.h" |
| 88 #include "public/platform/WebCompositorSupport.h" | 89 #include "public/platform/WebCompositorSupport.h" |
| 89 #include "public/platform/WebCursorInfo.h" | 90 #include "public/platform/WebCursorInfo.h" |
| 90 #include "public/platform/WebDragData.h" | 91 #include "public/platform/WebDragData.h" |
| 91 #include "public/platform/WebExternalTextureLayer.h" | 92 #include "public/platform/WebExternalTextureLayer.h" |
| 92 #include "public/platform/WebInputEvent.h" | 93 #include "public/platform/WebInputEvent.h" |
| 93 #include "public/platform/WebRect.h" | 94 #include "public/platform/WebRect.h" |
| 94 #include "public/platform/WebString.h" | 95 #include "public/platform/WebString.h" |
| 95 #include "public/platform/WebURL.h" | 96 #include "public/platform/WebURL.h" |
| 96 #include "public/platform/WebURLError.h" | 97 #include "public/platform/WebURLError.h" |
| 97 #include "public/platform/WebURLRequest.h" | 98 #include "public/platform/WebURLRequest.h" |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 // in this class. | 716 // in this class. |
| 716 WebMouseEventBuilder transformed_event( | 717 WebMouseEventBuilder transformed_event( |
| 717 parent_, LayoutItem(element_->GetLayoutObject()), *event); | 718 parent_, LayoutItem(element_->GetLayoutObject()), *event); |
| 718 if (transformed_event.GetType() == WebInputEvent::kUndefined) | 719 if (transformed_event.GetType() == WebInputEvent::kUndefined) |
| 719 return; | 720 return; |
| 720 | 721 |
| 721 if (event->type() == EventTypeNames::mousedown) | 722 if (event->type() == EventTypeNames::mousedown) |
| 722 FocusPlugin(); | 723 FocusPlugin(); |
| 723 | 724 |
| 724 WebCursorInfo cursor_info; | 725 WebCursorInfo cursor_info; |
| 725 if (web_plugin_ && | 726 if (web_plugin_ && web_plugin_->HandleInputEvent( |
| 726 web_plugin_->HandleInputEvent(transformed_event, cursor_info) != | 727 WebCoalescedInputEvent(transformed_event), |
| 727 WebInputEventResult::kNotHandled) | 728 cursor_info) != WebInputEventResult::kNotHandled) |
| 728 event->SetDefaultHandled(); | 729 event->SetDefaultHandled(); |
| 729 | 730 |
| 730 // A windowless plugin can change the cursor in response to a mouse move | 731 // A windowless plugin can change the cursor in response to a mouse move |
| 731 // event. We need to reflect the changed cursor in the frame view as the | 732 // event. We need to reflect the changed cursor in the frame view as the |
| 732 // mouse is moved in the boundaries of the windowless plugin. | 733 // mouse is moved in the boundaries of the windowless plugin. |
| 733 Page* page = parent_view->GetFrame().GetPage(); | 734 Page* page = parent_view->GetFrame().GetPage(); |
| 734 if (!page) | 735 if (!page) |
| 735 return; | 736 return; |
| 736 ToChromeClientImpl(page->GetChromeClient()) | 737 ToChromeClientImpl(page->GetChromeClient()) |
| 737 .SetCursorForPlugin(cursor_info, | 738 .SetCursorForPlugin(cursor_info, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 absolute_location = parent_->RootFrameToContents(absolute_location); | 777 absolute_location = parent_->RootFrameToContents(absolute_location); |
| 777 } | 778 } |
| 778 | 779 |
| 779 IntPoint local_point = | 780 IntPoint local_point = |
| 780 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( | 781 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( |
| 781 absolute_location, kUseTransforms)); | 782 absolute_location, kUseTransforms)); |
| 782 WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform(); | 783 WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform(); |
| 783 translated_event.SetPositionInWidget(local_point.X(), local_point.Y()); | 784 translated_event.SetPositionInWidget(local_point.X(), local_point.Y()); |
| 784 | 785 |
| 785 WebCursorInfo cursor_info; | 786 WebCursorInfo cursor_info; |
| 786 if (web_plugin_->HandleInputEvent(translated_event, cursor_info) != | 787 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(translated_event), |
| 788 cursor_info) != |
| 787 WebInputEventResult::kNotHandled) | 789 WebInputEventResult::kNotHandled) |
| 788 event->SetDefaultHandled(); | 790 event->SetDefaultHandled(); |
| 789 } | 791 } |
| 790 | 792 |
| 791 void WebPluginContainerImpl::HandleKeyboardEvent(KeyboardEvent* event) { | 793 void WebPluginContainerImpl::HandleKeyboardEvent(KeyboardEvent* event) { |
| 792 WebKeyboardEventBuilder web_event(*event); | 794 WebKeyboardEventBuilder web_event(*event); |
| 793 if (web_event.GetType() == WebInputEvent::kUndefined) | 795 if (web_event.GetType() == WebInputEvent::kUndefined) |
| 794 return; | 796 return; |
| 795 | 797 |
| 796 if (web_event.GetType() == WebInputEvent::kKeyDown) { | 798 if (web_event.GetType() == WebInputEvent::kKeyDown) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 813 } | 815 } |
| 814 } | 816 } |
| 815 | 817 |
| 816 // Give the client a chance to issue edit comamnds. | 818 // Give the client a chance to issue edit comamnds. |
| 817 WebLocalFrameImpl* web_frame = | 819 WebLocalFrameImpl* web_frame = |
| 818 WebLocalFrameImpl::FromFrame(element_->GetDocument().GetFrame()); | 820 WebLocalFrameImpl::FromFrame(element_->GetDocument().GetFrame()); |
| 819 if (web_plugin_->SupportsEditCommands()) | 821 if (web_plugin_->SupportsEditCommands()) |
| 820 web_frame->Client()->HandleCurrentKeyboardEvent(); | 822 web_frame->Client()->HandleCurrentKeyboardEvent(); |
| 821 | 823 |
| 822 WebCursorInfo cursor_info; | 824 WebCursorInfo cursor_info; |
| 823 if (web_plugin_->HandleInputEvent(web_event, cursor_info) != | 825 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(web_event), |
| 826 cursor_info) != |
| 824 WebInputEventResult::kNotHandled) | 827 WebInputEventResult::kNotHandled) |
| 825 event->SetDefaultHandled(); | 828 event->SetDefaultHandled(); |
| 826 } | 829 } |
| 827 | 830 |
| 831 WebTouchEvent WebPluginContainerImpl::TransformTouchEvent( |
| 832 const WebInputEvent& event) { |
| 833 DCHECK(blink::WebInputEvent::IsTouchEventType(event.GetType())); |
| 834 const WebTouchEvent* touch_event = static_cast<const WebTouchEvent*>(&event); |
| 835 WebTouchEvent transformed_event = touch_event->FlattenTransform(); |
| 836 |
| 837 for (unsigned i = 0; i < transformed_event.touches_length; ++i) { |
| 838 WebFloatPoint absolute_location = transformed_event.touches[i].position; |
| 839 |
| 840 // Translate the root frame position to content coordinates. |
| 841 if (parent_) { |
| 842 absolute_location = parent_->RootFrameToContents(absolute_location); |
| 843 } |
| 844 |
| 845 IntPoint local_point = |
| 846 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( |
| 847 absolute_location, kUseTransforms)); |
| 848 transformed_event.touches[i].position.x = local_point.X(); |
| 849 transformed_event.touches[i].position.y = local_point.Y(); |
| 850 } |
| 851 return transformed_event; |
| 852 } |
| 853 |
| 854 WebCoalescedInputEvent WebPluginContainerImpl::TransformCoalescedTouchEvent( |
| 855 const WebCoalescedInputEvent& coalesced_event) { |
| 856 WebCoalescedInputEvent transformed_event( |
| 857 TransformTouchEvent(coalesced_event.Event()), |
| 858 std::vector<const WebInputEvent*>()); |
| 859 for (size_t i = 0; i < coalesced_event.CoalescedEventSize(); ++i) { |
| 860 transformed_event.AddCoalescedEvent( |
| 861 TransformTouchEvent(coalesced_event.CoalescedEvent(i))); |
| 862 } |
| 863 return transformed_event; |
| 864 } |
| 865 |
| 828 void WebPluginContainerImpl::HandleTouchEvent(TouchEvent* event) { | 866 void WebPluginContainerImpl::HandleTouchEvent(TouchEvent* event) { |
| 829 switch (touch_event_request_type_) { | 867 switch (touch_event_request_type_) { |
| 830 case kTouchEventRequestTypeNone: | 868 case kTouchEventRequestTypeNone: |
| 831 return; | 869 return; |
| 832 case kTouchEventRequestTypeRaw: { | 870 case kTouchEventRequestTypeRaw: { |
| 833 if (!event->NativeEvent()) | 871 if (!event->NativeEvent()) |
| 834 return; | 872 return; |
| 835 | 873 |
| 836 if (event->type() == EventTypeNames::touchstart) | 874 if (event->type() == EventTypeNames::touchstart) |
| 837 FocusPlugin(); | 875 FocusPlugin(); |
| 838 | 876 |
| 839 WebTouchEvent transformed_event = | 877 WebCoalescedInputEvent transformed_event = |
| 840 event->NativeEvent()->FlattenTransform(); | 878 TransformCoalescedTouchEvent(*event->NativeEvent()); |
| 841 | |
| 842 for (unsigned i = 0; i < transformed_event.touches_length; ++i) { | |
| 843 WebFloatPoint absolute_location = transformed_event.touches[i].position; | |
| 844 | |
| 845 // Translate the root frame position to content coordinates. | |
| 846 if (parent_) { | |
| 847 absolute_location = parent_->RootFrameToContents(absolute_location); | |
| 848 } | |
| 849 | |
| 850 IntPoint local_point = | |
| 851 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( | |
| 852 absolute_location, kUseTransforms)); | |
| 853 transformed_event.touches[i].position.x = local_point.X(); | |
| 854 transformed_event.touches[i].position.y = local_point.Y(); | |
| 855 } | |
| 856 | 879 |
| 857 WebCursorInfo cursor_info; | 880 WebCursorInfo cursor_info; |
| 858 if (web_plugin_->HandleInputEvent(transformed_event, cursor_info) != | 881 if (web_plugin_->HandleInputEvent(transformed_event, cursor_info) != |
| 859 WebInputEventResult::kNotHandled) | 882 WebInputEventResult::kNotHandled) |
| 860 event->SetDefaultHandled(); | 883 event->SetDefaultHandled(); |
| 861 // FIXME: Can a plugin change the cursor from a touch-event callback? | 884 // FIXME: Can a plugin change the cursor from a touch-event callback? |
| 862 return; | 885 return; |
| 863 } | 886 } |
| 864 case kTouchEventRequestTypeSynthesizedMouse: | 887 case kTouchEventRequestTypeSynthesizedMouse: |
| 865 SynthesizeMouseEventIfPossible(event); | 888 SynthesizeMouseEventIfPossible(event); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 879 WebFloatPoint absolute_root_frame_location = | 902 WebFloatPoint absolute_root_frame_location = |
| 880 event->NativeEvent().PositionInRootFrame(); | 903 event->NativeEvent().PositionInRootFrame(); |
| 881 IntPoint local_point = | 904 IntPoint local_point = |
| 882 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( | 905 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( |
| 883 absolute_root_frame_location, kUseTransforms)); | 906 absolute_root_frame_location, kUseTransforms)); |
| 884 translated_event.FlattenTransform(); | 907 translated_event.FlattenTransform(); |
| 885 translated_event.x = local_point.X(); | 908 translated_event.x = local_point.X(); |
| 886 translated_event.y = local_point.Y(); | 909 translated_event.y = local_point.Y(); |
| 887 | 910 |
| 888 WebCursorInfo cursor_info; | 911 WebCursorInfo cursor_info; |
| 889 if (web_plugin_->HandleInputEvent(translated_event, cursor_info) != | 912 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(translated_event), |
| 913 cursor_info) != |
| 890 WebInputEventResult::kNotHandled) { | 914 WebInputEventResult::kNotHandled) { |
| 891 event->SetDefaultHandled(); | 915 event->SetDefaultHandled(); |
| 892 return; | 916 return; |
| 893 } | 917 } |
| 894 | 918 |
| 895 // FIXME: Can a plugin change the cursor from a touch-event callback? | 919 // FIXME: Can a plugin change the cursor from a touch-event callback? |
| 896 } | 920 } |
| 897 | 921 |
| 898 void WebPluginContainerImpl::SynthesizeMouseEventIfPossible(TouchEvent* event) { | 922 void WebPluginContainerImpl::SynthesizeMouseEventIfPossible(TouchEvent* event) { |
| 899 WebMouseEventBuilder web_event( | 923 WebMouseEventBuilder web_event( |
| 900 parent_, LayoutItem(element_->GetLayoutObject()), *event); | 924 parent_, LayoutItem(element_->GetLayoutObject()), *event); |
| 901 if (web_event.GetType() == WebInputEvent::kUndefined) | 925 if (web_event.GetType() == WebInputEvent::kUndefined) |
| 902 return; | 926 return; |
| 903 | 927 |
| 904 WebCursorInfo cursor_info; | 928 WebCursorInfo cursor_info; |
| 905 if (web_plugin_->HandleInputEvent(web_event, cursor_info) != | 929 if (web_plugin_->HandleInputEvent(WebCoalescedInputEvent(web_event), |
| 930 cursor_info) != |
| 906 WebInputEventResult::kNotHandled) | 931 WebInputEventResult::kNotHandled) |
| 907 event->SetDefaultHandled(); | 932 event->SetDefaultHandled(); |
| 908 } | 933 } |
| 909 | 934 |
| 910 void WebPluginContainerImpl::FocusPlugin() { | 935 void WebPluginContainerImpl::FocusPlugin() { |
| 911 LocalFrame& containing_frame = parent_->GetFrame(); | 936 LocalFrame& containing_frame = parent_->GetFrame(); |
| 912 if (Page* current_page = containing_frame.GetPage()) | 937 if (Page* current_page = containing_frame.GetPage()) |
| 913 current_page->GetFocusController().SetFocusedElement(element_, | 938 current_page->GetFocusController().SetFocusedElement(element_, |
| 914 &containing_frame); | 939 &containing_frame); |
| 915 else | 940 else |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 ComputeClipRectsForPlugin(element_, window_rect, clip_rect, | 1034 ComputeClipRectsForPlugin(element_, window_rect, clip_rect, |
| 1010 unobscured_rect); | 1035 unobscured_rect); |
| 1011 } | 1036 } |
| 1012 GetPluginOcclusions(element_, parent_, frame_rect_, cut_out_rects); | 1037 GetPluginOcclusions(element_, parent_, frame_rect_, cut_out_rects); |
| 1013 // Convert to the plugin position. | 1038 // Convert to the plugin position. |
| 1014 for (size_t i = 0; i < cut_out_rects.size(); i++) | 1039 for (size_t i = 0; i < cut_out_rects.size(); i++) |
| 1015 cut_out_rects[i].Move(-frame_rect_.X(), -frame_rect_.Y()); | 1040 cut_out_rects[i].Move(-frame_rect_.X(), -frame_rect_.Y()); |
| 1016 } | 1041 } |
| 1017 | 1042 |
| 1018 } // namespace blink | 1043 } // namespace blink |
| OLD | NEW |