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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp b/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
index 7802cd487bbc30deeef86de85c1bef7fb4cb9b58..7e2ce21ec0814197dc50422702d23ad781750c94 100644
--- a/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
+++ b/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
@@ -710,6 +710,8 @@ void WebPluginContainerImpl::HandleMouseEvent(MouseEvent* event) {
// in the call to HandleEvent. See http://b/issue?id=1362948
FrameView* parent_view = ToFrameView(Parent());
+ // TODO(dtapuska): Move WebMouseEventBuilder into the anonymous namespace
+ // in this class.
WebMouseEventBuilder transformed_event(
ToFrameView(Parent()), LayoutItem(element_->GetLayoutObject()), *event);
if (transformed_event.GetType() == WebInputEvent::kUndefined)
@@ -765,11 +767,17 @@ void WebPluginContainerImpl::HandleDragEvent(MouseEvent* event) {
}
void WebPluginContainerImpl::HandleWheelEvent(WheelEvent* event) {
- WebFloatPoint absolute_root_frame_location =
- event->NativeEvent().PositionInRootFrame();
+ WebFloatPoint absolute_location = event->NativeEvent().PositionInRootFrame();
+
+ FrameView* view = ToFrameView(Parent());
+ // Translate the root frame position to content coordinates.
+ if (view) {
+ absolute_location = view->RootFrameToContents(absolute_location);
+ }
+
IntPoint local_point =
RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal(
- absolute_root_frame_location, kUseTransforms));
+ absolute_location, kUseTransforms));
WebMouseWheelEvent translated_event = event->NativeEvent().FlattenTransform();
translated_event.SetPositionInWidget(local_point.X(), local_point.Y());
@@ -830,12 +838,19 @@ void WebPluginContainerImpl::HandleTouchEvent(TouchEvent* event) {
WebTouchEvent transformed_event =
event->NativeEvent()->FlattenTransform();
+ FrameView* view = ToFrameView(Parent());
+
for (unsigned i = 0; i < transformed_event.touches_length; ++i) {
- WebFloatPoint absolute_root_frame_location =
- transformed_event.touches[i].position;
+ WebFloatPoint absolute_location = transformed_event.touches[i].position;
+
+ // Translate the root frame position to content coordinates.
+ if (view) {
+ absolute_location = view->RootFrameToContents(absolute_location);
+ }
+
IntPoint local_point =
RoundedIntPoint(element_->GetLayoutObject()->AbsoluteToLocal(
- absolute_root_frame_location, kUseTransforms));
+ absolute_location, kUseTransforms));
transformed_event.touches[i].position.x = local_point.X();
transformed_event.touches[i].position.y = local_point.Y();
}

Powered by Google App Engine
This is Rietveld 408576698