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