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