Skip to content

Commit

Permalink
Bug 1618582 - Make GeckoView#onTouchEventForResult() return correct…
Browse files Browse the repository at this point in the history
… values r=kats

This also makes `GeckoView#onTouchEvent()` always return `true`, because
returning `false` will cause us to not receive any more events for that
touch. We always want to receive events.

Differential Revision: https://phabricator.services.mozilla.com/D64781

--HG--
extra : moz-landing-system : lando
  • Loading branch information
snorp committed Feb 28, 2020
1 parent bea6ff1 commit 7769e21
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,8 @@ public void dispatchDraw(final Canvas canvas) {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(final MotionEvent event) {
return onTouchEventForResult(event) != PanZoomController.INPUT_RESULT_UNHANDLED;
onTouchEventForResult(event);
return true;
}

/**
Expand All @@ -759,7 +760,8 @@ public boolean onTouchEvent(final MotionEvent event) {

@Override
public boolean onGenericMotionEvent(final MotionEvent event) {
return onGenericMotionEventForResult(event) != PanZoomController.INPUT_RESULT_HANDLED;
onGenericMotionEventForResult(event);
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ public class PanZoomController {
/* package */ @interface InputResult {}

/**
* Specifies that an input event was not handled by the PanZoomController.
* Specifies that an input event was not handled by the PanZoomController for a panning
* or zooming operation. The event may have been handled by Web content or
* internally (e.g. text selection).
*/
@WrapForJNI
public static final int INPUT_RESULT_UNHANDLED = 0;

/**
* Specifies that an input event was handled by the PanZoomController, but likely
* not by any touch event listeners in Web content.
* Specifies that an input event was handled by the PanZoomController for a
* panning or zooming operation, but likely not by any touch event listeners in Web content.
*/
@WrapForJNI
public static final int INPUT_RESULT_HANDLED = 1;
Expand Down
45 changes: 39 additions & 6 deletions widget/android/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,19 @@ class nsWindow::NPZCSupport final
window->ProcessUntransformedAPZEvent(&wheelEvent, result);
});

return result.mHitRegionWithApzAwareListeners ? INPUT_RESULT_HANDLED_CONTENT
: INPUT_RESULT_HANDLED;
if (result.mHitRegionWithApzAwareListeners) {
return INPUT_RESULT_HANDLED_CONTENT;
}

switch (result.mStatus) {
case nsEventStatus_eIgnore:
return INPUT_RESULT_UNHANDLED;
case nsEventStatus_eConsumeDoDefault:
return INPUT_RESULT_HANDLED;
default:
MOZ_ASSERT_UNREACHABLE("Unexpected nsEventStatus");
return INPUT_RESULT_UNHANDLED;
}
}

private:
Expand Down Expand Up @@ -642,8 +653,19 @@ class nsWindow::NPZCSupport final
window->ProcessUntransformedAPZEvent(&mouseEvent, result);
});

return result.mHitRegionWithApzAwareListeners ? INPUT_RESULT_HANDLED_CONTENT
: INPUT_RESULT_HANDLED;
if (result.mHitRegionWithApzAwareListeners) {
return INPUT_RESULT_HANDLED_CONTENT;
}

switch (result.mStatus) {
case nsEventStatus_eIgnore:
return INPUT_RESULT_UNHANDLED;
case nsEventStatus_eConsumeDoDefault:
return INPUT_RESULT_HANDLED;
default:
MOZ_ASSERT_UNREACHABLE("Unexpected nsEventStatus");
return INPUT_RESULT_UNHANDLED;
}
}

int32_t HandleMotionEvent(
Expand Down Expand Up @@ -760,8 +782,19 @@ class nsWindow::NPZCSupport final
window->DispatchHitTest(touchEvent);
});

return result.mHitRegionWithApzAwareListeners ? INPUT_RESULT_HANDLED_CONTENT
: INPUT_RESULT_HANDLED;
if (result.mHitRegionWithApzAwareListeners) {
return INPUT_RESULT_HANDLED_CONTENT;
}

switch (result.mStatus) {
case nsEventStatus_eIgnore:
return INPUT_RESULT_UNHANDLED;
case nsEventStatus_eConsumeDoDefault:
return INPUT_RESULT_HANDLED;
default:
MOZ_ASSERT_UNREACHABLE("Unexpected nsEventStatus");
return INPUT_RESULT_UNHANDLED;
}
}
};

Expand Down

0 comments on commit 7769e21

Please sign in to comment.