Bug 1212876 - Fix a bug in UntransformVector and in code that was relying on that bug. r=botond

This commit is contained in:
Markus Stange 2015-10-09 12:57:56 +02:00
parent 6cded789af
commit 733701d783
4 changed files with 14 additions and 3 deletions

View File

@ -1828,8 +1828,16 @@ nsEventStatus AsyncPanZoomController::OnPan(const PanGestureInput& aEvent, bool
*CurrentPanGestureBlock()->GetOverscrollHandoffChain(),
panDistance,
ScrollSource::Wheel);
// Create fake "touch" positions that will result in the desired scroll motion.
// Note that the pan displacement describes the change in scroll position:
// positive displacement values mean that the scroll position increases.
// However, an increase in scroll position means that the scrolled contents
// are moved to the left / upwards. Since our simulated "touches" determine
// the motion of the scrolled contents, not of the scroll position, they need
// to move in the opposite direction of the pan displacement.
ParentLayerPoint startPoint = aEvent.mLocalPanStartPoint;
ParentLayerPoint endPoint = aEvent.mLocalPanStartPoint + aEvent.mLocalPanDisplacement;
ParentLayerPoint endPoint = aEvent.mLocalPanStartPoint - aEvent.mLocalPanDisplacement;
CallDispatchScroll(startPoint, endPoint, handoffState);
return nsEventStatus_eConsumeNoDefault;

View File

@ -76,7 +76,7 @@ void Axis::UpdateWithTouchAtDevicePoint(ParentLayerCoord aPos, ParentLayerCoord
return;
}
float newVelocity = mAxisLocked ? 0.0f : (float)(mPos - aPos + aAdditionalDelta) / (float)(aTimestampMs - mPosTimeMs);
float newVelocity = mAxisLocked ? 0.0f : (float)(mPos - aPos - aAdditionalDelta) / (float)(aTimestampMs - mPosTimeMs);
if (gfxPrefs::APZMaxVelocity() > 0.0f) {
bool velocityIsNegative = (newVelocity < 0);
newVelocity = fabs(newVelocity);

View File

@ -43,6 +43,9 @@ public:
/**
* Notify this Axis that a new touch has been received, including a timestamp
* for when the touch was received. This triggers a recalculation of velocity.
* This can also used for pan gesture events. For those events, the "touch"
* location is stationary and the scroll displacement is passed in as
* aAdditionalDelta.
*/
void UpdateWithTouchAtDevicePoint(ParentLayerCoord aPos, ParentLayerCoord aAdditionalDelta, uint32_t aTimestampMs);

View File

@ -217,7 +217,7 @@ static Maybe<gfx::PointTyped<TargetUnits>> UntransformVector(const gfx::Matrix4x
if (!projectedAnchor.HasPositiveWCoord() || !projectedTarget.HasPositiveWCoord()){
return Nothing();
}
return Some(ViewAs<TargetUnits>(projectedAnchor.As2DPoint() - projectedTarget.As2DPoint()));
return Some(ViewAs<TargetUnits>(projectedTarget.As2DPoint() - projectedAnchor.As2DPoint()));
}
} // namespace mozilla