Bug 1618582 - Make GeckoView#onTouchEventForResult() return correct 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
This commit is contained in:
James Willcox 2020-02-28 17:44:33 +00:00
parent bea6ff18e0
commit 7769e2195b
3 changed files with 48 additions and 11 deletions

View File

@ -732,7 +732,8 @@ public class GeckoView extends FrameLayout {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(final MotionEvent event) {
return onTouchEventForResult(event) != PanZoomController.INPUT_RESULT_UNHANDLED;
onTouchEventForResult(event);
return true;
}
/**
@ -759,7 +760,8 @@ public class GeckoView extends FrameLayout {
@Override
public boolean onGenericMotionEvent(final MotionEvent event) {
return onGenericMotionEventForResult(event) != PanZoomController.INPUT_RESULT_HANDLED;
onGenericMotionEventForResult(event);
return true;
}
/**

View File

@ -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;

View File

@ -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:
@ -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(
@ -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;
}
}
};