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

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 unittest 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_root_frame_location =
bokan 2017/04/12 17:28:44 This (and below) should now be called absolute_loc
dtapuska 2017/04/12 19:02:56 Done.
769 event->NativeEvent().PositionInRootFrame(); 771 event->NativeEvent().PositionInRootFrame();
772
773 FrameView* view = ToFrameView(Parent());
774 // Translate the root frame position to content coordinates.
775 if (view) {
776 absolute_root_frame_location =
777 view->RootFrameToContents(absolute_root_frame_location);
778 }
779
770 IntPoint local_point = 780 IntPoint local_point =
771 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( 781 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal(
772 absolute_root_frame_location, kUseTransforms)); 782 absolute_root_frame_location, kUseTransforms));
773 WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform(); 783 WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform();
774 translated_event.SetPositionInWidget(local_point.X(), local_point.Y()); 784 translated_event.SetPositionInWidget(local_point.X(), local_point.Y());
775 785
776 WebCursorInfo cursor_info; 786 WebCursorInfo cursor_info;
777 if (web_plugin_->HandleInputEvent(translated_event, cursor_info) != 787 if (web_plugin_->HandleInputEvent(translated_event, cursor_info) !=
778 WebInputEventResult::kNotHandled) 788 WebInputEventResult::kNotHandled)
779 event->SetDefaultHandled(); 789 event->SetDefaultHandled();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 case kTouchEventRequestTypeRaw: { 833 case kTouchEventRequestTypeRaw: {
824 if (!event->NativeEvent()) 834 if (!event->NativeEvent())
825 return; 835 return;
826 836
827 if (event->type() == EventTypeNames::touchstart) 837 if (event->type() == EventTypeNames::touchstart)
828 FocusPlugin(); 838 FocusPlugin();
829 839
830 WebTouchEvent transformed_event = 840 WebTouchEvent transformed_event =
831 event->NativeEvent()->FlattenTransform(); 841 event->NativeEvent()->FlattenTransform();
832 842
843 FrameView* view = ToFrameView(Parent());
844
833 for (unsigned i = 0; i < transformed_event.touches_length; ++i) { 845 for (unsigned i = 0; i < transformed_event.touches_length; ++i) {
834 WebFloatPoint absolute_root_frame_location = 846 WebFloatPoint absolute_root_frame_location =
835 transformed_event.touches[i].position; 847 transformed_event.touches[i].position;
848
849 // Translate the root frame position to content coordinates.
850 if (view) {
851 absolute_root_frame_location =
852 view->RootFrameToContents(absolute_root_frame_location);
853 }
854
836 IntPoint local_point = 855 IntPoint local_point =
837 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal( 856 RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal(
838 absolute_root_frame_location, kUseTransforms)); 857 absolute_root_frame_location, kUseTransforms));
839 transformed_event.touches[i].position.x = local_point.X(); 858 transformed_event.touches[i].position.x = local_point.X();
840 transformed_event.touches[i].position.y = local_point.Y(); 859 transformed_event.touches[i].position.y = local_point.Y();
841 } 860 }
842 861
843 WebCursorInfo cursor_info; 862 WebCursorInfo cursor_info;
844 if (web_plugin_->HandleInputEvent(transformed_event, cursor_info) != 863 if (web_plugin_->HandleInputEvent(transformed_event, cursor_info) !=
845 WebInputEventResult::kNotHandled) 864 WebInputEventResult::kNotHandled)
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 ComputeClipRectsForPlugin(element_, window_rect, clip_rect, 1014 ComputeClipRectsForPlugin(element_, window_rect, clip_rect,
996 unobscured_rect); 1015 unobscured_rect);
997 } 1016 }
998 GetPluginOcclusions(element_, this->Parent(), FrameRect(), cut_out_rects); 1017 GetPluginOcclusions(element_, this->Parent(), FrameRect(), cut_out_rects);
999 // Convert to the plugin position. 1018 // Convert to the plugin position.
1000 for (size_t i = 0; i < cut_out_rects.size(); i++) 1019 for (size_t i = 0; i < cut_out_rects.size(); i++)
1001 cut_out_rects[i].Move(-FrameRect().X(), -FrameRect().Y()); 1020 cut_out_rects[i].Move(-FrameRect().X(), -FrameRect().Y());
1002 } 1021 }
1003 1022
1004 } // namespace blink 1023 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698