Bug 918273 - Pass back the target scrollable layer id from apzc event methods. r=kats

This commit is contained in:
Jim Mathies
2013-11-10 10:43:17 -06:00
parent 1ec9be0904
commit 03ba649a43
6 changed files with 60 additions and 14 deletions

View File

@@ -231,7 +231,8 @@ ApplyTransform(nsIntPoint* aPoint, const gfx3DMatrix& aMatrix)
} }
nsEventStatus nsEventStatus
APZCTreeManager::ReceiveInputEvent(const InputData& aEvent) APZCTreeManager::ReceiveInputEvent(const InputData& aEvent,
ScrollableLayerGuid* aOutTargetGuid)
{ {
nsEventStatus result = nsEventStatus_eIgnore; nsEventStatus result = nsEventStatus_eIgnore;
gfx3DMatrix transformToApzc; 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()); APZC_LOG("Re-using APZC %p as continuation of event block\n", mApzcForInputBlock.get());
} }
if (mApzcForInputBlock) { if (mApzcForInputBlock) {
mApzcForInputBlock->GetGuid(aOutTargetGuid);
// Use the cached transform to compute the point to send to the APZC. // 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 // This ensures that the sequence of touch points an APZC sees in an
// input block are all in the same coordinate space. // input block are all in the same coordinate space.
@@ -290,6 +292,7 @@ APZCTreeManager::ReceiveInputEvent(const InputData& aEvent)
const PinchGestureInput& pinchInput = aEvent.AsPinchGestureInput(); const PinchGestureInput& pinchInput = aEvent.AsPinchGestureInput();
nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(pinchInput.mFocusPoint); nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(pinchInput.mFocusPoint);
if (apzc) { if (apzc) {
apzc->GetGuid(aOutTargetGuid);
GetInputTransforms(apzc, transformToApzc, transformToGecko); GetInputTransforms(apzc, transformToApzc, transformToGecko);
PinchGestureInput inputForApzc(pinchInput); PinchGestureInput inputForApzc(pinchInput);
ApplyTransform(&(inputForApzc.mFocusPoint), transformToApzc); ApplyTransform(&(inputForApzc.mFocusPoint), transformToApzc);
@@ -300,6 +303,7 @@ APZCTreeManager::ReceiveInputEvent(const InputData& aEvent)
const TapGestureInput& tapInput = aEvent.AsTapGestureInput(); const TapGestureInput& tapInput = aEvent.AsTapGestureInput();
nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(ScreenPoint(tapInput.mPoint)); nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(ScreenPoint(tapInput.mPoint));
if (apzc) { if (apzc) {
apzc->GetGuid(aOutTargetGuid);
GetInputTransforms(apzc, transformToApzc, transformToGecko); GetInputTransforms(apzc, transformToApzc, transformToGecko);
TapGestureInput inputForApzc(tapInput); TapGestureInput inputForApzc(tapInput);
ApplyTransform(&(inputForApzc.mPoint), transformToApzc); ApplyTransform(&(inputForApzc.mPoint), transformToApzc);
@@ -342,6 +346,7 @@ APZCTreeManager::GetTouchInputBlockAPZC(const WidgetTouchEvent& aEvent,
nsEventStatus nsEventStatus
APZCTreeManager::ProcessTouchEvent(const WidgetTouchEvent& aEvent, APZCTreeManager::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
WidgetTouchEvent* aOutEvent) WidgetTouchEvent* aOutEvent)
{ {
nsEventStatus ret = nsEventStatus_eIgnore; nsEventStatus ret = nsEventStatus_eIgnore;
@@ -355,6 +360,7 @@ APZCTreeManager::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
} }
if (mApzcForInputBlock) { if (mApzcForInputBlock) {
mApzcForInputBlock->GetGuid(aOutTargetGuid);
// For computing the input for the APZC, used the cached transform. // For computing the input for the APZC, used the cached transform.
// This ensures that the sequence of touch points an APZC sees in an // This ensures that the sequence of touch points an APZC sees in an
// input block are all in the same coordinate space. // input block are all in the same coordinate space.
@@ -394,12 +400,14 @@ APZCTreeManager::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
nsEventStatus nsEventStatus
APZCTreeManager::ProcessMouseEvent(const WidgetMouseEvent& aEvent, APZCTreeManager::ProcessMouseEvent(const WidgetMouseEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
WidgetMouseEvent* aOutEvent) WidgetMouseEvent* aOutEvent)
{ {
nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(ScreenPoint(aEvent.refPoint.x, aEvent.refPoint.y)); nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(ScreenPoint(aEvent.refPoint.x, aEvent.refPoint.y));
if (!apzc) { if (!apzc) {
return nsEventStatus_eIgnore; return nsEventStatus_eIgnore;
} }
apzc->GetGuid(aOutTargetGuid);
gfx3DMatrix transformToApzc; gfx3DMatrix transformToApzc;
gfx3DMatrix transformToGecko; gfx3DMatrix transformToGecko;
GetInputTransforms(apzc, transformToApzc, transformToGecko); GetInputTransforms(apzc, transformToApzc, transformToGecko);
@@ -412,6 +420,7 @@ APZCTreeManager::ProcessMouseEvent(const WidgetMouseEvent& aEvent,
nsEventStatus nsEventStatus
APZCTreeManager::ProcessEvent(const WidgetInputEvent& aEvent, APZCTreeManager::ProcessEvent(const WidgetInputEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
WidgetInputEvent* aOutEvent) WidgetInputEvent* aOutEvent)
{ {
// Transform the refPoint // Transform the refPoint
@@ -419,6 +428,7 @@ APZCTreeManager::ProcessEvent(const WidgetInputEvent& aEvent,
if (!apzc) { if (!apzc) {
return nsEventStatus_eIgnore; return nsEventStatus_eIgnore;
} }
apzc->GetGuid(aOutTargetGuid);
gfx3DMatrix transformToApzc; gfx3DMatrix transformToApzc;
gfx3DMatrix transformToGecko; gfx3DMatrix transformToGecko;
GetInputTransforms(apzc, transformToApzc, transformToGecko); GetInputTransforms(apzc, transformToApzc, transformToGecko);
@@ -429,6 +439,7 @@ APZCTreeManager::ProcessEvent(const WidgetInputEvent& aEvent,
nsEventStatus nsEventStatus
APZCTreeManager::ReceiveInputEvent(const WidgetInputEvent& aEvent, APZCTreeManager::ReceiveInputEvent(const WidgetInputEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
WidgetInputEvent* aOutEvent) WidgetInputEvent* aOutEvent)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@@ -436,32 +447,33 @@ APZCTreeManager::ReceiveInputEvent(const WidgetInputEvent& aEvent,
switch (aEvent.eventStructType) { switch (aEvent.eventStructType) {
case NS_TOUCH_EVENT: { case NS_TOUCH_EVENT: {
const WidgetTouchEvent& touchEvent = *aEvent.AsTouchEvent(); const WidgetTouchEvent& touchEvent = *aEvent.AsTouchEvent();
return ProcessTouchEvent(touchEvent, aOutEvent->AsTouchEvent()); return ProcessTouchEvent(touchEvent, aOutTargetGuid, aOutEvent->AsTouchEvent());
} }
case NS_MOUSE_EVENT: { case NS_MOUSE_EVENT: {
// For b2g emulation // For b2g emulation
const WidgetMouseEvent& mouseEvent = *aEvent.AsMouseEvent(); const WidgetMouseEvent& mouseEvent = *aEvent.AsMouseEvent();
WidgetMouseEvent* outMouseEvent = aOutEvent->AsMouseEvent(); WidgetMouseEvent* outMouseEvent = aOutEvent->AsMouseEvent();
return ProcessMouseEvent(mouseEvent, outMouseEvent); return ProcessMouseEvent(mouseEvent, aOutTargetGuid, outMouseEvent);
} }
default: { default: {
return ProcessEvent(aEvent, aOutEvent); return ProcessEvent(aEvent, aOutTargetGuid, aOutEvent);
} }
} }
} }
nsEventStatus nsEventStatus
APZCTreeManager::ReceiveInputEvent(WidgetInputEvent& aEvent) APZCTreeManager::ReceiveInputEvent(WidgetInputEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
switch (aEvent.eventStructType) { switch (aEvent.eventStructType) {
case NS_TOUCH_EVENT: { case NS_TOUCH_EVENT: {
WidgetTouchEvent& touchEvent = *aEvent.AsTouchEvent(); WidgetTouchEvent& touchEvent = *aEvent.AsTouchEvent();
return ProcessTouchEvent(touchEvent, &touchEvent); return ProcessTouchEvent(touchEvent, aOutTargetGuid, &touchEvent);
} }
default: { default: {
return ProcessEvent(aEvent, &aEvent); return ProcessEvent(aEvent, aOutTargetGuid, &aEvent);
} }
} }
} }

View File

@@ -44,6 +44,14 @@ struct ScrollableLayerGuid {
uint32_t mPresShellId; uint32_t mPresShellId;
FrameMetrics::ViewID mScrollId; FrameMetrics::ViewID mScrollId;
ScrollableLayerGuid()
: mLayersId(0)
, mPresShellId(0)
, mScrollId(0)
{
MOZ_COUNT_CTOR(ScrollableLayerGuid);
}
ScrollableLayerGuid(uint64_t aLayersId, uint32_t aPresShellId, ScrollableLayerGuid(uint64_t aLayersId, uint32_t aPresShellId,
FrameMetrics::ViewID aScrollId) FrameMetrics::ViewID aScrollId)
: mLayersId(aLayersId) : mLayersId(aLayersId)
@@ -142,8 +150,13 @@ public:
* General handler for incoming input events. Manipulates the frame metrics * General handler for incoming input events. Manipulates the frame metrics
* based on what type of input it is. For example, a PinchGestureEvent will * based on what type of input it is. For example, a PinchGestureEvent will
* cause scaling. This should only be called externally to this class. * 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 * WidgetInputEvent handler. Sets |aOutEvent| (which is assumed to be an
@@ -158,9 +171,12 @@ public:
* to the appropriate apz as such. * to the appropriate apz as such.
* *
* @param aEvent input event object, will not be modified * @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. * @param aOutEvent event object transformed to DOM coordinate space.
*/ */
nsEventStatus ReceiveInputEvent(const WidgetInputEvent& aEvent, nsEventStatus ReceiveInputEvent(const WidgetInputEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
WidgetInputEvent* aOutEvent); WidgetInputEvent* aOutEvent);
/** /**
@@ -168,8 +184,11 @@ public:
* WidgetInputEvent. Must be called on the main thread. * WidgetInputEvent. Must be called on the main thread.
* *
* @param aEvent input event object * @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 * 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* CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2);
AsyncPanZoomController* RootAPZCForLayersId(AsyncPanZoomController* aApzc); AsyncPanZoomController* RootAPZCForLayersId(AsyncPanZoomController* aApzc);
AsyncPanZoomController* GetTouchInputBlockAPZC(const WidgetTouchEvent& aEvent, ScreenPoint aPoint); AsyncPanZoomController* GetTouchInputBlockAPZC(const WidgetTouchEvent& aEvent, ScreenPoint aPoint);
nsEventStatus ProcessTouchEvent(const WidgetTouchEvent& touchEvent, WidgetTouchEvent* aOutEvent); nsEventStatus ProcessTouchEvent(const WidgetTouchEvent& touchEvent, ScrollableLayerGuid* aOutTargetGuid, WidgetTouchEvent* aOutEvent);
nsEventStatus ProcessMouseEvent(const WidgetMouseEvent& mouseEvent, WidgetMouseEvent* aOutEvent); nsEventStatus ProcessMouseEvent(const WidgetMouseEvent& mouseEvent, ScrollableLayerGuid* aOutTargetGuid, WidgetMouseEvent* aOutEvent);
nsEventStatus ProcessEvent(const WidgetInputEvent& inputEvent, WidgetInputEvent* aOutEvent); nsEventStatus ProcessEvent(const WidgetInputEvent& inputEvent, ScrollableLayerGuid* aOutTargetGuid, WidgetInputEvent* aOutEvent);
/** /**
* Recursive helper function to build the APZC tree. The tree of APZC instances has * Recursive helper function to build the APZC tree. The tree of APZC instances has

View File

@@ -1544,5 +1544,15 @@ bool AsyncPanZoomController::Matches(const ScrollableLayerGuid& aGuid)
return aGuid.mLayersId == mLayersId && aGuid.mScrollId == mFrameMetrics.mScrollId; 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;
}
} }
} }

View File

@@ -231,6 +231,11 @@ public:
*/ */
nsEventStatus HandleInputEvent(const InputData& aEvent); 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. * Returns true if this APZC instance is for the layer identified by the guid.
*/ */

View File

@@ -830,7 +830,7 @@ RenderFrameParent::NotifyInputEvent(const WidgetInputEvent& aEvent,
WidgetInputEvent* aOutEvent) WidgetInputEvent* aOutEvent)
{ {
if (GetApzcTreeManager()) { if (GetApzcTreeManager()) {
GetApzcTreeManager()->ReceiveInputEvent(aEvent, aOutEvent); GetApzcTreeManager()->ReceiveInputEvent(aEvent, nullptr, aOutEvent);
} }
} }

View File

@@ -877,7 +877,7 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent(JNIEnv* env,
const MultiTouchInput& input = wrapper->MakeMultiTouchInput(nsWindow::TopWindow()); const MultiTouchInput& input = wrapper->MakeMultiTouchInput(nsWindow::TopWindow());
delete wrapper; delete wrapper;
if (input.mType >= 0) { if (input.mType >= 0) {
controller->ReceiveInputEvent(input); controller->ReceiveInputEvent(input, nullptr);
} }
} }
} }