| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <queue> | 11 #include <queue> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
| 21 #include "base/process_util.h" | 21 #include "base/process_util.h" |
| 22 #include "base/string16.h" | 22 #include "base/string16.h" |
| 23 #include "base/time.h" | 23 #include "base/time.h" |
| 24 #include "base/timer.h" | 24 #include "base/timer.h" |
| 25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 26 #include "cc/debug/latency_info.h" |
| 27 #include "content/browser/renderer_host/event_with_latency_info.h" |
| 26 #include "content/browser/renderer_host/smooth_scroll_gesture_controller.h" | 28 #include "content/browser/renderer_host/smooth_scroll_gesture_controller.h" |
| 27 #include "content/common/view_message_enums.h" | 29 #include "content/common/view_message_enums.h" |
| 28 #include "content/port/common/input_event_ack_state.h" | 30 #include "content/port/common/input_event_ack_state.h" |
| 29 #include "content/public/browser/render_widget_host.h" | 31 #include "content/public/browser/render_widget_host.h" |
| 30 #include "content/public/common/page_zoom.h" | 32 #include "content/public/common/page_zoom.h" |
| 31 #include "ipc/ipc_listener.h" | 33 #include "ipc/ipc_listener.h" |
| 32 #include "ui/base/ime/text_input_type.h" | 34 #include "ui/base/ime/text_input_type.h" |
| 33 #include "ui/gfx/native_widget_types.h" | 35 #include "ui/gfx/native_widget_types.h" |
| 34 | 36 |
| 35 class WebCursor; | 37 class WebCursor; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // Stops all existing hang monitor timeouts and assumes the renderer is | 254 // Stops all existing hang monitor timeouts and assumes the renderer is |
| 253 // responsive. | 255 // responsive. |
| 254 void StopHangMonitorTimeout(); | 256 void StopHangMonitorTimeout(); |
| 255 | 257 |
| 256 // Forwards the given message to the renderer. These are called by the view | 258 // Forwards the given message to the renderer. These are called by the view |
| 257 // when it has received a message. | 259 // when it has received a message. |
| 258 void ForwardGestureEvent(const WebKit::WebGestureEvent& gesture_event); | 260 void ForwardGestureEvent(const WebKit::WebGestureEvent& gesture_event); |
| 259 virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event); | 261 virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event); |
| 260 | 262 |
| 261 // Forwards the given event immediately to the renderer. | 263 // Forwards the given event immediately to the renderer. |
| 262 void ForwardMouseEventImmediately(const WebKit::WebMouseEvent& mouse_event); | 264 void ForwardMouseEventImmediately( |
| 265 const MouseEventWithLatencyInfo& mouse_event); |
| 263 void ForwardTouchEventImmediately(const WebKit::WebTouchEvent& touch_event); | 266 void ForwardTouchEventImmediately(const WebKit::WebTouchEvent& touch_event); |
| 264 void ForwardGestureEventImmediately( | 267 void ForwardGestureEventImmediately( |
| 265 const WebKit::WebGestureEvent& gesture_event); | 268 const GestureEventWithLatencyInfo& gesture_event); |
| 266 | 269 |
| 267 void CancelUpdateTextDirection(); | 270 void CancelUpdateTextDirection(); |
| 268 | 271 |
| 269 // Called when a mouse click/gesture tap activates the renderer. | 272 // Called when a mouse click/gesture tap activates the renderer. |
| 270 virtual void OnPointerEventActivate(); | 273 virtual void OnPointerEventActivate(); |
| 271 | 274 |
| 272 // Notifies the renderer whether or not the input method attached to this | 275 // Notifies the renderer whether or not the input method attached to this |
| 273 // process is activated. | 276 // process is activated. |
| 274 // When the input method is activated, a renderer process sends IPC messages | 277 // When the input method is activated, a renderer process sends IPC messages |
| 275 // to notify the status of its composition node. (This message is mainly used | 278 // to notify the status of its composition node. (This message is mainly used |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 void SetOverscrollControllerEnabled(bool enabled); | 469 void SetOverscrollControllerEnabled(bool enabled); |
| 467 | 470 |
| 468 // Suppreses future char events until a keydown. See | 471 // Suppreses future char events until a keydown. See |
| 469 // suppress_next_char_events_. | 472 // suppress_next_char_events_. |
| 470 void SuppressNextCharEvents(); | 473 void SuppressNextCharEvents(); |
| 471 | 474 |
| 472 // Indicates whether the renderer drives the RenderWidgetHosts's size or the | 475 // Indicates whether the renderer drives the RenderWidgetHosts's size or the |
| 473 // other way around. | 476 // other way around. |
| 474 bool should_auto_resize() { return should_auto_resize_; } | 477 bool should_auto_resize() { return should_auto_resize_; } |
| 475 | 478 |
| 479 void FrameSwapped(const cc::LatencyInfo& latency_info); |
| 480 |
| 481 // Returns the ID that uniquely describes this component to the latency |
| 482 // subsystem. |
| 483 int64 GetLatencyComponentId(); |
| 484 |
| 476 protected: | 485 protected: |
| 477 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE; | 486 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE; |
| 478 | 487 |
| 479 // Transmits the given input event. This is an internal helper for | 488 // Transmits the given input event. This is an internal helper for |
| 480 // |ForwardInputEvent()| and should not be used directly from elsewhere. | 489 // |ForwardInputEvent()| and should not be used directly from elsewhere. |
| 481 void SendInputEvent(const WebKit::WebInputEvent& input_event, | 490 void SendInputEvent(const WebKit::WebInputEvent& input_event, |
| 482 int event_size, bool is_keyboard_shortcut); | 491 int event_size, const cc::LatencyInfo& latency_info, |
| 492 bool is_keyboard_shortcut); |
| 483 | 493 |
| 484 // Internal implementation of the public Forward*Event() methods. | 494 // Internal implementation of the public Forward*Event() methods. |
| 485 void ForwardInputEvent(const WebKit::WebInputEvent& input_event, | 495 void ForwardInputEvent(const WebKit::WebInputEvent& input_event, |
| 486 int event_size, bool is_keyboard_shortcut); | 496 int event_size, const cc::LatencyInfo& latency_info, |
| 497 bool is_keyboard_shortcut); |
| 498 |
| 499 // Internal forwarding implementations that take a LatencyInfo. |
| 500 virtual void ForwardMouseEventWithLatencyInfo( |
| 501 const MouseEventWithLatencyInfo& mouse_event); |
| 502 virtual void ForwardWheelEventWithLatencyInfo( |
| 503 const WebKit::WebMouseWheelEvent& wheel_event, |
| 504 const cc::LatencyInfo& latency_info); |
| 505 |
| 506 // Create a LatencyInfo struct for a new input event that was just received. |
| 507 cc::LatencyInfo NewInputLatencyInfo(); |
| 487 | 508 |
| 488 // Called when we receive a notification indicating that the renderer | 509 // Called when we receive a notification indicating that the renderer |
| 489 // process has gone. This will reset our state so that our state will be | 510 // process has gone. This will reset our state so that our state will be |
| 490 // consistent if a new renderer is created. | 511 // consistent if a new renderer is created. |
| 491 void RendererExited(base::TerminationStatus status, int exit_code); | 512 void RendererExited(base::TerminationStatus status, int exit_code); |
| 492 | 513 |
| 493 // Retrieves an id the renderer can use to refer to its view. | 514 // Retrieves an id the renderer can use to refer to its view. |
| 494 // This is used for various IPC messages, including plugins. | 515 // This is used for various IPC messages, including plugins. |
| 495 gfx::NativeViewId GetNativeViewId() const; | 516 gfx::NativeViewId GetNativeViewId() const; |
| 496 | 517 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 bool waiting_for_screen_rects_ack_; | 763 bool waiting_for_screen_rects_ack_; |
| 743 gfx::Rect last_view_screen_rect_; | 764 gfx::Rect last_view_screen_rect_; |
| 744 gfx::Rect last_window_screen_rect_; | 765 gfx::Rect last_window_screen_rect_; |
| 745 | 766 |
| 746 // True if a mouse move event was sent to the render view and we are waiting | 767 // True if a mouse move event was sent to the render view and we are waiting |
| 747 // for a corresponding InputHostMsg_HandleInputEvent_ACK message. | 768 // for a corresponding InputHostMsg_HandleInputEvent_ACK message. |
| 748 bool mouse_move_pending_; | 769 bool mouse_move_pending_; |
| 749 | 770 |
| 750 // The next mouse move event to send (only non-null while mouse_move_pending_ | 771 // The next mouse move event to send (only non-null while mouse_move_pending_ |
| 751 // is true). | 772 // is true). |
| 752 scoped_ptr<WebKit::WebMouseEvent> next_mouse_move_; | 773 scoped_ptr<MouseEventWithLatencyInfo> next_mouse_move_; |
| 753 | 774 |
| 754 // (Similar to |mouse_move_pending_|.) True if a mouse wheel event was sent | 775 // (Similar to |mouse_move_pending_|.) True if a mouse wheel event was sent |
| 755 // and we are waiting for a corresponding ack. | 776 // and we are waiting for a corresponding ack. |
| 756 bool mouse_wheel_pending_; | 777 bool mouse_wheel_pending_; |
| 757 WebKit::WebMouseWheelEvent current_wheel_event_; | 778 WebKit::WebMouseWheelEvent current_wheel_event_; |
| 758 | 779 |
| 759 typedef std::deque<WebKit::WebMouseWheelEvent> WheelEventQueue; | 780 typedef std::deque<MouseWheelEventWithLatencyInfo> WheelEventQueue; |
| 760 | 781 |
| 761 // (Similar to |next_mouse_move_|.) The next mouse wheel events to send. | 782 // (Similar to |next_mouse_move_|.) The next mouse wheel events to send. |
| 762 // Unlike mouse moves, mouse wheel events received while one is pending are | 783 // Unlike mouse moves, mouse wheel events received while one is pending are |
| 763 // coalesced (by accumulating deltas) if they match the previous event in | 784 // coalesced (by accumulating deltas) if they match the previous event in |
| 764 // modifiers. On the Mac, in particular, mouse wheel events are received at a | 785 // modifiers. On the Mac, in particular, mouse wheel events are received at a |
| 765 // high rate; not waiting for the ack results in jankiness, and using the same | 786 // high rate; not waiting for the ack results in jankiness, and using the same |
| 766 // mechanism as for mouse moves (just dropping old events when multiple ones | 787 // mechanism as for mouse moves (just dropping old events when multiple ones |
| 767 // would be queued) results in very slow scrolling. | 788 // would be queued) results in very slow scrolling. |
| 768 WheelEventQueue coalesced_mouse_wheel_events_; | 789 WheelEventQueue coalesced_mouse_wheel_events_; |
| 769 | 790 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 scoped_ptr<GestureEventFilter> gesture_event_filter_; | 897 scoped_ptr<GestureEventFilter> gesture_event_filter_; |
| 877 scoped_ptr<OverscrollController> overscroll_controller_; | 898 scoped_ptr<OverscrollController> overscroll_controller_; |
| 878 | 899 |
| 879 #if defined(OS_WIN) | 900 #if defined(OS_WIN) |
| 880 std::list<HWND> dummy_windows_for_activation_; | 901 std::list<HWND> dummy_windows_for_activation_; |
| 881 #endif | 902 #endif |
| 882 | 903 |
| 883 // List of callbacks for pending snapshot requests to the renderer. | 904 // List of callbacks for pending snapshot requests to the renderer. |
| 884 std::queue<base::Callback<void(bool, const SkBitmap&)> > pending_snapshots_; | 905 std::queue<base::Callback<void(bool, const SkBitmap&)> > pending_snapshots_; |
| 885 | 906 |
| 907 int64 last_input_number_; |
| 908 |
| 886 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 909 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
| 887 }; | 910 }; |
| 888 | 911 |
| 889 } // namespace content | 912 } // namespace content |
| 890 | 913 |
| 891 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 914 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| OLD | NEW |