| 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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 gfx::Vector2d offset = | 542 gfx::Vector2d offset = |
| 543 GetViewBounds().origin() - | 543 GetViewBounds().origin() - |
| 544 GetOwnerRenderWidgetHostView()->GetBoundsInRootWindow().origin(); | 544 GetOwnerRenderWidgetHostView()->GetBoundsInRootWindow().origin(); |
| 545 blink::WebGestureEvent gesture_tap_event; | 545 blink::WebGestureEvent gesture_tap_event; |
| 546 gesture_tap_event.sourceDevice = blink::WebGestureDeviceTouchscreen; | 546 gesture_tap_event.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 547 gesture_tap_event.type = blink::WebGestureEvent::GestureTapDown; | 547 gesture_tap_event.type = blink::WebGestureEvent::GestureTapDown; |
| 548 gesture_tap_event.x = position.x + offset.x(); | 548 gesture_tap_event.x = position.x + offset.x(); |
| 549 gesture_tap_event.y = position.y + offset.y(); | 549 gesture_tap_event.y = position.y + offset.y(); |
| 550 gesture_tap_event.globalX = screenPosition.x; | 550 gesture_tap_event.globalX = screenPosition.x; |
| 551 gesture_tap_event.globalY = screenPosition.y; | 551 gesture_tap_event.globalY = screenPosition.y; |
| 552 GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_event, | 552 GetOwnerRenderWidgetHostView()->ProcessGestureEvent( |
| 553 ui::LatencyInfo()); | 553 gesture_tap_event, ui::LatencyInfo(ui::SourceEventType::TOUCH)); |
| 554 gesture_tap_event.type = blink::WebGestureEvent::GestureTapCancel; | 554 gesture_tap_event.type = blink::WebGestureEvent::GestureTapCancel; |
| 555 GetOwnerRenderWidgetHostView()->ProcessGestureEvent(gesture_tap_event, | 555 GetOwnerRenderWidgetHostView()->ProcessGestureEvent( |
| 556 ui::LatencyInfo()); | 556 gesture_tap_event, ui::LatencyInfo(ui::SourceEventType::TOUCH)); |
| 557 } | 557 } |
| 558 } | 558 } |
| 559 | 559 |
| 560 void RenderWidgetHostViewGuest::WheelEventAck( | 560 void RenderWidgetHostViewGuest::WheelEventAck( |
| 561 const blink::WebMouseWheelEvent& event, | 561 const blink::WebMouseWheelEvent& event, |
| 562 InputEventAckState ack_result) { | 562 InputEventAckState ack_result) { |
| 563 if (ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED || | 563 if (ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED || |
| 564 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) { | 564 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) { |
| 565 guest_->ResendEventToEmbedder(event); | 565 guest_->ResendEventToEmbedder(event); |
| 566 } | 566 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 588 if (IsUseZoomForDSFEnabled() && | 588 if (IsUseZoomForDSFEnabled() && |
| 589 event->type == blink::WebInputEvent::MouseWheel) { | 589 event->type == blink::WebInputEvent::MouseWheel) { |
| 590 blink::WebMouseWheelEvent rescaled_event = | 590 blink::WebMouseWheelEvent rescaled_event = |
| 591 *static_cast<const blink::WebMouseWheelEvent*>(event); | 591 *static_cast<const blink::WebMouseWheelEvent*>(event); |
| 592 rescaled_event.x /= current_device_scale_factor(); | 592 rescaled_event.x /= current_device_scale_factor(); |
| 593 rescaled_event.y /= current_device_scale_factor(); | 593 rescaled_event.y /= current_device_scale_factor(); |
| 594 rescaled_event.deltaX /= current_device_scale_factor(); | 594 rescaled_event.deltaX /= current_device_scale_factor(); |
| 595 rescaled_event.deltaY /= current_device_scale_factor(); | 595 rescaled_event.deltaY /= current_device_scale_factor(); |
| 596 rescaled_event.wheelTicksX /= current_device_scale_factor(); | 596 rescaled_event.wheelTicksX /= current_device_scale_factor(); |
| 597 rescaled_event.wheelTicksY /= current_device_scale_factor(); | 597 rescaled_event.wheelTicksY /= current_device_scale_factor(); |
| 598 host_->ForwardWheelEvent(rescaled_event); | 598 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
| 599 host_->ForwardWheelEventWithLatencyInfo(rescaled_event, latency_info); |
| 599 return; | 600 return; |
| 600 } | 601 } |
| 601 | 602 |
| 602 ScopedInputScaleDisabler disable(host_, current_device_scale_factor()); | 603 ScopedInputScaleDisabler disable(host_, current_device_scale_factor()); |
| 603 if (blink::WebInputEvent::isMouseEventType(event->type)) { | 604 if (blink::WebInputEvent::isMouseEventType(event->type)) { |
| 604 // The mouse events for BrowserPlugin are modified by all | 605 // The mouse events for BrowserPlugin are modified by all |
| 605 // the CSS transforms applied on the <object> and embedder. As a result of | 606 // the CSS transforms applied on the <object> and embedder. As a result of |
| 606 // this, the coordinates passed on to the guest renderer are potentially | 607 // this, the coordinates passed on to the guest renderer are potentially |
| 607 // incorrect to determine the position of the context menu(they are not the | 608 // incorrect to determine the position of the context menu(they are not the |
| 608 // actual X, Y of the window). As a hack, we report the last location of a | 609 // actual X, Y of the window). As a hack, we report the last location of a |
| 609 // right mouse up to the BrowserPluginGuest to inform it of the next | 610 // right mouse up to the BrowserPluginGuest to inform it of the next |
| 610 // potential location for context menu (BUG=470087). | 611 // potential location for context menu (BUG=470087). |
| 611 // TODO(ekaramad): Find a better and more fundamental solution. Could the | 612 // TODO(ekaramad): Find a better and more fundamental solution. Could the |
| 612 // ContextMenuParams be based on global X, Y? | 613 // ContextMenuParams be based on global X, Y? |
| 613 const blink::WebMouseEvent& mouse_event = | 614 const blink::WebMouseEvent& mouse_event = |
| 614 static_cast<const blink::WebMouseEvent&>(*event); | 615 static_cast<const blink::WebMouseEvent&>(*event); |
| 615 // A MouseDown on the ButtonRight could suggest a ContextMenu. | 616 // A MouseDown on the ButtonRight could suggest a ContextMenu. |
| 616 if (guest_ && mouse_event.type == blink::WebInputEvent::MouseDown && | 617 if (guest_ && mouse_event.type == blink::WebInputEvent::MouseDown && |
| 617 mouse_event.button == blink::WebPointerProperties::Button::Right) | 618 mouse_event.button == blink::WebPointerProperties::Button::Right) |
| 618 guest_->SetContextMenuPosition( | 619 guest_->SetContextMenuPosition( |
| 619 gfx::Point(mouse_event.globalX - GetViewBounds().x(), | 620 gfx::Point(mouse_event.globalX - GetViewBounds().x(), |
| 620 mouse_event.globalY - GetViewBounds().y())); | 621 mouse_event.globalY - GetViewBounds().y())); |
| 621 host_->ForwardMouseEvent(mouse_event); | 622 host_->ForwardMouseEvent(mouse_event); |
| 622 return; | 623 return; |
| 623 } | 624 } |
| 624 | 625 |
| 625 if (event->type == blink::WebInputEvent::MouseWheel) { | 626 if (event->type == blink::WebInputEvent::MouseWheel) { |
| 626 host_->ForwardWheelEvent( | 627 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
| 627 *static_cast<const blink::WebMouseWheelEvent*>(event)); | 628 host_->ForwardWheelEventWithLatencyInfo( |
| 629 *static_cast<const blink::WebMouseWheelEvent*>(event), latency_info); |
| 628 return; | 630 return; |
| 629 } | 631 } |
| 630 | 632 |
| 631 if (blink::WebInputEvent::isKeyboardEventType(event->type)) { | 633 if (blink::WebInputEvent::isKeyboardEventType(event->type)) { |
| 632 if (!embedder->GetLastKeyboardEvent()) | 634 if (!embedder->GetLastKeyboardEvent()) |
| 633 return; | 635 return; |
| 634 NativeWebKeyboardEvent keyboard_event(*embedder->GetLastKeyboardEvent()); | 636 NativeWebKeyboardEvent keyboard_event(*embedder->GetLastKeyboardEvent()); |
| 635 host_->ForwardKeyboardEvent(keyboard_event); | 637 host_->ForwardKeyboardEvent(keyboard_event); |
| 636 return; | 638 return; |
| 637 } | 639 } |
| 638 | 640 |
| 639 if (blink::WebInputEvent::isTouchEventType(event->type)) { | 641 if (blink::WebInputEvent::isTouchEventType(event->type)) { |
| 640 if (event->type == blink::WebInputEvent::TouchStart && | 642 if (event->type == blink::WebInputEvent::TouchStart && |
| 641 !embedder->GetView()->HasFocus()) { | 643 !embedder->GetView()->HasFocus()) { |
| 642 embedder->GetView()->Focus(); | 644 embedder->GetView()->Focus(); |
| 643 } | 645 } |
| 644 | 646 ui::LatencyInfo latency_info(ui::SourceEventType::TOUCH); |
| 645 host_->ForwardTouchEventWithLatencyInfo( | 647 host_->ForwardTouchEventWithLatencyInfo( |
| 646 *static_cast<const blink::WebTouchEvent*>(event), | 648 *static_cast<const blink::WebTouchEvent*>(event), latency_info); |
| 647 ui::LatencyInfo()); | |
| 648 return; | 649 return; |
| 649 } | 650 } |
| 650 | 651 |
| 651 if (blink::WebInputEvent::isGestureEventType(event->type)) { | 652 if (blink::WebInputEvent::isGestureEventType(event->type)) { |
| 652 const blink::WebGestureEvent& gesture_event = | 653 const blink::WebGestureEvent& gesture_event = |
| 653 *static_cast<const blink::WebGestureEvent*>(event); | 654 *static_cast<const blink::WebGestureEvent*>(event); |
| 654 | 655 |
| 655 // We don't forward inertial GestureScrollUpdates to the guest anymore | 656 // We don't forward inertial GestureScrollUpdates to the guest anymore |
| 656 // since it now receives GestureFlingStart and will have its own fling | 657 // since it now receives GestureFlingStart and will have its own fling |
| 657 // curve generating GestureScrollUpdate events for it. | 658 // curve generating GestureScrollUpdate events for it. |
| 658 // TODO(wjmaclean): Should we try to avoid creating a fling curve in the | 659 // TODO(wjmaclean): Should we try to avoid creating a fling curve in the |
| 659 // embedder renderer in this case? BrowserPlugin can return 'true' for | 660 // embedder renderer in this case? BrowserPlugin can return 'true' for |
| 660 // handleInputEvent() on a GestureFlingStart, and we could use this as | 661 // handleInputEvent() on a GestureFlingStart, and we could use this as |
| 661 // a signal to let the guest handle the fling, though we'd need to be | 662 // a signal to let the guest handle the fling, though we'd need to be |
| 662 // sure other plugins would behave appropriately (i.e. return 'false'). | 663 // sure other plugins would behave appropriately (i.e. return 'false'). |
| 663 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && | 664 if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && |
| 664 gesture_event.data.scrollUpdate.inertialPhase == | 665 gesture_event.data.scrollUpdate.inertialPhase == |
| 665 blink::WebGestureEvent::MomentumPhase) { | 666 blink::WebGestureEvent::MomentumPhase) { |
| 666 return; | 667 return; |
| 667 } | 668 } |
| 668 host_->ForwardGestureEvent(gesture_event); | 669 host_->ForwardGestureEvent(gesture_event); |
| 669 return; | 670 return; |
| 670 } | 671 } |
| 671 } | 672 } |
| 672 | 673 |
| 673 } // namespace content | 674 } // namespace content |
| OLD | NEW |