Bug 918288 - Modify the SetTargetAPZC API to take an array of targets for multiple touch points. r=botond

This commit is contained in:
Kartikaya Gupta 2014-11-21 21:36:25 -05:00
parent f4fc72589d
commit 08918bfa1a
3 changed files with 34 additions and 16 deletions

View File

@ -721,11 +721,7 @@ APZCTreeManager::GetTouchInputBlockAPZC(const MultiTouchInput& aEvent,
apzc = GetTargetAPZC(aEvent.mTouches[0].mScreenPoint, aOutHitResult);
for (size_t i = 1; i < aEvent.mTouches.Length(); i++) {
nsRefPtr<AsyncPanZoomController> apzc2 = GetTargetAPZC(aEvent.mTouches[i].mScreenPoint, aOutHitResult);
apzc = CommonAncestor(apzc.get(), apzc2.get());
APZCTM_LOG("Using APZC %p as the common ancestor\n", apzc.get());
// For now, we only ever want to do pinching on the root APZC for a given layers id. So
// when we find the common ancestor of multiple points, also walk up to the root APZC.
apzc = RootAPZCForLayersId(apzc);
apzc = GetMultitouchTarget(apzc, apzc2);
APZCTM_LOG("Using APZC %p as the root APZC for multi-touch\n", apzc.get());
}
@ -960,9 +956,16 @@ APZCTreeManager::ContentReceivedTouch(uint64_t aInputBlockId,
void
APZCTreeManager::SetTargetAPZC(uint64_t aInputBlockId,
const ScrollableLayerGuid& aGuid)
const nsTArray<ScrollableLayerGuid>& aTargets)
{
nsRefPtr<AsyncPanZoomController> target = GetTargetAPZC(aGuid);
nsRefPtr<AsyncPanZoomController> target = nullptr;
if (aTargets.Length() > 0) {
target = GetTargetAPZC(aTargets[0]);
}
for (size_t i = 1; i < aTargets.Length(); i++) {
nsRefPtr<AsyncPanZoomController> apzc2 = GetTargetAPZC(aTargets[i]);
target = GetMultitouchTarget(target, apzc2);
}
mInputQueue->SetConfirmedTargetApzc(aInputBlockId, target);
}
@ -1556,7 +1559,17 @@ APZCTreeManager::GetApzcToGeckoTransform(const AsyncPanZoomController *aApzc) co
}
already_AddRefed<AsyncPanZoomController>
APZCTreeManager::CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2)
APZCTreeManager::GetMultitouchTarget(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2) const
{
nsRefPtr<AsyncPanZoomController> apzc = CommonAncestor(aApzc1, aApzc2);
// For now, we only ever want to do pinching on the root APZC for a given layers id. So
// when we find the common ancestor of multiple points, also walk up to the root APZC.
apzc = RootAPZCForLayersId(apzc);
return apzc.forget();
}
already_AddRefed<AsyncPanZoomController>
APZCTreeManager::CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2) const
{
MonitorAutoLock lock(mTreeLock);
nsRefPtr<AsyncPanZoomController> ancestor;
@ -1602,7 +1615,7 @@ APZCTreeManager::CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomCont
}
already_AddRefed<AsyncPanZoomController>
APZCTreeManager::RootAPZCForLayersId(AsyncPanZoomController* aApzc)
APZCTreeManager::RootAPZCForLayersId(AsyncPanZoomController* aApzc) const
{
MonitorAutoLock lock(mTreeLock);
nsRefPtr<AsyncPanZoomController> apzc = aApzc;

View File

@ -219,11 +219,13 @@ public:
* where the initial input event of the block hit a dispatch-to-content region
* but is safe to call for all input blocks. This function should always be
* invoked on the controller thread.
* In the case where the input block has no target, or the target is not a
* scrollable frame, |aGuid.mScrollId| should be set to FrameMetrics::
* NULL_SCROLL_ID.
* The different elements in the array of targets correspond to the targets
* for the different touch points. In the case where the touch point has no
* target, or the target is not a scrollable frame, the target's |mScrollId|
* should be set to FrameMetrics::NULL_SCROLL_ID.
*/
void SetTargetAPZC(uint64_t aInputBlockId, const ScrollableLayerGuid& aGuid);
void SetTargetAPZC(uint64_t aInputBlockId,
const nsTArray<ScrollableLayerGuid>& aTargets);
/**
* Updates any zoom constraints contained in the <meta name="viewport"> tag.
@ -404,8 +406,9 @@ private:
AsyncPanZoomController* GetAPZCAtPoint(AsyncPanZoomController* aApzc,
const gfx::Point& aHitTestPoint,
HitTestResult* aOutHitResult);
already_AddRefed<AsyncPanZoomController> CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2);
already_AddRefed<AsyncPanZoomController> RootAPZCForLayersId(AsyncPanZoomController* aApzc);
already_AddRefed<AsyncPanZoomController> GetMultitouchTarget(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2) const;
already_AddRefed<AsyncPanZoomController> CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2) const;
already_AddRefed<AsyncPanZoomController> RootAPZCForLayersId(AsyncPanZoomController* aApzc) const;
already_AddRefed<AsyncPanZoomController> GetTouchInputBlockAPZC(const MultiTouchInput& aEvent,
HitTestResult* aOutHitResult);
nsEventStatus ProcessTouchInput(MultiTouchInput& aInput,

View File

@ -2485,7 +2485,9 @@ TEST_F(APZEventRegionsTester, HitRegionImmediateResponse) {
// Now let's do that again, but simulate a main-thread response
uint64_t inputBlockId = 0;
Tap(manager, 10, 110, time, 100, nullptr, &inputBlockId);
manager->SetTargetAPZC(inputBlockId, left->GetGuid());
nsTArray<ScrollableLayerGuid> targets;
targets.AppendElement(left->GetGuid());
manager->SetTargetAPZC(inputBlockId, targets);
while (mcc->RunThroughDelayedTasks()); // this runs the tap event
check.Call("Tapped on left this time");
}