зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1646891 - Ensure the pinch gesture inputs dispatched to gecko have a refpoint set. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D83376
This commit is contained in:
Родитель
46c04e90f2
Коммит
2c7f65ff19
|
@ -74,6 +74,7 @@ class GeckoContentController {
|
|||
* of the pinch.
|
||||
* @param aGuid The guid of the APZ that is detecting the pinch. This is
|
||||
* generally the root APZC for the layers id.
|
||||
* @param aFocusPoint The focus point of the pinch event.
|
||||
* @param aSpanChange For the START or END event, this is always 0.
|
||||
* For a SCALE event, this is the difference in span between the
|
||||
* previous state and the new state.
|
||||
|
@ -81,6 +82,7 @@ class GeckoContentController {
|
|||
*/
|
||||
virtual void NotifyPinchGesture(PinchGestureInput::PinchGestureType aType,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
const LayoutDevicePoint& aFocusPoint,
|
||||
LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers) = 0;
|
||||
|
||||
|
|
|
@ -1566,8 +1566,14 @@ nsEventStatus AsyncPanZoomController::OnScaleBegin(
|
|||
if (!StaticPrefs::apz_allow_zooming()) {
|
||||
if (RefPtr<GeckoContentController> controller =
|
||||
GetGeckoContentController()) {
|
||||
controller->NotifyPinchGesture(aEvent.mType, GetGuid(), 0,
|
||||
aEvent.modifiers);
|
||||
APZC_LOG("%p notifying controller of pinch gesture start\n", this);
|
||||
controller->NotifyPinchGesture(
|
||||
aEvent.mType, GetGuid(),
|
||||
ViewAs<LayoutDevicePixel>(
|
||||
aEvent.mFocusPoint,
|
||||
PixelCastJustification::
|
||||
LayoutDeviceIsScreenForUntransformedEvent),
|
||||
0, aEvent.modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1615,11 +1621,17 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
|
|||
if (!StaticPrefs::apz_allow_zooming()) {
|
||||
if (RefPtr<GeckoContentController> controller =
|
||||
GetGeckoContentController()) {
|
||||
APZC_LOG("%p notifying controller of pinch gesture\n", this);
|
||||
controller->NotifyPinchGesture(
|
||||
aEvent.mType, GetGuid(),
|
||||
ViewAs<LayoutDevicePixel>(
|
||||
aEvent.mFocusPoint,
|
||||
PixelCastJustification::
|
||||
LayoutDeviceIsScreenForUntransformedEvent),
|
||||
ViewAs<LayoutDevicePixel>(
|
||||
aEvent.mCurrentSpan - aEvent.mPreviousSpan,
|
||||
PixelCastJustification::LayoutDeviceIsParentLayerForRCDRSF),
|
||||
PixelCastJustification::
|
||||
LayoutDeviceIsScreenForUntransformedEvent),
|
||||
aEvent.modifiers);
|
||||
}
|
||||
}
|
||||
|
@ -1749,8 +1761,13 @@ nsEventStatus AsyncPanZoomController::OnScaleEnd(
|
|||
if (!StaticPrefs::apz_allow_zooming()) {
|
||||
if (RefPtr<GeckoContentController> controller =
|
||||
GetGeckoContentController()) {
|
||||
controller->NotifyPinchGesture(aEvent.mType, GetGuid(), 0,
|
||||
aEvent.modifiers);
|
||||
controller->NotifyPinchGesture(
|
||||
aEvent.mType, GetGuid(),
|
||||
ViewAs<LayoutDevicePixel>(
|
||||
aEvent.mFocusPoint,
|
||||
PixelCastJustification::
|
||||
LayoutDeviceIsScreenForUntransformedEvent),
|
||||
0, aEvent.modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,9 +137,10 @@ class MockContentController : public GeckoContentController {
|
|||
const uint32_t& aScrollGeneration));
|
||||
MOCK_METHOD5(HandleTap, void(TapType, const LayoutDevicePoint&, Modifiers,
|
||||
const ScrollableLayerGuid&, uint64_t));
|
||||
MOCK_METHOD4(NotifyPinchGesture,
|
||||
MOCK_METHOD5(NotifyPinchGesture,
|
||||
void(PinchGestureInput::PinchGestureType,
|
||||
const ScrollableLayerGuid&, LayoutDeviceCoord, Modifiers));
|
||||
const ScrollableLayerGuid&, const LayoutDevicePoint&,
|
||||
LayoutDeviceCoord, Modifiers));
|
||||
// Can't use the macros with already_AddRefed :(
|
||||
void PostDelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs) {
|
||||
RefPtr<Runnable> task = aTask;
|
||||
|
|
|
@ -257,7 +257,7 @@ TEST_F(APZCPinchGestureDetectorTester,
|
|||
// Since we are preventing the pinch action via touch-action we should not be
|
||||
// sending the pinch gesture notifications that would normally be sent when
|
||||
// apz_allow_zooming is false.
|
||||
EXPECT_CALL(*mcc, NotifyPinchGesture(_, _, _, _)).Times(0);
|
||||
EXPECT_CALL(*mcc, NotifyPinchGesture(_, _, _, _, _)).Times(0);
|
||||
nsTArray<uint32_t> behaviors = {mozilla::layers::AllowedTouchBehavior::NONE,
|
||||
mozilla::layers::AllowedTouchBehavior::NONE};
|
||||
DoPinchTest(false, &behaviors);
|
||||
|
@ -273,7 +273,7 @@ TEST_F(APZCPinchGestureDetectorTester, Pinch_PreventDefault_NoAPZZoom) {
|
|||
// Since we are preventing the pinch action we should not be sending the pinch
|
||||
// gesture notifications that would normally be sent when apz_allow_zooming is
|
||||
// false.
|
||||
EXPECT_CALL(*mcc, NotifyPinchGesture(_, _, _, _)).Times(0);
|
||||
EXPECT_CALL(*mcc, NotifyPinchGesture(_, _, _, _, _)).Times(0);
|
||||
|
||||
DoPinchWithPreventDefaultTest();
|
||||
}
|
||||
|
@ -449,14 +449,14 @@ TEST_F(APZCPinchGestureDetectorTester, Pinch_APZZoom_Disabled) {
|
|||
// get called as the pinch progresses, but the metrics shouldn't change.
|
||||
EXPECT_CALL(*mcc,
|
||||
NotifyPinchGesture(PinchGestureInput::PINCHGESTURE_START,
|
||||
apzc->GetGuid(), LayoutDeviceCoord(0), _))
|
||||
apzc->GetGuid(), _, LayoutDeviceCoord(0), _))
|
||||
.Times(1);
|
||||
EXPECT_CALL(*mcc, NotifyPinchGesture(PinchGestureInput::PINCHGESTURE_SCALE,
|
||||
apzc->GetGuid(), _, _))
|
||||
apzc->GetGuid(), _, _, _))
|
||||
.Times(AtLeast(1));
|
||||
EXPECT_CALL(*mcc,
|
||||
NotifyPinchGesture(PinchGestureInput::PINCHGESTURE_END,
|
||||
apzc->GetGuid(), LayoutDeviceCoord(0), _))
|
||||
apzc->GetGuid(), _, LayoutDeviceCoord(0), _))
|
||||
.Times(1);
|
||||
|
||||
int touchInputId = 0;
|
||||
|
@ -488,14 +488,14 @@ TEST_F(APZCPinchGestureDetectorTester, Pinch_NoSpan) {
|
|||
// get called as the pinch progresses, but the metrics shouldn't change.
|
||||
EXPECT_CALL(*mcc,
|
||||
NotifyPinchGesture(PinchGestureInput::PINCHGESTURE_START,
|
||||
apzc->GetGuid(), LayoutDeviceCoord(0), _))
|
||||
apzc->GetGuid(), _, LayoutDeviceCoord(0), _))
|
||||
.Times(1);
|
||||
EXPECT_CALL(*mcc, NotifyPinchGesture(PinchGestureInput::PINCHGESTURE_SCALE,
|
||||
apzc->GetGuid(), _, _))
|
||||
apzc->GetGuid(), _, _, _))
|
||||
.Times(AtLeast(1));
|
||||
EXPECT_CALL(*mcc,
|
||||
NotifyPinchGesture(PinchGestureInput::PINCHGESTURE_END,
|
||||
apzc->GetGuid(), LayoutDeviceCoord(0), _))
|
||||
apzc->GetGuid(), _, LayoutDeviceCoord(0), _))
|
||||
.Times(1);
|
||||
|
||||
int inputId = 0;
|
||||
|
|
|
@ -890,8 +890,10 @@ void APZCCallbackHelper::CancelAutoscroll(
|
|||
|
||||
/* static */
|
||||
void APZCCallbackHelper::NotifyPinchGesture(
|
||||
PinchGestureInput::PinchGestureType aType, LayoutDeviceCoord aSpanChange,
|
||||
PinchGestureInput::PinchGestureType aType,
|
||||
const LayoutDevicePoint& aFocusPoint, LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers, const nsCOMPtr<nsIWidget>& aWidget) {
|
||||
APZCCH_LOG("APZCCallbackHelper dispatching pinch gesture\n");
|
||||
EventMessage msg;
|
||||
switch (aType) {
|
||||
case PinchGestureInput::PINCHGESTURE_START:
|
||||
|
@ -914,6 +916,8 @@ void APZCCallbackHelper::NotifyPinchGesture(
|
|||
// on that currently, but we might want to fix it at some point.
|
||||
event.mDelta = aSpanChange;
|
||||
event.mModifiers = aModifiers;
|
||||
event.mRefPoint = RoundedToInt(aFocusPoint);
|
||||
|
||||
DispatchWidgetEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -190,6 +190,7 @@ class APZCCallbackHelper {
|
|||
* will dispatch appropriate WidgetSimpleGestureEvent events to gecko.
|
||||
*/
|
||||
static void NotifyPinchGesture(PinchGestureInput::PinchGestureType aType,
|
||||
const LayoutDevicePoint& aFocusPoint,
|
||||
LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers,
|
||||
const nsCOMPtr<nsIWidget>& aWidget);
|
||||
|
|
|
@ -214,14 +214,16 @@ void ChromeProcessController::HandleTap(
|
|||
|
||||
void ChromeProcessController::NotifyPinchGesture(
|
||||
PinchGestureInput::PinchGestureType aType, const ScrollableLayerGuid& aGuid,
|
||||
LayoutDeviceCoord aSpanChange, Modifiers aModifiers) {
|
||||
const LayoutDevicePoint& aFocusPoint, LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers) {
|
||||
if (!mUIThread->IsOnCurrentThread()) {
|
||||
mUIThread->Dispatch(
|
||||
NewRunnableMethod<PinchGestureInput::PinchGestureType,
|
||||
ScrollableLayerGuid, LayoutDeviceCoord, Modifiers>(
|
||||
ScrollableLayerGuid, LayoutDevicePoint,
|
||||
LayoutDeviceCoord, Modifiers>(
|
||||
"layers::ChromeProcessController::NotifyPinchGesture", this,
|
||||
&ChromeProcessController::NotifyPinchGesture, aType, aGuid,
|
||||
aSpanChange, aModifiers));
|
||||
aFocusPoint, aSpanChange, aModifiers));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -232,8 +234,8 @@ void ChromeProcessController::NotifyPinchGesture(
|
|||
// loop and cause undesirable re-entrancy in APZ.
|
||||
mUIThread->Dispatch(NewRunnableFunction(
|
||||
"layers::ChromeProcessController::NotifyPinchGestureAsync",
|
||||
&APZCCallbackHelper::NotifyPinchGesture, aType, aSpanChange, aModifiers,
|
||||
mWidget));
|
||||
&APZCCallbackHelper::NotifyPinchGesture, aType, aFocusPoint,
|
||||
aSpanChange, aModifiers, mWidget));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ class ChromeProcessController : public mozilla::layers::GeckoContentController {
|
|||
uint64_t aInputBlockId) override;
|
||||
void NotifyPinchGesture(PinchGestureInput::PinchGestureType aType,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
const LayoutDevicePoint& aFocusPoint,
|
||||
LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers) override;
|
||||
void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
|
||||
|
|
|
@ -47,7 +47,8 @@ void ContentProcessController::HandleTap(TapType aType,
|
|||
|
||||
void ContentProcessController::NotifyPinchGesture(
|
||||
PinchGestureInput::PinchGestureType aType, const ScrollableLayerGuid& aGuid,
|
||||
LayoutDeviceCoord aSpanChange, Modifiers aModifiers) {
|
||||
const LayoutDevicePoint& aFocusPoint, LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers) {
|
||||
// This should never get called
|
||||
MOZ_ASSERT_UNREACHABLE("Unexpected message to content process");
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ class ContentProcessController final : public GeckoContentController {
|
|||
|
||||
void NotifyPinchGesture(PinchGestureInput::PinchGestureType aType,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
const LayoutDevicePoint& aFocusPoint,
|
||||
LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers) override;
|
||||
|
||||
|
|
|
@ -143,7 +143,8 @@ mozilla::ipc::IPCResult APZCTreeManagerChild::RecvHandleTap(
|
|||
|
||||
mozilla::ipc::IPCResult APZCTreeManagerChild::RecvNotifyPinchGesture(
|
||||
const PinchGestureType& aType, const ScrollableLayerGuid& aGuid,
|
||||
const LayoutDeviceCoord& aSpanChange, const Modifiers& aModifiers) {
|
||||
const LayoutDevicePoint& aFocusPoint, const LayoutDeviceCoord& aSpanChange,
|
||||
const Modifiers& aModifiers) {
|
||||
// This will only get sent from the GPU process to the parent process, so
|
||||
// this function should never get called in the content process.
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
@ -152,7 +153,8 @@ mozilla::ipc::IPCResult APZCTreeManagerChild::RecvNotifyPinchGesture(
|
|||
// We want to handle it in this process regardless of what the target guid
|
||||
// of the pinch is. This may change in the future.
|
||||
if (mCompositorSession && mCompositorSession->GetWidget()) {
|
||||
APZCCallbackHelper::NotifyPinchGesture(aType, aSpanChange, aModifiers,
|
||||
APZCCallbackHelper::NotifyPinchGesture(aType, aFocusPoint, aSpanChange,
|
||||
aModifiers,
|
||||
mCompositorSession->GetWidget());
|
||||
}
|
||||
return IPC_OK();
|
||||
|
|
|
@ -76,6 +76,7 @@ class APZCTreeManagerChild : public IAPZCTreeManager,
|
|||
|
||||
mozilla::ipc::IPCResult RecvNotifyPinchGesture(
|
||||
const PinchGestureType& aType, const ScrollableLayerGuid& aGuid,
|
||||
const LayoutDevicePoint& aFocusPoint,
|
||||
const LayoutDeviceCoord& aSpanChange, const Modifiers& aModifiers);
|
||||
|
||||
mozilla::ipc::IPCResult RecvCancelAutoscroll(
|
||||
|
|
|
@ -76,7 +76,8 @@ child:
|
|||
ScrollableLayerGuid aGuid, uint64_t aInputBlockId);
|
||||
|
||||
async NotifyPinchGesture(PinchGestureType aType, ScrollableLayerGuid aGuid,
|
||||
LayoutDeviceCoord aSpanChange, Modifiers aModifiers);
|
||||
LayoutDevicePoint aFocusPoint, LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers);
|
||||
|
||||
async CancelAutoscroll(ViewID aScrollId);
|
||||
};
|
||||
|
|
|
@ -144,7 +144,8 @@ void RemoteContentController::HandleTap(TapType aTapType,
|
|||
|
||||
void RemoteContentController::NotifyPinchGestureOnCompositorThread(
|
||||
PinchGestureInput::PinchGestureType aType, const ScrollableLayerGuid& aGuid,
|
||||
LayoutDeviceCoord aSpanChange, Modifiers aModifiers) {
|
||||
const LayoutDevicePoint& aFocusPoint, LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers) {
|
||||
MOZ_ASSERT(mCompositorThread->IsOnCurrentThread());
|
||||
|
||||
// The raw pointer to APZCTreeManagerParent is ok here because we are on the
|
||||
|
@ -152,14 +153,15 @@ void RemoteContentController::NotifyPinchGestureOnCompositorThread(
|
|||
APZCTreeManagerParent* apzctmp =
|
||||
CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
|
||||
if (apzctmp) {
|
||||
Unused << apzctmp->SendNotifyPinchGesture(aType, aGuid, aSpanChange,
|
||||
aModifiers);
|
||||
Unused << apzctmp->SendNotifyPinchGesture(aType, aGuid, aFocusPoint,
|
||||
aSpanChange, aModifiers);
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteContentController::NotifyPinchGesture(
|
||||
PinchGestureInput::PinchGestureType aType, const ScrollableLayerGuid& aGuid,
|
||||
LayoutDeviceCoord aSpanChange, Modifiers aModifiers) {
|
||||
const LayoutDevicePoint& aFocusPoint, LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers) {
|
||||
APZThreadUtils::AssertOnControllerThread();
|
||||
|
||||
// For now we only ever want to handle this NotifyPinchGesture message in
|
||||
|
@ -169,17 +171,18 @@ void RemoteContentController::NotifyPinchGesture(
|
|||
// and send it there.
|
||||
if (XRE_IsGPUProcess()) {
|
||||
if (mCompositorThread->IsOnCurrentThread()) {
|
||||
NotifyPinchGestureOnCompositorThread(aType, aGuid, aSpanChange,
|
||||
aModifiers);
|
||||
NotifyPinchGestureOnCompositorThread(aType, aGuid, aFocusPoint,
|
||||
aSpanChange, aModifiers);
|
||||
} else {
|
||||
mCompositorThread->Dispatch(
|
||||
NewRunnableMethod<PinchGestureInput::PinchGestureType,
|
||||
ScrollableLayerGuid, LayoutDeviceCoord, Modifiers>(
|
||||
ScrollableLayerGuid, LayoutDevicePoint,
|
||||
LayoutDeviceCoord, Modifiers>(
|
||||
"layers::RemoteContentController::"
|
||||
"NotifyPinchGestureOnCompositorThread",
|
||||
this,
|
||||
&RemoteContentController::NotifyPinchGestureOnCompositorThread,
|
||||
aType, aGuid, aSpanChange, aModifiers));
|
||||
aType, aGuid, aFocusPoint, aSpanChange, aModifiers));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -193,7 +196,8 @@ void RemoteContentController::NotifyPinchGesture(
|
|||
CompositorBridgeParent::GetGeckoContentControllerForRoot(
|
||||
aGuid.mLayersId);
|
||||
if (rootController) {
|
||||
rootController->NotifyPinchGesture(aType, aGuid, aSpanChange, aModifiers);
|
||||
rootController->NotifyPinchGesture(aType, aGuid, aFocusPoint, aSpanChange,
|
||||
aModifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ class RemoteContentController : public GeckoContentController,
|
|||
|
||||
void NotifyPinchGesture(PinchGestureInput::PinchGestureType aType,
|
||||
const ScrollableLayerGuid& aGuid,
|
||||
const LayoutDevicePoint& aFocusPoint,
|
||||
LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers) override;
|
||||
|
||||
|
@ -101,8 +102,8 @@ class RemoteContentController : public GeckoContentController,
|
|||
uint64_t aInputBlockId);
|
||||
void NotifyPinchGestureOnCompositorThread(
|
||||
PinchGestureInput::PinchGestureType aType,
|
||||
const ScrollableLayerGuid& aGuid, LayoutDeviceCoord aSpanChange,
|
||||
Modifiers aModifiers);
|
||||
const ScrollableLayerGuid& aGuid, const LayoutDevicePoint& aFocusPoint,
|
||||
LayoutDeviceCoord aSpanChange, Modifiers aModifiers);
|
||||
|
||||
void CancelAutoscrollInProcess(const ScrollableLayerGuid& aScrollId);
|
||||
void CancelAutoscrollCrossProcess(const ScrollableLayerGuid& aScrollId);
|
||||
|
|
Загрузка…
Ссылка в новой задаче