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