Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: content/renderer/render_widget.cc

Issue 62443007: Replace old with new synthetic gesture framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forward declare SyntheticGestureController. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "cc/base/switches.h" 18 #include "cc/base/switches.h"
19 #include "cc/debug/benchmark_instrumentation.h" 19 #include "cc/debug/benchmark_instrumentation.h"
20 #include "cc/output/output_surface.h" 20 #include "cc/output/output_surface.h"
21 #include "cc/trees/layer_tree_host.h" 21 #include "cc/trees/layer_tree_host.h"
22 #include "content/child/npapi/webplugin.h" 22 #include "content/child/npapi/webplugin.h"
23 #include "content/common/gpu/client/context_provider_command_buffer.h" 23 #include "content/common/gpu/client/context_provider_command_buffer.h"
24 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 24 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
25 #include "content/common/gpu/gpu_process_launch_causes.h" 25 #include "content/common/gpu/gpu_process_launch_causes.h"
26 #include "content/common/input/synthetic_gesture_packet.h"
26 #include "content/common/input/web_input_event_traits.h" 27 #include "content/common/input/web_input_event_traits.h"
27 #include "content/common/input_messages.h" 28 #include "content/common/input_messages.h"
28 #include "content/common/swapped_out_messages.h" 29 #include "content/common/swapped_out_messages.h"
29 #include "content/common/view_messages.h" 30 #include "content/common/view_messages.h"
30 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
31 #include "content/renderer/cursor_utils.h" 32 #include "content/renderer/cursor_utils.h"
32 #include "content/renderer/external_popup_menu.h" 33 #include "content/renderer/external_popup_menu.h"
33 #include "content/renderer/gpu/compositor_output_surface.h" 34 #include "content/renderer/gpu/compositor_output_surface.h"
34 #include "content/renderer/gpu/compositor_software_output_device.h" 35 #include "content/renderer/gpu/compositor_software_output_device.h"
35 #include "content/renderer/gpu/delegated_compositor_output_surface.h" 36 #include "content/renderer/gpu/delegated_compositor_output_surface.h"
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 589 }
589 590
590 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { 591 bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
591 bool handled = true; 592 bool handled = true;
592 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) 593 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
593 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) 594 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
594 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, 595 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
595 OnCursorVisibilityChange) 596 OnCursorVisibilityChange)
596 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) 597 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
597 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) 598 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
599 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted,
600 OnSyntheticGestureCompleted)
598 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) 601 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
599 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) 602 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
600 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) 603 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
601 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) 604 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect)
602 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) 605 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
603 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) 606 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
604 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut) 607 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut)
605 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck) 608 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck)
606 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete) 609 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete)
607 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive) 610 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive)
608 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition) 611 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition)
609 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition) 612 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition)
610 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize) 613 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize)
611 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 614 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
612 IPC_MESSAGE_HANDLER(ViewMsg_SyntheticGestureCompleted,
613 OnSyntheticGestureCompleted)
614 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) 615 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
615 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) 616 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
616 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) 617 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
617 #if defined(OS_ANDROID) 618 #if defined(OS_ANDROID)
618 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) 619 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
619 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck) 620 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck)
620 #endif 621 #endif
621 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot) 622 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot)
622 IPC_MESSAGE_HANDLER(ViewMsg_SetBrowserRenderingStats, 623 IPC_MESSAGE_HANDLER(ViewMsg_SetBrowserRenderingStats,
623 OnSetBrowserRenderingStats) 624 OnSetBrowserRenderingStats)
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 1996
1996 // Ask the RenderWidgetHost to initiate close. We could be called from deep 1997 // Ask the RenderWidgetHost to initiate close. We could be called from deep
1997 // in Javascript. If we ask the RendwerWidgetHost to close now, the window 1998 // in Javascript. If we ask the RendwerWidgetHost to close now, the window
1998 // could be closed before the JS finishes executing. So instead, post a 1999 // could be closed before the JS finishes executing. So instead, post a
1999 // message back to the message loop, which won't run until the JS is 2000 // message back to the message loop, which won't run until the JS is
2000 // complete, and then the Close message can be sent. 2001 // complete, and then the Close message can be sent.
2001 base::MessageLoop::current()->PostTask( 2002 base::MessageLoop::current()->PostTask(
2002 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this)); 2003 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this));
2003 } 2004 }
2004 2005
2006 void RenderWidget::QueueSyntheticGesture(
2007 scoped_ptr<SyntheticGestureParams> gesture_params,
2008 const SyntheticGestureCompletionCallback& callback) {
2009 DCHECK(!callback.is_null());
2010
2011 pending_synthetic_gesture_callbacks_.push(callback);
2012
2013 SyntheticGesturePacket gesture_packet;
2014 gesture_packet.set_gesture_params(gesture_params.Pass());
2015
2016 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet));
2017 }
2018
2005 void RenderWidget::Close() { 2019 void RenderWidget::Close() {
2006 if (webwidget_) { 2020 if (webwidget_) {
2007 webwidget_->willCloseLayerTreeView(); 2021 webwidget_->willCloseLayerTreeView();
2008 compositor_.reset(); 2022 compositor_.reset();
2009 webwidget_->close(); 2023 webwidget_->close();
2010 webwidget_ = NULL; 2024 webwidget_ = NULL;
2011 } 2025 }
2012 } 2026 }
2013 2027
2014 WebRect RenderWidget::windowRect() { 2028 WebRect RenderWidget::windowRect() {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 set_next_paint_is_repaint_ack(); 2265 set_next_paint_is_repaint_ack();
2252 if (is_accelerated_compositing_active_ && compositor_) { 2266 if (is_accelerated_compositing_active_ && compositor_) {
2253 compositor_->SetNeedsRedrawRect(gfx::Rect(size_to_paint)); 2267 compositor_->SetNeedsRedrawRect(gfx::Rect(size_to_paint));
2254 } else { 2268 } else {
2255 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); 2269 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height());
2256 didInvalidateRect(repaint_rect); 2270 didInvalidateRect(repaint_rect);
2257 } 2271 }
2258 } 2272 }
2259 2273
2260 void RenderWidget::OnSyntheticGestureCompleted() { 2274 void RenderWidget::OnSyntheticGestureCompleted() {
2261 pending_synthetic_gesture_.Run(); 2275 DCHECK(!pending_synthetic_gesture_callbacks_.empty());
2276
2277 pending_synthetic_gesture_callbacks_.front().Run();
2278 pending_synthetic_gesture_callbacks_.pop();
2262 } 2279 }
2263 2280
2264 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { 2281 void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
2265 if (!webwidget_) 2282 if (!webwidget_)
2266 return; 2283 return;
2267 webwidget_->setTextDirection(direction); 2284 webwidget_->setTextDirection(direction);
2268 } 2285 }
2269 2286
2270 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, 2287 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
2271 const gfx::Rect& window_screen_rect) { 2288 const gfx::Rect& window_screen_rect) {
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
2723 2740
2724 void RenderWidget::OnSetBrowserRenderingStats( 2741 void RenderWidget::OnSetBrowserRenderingStats(
2725 const BrowserRenderingStats& stats) { 2742 const BrowserRenderingStats& stats) {
2726 browser_rendering_stats_ = stats; 2743 browser_rendering_stats_ = stats;
2727 } 2744 }
2728 2745
2729 void RenderWidget::GetBrowserRenderingStats(BrowserRenderingStats* stats) { 2746 void RenderWidget::GetBrowserRenderingStats(BrowserRenderingStats* stats) {
2730 *stats = browser_rendering_stats_; 2747 *stats = browser_rendering_stats_;
2731 } 2748 }
2732 2749
2733 void RenderWidget::BeginSmoothScroll(
2734 bool down,
2735 const SyntheticGestureCompletionCallback& callback,
2736 int pixels_to_scroll,
2737 int mouse_event_x,
2738 int mouse_event_y) {
2739 DCHECK(!callback.is_null());
2740
2741 ViewHostMsg_BeginSmoothScroll_Params params;
2742 params.scroll_down = down;
2743 params.pixels_to_scroll = pixels_to_scroll;
2744 params.mouse_event_x = mouse_event_x;
2745 params.mouse_event_y = mouse_event_y;
2746
2747 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, params));
2748 pending_synthetic_gesture_ = callback;
2749 }
2750
2751 void RenderWidget::BeginPinch(
2752 bool zoom_in,
2753 int pixels_to_move,
2754 int anchor_x,
2755 int anchor_y,
2756 const SyntheticGestureCompletionCallback& callback) {
2757 DCHECK(!callback.is_null());
2758
2759 ViewHostMsg_BeginPinch_Params params;
2760 params.zoom_in = zoom_in;
2761 params.pixels_to_move = pixels_to_move;
2762 params.anchor_x = anchor_x;
2763 params.anchor_y = anchor_y;
2764
2765 Send(new ViewHostMsg_BeginPinch(routing_id_, params));
2766 pending_synthetic_gesture_ = callback;
2767 }
2768
2769 bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) { 2750 bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) {
2770 return false; 2751 return false;
2771 } 2752 }
2772 2753
2773 bool RenderWidget::WillHandleKeyEvent(const blink::WebKeyboardEvent& event) { 2754 bool RenderWidget::WillHandleKeyEvent(const blink::WebKeyboardEvent& event) {
2774 return false; 2755 return false;
2775 } 2756 }
2776 2757
2777 bool RenderWidget::WillHandleGestureEvent( 2758 bool RenderWidget::WillHandleGestureEvent(
2778 const blink::WebGestureEvent& event) { 2759 const blink::WebGestureEvent& event) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 GetURLForGraphicsContext3D(), 2823 GetURLForGraphicsContext3D(),
2843 gpu_channel_host.get(), 2824 gpu_channel_host.get(),
2844 use_echo_for_swap_ack, 2825 use_echo_for_swap_ack,
2845 attributes, 2826 attributes,
2846 false /* bind generates resources */, 2827 false /* bind generates resources */,
2847 limits)); 2828 limits));
2848 return context.Pass(); 2829 return context.Pass();
2849 } 2830 }
2850 2831
2851 } // namespace content 2832 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698