Commit 84c09050 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Fix nullptr access with MojoInputMessages on.

With event sender input is possibly injected solely on the main thread and
a host may not be bound yet. So protect against null host objects on
the main thread.

BUG=788886

Change-Id: I6b8d1449ce01e3a1f0872133440839fa445d1567
Reviewed-on: https://chromium-review.googlesource.com/793971Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519746}
parent 8dfb7f83
...@@ -150,17 +150,23 @@ void WidgetInputHandlerManager::DidOverscroll( ...@@ -150,17 +150,23 @@ void WidgetInputHandlerManager::DidOverscroll(
const gfx::Vector2dF& current_fling_velocity, const gfx::Vector2dF& current_fling_velocity,
const gfx::PointF& causal_event_viewport_point, const gfx::PointF& causal_event_viewport_point,
const cc::ScrollBoundaryBehavior& scroll_boundary_behavior) { const cc::ScrollBoundaryBehavior& scroll_boundary_behavior) {
mojom::WidgetInputHandlerHost* host = GetWidgetInputHandlerHost();
if (!host)
return;
ui::DidOverscrollParams params; ui::DidOverscrollParams params;
params.accumulated_overscroll = accumulated_overscroll; params.accumulated_overscroll = accumulated_overscroll;
params.latest_overscroll_delta = latest_overscroll_delta; params.latest_overscroll_delta = latest_overscroll_delta;
params.current_fling_velocity = current_fling_velocity; params.current_fling_velocity = current_fling_velocity;
params.causal_event_viewport_point = causal_event_viewport_point; params.causal_event_viewport_point = causal_event_viewport_point;
params.scroll_boundary_behavior = scroll_boundary_behavior; params.scroll_boundary_behavior = scroll_boundary_behavior;
GetWidgetInputHandlerHost()->DidOverscroll(params); host->DidOverscroll(params);
} }
void WidgetInputHandlerManager::DidStopFlinging() { void WidgetInputHandlerManager::DidStopFlinging() {
GetWidgetInputHandlerHost()->DidStopFlinging(); mojom::WidgetInputHandlerHost* host = GetWidgetInputHandlerHost();
if (!host)
return;
host->DidStopFlinging();
} }
void WidgetInputHandlerManager::DidAnimateForInput() { void WidgetInputHandlerManager::DidAnimateForInput() {
...@@ -189,17 +195,22 @@ void WidgetInputHandlerManager::SetWhiteListedTouchAction( ...@@ -189,17 +195,22 @@ void WidgetInputHandlerManager::SetWhiteListedTouchAction(
cc::TouchAction touch_action, cc::TouchAction touch_action,
uint32_t unique_touch_event_id, uint32_t unique_touch_event_id,
ui::InputHandlerProxy::EventDisposition event_disposition) { ui::InputHandlerProxy::EventDisposition event_disposition) {
mojom::WidgetInputHandlerHost* host = GetWidgetInputHandlerHost();
if (!host)
return;
InputEventAckState ack_state = InputEventDispositionToAck(event_disposition); InputEventAckState ack_state = InputEventDispositionToAck(event_disposition);
GetWidgetInputHandlerHost()->SetWhiteListedTouchAction( host->SetWhiteListedTouchAction(touch_action, unique_touch_event_id,
touch_action, unique_touch_event_id, ack_state); ack_state);
} }
void WidgetInputHandlerManager::ProcessTouchAction( void WidgetInputHandlerManager::ProcessTouchAction(
cc::TouchAction touch_action) { cc::TouchAction touch_action) {
// Cancel the touch timeout on TouchActionNone since it is a good hint // Cancel the touch timeout on TouchActionNone since it is a good hint
// that author doesn't want scrolling. // that author doesn't want scrolling.
if (touch_action == cc::TouchAction::kTouchActionNone) if (touch_action == cc::TouchAction::kTouchActionNone) {
GetWidgetInputHandlerHost()->CancelTouchTimeout(); if (mojom::WidgetInputHandlerHost* host = GetWidgetInputHandlerHost())
host->CancelTouchTimeout();
}
} }
mojom::WidgetInputHandlerHost* mojom::WidgetInputHandlerHost*
......
...@@ -1133,8 +1133,10 @@ void RenderWidget::ClearEditCommands() { ...@@ -1133,8 +1133,10 @@ void RenderWidget::ClearEditCommands() {
void RenderWidget::OnDidOverscroll(const ui::DidOverscrollParams& params) { void RenderWidget::OnDidOverscroll(const ui::DidOverscrollParams& params) {
if (widget_input_handler_manager_) { if (widget_input_handler_manager_) {
widget_input_handler_manager_->GetWidgetInputHandlerHost()->DidOverscroll( if (mojom::WidgetInputHandlerHost* host =
params); widget_input_handler_manager_->GetWidgetInputHandlerHost()) {
host->DidOverscroll(params);
}
} else { } else {
Send(new InputHostMsg_DidOverscroll(routing_id_, params)); Send(new InputHostMsg_DidOverscroll(routing_id_, params));
} }
...@@ -1737,8 +1739,10 @@ void RenderWidget::OnImeSetComposition( ...@@ -1737,8 +1739,10 @@ void RenderWidget::OnImeSetComposition(
// process to cancel the input method's ongoing composition session, to make // process to cancel the input method's ongoing composition session, to make
// sure we are in a consistent state. // sure we are in a consistent state.
if (widget_input_handler_manager_) { if (widget_input_handler_manager_) {
widget_input_handler_manager_->GetWidgetInputHandlerHost() if (mojom::WidgetInputHandlerHost* host =
->ImeCancelComposition(); widget_input_handler_manager_->GetWidgetInputHandlerHost()) {
host->ImeCancelComposition();
}
} else { } else {
Send(new InputHostMsg_ImeCancelComposition(routing_id())); Send(new InputHostMsg_ImeCancelComposition(routing_id()));
} }
...@@ -2003,9 +2007,11 @@ void RenderWidget::UpdateCompositionInfo(bool immediate_request) { ...@@ -2003,9 +2007,11 @@ void RenderWidget::UpdateCompositionInfo(bool immediate_request) {
composition_character_bounds_ = character_bounds; composition_character_bounds_ = character_bounds;
composition_range_ = range; composition_range_ = range;
if (widget_input_handler_manager_) { if (widget_input_handler_manager_) {
widget_input_handler_manager_->GetWidgetInputHandlerHost() if (mojom::WidgetInputHandlerHost* host =
->ImeCompositionRangeChanged(composition_range_, widget_input_handler_manager_->GetWidgetInputHandlerHost()) {
composition_character_bounds_); host->ImeCompositionRangeChanged(composition_range_,
composition_character_bounds_);
}
} else { } else {
Send(new InputHostMsg_ImeCompositionRangeChanged( Send(new InputHostMsg_ImeCompositionRangeChanged(
routing_id(), composition_range_, composition_character_bounds_)); routing_id(), composition_range_, composition_character_bounds_));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment