Commit 0792afed authored by David Bokan's avatar David Bokan Committed by Commit Bot

Fix crash in Optional.value()

This was introduced in https://crrev.com/c/2142514 when the invalid
value being case to an EventDisposition enum was turned into a
base::Optional de-ref. This situation should never occur but the crashes
indicate it does.

This CL preverves old behavior to prevent the crash.

TBR=nzolghadr@chromium.org

Bug: 1069760
Change-Id: I412edf2bff202d68730a3374792f1dab16a91426
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145567
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758268}
parent 5c98faff
...@@ -809,10 +809,13 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel( ...@@ -809,10 +809,13 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel(
// Noncancellable wheel events should have phase info. // Noncancellable wheel events should have phase info.
DCHECK(wheel_event.phase != WebMouseWheelEvent::kPhaseNone || DCHECK(wheel_event.phase != WebMouseWheelEvent::kPhaseNone ||
wheel_event.momentum_phase != WebMouseWheelEvent::kPhaseNone); wheel_event.momentum_phase != WebMouseWheelEvent::kPhaseNone);
DCHECK(mouse_wheel_result_.has_value());
DCHECK(mouse_wheel_result_.has_value());
// TODO(bokan): This should never happen but after changing
// mouse_event_result_ to a base::Optional, crashes indicate that it does
// so |if| maintains prior behavior. https://crbug.com/1069760.
if (mouse_wheel_result_.has_value()) {
result = mouse_wheel_result_.value(); result = mouse_wheel_result_.value();
if (wheel_event.phase == WebMouseWheelEvent::kPhaseEnded || if (wheel_event.phase == WebMouseWheelEvent::kPhaseEnded ||
wheel_event.phase == WebMouseWheelEvent::kPhaseCancelled || wheel_event.phase == WebMouseWheelEvent::kPhaseCancelled ||
wheel_event.momentum_phase == WebMouseWheelEvent::kPhaseEnded || wheel_event.momentum_phase == WebMouseWheelEvent::kPhaseEnded ||
...@@ -822,6 +825,7 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel( ...@@ -822,6 +825,7 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel(
return result; return result;
} }
} }
}
gfx::PointF position_in_widget = wheel_event.PositionInWidget(); gfx::PointF position_in_widget = wheel_event.PositionInWidget();
if (input_handler_->HasBlockingWheelEventHandlerAt( if (input_handler_->HasBlockingWheelEventHandlerAt(
......
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