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

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

Issue 19220002: [WIP] BufferedInputRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix client assignment Created 7 years, 3 months 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return SynchronousCompositorFactory::GetInstance() != NULL; 366 return SynchronousCompositorFactory::GetInstance() != NULL;
367 #else 367 #else
368 return false; 368 return false;
369 #endif 369 #endif
370 } 370 }
371 371
372 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { 372 bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
373 bool handled = true; 373 bool handled = true;
374 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) 374 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
375 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) 375 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
376 IPC_MESSAGE_HANDLER(InputMsg_HandleEventPacket, OnHandleEventPacket)
376 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, 377 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
377 OnCursorVisibilityChange) 378 OnCursorVisibilityChange)
378 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) 379 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
379 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) 380 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
380 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) 381 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
381 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) 382 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
382 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) 383 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize)
383 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) 384 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect)
384 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) 385 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
385 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) 386 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 // generated it. 805 // generated it.
805 if (!animation_update_pending_ && !paint_aggregator_.HasPendingUpdate()) { 806 if (!animation_update_pending_ && !paint_aggregator_.HasPendingUpdate()) {
806 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); 807 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate");
807 return; 808 return;
808 } 809 }
809 810
810 // Continue painting if necessary... 811 // Continue painting if necessary...
811 DoDeferredUpdateAndSendInputAck(); 812 DoDeferredUpdateAndSendInputAck();
812 } 813 }
813 814
814 void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event, 815 InputEventDisposition RenderWidget::HandleWebEvent(
815 const ui::LatencyInfo& latency_info, 816 const WebKit::WebInputEvent* input_event,
816 bool is_keyboard_shortcut) { 817 const ui::LatencyInfo& latency_info,
818 bool is_keyboard_shortcut,
819 bool send_ack) {
817 handling_input_event_ = true; 820 handling_input_event_ = true;
818 if (!input_event) { 821 if (!input_event) {
819 handling_input_event_ = false; 822 handling_input_event_ = false;
820 return; 823 return INPUT_EVENT_COULD_NOT_DELIVER;
821 } 824 }
822 825
823 const char* const event_name = GetEventName(input_event->type); 826 const char* const event_name = GetEventName(input_event->type);
824 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent", 827 TRACE_EVENT1("renderer", "RenderWidget::HandleInputEvent",
825 "event", event_name); 828 "event", event_name);
826 829
827 if (compositor_) 830 if (compositor_)
828 compositor_->SetLatencyInfo(latency_info); 831 compositor_->SetLatencyInfo(latency_info);
829 else 832 else
830 latency_info_.MergeWith(latency_info); 833 latency_info_.MergeWith(latency_info);
831 834
832 base::TimeDelta now = base::TimeDelta::FromInternalValue( 835 base::TimeDelta now = base::TimeDelta::FromInternalValue(
833 base::TimeTicks::Now().ToInternalValue()); 836 base::TimeTicks::Now().ToInternalValue());
834 837
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 InputEventAckState ack_result = processed ? 889 InputEventAckState ack_result = processed ?
887 INPUT_EVENT_ACK_STATE_CONSUMED : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 890 INPUT_EVENT_ACK_STATE_CONSUMED : INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
888 if (!processed && input_event->type == WebInputEvent::TouchStart) { 891 if (!processed && input_event->type == WebInputEvent::TouchStart) {
889 const WebTouchEvent& touch_event = 892 const WebTouchEvent& touch_event =
890 *static_cast<const WebTouchEvent*>(input_event); 893 *static_cast<const WebTouchEvent*>(input_event);
891 ack_result = HasTouchEventHandlersAt(touch_event.touches[0].position) ? 894 ack_result = HasTouchEventHandlersAt(touch_event.touches[0].position) ?
892 INPUT_EVENT_ACK_STATE_NOT_CONSUMED : 895 INPUT_EVENT_ACK_STATE_NOT_CONSUMED :
893 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; 896 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
894 } 897 }
895 898
896 IPC::Message* response = 899 if (send_ack) {
897 new InputHostMsg_HandleInputEvent_ACK(routing_id_, 900 IPC::Message* response =
898 input_event->type, 901 new InputHostMsg_HandleInputEvent_ACK(routing_id_,
899 ack_result, 902 input_event->type,
900 latency_info); 903 ack_result,
901 bool event_type_gets_rate_limited = 904 latency_info);
902 input_event->type == WebInputEvent::MouseMove ||
903 input_event->type == WebInputEvent::MouseWheel ||
904 WebInputEvent::isTouchEventType(input_event->type);
905 905
906 bool frame_pending = paint_aggregator_.HasPendingUpdate(); 906 bool event_type_gets_rate_limited =
907 if (is_accelerated_compositing_active_) { 907 input_event->type == WebInputEvent::MouseMove ||
908 frame_pending = compositor_ && 908 input_event->type == WebInputEvent::MouseWheel ||
909 compositor_->commitRequested(); 909 WebInputEvent::isTouchEventType(input_event->type);
910 }
911 910
912 if (event_type_gets_rate_limited && frame_pending && !is_hidden_) { 911 bool frame_pending = paint_aggregator_.HasPendingUpdate();
913 // We want to rate limit the input events in this case, so we'll wait for 912 if (is_accelerated_compositing_active_) {
914 // painting to finish before ACKing this message. 913 frame_pending = compositor_ &&
915 if (pending_input_event_ack_) { 914 compositor_->commitRequested();
916 // As two different kinds of events could cause us to postpone an ack
917 // we send it now, if we have one pending. The Browser should never
918 // send us the same kind of event we are delaying the ack for.
919 Send(pending_input_event_ack_.release());
920 } 915 }
921 pending_input_event_ack_.reset(response); 916
922 if (compositor_) 917 if (event_type_gets_rate_limited && frame_pending && !is_hidden_) {
923 compositor_->NotifyInputThrottledUntilCommit(); 918 // We want to rate limit the input events in this case, so we'll wait for
924 } else { 919 // painting to finish before ACKing this message.
925 Send(response); 920 if (pending_input_event_ack_) {
921 // As two different kinds of events could cause us to postpone an ack
922 // we send it now, if we have one pending. The Browser should never
923 // send us the same kind of event we are delaying the ack for.
924 Send(pending_input_event_ack_.release());
925 }
926 pending_input_event_ack_.reset(response);
927 if (compositor_)
928 compositor_->NotifyInputThrottledUntilCommit();
929 } else {
930 Send(response);
931 }
926 } 932 }
927 933
928 #if defined(OS_ANDROID) 934 #if defined(OS_ANDROID)
929 // Allow the IME to be shown when the focus changes as a consequence 935 // Allow the IME to be shown when the focus changes as a consequence
930 // of a processed touch end event. 936 // of a processed touch end event.
931 if (input_event->type == WebInputEvent::TouchEnd && processed) 937 if (input_event->type == WebInputEvent::TouchEnd && processed)
932 UpdateTextInputState(true, true); 938 UpdateTextInputState(true, true);
933 #endif 939 #endif
934 940
935 handling_input_event_ = false; 941 handling_input_event_ = false;
936 942
937 if (!prevent_default) { 943 if (!prevent_default) {
938 if (WebInputEvent::isKeyboardEventType(input_event->type)) 944 if (WebInputEvent::isKeyboardEventType(input_event->type))
939 DidHandleKeyEvent(); 945 DidHandleKeyEvent();
940 if (WebInputEvent::isMouseEventType(input_event->type)) 946 if (WebInputEvent::isMouseEventType(input_event->type))
941 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); 947 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event)));
942 if (WebInputEvent::isTouchEventType(input_event->type)) 948 if (WebInputEvent::isTouchEventType(input_event->type))
943 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event))); 949 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event)));
944 } 950 }
951
952 return ToDisposition(ack_result, true, prevent_default);
953 }
954
955 InputEventDisposition RenderWidget::Dispatch(const IPC::Message& message) {
956 OnMessageReceived(message);
957 return INPUT_EVENT_MAIN_THREAD_CONSUMED;
958 }
959
960 InputEventDisposition RenderWidget::Dispatch(
961 int routing_id,
962 const WebKit::WebInputEvent* web_event,
963 const ui::LatencyInfo& latency_info,
964 bool is_keyboard_shortcut) {
965 DCHECK_EQ(routing_id_, routing_id);
966 return HandleWebEvent(web_event, latency_info, is_keyboard_shortcut, false);
967 }
968
969 void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event,
970 const ui::LatencyInfo& latency_info,
971 bool is_keyboard_shortcut) {
972 HandleWebEvent(input_event, latency_info, is_keyboard_shortcut, true);
973 }
974
975 void RenderWidget::OnHandleEventPacket(
976 const EventPacket& packet,
977 const InputEventDispositions& dispositions) {
978 TRACE_EVENT0("renderer", "OnHandleEventPacket");
979
980 RendererEventPacket renderer_packet(&packet, dispositions);
981
982 scoped_ptr<IPC::Message> dispatch_result =
983 renderer_packet.DispatchWith(this,
984 RendererEventPacket::THREAD_MAIN,
985 routing_id_);
986
987 DCHECK_EQ(InputHostMsg_HandleEventPacket_ACK::ID, dispatch_result->type());
988 Send(dispatch_result.release());
945 } 989 }
946 990
947 void RenderWidget::OnCursorVisibilityChange(bool is_visible) { 991 void RenderWidget::OnCursorVisibilityChange(bool is_visible) {
948 if (webwidget_) 992 if (webwidget_)
949 webwidget_->setCursorVisibilityState(is_visible); 993 webwidget_->setCursorVisibilityState(is_visible);
950 } 994 }
951 995
952 void RenderWidget::OnMouseCaptureLost() { 996 void RenderWidget::OnMouseCaptureLost() {
953 if (webwidget_) 997 if (webwidget_)
954 webwidget_->mouseCaptureLost(); 998 webwidget_->mouseCaptureLost();
(...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 kDefaultCommandBufferSize, 2600 kDefaultCommandBufferSize,
2557 kDefaultStartTransferBufferSize, 2601 kDefaultStartTransferBufferSize,
2558 kDefaultMinTransferBufferSize, 2602 kDefaultMinTransferBufferSize,
2559 kDefaultMaxTransferBufferSize, 2603 kDefaultMaxTransferBufferSize,
2560 mapped_memory_reclaim_limit)) 2604 mapped_memory_reclaim_limit))
2561 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2605 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2562 return context.Pass(); 2606 return context.Pass();
2563 } 2607 }
2564 2608
2565 } // namespace content 2609 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698