Bug 1515774 - Pass current GeckoView position with touch events to APZC. r=geckoview-reviewers,snorp

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eitan Isaacson 2019-01-29 23:18:41 +00:00
Родитель 8ae47905e7
Коммит d7b9a2b61f
2 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -39,7 +39,7 @@ public class PanZoomController extends JNIObject {
@WrapForJNI(calledFrom = "ui") @WrapForJNI(calledFrom = "ui")
private native boolean handleMotionEvent( private native boolean handleMotionEvent(
int action, int actionIndex, long time, int metaState, int action, int actionIndex, long time, int metaState, float screenX, float screenY,
int pointerId[], float x[], float y[], float orientation[], float pressure[], int pointerId[], float x[], float y[], float orientation[], float pressure[],
float toolMajor[], float toolMinor[]); float toolMajor[], float toolMinor[]);
@ -94,8 +94,15 @@ public class PanZoomController extends JNIObject {
toolMinor[i] = coords.toolMinor; toolMinor[i] = coords.toolMinor;
} }
final float screenX = event.getRawX() - event.getX();
final float screenY = event.getRawY() - event.getY();
// Take this opportunity to update screen origin of session. This gets
// dispatched to the gecko thread, so we also pass the new screen x/y directly to apz.
mSession.onScreenOriginChanged((int)screenX, (int)screenY);
return handleMotionEvent(action, event.getActionIndex(), event.getEventTime(), return handleMotionEvent(action, event.getActionIndex(), event.getEventTime(),
event.getMetaState(), pointerId, x, y, orientation, pressure, event.getMetaState(), screenX, screenY, pointerId, x, y, orientation, pressure,
toolMajor, toolMinor); toolMajor, toolMinor);
} }

Просмотреть файл

@ -647,7 +647,8 @@ class nsWindow::NPZCSupport final
bool HandleMotionEvent(const PanZoomController::LocalRef& aInstance, bool HandleMotionEvent(const PanZoomController::LocalRef& aInstance,
int32_t aAction, int32_t aActionIndex, int64_t aTime, int32_t aAction, int32_t aActionIndex, int64_t aTime,
int32_t aMetaState, jni::IntArray::Param aPointerId, int32_t aMetaState, float aScreenX, float aScreenY,
jni::IntArray::Param aPointerId,
jni::FloatArray::Param aX, jni::FloatArray::Param aY, jni::FloatArray::Param aX, jni::FloatArray::Param aY,
jni::FloatArray::Param aOrientation, jni::FloatArray::Param aOrientation,
jni::FloatArray::Param aPressure, jni::FloatArray::Param aPressure,
@ -697,6 +698,8 @@ class nsWindow::NPZCSupport final
MultiTouchInput input(type, aTime, GetEventTimeStamp(aTime), 0); MultiTouchInput input(type, aTime, GetEventTimeStamp(aTime), 0);
input.modifiers = GetModifiers(aMetaState); input.modifiers = GetModifiers(aMetaState);
input.mTouches.SetCapacity(endIndex - startIndex); input.mTouches.SetCapacity(endIndex - startIndex);
input.mScreenOffset =
ExternalIntPoint(int32_t(floorf(aScreenX)), int32_t(floorf(aScreenY)));
nsTArray<float> x(aX->GetElements()); nsTArray<float> x(aX->GetElements());
nsTArray<float> y(aY->GetElements()); nsTArray<float> y(aY->GetElements());