Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: third_party/WebKit/Source/web/WebPluginContainerImpl.cpp

Issue 2814473003: Fix frame coordinate translation issue with scroll views. (Closed)
Patch Set: Add more zoom tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 PluginView::Trace(visitor); 703 PluginView::Trace(visitor);
704 } 704 }
705 705
706 void WebPluginContainerImpl::HandleMouseEvent(MouseEvent* event) { 706 void WebPluginContainerImpl::HandleMouseEvent(MouseEvent* event) {
707 DCHECK(Parent()->IsFrameView()); 707 DCHECK(Parent()->IsFrameView());
708 708
709 // We cache the parent FrameView here as the plugin widget could be deleted 709 // We cache the parent FrameView here as the plugin widget could be deleted
710 // in the call to HandleEvent. See http://b/issue?id=1362948 710 // in the call to HandleEvent. See http://b/issue?id=1362948
711 FrameView* parent_view = ToFrameView(Parent()); 711 FrameView* parent_view = ToFrameView(Parent());
712 712
713 // TODO(dtapuska): Move WebMouseEventBuilder into the anonymous namespace
714 // in this class.
713 WebMouseEventBuilder transformed_event( 715 WebMouseEventBuilder transformed_event(
714 ToFrameView(Parent()), LayoutItem(element_->GetLayoutObject()), *event); 716 ToFrameView(Parent()), LayoutItem(element_->GetLayoutObject()), *event);
715 if (transformed_event.GetType() == WebInputEvent::kUndefined) 717 if (transformed_event.GetType() == WebInputEvent::kUndefined)
716 return; 718 return;
717 719
718 if (event->type() == EventTypeNames::mousedown) 720 if (event->type() == EventTypeNames::mousedown)
719 FocusPlugin(); 721 FocusPlugin();
720 722
721 WebCursorInfo cursor_info; 723 WebCursorInfo cursor_info;
722 if (web_plugin_ && 724 if (web_plugin_ &&
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 WebPoint drag_screen_location(event->screenX(), event->screenY()); 760 WebPoint drag_screen_location(event->screenX(), event->screenY());
759 WebPoint drag_location(event->AbsoluteLocation().X() - Location().X(), 761 WebPoint drag_location(event->AbsoluteLocation().X() - Location().X(),
760 event->AbsoluteLocation().Y() - Location().Y()); 762 event->AbsoluteLocation().Y() - Location().Y());
761 763
762 web_plugin_->HandleDragStatusUpdate(drag_status, drag_data, 764 web_plugin_->HandleDragStatusUpdate(drag_status, drag_data,
763 drag_operation_mask, drag_location, 765 drag_operation_mask, drag_location,
764 drag_screen_location); 766 drag_screen_location);
765 } 767 }
766 768
767 void WebPluginContainerImpl::HandleWheelEvent(WheelEvent* event) { 769 void WebPluginContainerImpl::HandleWheelEvent(WheelEvent* event) {
768 WebFloatPoint absolute_root_frame_location = 770 WebFloatPoint absolute_location = event->NativeEvent().PositionInRootFrame();
769 event->NativeEvent().PositionInRootFrame(); 771
772 FrameView* view = ToFrameView(Parent());
773 // Translate the root frame position to content coordinates.
774 if (view) {
775 absolute_location = view->RootFrameToContents(absolute_location);
776 }
777
770 IntPoint local_point = 778 IntPoint local_point =
771 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( 779 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal(
772 absolute_root_frame_location, kUseTransforms)); 780 absolute_location, kUseTransforms));
773 WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform(); 781 WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform();
774 translated_event.SetPositionInWidget(local_point.X(), local_point.Y()); 782 translated_event.SetPositionInWidget(local_point.X(), local_point.Y());
775 783
776 WebCursorInfo cursor_info; 784 WebCursorInfo cursor_info;
777 if (web_plugin_->HandleInputEvent(translated_event, cursor_info) != 785 if (web_plugin_->HandleInputEvent(translated_event, cursor_info) !=
778 WebInputEventResult::kNotHandled) 786 WebInputEventResult::kNotHandled)
779 event->SetDefaultHandled(); 787 event->SetDefaultHandled();
780 } 788 }
781 789
782 void WebPluginContainerImpl::HandleKeyboardEvent(KeyboardEvent* event) { 790 void WebPluginContainerImpl::HandleKeyboardEvent(KeyboardEvent* event) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 case kTouchEventRequestTypeRaw: { 831 case kTouchEventRequestTypeRaw: {
824 if (!event->NativeEvent()) 832 if (!event->NativeEvent())
825 return; 833 return;
826 834
827 if (event->type() == EventTypeNames::touchstart) 835 if (event->type() == EventTypeNames::touchstart)
828 FocusPlugin(); 836 FocusPlugin();
829 837
830 WebTouchEvent transformed_event = 838 WebTouchEvent transformed_event =
831 event->NativeEvent()->FlattenTransform(); 839 event->NativeEvent()->FlattenTransform();
832 840
841 FrameView* view = ToFrameView(Parent());
842
833 for (unsigned i = 0; i < transformed_event.touches_length; ++i) { 843 for (unsigned i = 0; i < transformed_event.touches_length; ++i) {
834 WebFloatPoint absolute_root_frame_location = 844 WebFloatPoint absolute_location = transformed_event.touches[i].position;
835 transformed_event.touches[i].position; 845
846 // Translate the root frame position to content coordinates.
847 if (view) {
848 absolute_location = view->RootFrameToContents(absolute_location);
849 }
850
836 IntPoint local_point = 851 IntPoint local_point =
837 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( 852 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal(
838 absolute_root_frame_location, kUseTransforms)); 853 absolute_location, kUseTransforms));
839 transformed_event.touches[i].position.x = local_point.X(); 854 transformed_event.touches[i].position.x = local_point.X();
840 transformed_event.touches[i].position.y = local_point.Y(); 855 transformed_event.touches[i].position.y = local_point.Y();
841 } 856 }
842 857
843 WebCursorInfo cursor_info; 858 WebCursorInfo cursor_info;
844 if (web_plugin_->HandleInputEvent(transformed_event, cursor_info) != 859 if (web_plugin_->HandleInputEvent(transformed_event, cursor_info) !=
845 WebInputEventResult::kNotHandled) 860 WebInputEventResult::kNotHandled)
846 event->SetDefaultHandled(); 861 event->SetDefaultHandled();
847 // FIXME: Can a plugin change the cursor from a touch-event callback? 862 // FIXME: Can a plugin change the cursor from a touch-event callback?
848 return; 863 return;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 ComputeClipRectsForPlugin(element_, window_rect, clip_rect, 1010 ComputeClipRectsForPlugin(element_, window_rect, clip_rect,
996 unobscured_rect); 1011 unobscured_rect);
997 } 1012 }
998 GetPluginOcclusions(element_, this->Parent(), FrameRect(), cut_out_rects); 1013 GetPluginOcclusions(element_, this->Parent(), FrameRect(), cut_out_rects);
999 // Convert to the plugin position. 1014 // Convert to the plugin position.
1000 for (size_t i = 0; i < cut_out_rects.size(); i++) 1015 for (size_t i = 0; i < cut_out_rects.size(); i++)
1001 cut_out_rects[i].Move(-FrameRect().X(), -FrameRect().Y()); 1016 cut_out_rects[i].Move(-FrameRect().X(), -FrameRect().Y());
1002 } 1017 }
1003 1018
1004 } // namespace blink 1019 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698