Commit f701a983 authored by boliu's avatar boliu Committed by Commit bot

Null check secondary_pointer_down_event_

There are some crash reports in android webview that suggests this
pointer is null and used. In android webview, the app gets the touch
events first, so can modify or drop events however they want. That may
be the reason certain assumptions holds in chrome, but not in webview.

Assuming that's the case, just add null checks before use.

BUG=675772

Review-Url: https://codereview.chromium.org/2595943003
Cr-Commit-Position: refs/heads/master@{#440960}
parent 4f5a6978
......@@ -311,8 +311,9 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev) {
if (!IsWithinTouchSlop(ev)) {
handled = listener_->OnScroll(
*current_down_event_, ev,
(maximum_pointer_count_ > 1 ? *secondary_pointer_down_event_
: ev),
(maximum_pointer_count_ > 1 && secondary_pointer_down_event_)
? *secondary_pointer_down_event_
: ev,
scroll_x, scroll_y);
last_focus_x_ = focus_x;
last_focus_y_ = focus_y;
......@@ -329,8 +330,9 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev) {
std::abs(scroll_y) > kScrollEpsilon) {
handled = listener_->OnScroll(
*current_down_event_, ev,
(maximum_pointer_count_ > 1 ? *secondary_pointer_down_event_
: ev),
(maximum_pointer_count_ > 1 && secondary_pointer_down_event_)
? *secondary_pointer_down_event_
: ev,
scroll_x, scroll_y);
last_focus_x_ = focus_x;
last_focus_y_ = focus_y;
......@@ -553,7 +555,8 @@ bool GestureDetector::IsWithinTouchSlop(const MotionEvent& ev) {
const int pointer_id = ev.GetPointerId(i);
const MotionEvent* source_pointer_down_event = GetSourcePointerDownEvent(
*current_down_event_,
maximum_pointer_count_ > 1 ? *secondary_pointer_down_event_
(maximum_pointer_count_ > 1 && secondary_pointer_down_event_)
? *secondary_pointer_down_event_
: *current_down_event_,
pointer_id);
DCHECK(source_pointer_down_event);
......
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