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