OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 5 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 DCHECK(guest_->GetOwnerRenderWidgetHostView()); | 177 DCHECK(guest_->GetOwnerRenderWidgetHostView()); |
178 RenderWidgetHost* embedder = | 178 RenderWidgetHost* embedder = |
179 guest_->GetOwnerRenderWidgetHostView()->GetRenderWidgetHost(); | 179 guest_->GetOwnerRenderWidgetHostView()->GetRenderWidgetHost(); |
180 if (!embedder->GetView()->HasFocus()) | 180 if (!embedder->GetView()->HasFocus()) |
181 embedder->GetView()->Focus(); | 181 embedder->GetView()->Focus(); |
182 | 182 |
183 // With direct routing, the embedder would not know to focus the guest on | 183 // With direct routing, the embedder would not know to focus the guest on |
184 // click. Sends a synthetic event for the focusing side effect. | 184 // click. Sends a synthetic event for the focusing side effect. |
185 // TODO(wjmaclean): When we remove BrowserPlugin, delete this code. | 185 // TODO(wjmaclean): When we remove BrowserPlugin, delete this code. |
186 // http://crbug.com/533069 | 186 // http://crbug.com/533069 |
187 MaybeSendSyntheticTapGesture( | 187 MaybeSendSyntheticTapGesture(event.position, event.screenPosition); |
188 blink::WebFloatPoint(event.x, event.y), | |
189 blink::WebFloatPoint(event.globalX, event.globalY)); | |
190 } | 188 } |
191 host_->ForwardMouseEventWithLatencyInfo(event, latency); | 189 host_->ForwardMouseEventWithLatencyInfo(event, latency); |
192 } | 190 } |
193 | 191 |
194 void RenderWidgetHostViewGuest::ProcessTouchEvent( | 192 void RenderWidgetHostViewGuest::ProcessTouchEvent( |
195 const blink::WebTouchEvent& event, | 193 const blink::WebTouchEvent& event, |
196 const ui::LatencyInfo& latency) { | 194 const ui::LatencyInfo& latency) { |
197 if (event.type() == blink::WebInputEvent::TouchStart) { | 195 if (event.type() == blink::WebInputEvent::TouchStart) { |
198 DCHECK(guest_->GetOwnerRenderWidgetHostView()); | 196 DCHECK(guest_->GetOwnerRenderWidgetHostView()); |
199 RenderWidgetHost* embedder = | 197 RenderWidgetHost* embedder = |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 int browser_plugin_instance_id, | 557 int browser_plugin_instance_id, |
560 const blink::WebInputEvent* event) { | 558 const blink::WebInputEvent* event) { |
561 // WebMouseWheelEvents go into a queue, and may not be forwarded to the | 559 // WebMouseWheelEvents go into a queue, and may not be forwarded to the |
562 // renderer until after this method goes out of scope. Therefore we need to | 560 // renderer until after this method goes out of scope. Therefore we need to |
563 // explicitly remove the additional device scale factor from the coordinates | 561 // explicitly remove the additional device scale factor from the coordinates |
564 // before allowing the event to be queued. | 562 // before allowing the event to be queued. |
565 if (IsUseZoomForDSFEnabled() && | 563 if (IsUseZoomForDSFEnabled() && |
566 event->type() == blink::WebInputEvent::MouseWheel) { | 564 event->type() == blink::WebInputEvent::MouseWheel) { |
567 blink::WebMouseWheelEvent rescaled_event = | 565 blink::WebMouseWheelEvent rescaled_event = |
568 *static_cast<const blink::WebMouseWheelEvent*>(event); | 566 *static_cast<const blink::WebMouseWheelEvent*>(event); |
569 rescaled_event.x /= current_device_scale_factor(); | 567 rescaled_event.position.x /= current_device_scale_factor(); |
570 rescaled_event.y /= current_device_scale_factor(); | 568 rescaled_event.position.y /= current_device_scale_factor(); |
571 rescaled_event.deltaX /= current_device_scale_factor(); | 569 rescaled_event.deltaX /= current_device_scale_factor(); |
572 rescaled_event.deltaY /= current_device_scale_factor(); | 570 rescaled_event.deltaY /= current_device_scale_factor(); |
573 rescaled_event.wheelTicksX /= current_device_scale_factor(); | 571 rescaled_event.wheelTicksX /= current_device_scale_factor(); |
574 rescaled_event.wheelTicksY /= current_device_scale_factor(); | 572 rescaled_event.wheelTicksY /= current_device_scale_factor(); |
575 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); | 573 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
576 host_->ForwardWheelEventWithLatencyInfo(rescaled_event, latency_info); | 574 host_->ForwardWheelEventWithLatencyInfo(rescaled_event, latency_info); |
577 return; | 575 return; |
578 } | 576 } |
579 | 577 |
580 ScopedInputScaleDisabler disable(host_, current_device_scale_factor()); | 578 ScopedInputScaleDisabler disable(host_, current_device_scale_factor()); |
581 if (blink::WebInputEvent::isMouseEventType(event->type())) { | 579 if (blink::WebInputEvent::isMouseEventType(event->type())) { |
582 // The mouse events for BrowserPlugin are modified by all | 580 // The mouse events for BrowserPlugin are modified by all |
583 // the CSS transforms applied on the <object> and embedder. As a result of | 581 // the CSS transforms applied on the <object> and embedder. As a result of |
584 // this, the coordinates passed on to the guest renderer are potentially | 582 // this, the coordinates passed on to the guest renderer are potentially |
585 // incorrect to determine the position of the context menu(they are not the | 583 // incorrect to determine the position of the context menu(they are not the |
586 // actual X, Y of the window). As a hack, we report the last location of a | 584 // actual X, Y of the window). As a hack, we report the last location of a |
587 // right mouse up to the BrowserPluginGuest to inform it of the next | 585 // right mouse up to the BrowserPluginGuest to inform it of the next |
588 // potential location for context menu (BUG=470087). | 586 // potential location for context menu (BUG=470087). |
589 // TODO(ekaramad): Find a better and more fundamental solution. Could the | 587 // TODO(ekaramad): Find a better and more fundamental solution. Could the |
590 // ContextMenuParams be based on global X, Y? | 588 // ContextMenuParams be based on global X, Y? |
591 const blink::WebMouseEvent& mouse_event = | 589 const blink::WebMouseEvent& mouse_event = |
592 static_cast<const blink::WebMouseEvent&>(*event); | 590 static_cast<const blink::WebMouseEvent&>(*event); |
593 // A MouseDown on the ButtonRight could suggest a ContextMenu. | 591 // A MouseDown on the ButtonRight could suggest a ContextMenu. |
594 if (guest_ && mouse_event.type() == blink::WebInputEvent::MouseDown && | 592 if (guest_ && mouse_event.type() == blink::WebInputEvent::MouseDown && |
595 mouse_event.button == blink::WebPointerProperties::Button::Right) | 593 mouse_event.button == blink::WebPointerProperties::Button::Right) |
596 guest_->SetContextMenuPosition( | 594 guest_->SetContextMenuPosition( |
597 gfx::Point(mouse_event.globalX - GetViewBounds().x(), | 595 gfx::Point(mouse_event.screenPosition.x - GetViewBounds().x(), |
598 mouse_event.globalY - GetViewBounds().y())); | 596 mouse_event.screenPosition.y - GetViewBounds().y())); |
599 host_->ForwardMouseEvent(mouse_event); | 597 host_->ForwardMouseEvent(mouse_event); |
600 return; | 598 return; |
601 } | 599 } |
602 | 600 |
603 if (event->type() == blink::WebInputEvent::MouseWheel) { | 601 if (event->type() == blink::WebInputEvent::MouseWheel) { |
604 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); | 602 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
605 host_->ForwardWheelEventWithLatencyInfo( | 603 host_->ForwardWheelEventWithLatencyInfo( |
606 *static_cast<const blink::WebMouseWheelEvent*>(event), latency_info); | 604 *static_cast<const blink::WebMouseWheelEvent*>(event), latency_info); |
607 return; | 605 return; |
608 } | 606 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 host_->ForwardGestureEvent(gesture_event); | 644 host_->ForwardGestureEvent(gesture_event); |
647 return; | 645 return; |
648 } | 646 } |
649 } | 647 } |
650 | 648 |
651 bool RenderWidgetHostViewGuest::HasEmbedderChanged() { | 649 bool RenderWidgetHostViewGuest::HasEmbedderChanged() { |
652 return guest_ && guest_->has_attached_since_surface_set(); | 650 return guest_ && guest_->has_attached_since_surface_set(); |
653 } | 651 } |
654 | 652 |
655 } // namespace content | 653 } // namespace content |
OLD | NEW |