Bug 1101628 - Add additional HitResult types to reflect the different event regions. r=botond

MozReview-Commit-ID: DxZjv1eCWLU
This commit is contained in:
Kartikaya Gupta 2016-06-01 15:48:05 -04:00
Родитель 91677b958d
Коммит f8cf1bc2e1
4 изменённых файлов: 37 добавлений и 33 удалений

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

@ -190,31 +190,16 @@ struct EventRegions {
bool operator==(const EventRegions& aRegions) const
{
return mHitRegion == aRegions.mHitRegion &&
mDispatchToContentHitRegion == aRegions.mDispatchToContentHitRegion;
mDispatchToContentHitRegion == aRegions.mDispatchToContentHitRegion &&
mNoActionRegion == aRegions.mNoActionRegion &&
mHorizontalPanRegion == aRegions.mHorizontalPanRegion &&
mVerticalPanRegion == aRegions.mVerticalPanRegion;
}
bool operator!=(const EventRegions& aRegions) const
{
return !(*this == aRegions);
}
void OrWith(const EventRegions& aOther)
{
mHitRegion.OrWith(aOther.mHitRegion);
mDispatchToContentHitRegion.OrWith(aOther.mDispatchToContentHitRegion);
}
void AndWith(const nsIntRegion& aRegion)
{
mHitRegion.AndWith(aRegion);
mDispatchToContentHitRegion.AndWith(aRegion);
}
void Sub(const EventRegions& aMinuend, const nsIntRegion& aSubtrahend)
{
mHitRegion.Sub(aMinuend.mHitRegion, aSubtrahend);
mDispatchToContentHitRegion.Sub(aMinuend.mDispatchToContentHitRegion, aSubtrahend);
}
void ApplyTranslationAndScale(float aXTrans, float aYTrans, float aXScale, float aYScale)
{
mHitRegion.ScaleRoundOut(aXScale, aYScale);
@ -234,12 +219,18 @@ struct EventRegions {
{
mHitRegion.Transform(aTransform);
mDispatchToContentHitRegion.Transform(aTransform);
mNoActionRegion.Transform(aTransform);
mHorizontalPanRegion.Transform(aTransform);
mVerticalPanRegion.Transform(aTransform);
}
bool IsEmpty() const
{
return mHitRegion.IsEmpty()
&& mDispatchToContentHitRegion.IsEmpty();
&& mDispatchToContentHitRegion.IsEmpty()
&& mNoActionRegion.IsEmpty()
&& mHorizontalPanRegion.IsEmpty()
&& mVerticalPanRegion.IsEmpty();
}
nsCString ToString() const

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

@ -696,7 +696,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
}
if (apzc) {
bool targetConfirmed = (hitResult == HitLayer);
bool targetConfirmed = (hitResult != HitNothing && hitResult != HitDispatchToContentRegion);
if (gfxPrefs::APZDragEnabled() && hitScrollbar) {
// If scrollbar dragging is enabled and we hit a scrollbar, wait
// for the main-thread confirmation because it contains drag metrics
@ -752,7 +752,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(wheelInput.mOrigin,
&hitResult);
if (apzc) {
MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion);
MOZ_ASSERT(hitResult != HitNothing);
// For wheel events, the call to ReceiveInputEvent below may result in
// scrolling, which changes the async transform. However, the event we
@ -772,7 +772,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
result = mInputQueue->ReceiveInputEvent(
apzc,
/* aTargetConfirmed = */ hitResult == HitLayer,
/* aTargetConfirmed = */ hitResult != HitDispatchToContentRegion,
wheelInput, aOutInputBlockId);
// Update the out-parameters so they are what the caller expects.
@ -802,7 +802,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(panInput.mPanStartPoint,
&hitResult);
if (apzc) {
MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion);
MOZ_ASSERT(hitResult != HitNothing);
// For pan gesture events, the call to ReceiveInputEvent below may result in
// scrolling, which changes the async transform. However, the event we
@ -824,7 +824,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
result = mInputQueue->ReceiveInputEvent(
apzc,
/* aTargetConfirmed = */ hitResult == HitLayer,
/* aTargetConfirmed = */ hitResult != HitDispatchToContentRegion,
panInput, aOutInputBlockId);
// Update the out-parameters so they are what the caller expects.
@ -838,7 +838,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(pinchInput.mFocusPoint,
&hitResult);
if (apzc) {
MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion);
MOZ_ASSERT(hitResult != HitNothing);
ScreenToScreenMatrix4x4 outTransform = GetScreenToApzcTransform(apzc)
* GetApzcToGeckoTransform(apzc);
@ -851,7 +851,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
result = mInputQueue->ReceiveInputEvent(
apzc,
/* aTargetConfirmed = */ hitResult == HitLayer,
/* aTargetConfirmed = */ hitResult != HitDispatchToContentRegion,
pinchInput, aOutInputBlockId);
// Update the out-parameters so they are what the caller expects.
@ -864,7 +864,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(tapInput.mPoint,
&hitResult);
if (apzc) {
MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion);
MOZ_ASSERT(hitResult != HitNothing);
ScreenToScreenMatrix4x4 outTransform = GetScreenToApzcTransform(apzc)
* GetApzcToGeckoTransform(apzc);
@ -877,7 +877,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
result = mInputQueue->ReceiveInputEvent(
apzc,
/* aTargetConfirmed = */ hitResult == HitLayer,
/* aTargetConfirmed = */ hitResult != HitDispatchToContentRegion,
tapInput, aOutInputBlockId);
// Update the out-parameters so they are what the caller expects.
@ -964,11 +964,11 @@ APZCTreeManager::ProcessTouchInput(MultiTouchInput& aInput,
nsEventStatus result = nsEventStatus_eIgnore;
if (mApzcForInputBlock) {
MOZ_ASSERT(mHitResultForInputBlock == HitLayer || mHitResultForInputBlock == HitDispatchToContentRegion);
MOZ_ASSERT(mHitResultForInputBlock != HitNothing);
mApzcForInputBlock->GetGuid(aOutTargetGuid);
result = mInputQueue->ReceiveInputEvent(mApzcForInputBlock,
/* aTargetConfirmed = */ mHitResultForInputBlock == HitLayer,
/* aTargetConfirmed = */ mHitResultForInputBlock != HitDispatchToContentRegion,
aInput, aOutInputBlockId);
// For computing the event to pass back to Gecko, use up-to-date transforms
@ -1065,7 +1065,7 @@ APZCTreeManager::ProcessEvent(WidgetInputEvent& aEvent,
ViewAs<ScreenPixel>(aEvent.mRefPoint, LDIsScreen);
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(refPointAsScreen, &hitResult);
if (apzc) {
MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion);
MOZ_ASSERT(hitResult != HitNothing);
apzc->GetGuid(aOutTargetGuid);
ScreenToParentLayerMatrix4x4 transformToApzc = GetScreenToApzcTransform(apzc);
ParentLayerToScreenMatrix4x4 transformToGecko = GetApzcToGeckoTransform(apzc);
@ -1783,7 +1783,6 @@ APZCTreeManager::GetAPZCAtPoint(HitTestingTreeNode* aNode,
Stringify(hitTestPoints.top()).c_str(), aNode);
if (hitResult != HitTestResult::HitNothing) {
resultNode = aNode;
MOZ_ASSERT(hitResult == HitLayer || hitResult == HitDispatchToContentRegion);
// If event regions are disabled, *aOutHitResult will be HitLayer
*aOutHitResult = hitResult;
return TraversalFlag::Abort;

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

@ -19,6 +19,9 @@ namespace layers {
enum HitTestResult {
HitNothing,
HitLayer,
HitLayerTouchActionNone,
HitLayerTouchActionPanX,
HitLayerTouchActionPanY,
HitDispatchToContentRegion,
};

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

@ -278,6 +278,17 @@ HitTestingTreeNode::HitTest(const ParentLayerPoint& aPoint) const
{
return HitTestResult::HitDispatchToContentRegion;
}
if (gfxPrefs::TouchActionEnabled()) {
if (mEventRegions.mNoActionRegion.Contains(point.x, point.y)) {
return HitTestResult::HitLayerTouchActionNone;
}
if (mEventRegions.mHorizontalPanRegion.Contains(point.x, point.y)) {
return HitTestResult::HitLayerTouchActionPanX;
}
if (mEventRegions.mVerticalPanRegion.Contains(point.x, point.y)) {
return HitTestResult::HitLayerTouchActionPanY;
}
}
return HitTestResult::HitLayer;
}