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

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

Issue 79143002: Revert 236254 "Replace old with new synthetic gesture framework." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 | Annotate | Revision Log
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"
27 #include "content/common/input/web_input_event_traits.h" 26 #include "content/common/input/web_input_event_traits.h"
28 #include "content/common/input_messages.h" 27 #include "content/common/input_messages.h"
29 #include "content/common/swapped_out_messages.h" 28 #include "content/common/swapped_out_messages.h"
30 #include "content/common/view_messages.h" 29 #include "content/common/view_messages.h"
31 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
32 #include "content/renderer/cursor_utils.h" 31 #include "content/renderer/cursor_utils.h"
33 #include "content/renderer/external_popup_menu.h" 32 #include "content/renderer/external_popup_menu.h"
34 #include "content/renderer/gpu/compositor_output_surface.h" 33 #include "content/renderer/gpu/compositor_output_surface.h"
35 #include "content/renderer/gpu/compositor_software_output_device.h" 34 #include "content/renderer/gpu/compositor_software_output_device.h"
36 #include "content/renderer/gpu/delegated_compositor_output_surface.h" 35 #include "content/renderer/gpu/delegated_compositor_output_surface.h"
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 588 }
590 589
591 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { 590 bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
592 bool handled = true; 591 bool handled = true;
593 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) 592 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
594 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) 593 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
595 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, 594 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
596 OnCursorVisibilityChange) 595 OnCursorVisibilityChange)
597 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) 596 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
598 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) 597 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
599 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted,
600 OnSyntheticGestureCompleted)
601 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) 598 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
602 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) 599 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
603 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) 600 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
604 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) 601 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect)
605 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) 602 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
606 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) 603 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
607 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut) 604 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut)
608 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck) 605 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck)
609 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete) 606 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete)
610 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive) 607 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive)
611 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition) 608 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition)
612 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition) 609 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition)
613 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize) 610 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize)
614 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 611 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
612 IPC_MESSAGE_HANDLER(ViewMsg_SyntheticGestureCompleted,
613 OnSyntheticGestureCompleted)
615 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) 614 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
616 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) 615 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
617 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) 616 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
618 #if defined(OS_ANDROID) 617 #if defined(OS_ANDROID)
619 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) 618 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
620 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck) 619 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck)
621 #endif 620 #endif
622 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot) 621 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot)
623 IPC_MESSAGE_HANDLER(ViewMsg_SetBrowserRenderingStats, 622 IPC_MESSAGE_HANDLER(ViewMsg_SetBrowserRenderingStats,
624 OnSetBrowserRenderingStats) 623 OnSetBrowserRenderingStats)
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 1995
1997 // Ask the RenderWidgetHost to initiate close. We could be called from deep 1996 // Ask the RenderWidgetHost to initiate close. We could be called from deep
1998 // in Javascript. If we ask the RendwerWidgetHost to close now, the window 1997 // in Javascript. If we ask the RendwerWidgetHost to close now, the window
1999 // could be closed before the JS finishes executing. So instead, post a 1998 // could be closed before the JS finishes executing. So instead, post a
2000 // message back to the message loop, which won't run until the JS is 1999 // message back to the message loop, which won't run until the JS is
2001 // complete, and then the Close message can be sent. 2000 // complete, and then the Close message can be sent.
2002 base::MessageLoop::current()->PostTask( 2001 base::MessageLoop::current()->PostTask(
2003 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this)); 2002 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this));
2004 } 2003 }
2005 2004
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
2019 void RenderWidget::Close() { 2005 void RenderWidget::Close() {
2020 if (webwidget_) { 2006 if (webwidget_) {
2021 webwidget_->willCloseLayerTreeView(); 2007 webwidget_->willCloseLayerTreeView();
2022 compositor_.reset(); 2008 compositor_.reset();
2023 webwidget_->close(); 2009 webwidget_->close();
2024 webwidget_ = NULL; 2010 webwidget_ = NULL;
2025 } 2011 }
2026 } 2012 }
2027 2013
2028 WebRect RenderWidget::windowRect() { 2014 WebRect RenderWidget::windowRect() {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 set_next_paint_is_repaint_ack(); 2251 set_next_paint_is_repaint_ack();
2266 if (is_accelerated_compositing_active_ && compositor_) { 2252 if (is_accelerated_compositing_active_ && compositor_) {
2267 compositor_->SetNeedsRedrawRect(gfx::Rect(size_to_paint)); 2253 compositor_->SetNeedsRedrawRect(gfx::Rect(size_to_paint));
2268 } else { 2254 } else {
2269 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); 2255 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height());
2270 didInvalidateRect(repaint_rect); 2256 didInvalidateRect(repaint_rect);
2271 } 2257 }
2272 } 2258 }
2273 2259
2274 void RenderWidget::OnSyntheticGestureCompleted() { 2260 void RenderWidget::OnSyntheticGestureCompleted() {
2275 DCHECK(!pending_synthetic_gesture_callbacks_.empty()); 2261 pending_synthetic_gesture_.Run();
2276
2277 pending_synthetic_gesture_callbacks_.front().Run();
2278 pending_synthetic_gesture_callbacks_.pop();
2279 } 2262 }
2280 2263
2281 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { 2264 void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
2282 if (!webwidget_) 2265 if (!webwidget_)
2283 return; 2266 return;
2284 webwidget_->setTextDirection(direction); 2267 webwidget_->setTextDirection(direction);
2285 } 2268 }
2286 2269
2287 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, 2270 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect,
2288 const gfx::Rect& window_screen_rect) { 2271 const gfx::Rect& window_screen_rect) {
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 2723
2741 void RenderWidget::OnSetBrowserRenderingStats( 2724 void RenderWidget::OnSetBrowserRenderingStats(
2742 const BrowserRenderingStats& stats) { 2725 const BrowserRenderingStats& stats) {
2743 browser_rendering_stats_ = stats; 2726 browser_rendering_stats_ = stats;
2744 } 2727 }
2745 2728
2746 void RenderWidget::GetBrowserRenderingStats(BrowserRenderingStats* stats) { 2729 void RenderWidget::GetBrowserRenderingStats(BrowserRenderingStats* stats) {
2747 *stats = browser_rendering_stats_; 2730 *stats = browser_rendering_stats_;
2748 } 2731 }
2749 2732
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
2750 bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) { 2769 bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) {
2751 return false; 2770 return false;
2752 } 2771 }
2753 2772
2754 bool RenderWidget::WillHandleKeyEvent(const blink::WebKeyboardEvent& event) { 2773 bool RenderWidget::WillHandleKeyEvent(const blink::WebKeyboardEvent& event) {
2755 return false; 2774 return false;
2756 } 2775 }
2757 2776
2758 bool RenderWidget::WillHandleGestureEvent( 2777 bool RenderWidget::WillHandleGestureEvent(
2759 const blink::WebGestureEvent& event) { 2778 const blink::WebGestureEvent& event) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2823 GetURLForGraphicsContext3D(), 2842 GetURLForGraphicsContext3D(),
2824 gpu_channel_host.get(), 2843 gpu_channel_host.get(),
2825 use_echo_for_swap_ack, 2844 use_echo_for_swap_ack,
2826 attributes, 2845 attributes,
2827 false /* bind generates resources */, 2846 false /* bind generates resources */,
2828 limits)); 2847 limits));
2829 return context.Pass(); 2848 return context.Pass();
2830 } 2849 }
2831 2850
2832 } // namespace content 2851 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/renderer/render_widget.h ('k') | trunk/src/tools/telemetry/telemetry/page/actions/scroll.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698