Bug 918273 - Pass back the target scrollable layer id from apzc event methods. r=kats
This commit is contained in:
@@ -231,7 +231,8 @@ ApplyTransform(nsIntPoint* aPoint, const gfx3DMatrix& aMatrix)
|
||||
}
|
||||
|
||||
nsEventStatus
|
||||
APZCTreeManager::ReceiveInputEvent(const InputData& aEvent)
|
||||
APZCTreeManager::ReceiveInputEvent(const InputData& aEvent,
|
||||
ScrollableLayerGuid* aOutTargetGuid)
|
||||
{
|
||||
nsEventStatus result = nsEventStatus_eIgnore;
|
||||
gfx3DMatrix transformToApzc;
|
||||
@@ -261,6 +262,7 @@ APZCTreeManager::ReceiveInputEvent(const InputData& aEvent)
|
||||
APZC_LOG("Re-using APZC %p as continuation of event block\n", mApzcForInputBlock.get());
|
||||
}
|
||||
if (mApzcForInputBlock) {
|
||||
mApzcForInputBlock->GetGuid(aOutTargetGuid);
|
||||
// Use the cached transform to compute the point to send to the APZC.
|
||||
// This ensures that the sequence of touch points an APZC sees in an
|
||||
// input block are all in the same coordinate space.
|
||||
@@ -290,6 +292,7 @@ APZCTreeManager::ReceiveInputEvent(const InputData& aEvent)
|
||||
const PinchGestureInput& pinchInput = aEvent.AsPinchGestureInput();
|
||||
nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(pinchInput.mFocusPoint);
|
||||
if (apzc) {
|
||||
apzc->GetGuid(aOutTargetGuid);
|
||||
GetInputTransforms(apzc, transformToApzc, transformToGecko);
|
||||
PinchGestureInput inputForApzc(pinchInput);
|
||||
ApplyTransform(&(inputForApzc.mFocusPoint), transformToApzc);
|
||||
@@ -300,6 +303,7 @@ APZCTreeManager::ReceiveInputEvent(const InputData& aEvent)
|
||||
const TapGestureInput& tapInput = aEvent.AsTapGestureInput();
|
||||
nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(ScreenPoint(tapInput.mPoint));
|
||||
if (apzc) {
|
||||
apzc->GetGuid(aOutTargetGuid);
|
||||
GetInputTransforms(apzc, transformToApzc, transformToGecko);
|
||||
TapGestureInput inputForApzc(tapInput);
|
||||
ApplyTransform(&(inputForApzc.mPoint), transformToApzc);
|
||||
@@ -342,6 +346,7 @@ APZCTreeManager::GetTouchInputBlockAPZC(const WidgetTouchEvent& aEvent,
|
||||
|
||||
nsEventStatus
|
||||
APZCTreeManager::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
|
||||
ScrollableLayerGuid* aOutTargetGuid,
|
||||
WidgetTouchEvent* aOutEvent)
|
||||
{
|
||||
nsEventStatus ret = nsEventStatus_eIgnore;
|
||||
@@ -355,6 +360,7 @@ APZCTreeManager::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
|
||||
}
|
||||
|
||||
if (mApzcForInputBlock) {
|
||||
mApzcForInputBlock->GetGuid(aOutTargetGuid);
|
||||
// For computing the input for the APZC, used the cached transform.
|
||||
// This ensures that the sequence of touch points an APZC sees in an
|
||||
// input block are all in the same coordinate space.
|
||||
@@ -394,12 +400,14 @@ APZCTreeManager::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
|
||||
|
||||
nsEventStatus
|
||||
APZCTreeManager::ProcessMouseEvent(const WidgetMouseEvent& aEvent,
|
||||
ScrollableLayerGuid* aOutTargetGuid,
|
||||
WidgetMouseEvent* aOutEvent)
|
||||
{
|
||||
nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(ScreenPoint(aEvent.refPoint.x, aEvent.refPoint.y));
|
||||
if (!apzc) {
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
apzc->GetGuid(aOutTargetGuid);
|
||||
gfx3DMatrix transformToApzc;
|
||||
gfx3DMatrix transformToGecko;
|
||||
GetInputTransforms(apzc, transformToApzc, transformToGecko);
|
||||
@@ -412,6 +420,7 @@ APZCTreeManager::ProcessMouseEvent(const WidgetMouseEvent& aEvent,
|
||||
|
||||
nsEventStatus
|
||||
APZCTreeManager::ProcessEvent(const WidgetInputEvent& aEvent,
|
||||
ScrollableLayerGuid* aOutTargetGuid,
|
||||
WidgetInputEvent* aOutEvent)
|
||||
{
|
||||
// Transform the refPoint
|
||||
@@ -419,6 +428,7 @@ APZCTreeManager::ProcessEvent(const WidgetInputEvent& aEvent,
|
||||
if (!apzc) {
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
apzc->GetGuid(aOutTargetGuid);
|
||||
gfx3DMatrix transformToApzc;
|
||||
gfx3DMatrix transformToGecko;
|
||||
GetInputTransforms(apzc, transformToApzc, transformToGecko);
|
||||
@@ -429,6 +439,7 @@ APZCTreeManager::ProcessEvent(const WidgetInputEvent& aEvent,
|
||||
|
||||
nsEventStatus
|
||||
APZCTreeManager::ReceiveInputEvent(const WidgetInputEvent& aEvent,
|
||||
ScrollableLayerGuid* aOutTargetGuid,
|
||||
WidgetInputEvent* aOutEvent)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@@ -436,32 +447,33 @@ APZCTreeManager::ReceiveInputEvent(const WidgetInputEvent& aEvent,
|
||||
switch (aEvent.eventStructType) {
|
||||
case NS_TOUCH_EVENT: {
|
||||
const WidgetTouchEvent& touchEvent = *aEvent.AsTouchEvent();
|
||||
return ProcessTouchEvent(touchEvent, aOutEvent->AsTouchEvent());
|
||||
return ProcessTouchEvent(touchEvent, aOutTargetGuid, aOutEvent->AsTouchEvent());
|
||||
}
|
||||
case NS_MOUSE_EVENT: {
|
||||
// For b2g emulation
|
||||
const WidgetMouseEvent& mouseEvent = *aEvent.AsMouseEvent();
|
||||
WidgetMouseEvent* outMouseEvent = aOutEvent->AsMouseEvent();
|
||||
return ProcessMouseEvent(mouseEvent, outMouseEvent);
|
||||
return ProcessMouseEvent(mouseEvent, aOutTargetGuid, outMouseEvent);
|
||||
}
|
||||
default: {
|
||||
return ProcessEvent(aEvent, aOutEvent);
|
||||
return ProcessEvent(aEvent, aOutTargetGuid, aOutEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsEventStatus
|
||||
APZCTreeManager::ReceiveInputEvent(WidgetInputEvent& aEvent)
|
||||
APZCTreeManager::ReceiveInputEvent(WidgetInputEvent& aEvent,
|
||||
ScrollableLayerGuid* aOutTargetGuid)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
switch (aEvent.eventStructType) {
|
||||
case NS_TOUCH_EVENT: {
|
||||
WidgetTouchEvent& touchEvent = *aEvent.AsTouchEvent();
|
||||
return ProcessTouchEvent(touchEvent, &touchEvent);
|
||||
return ProcessTouchEvent(touchEvent, aOutTargetGuid, &touchEvent);
|
||||
}
|
||||
default: {
|
||||
return ProcessEvent(aEvent, &aEvent);
|
||||
return ProcessEvent(aEvent, aOutTargetGuid, &aEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,14 @@ struct ScrollableLayerGuid {
|
||||
uint32_t mPresShellId;
|
||||
FrameMetrics::ViewID mScrollId;
|
||||
|
||||
ScrollableLayerGuid()
|
||||
: mLayersId(0)
|
||||
, mPresShellId(0)
|
||||
, mScrollId(0)
|
||||
{
|
||||
MOZ_COUNT_CTOR(ScrollableLayerGuid);
|
||||
}
|
||||
|
||||
ScrollableLayerGuid(uint64_t aLayersId, uint32_t aPresShellId,
|
||||
FrameMetrics::ViewID aScrollId)
|
||||
: mLayersId(aLayersId)
|
||||
@@ -142,8 +150,13 @@ public:
|
||||
* General handler for incoming input events. Manipulates the frame metrics
|
||||
* based on what type of input it is. For example, a PinchGestureEvent will
|
||||
* cause scaling. This should only be called externally to this class.
|
||||
*
|
||||
* @param aEvent input event object, will not be modified
|
||||
* @param aOutTargetGuid returns the guid of the apzc this event was
|
||||
* delivered to. May be null.
|
||||
*/
|
||||
nsEventStatus ReceiveInputEvent(const InputData& aEvent);
|
||||
nsEventStatus ReceiveInputEvent(const InputData& aEvent,
|
||||
ScrollableLayerGuid* aOutTargetGuid);
|
||||
|
||||
/**
|
||||
* WidgetInputEvent handler. Sets |aOutEvent| (which is assumed to be an
|
||||
@@ -158,9 +171,12 @@ public:
|
||||
* to the appropriate apz as such.
|
||||
*
|
||||
* @param aEvent input event object, will not be modified
|
||||
* @param aOutTargetGuid returns the guid of the apzc this event was
|
||||
* delivered to. May be null.
|
||||
* @param aOutEvent event object transformed to DOM coordinate space.
|
||||
*/
|
||||
nsEventStatus ReceiveInputEvent(const WidgetInputEvent& aEvent,
|
||||
ScrollableLayerGuid* aOutTargetGuid,
|
||||
WidgetInputEvent* aOutEvent);
|
||||
|
||||
/**
|
||||
@@ -168,8 +184,11 @@ public:
|
||||
* WidgetInputEvent. Must be called on the main thread.
|
||||
*
|
||||
* @param aEvent input event object
|
||||
* @param aOutTargetGuid returns the guid of the apzc this event was
|
||||
* delivered to. May be null.
|
||||
*/
|
||||
nsEventStatus ReceiveInputEvent(WidgetInputEvent& aEvent);
|
||||
nsEventStatus ReceiveInputEvent(WidgetInputEvent& aEvent,
|
||||
ScrollableLayerGuid* aOutTargetGuid);
|
||||
|
||||
/**
|
||||
* Updates the composition bounds, i.e. the dimensions of the final size of
|
||||
@@ -285,9 +304,9 @@ private:
|
||||
AsyncPanZoomController* CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2);
|
||||
AsyncPanZoomController* RootAPZCForLayersId(AsyncPanZoomController* aApzc);
|
||||
AsyncPanZoomController* GetTouchInputBlockAPZC(const WidgetTouchEvent& aEvent, ScreenPoint aPoint);
|
||||
nsEventStatus ProcessTouchEvent(const WidgetTouchEvent& touchEvent, WidgetTouchEvent* aOutEvent);
|
||||
nsEventStatus ProcessMouseEvent(const WidgetMouseEvent& mouseEvent, WidgetMouseEvent* aOutEvent);
|
||||
nsEventStatus ProcessEvent(const WidgetInputEvent& inputEvent, WidgetInputEvent* aOutEvent);
|
||||
nsEventStatus ProcessTouchEvent(const WidgetTouchEvent& touchEvent, ScrollableLayerGuid* aOutTargetGuid, WidgetTouchEvent* aOutEvent);
|
||||
nsEventStatus ProcessMouseEvent(const WidgetMouseEvent& mouseEvent, ScrollableLayerGuid* aOutTargetGuid, WidgetMouseEvent* aOutEvent);
|
||||
nsEventStatus ProcessEvent(const WidgetInputEvent& inputEvent, ScrollableLayerGuid* aOutTargetGuid, WidgetInputEvent* aOutEvent);
|
||||
|
||||
/**
|
||||
* Recursive helper function to build the APZC tree. The tree of APZC instances has
|
||||
|
||||
@@ -1544,5 +1544,15 @@ bool AsyncPanZoomController::Matches(const ScrollableLayerGuid& aGuid)
|
||||
return aGuid.mLayersId == mLayersId && aGuid.mScrollId == mFrameMetrics.mScrollId;
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::GetGuid(ScrollableLayerGuid* aGuidOut)
|
||||
{
|
||||
if (!aGuidOut) {
|
||||
return;
|
||||
}
|
||||
aGuidOut->mLayersId = mLayersId;
|
||||
aGuidOut->mScrollId = mFrameMetrics.mScrollId;
|
||||
aGuidOut->mPresShellId = mFrameMetrics.mPresShellId;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,6 +231,11 @@ public:
|
||||
*/
|
||||
nsEventStatus HandleInputEvent(const InputData& aEvent);
|
||||
|
||||
/**
|
||||
* Populates the provided object with the scrollable guid of this apzc.
|
||||
*/
|
||||
void GetGuid(ScrollableLayerGuid* aGuidOut);
|
||||
|
||||
/**
|
||||
* Returns true if this APZC instance is for the layer identified by the guid.
|
||||
*/
|
||||
|
||||
@@ -830,7 +830,7 @@ RenderFrameParent::NotifyInputEvent(const WidgetInputEvent& aEvent,
|
||||
WidgetInputEvent* aOutEvent)
|
||||
{
|
||||
if (GetApzcTreeManager()) {
|
||||
GetApzcTreeManager()->ReceiveInputEvent(aEvent, aOutEvent);
|
||||
GetApzcTreeManager()->ReceiveInputEvent(aEvent, nullptr, aOutEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -877,7 +877,7 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent(JNIEnv* env,
|
||||
const MultiTouchInput& input = wrapper->MakeMultiTouchInput(nsWindow::TopWindow());
|
||||
delete wrapper;
|
||||
if (input.mType >= 0) {
|
||||
controller->ReceiveInputEvent(input);
|
||||
controller->ReceiveInputEvent(input, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user