зеркало из https://github.com/mozilla/gecko-dev.git
Bug 923512 - Introduce strongly-typed coordinate classes (Part2: Changes to rest of codebase, and switching Axis to use the strongly-typed coordinates). r=kats
This commit is contained in:
Родитель
320a557f2c
Коммит
4dcd36c48e
|
@ -728,7 +728,7 @@ public:
|
|||
int32_t ScrollTop()
|
||||
{
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
return sf ? sf->GetScrollPositionCSSPixels().y : 0;
|
||||
return sf ? sf->GetScrollPositionCSSPixels().y.value : 0;
|
||||
}
|
||||
void SetScrollTop(int32_t aScrollTop)
|
||||
{
|
||||
|
@ -741,7 +741,7 @@ public:
|
|||
int32_t ScrollLeft()
|
||||
{
|
||||
nsIScrollableFrame* sf = GetScrollFrame();
|
||||
return sf ? sf->GetScrollPositionCSSPixels().x : 0;
|
||||
return sf ? sf->GetScrollPositionCSSPixels().x.value : 0;
|
||||
}
|
||||
void SetScrollLeft(int32_t aScrollLeft)
|
||||
{
|
||||
|
|
|
@ -1987,7 +1987,7 @@ CanvasRenderingContext2D::ArcTo(double x1, double y1, double x2,
|
|||
}
|
||||
|
||||
// Check for colinearity
|
||||
dir = (p2.x - p1.x) * (p0.y - p1.y) + (p2.y - p1.y) * (p1.x - p0.x);
|
||||
dir = (p2.x - p1.x).value * (p0.y - p1.y).value + (p2.y - p1.y).value * (p1.x - p0.x).value;
|
||||
if (dir == 0) {
|
||||
LineTo(p1.x, p1.y);
|
||||
return;
|
||||
|
@ -4505,7 +4505,7 @@ CanvasPath::ArcTo(double x1, double y1, double x2, double y2, double radius,
|
|||
}
|
||||
|
||||
// Check for colinearity
|
||||
dir = (p2.x - p1.x) * (p0.y - p1.y) + (p2.y - p1.y) * (p1.x - p0.x);
|
||||
dir = (p2.x - p1.x).value * (p0.y - p1.y).value + (p2.y - p1.y).value * (p1.x - p0.x).value;
|
||||
if (dir == 0) {
|
||||
LineTo(p1.x, p1.y);
|
||||
return;
|
||||
|
|
|
@ -791,7 +791,7 @@ protected:
|
|||
// The spec says we should not draw shadows if the operator is OVER.
|
||||
// If it's over and the alpha value is zero, nothing needs to be drawn.
|
||||
return NS_GET_A(state.shadowColor) != 0 &&
|
||||
(state.shadowBlur != 0 || state.shadowOffset.x != 0 || state.shadowOffset.y != 0);
|
||||
(state.shadowBlur != 0.f || state.shadowOffset.x != 0.f || state.shadowOffset.y != 0.f);
|
||||
}
|
||||
|
||||
mozilla::gfx::CompositionOp UsedOperation()
|
||||
|
|
|
@ -1595,8 +1595,9 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
|
|||
// fire drag gesture if mouse has moved enough
|
||||
LayoutDeviceIntPoint pt = aEvent->refPoint +
|
||||
LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
|
||||
if (DeprecatedAbs(pt.x - mGestureDownPoint.x) > pixelThresholdX ||
|
||||
DeprecatedAbs(pt.y - mGestureDownPoint.y) > pixelThresholdY) {
|
||||
LayoutDeviceIntPoint distance = pt - mGestureDownPoint;
|
||||
if (Abs(distance.x.value) > SafeCast<uint32_t>(pixelThresholdX) ||
|
||||
Abs(distance.y.value) > SafeCast<uint32_t>(pixelThresholdY)) {
|
||||
if (Prefs::ClickHoldContextMenu()) {
|
||||
// stop the click-hold before we fire off the drag gesture, in case
|
||||
// it takes a long time
|
||||
|
|
|
@ -507,6 +507,38 @@ struct ParamTraits<nsIntSize>
|
|||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ParamTraits< mozilla::gfx::CoordTyped<T> >
|
||||
{
|
||||
typedef mozilla::gfx::CoordTyped<T> paramType;
|
||||
|
||||
static void Write(Message* msg, const paramType& param)
|
||||
{
|
||||
WriteParam(msg, param.value);
|
||||
}
|
||||
|
||||
static bool Read(const Message* msg, void** iter, paramType* result)
|
||||
{
|
||||
return (ReadParam(msg, iter, &result->value));
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct ParamTraits< mozilla::gfx::IntCoordTyped<T> >
|
||||
{
|
||||
typedef mozilla::gfx::IntCoordTyped<T> paramType;
|
||||
|
||||
static void Write(Message* msg, const paramType& param)
|
||||
{
|
||||
WriteParam(msg, param.value);
|
||||
}
|
||||
|
||||
static bool Read(const Message* msg, void** iter, paramType* result)
|
||||
{
|
||||
return (ReadParam(msg, iter, &result->value));
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
struct ParamTraits< mozilla::gfx::ScaleFactor<T, U> >
|
||||
{
|
||||
|
|
|
@ -384,16 +384,14 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
|
|||
ApplyTransform(gfx::PointTyped<T>* aPoint, const Matrix4x4& aMatrix)
|
||||
{
|
||||
Point result = aMatrix * aPoint->ToUnknownPoint();
|
||||
aPoint->x = result.x;
|
||||
aPoint->y = result.y;
|
||||
*aPoint = ViewAs<T>(result);
|
||||
}
|
||||
|
||||
/*static*/ template<class T> void
|
||||
ApplyTransform(gfx::IntPointTyped<T>* aPoint, const Matrix4x4& aMatrix)
|
||||
{
|
||||
Point result = aMatrix * aPoint->ToUnknownPoint();
|
||||
aPoint->x = result.x;
|
||||
aPoint->y = result.y;
|
||||
*aPoint = TruncatedToInt(ViewAs<T>(result));
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
|
@ -651,9 +649,7 @@ APZCTreeManager::TransformCoordinateToGecko(const ScreenIntPoint& aPoint,
|
|||
Matrix4x4 transformToGecko;
|
||||
GetInputTransforms(apzc, transformToApzc, transformToGecko);
|
||||
Matrix4x4 outTransform = transformToApzc * transformToGecko;
|
||||
aOutTransformedPoint->x = aPoint.x;
|
||||
aOutTransformedPoint->y = aPoint.y;
|
||||
ApplyTransform(aOutTransformedPoint, outTransform);
|
||||
*aOutTransformedPoint = TransformTo<LayoutDevicePixel>(outTransform, aPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -378,8 +378,8 @@ static bool IsCloseToVertical(float aAngle, float aThreshold)
|
|||
template <typename Units>
|
||||
static bool IsZero(const gfx::PointTyped<Units>& aPoint)
|
||||
{
|
||||
return FuzzyEqualsMultiplicative(aPoint.x, 0.0f)
|
||||
&& FuzzyEqualsMultiplicative(aPoint.y, 0.0f);
|
||||
return FuzzyEqualsMultiplicative(aPoint.x.value, 0.0f)
|
||||
&& FuzzyEqualsMultiplicative(aPoint.y.value, 0.0f);
|
||||
}
|
||||
|
||||
static inline void LogRendertraceRect(const ScrollableLayerGuid& aGuid, const char* aDesc, const char* aColor, const CSSRect& aRect)
|
||||
|
@ -529,9 +529,9 @@ public:
|
|||
// We may have reached the end of the scroll range along one axis but
|
||||
// not the other. In such a case we only want to hand off the relevant
|
||||
// component of the fling.
|
||||
if (FuzzyEqualsAdditive(overscroll.x, 0.0f, COORDINATE_EPSILON)) {
|
||||
if (FuzzyEqualsAdditive(overscroll.x.value, 0.0f, COORDINATE_EPSILON)) {
|
||||
velocity.x = 0;
|
||||
} else if (FuzzyEqualsAdditive(overscroll.y, 0.0f, COORDINATE_EPSILON)) {
|
||||
} else if (FuzzyEqualsAdditive(overscroll.y.value, 0.0f, COORDINATE_EPSILON)) {
|
||||
velocity.y = 0;
|
||||
}
|
||||
|
||||
|
@ -599,7 +599,7 @@ public:
|
|||
|
||||
// Sample the zoom at the current time point. The sampled zoom
|
||||
// will affect the final computed resolution.
|
||||
double sampledPosition = gComputedTimingFunction->GetValue(animPosition);
|
||||
float sampledPosition = gComputedTimingFunction->GetValue(animPosition);
|
||||
|
||||
// We scale the scrollOffset linearly with sampledPosition, so the zoom
|
||||
// needs to scale inversely to match.
|
||||
|
@ -1357,8 +1357,8 @@ AsyncPanZoomController::ConvertToGecko(const ScreenPoint& aPoint, CSSPoint* aOut
|
|||
nsEventStatus AsyncPanZoomController::OnPanMayBegin(const PanGestureInput& aEvent) {
|
||||
APZC_LOG("%p got a pan-maybegin in state %d\n", this, mState);
|
||||
|
||||
mX.StartTouch(aEvent.mPanStartPoint.x, aEvent.mTime);
|
||||
mY.StartTouch(aEvent.mPanStartPoint.y, aEvent.mTime);
|
||||
mX.StartTouch(aEvent.mPanStartPoint.x.Truncated(), aEvent.mTime);
|
||||
mY.StartTouch(aEvent.mPanStartPoint.y.Truncated(), aEvent.mTime);
|
||||
CancelAnimationForHandoffChain();
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
|
@ -1377,8 +1377,8 @@ nsEventStatus AsyncPanZoomController::OnPanCancelled(const PanGestureInput& aEve
|
|||
nsEventStatus AsyncPanZoomController::OnPanBegin(const PanGestureInput& aEvent) {
|
||||
APZC_LOG("%p got a pan-begin in state %d\n", this, mState);
|
||||
|
||||
mX.StartTouch(aEvent.mPanStartPoint.x, aEvent.mTime);
|
||||
mY.StartTouch(aEvent.mPanStartPoint.y, aEvent.mTime);
|
||||
mX.StartTouch(aEvent.mPanStartPoint.x.Truncated(), aEvent.mTime);
|
||||
mY.StartTouch(aEvent.mPanStartPoint.y.Truncated(), aEvent.mTime);
|
||||
|
||||
if (GetAxisLockMode() == FREE) {
|
||||
SetState(PANNING);
|
||||
|
@ -1401,8 +1401,8 @@ nsEventStatus AsyncPanZoomController::OnPan(const PanGestureInput& aEvent, bool
|
|||
// size and position. We need to do so even if this is a momentum pan (i.e.
|
||||
// aFingersOnTouchpad == false); in that case the "with touch" part is not
|
||||
// really appropriate, so we may want to rethink this at some point.
|
||||
mX.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.x, aEvent.mTime);
|
||||
mY.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.y, aEvent.mTime);
|
||||
mX.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.x.Truncated(), aEvent.mTime);
|
||||
mY.UpdateWithTouchAtDevicePoint(aEvent.mPanStartPoint.y.Truncated(), aEvent.mTime);
|
||||
|
||||
HandlePanningUpdate(aEvent.mPanDisplacement.x, aEvent.mPanDisplacement.y);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
|
|||
{
|
||||
}
|
||||
|
||||
void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, uint32_t aTimestampMs) {
|
||||
void Axis::UpdateWithTouchAtDevicePoint(ScreenIntCoord aPos, uint32_t aTimestampMs) {
|
||||
// mVelocityQueue is controller-thread only
|
||||
AsyncPanZoomController::AssertOnControllerThread();
|
||||
|
||||
|
@ -62,16 +62,16 @@ void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, uint32_t aTimestampMs) {
|
|||
}
|
||||
}
|
||||
|
||||
void Axis::StartTouch(int32_t aPos, uint32_t aTimestampMs) {
|
||||
void Axis::StartTouch(ScreenIntCoord aPos, uint32_t aTimestampMs) {
|
||||
mStartPos = aPos;
|
||||
mPos = aPos;
|
||||
mPosTimeMs = aTimestampMs;
|
||||
mAxisLocked = false;
|
||||
}
|
||||
|
||||
bool Axis::AdjustDisplacement(float aDisplacement,
|
||||
float& aDisplacementOut,
|
||||
float& aOverscrollAmountOut)
|
||||
bool Axis::AdjustDisplacement(CSSCoord aDisplacement,
|
||||
CSSCoord& aDisplacementOut,
|
||||
CSSCoord& aOverscrollAmountOut)
|
||||
{
|
||||
if (mAxisLocked) {
|
||||
aOverscrollAmountOut = 0;
|
||||
|
@ -79,14 +79,14 @@ bool Axis::AdjustDisplacement(float aDisplacement,
|
|||
return false;
|
||||
}
|
||||
|
||||
float displacement = aDisplacement;
|
||||
CSSCoord displacement = aDisplacement;
|
||||
|
||||
// First consume any overscroll in the opposite direction along this axis.
|
||||
float consumedOverscroll = 0;
|
||||
CSSCoord consumedOverscroll = 0;
|
||||
if (mOverscroll > 0 && aDisplacement < 0) {
|
||||
consumedOverscroll = std::min(mOverscroll, -aDisplacement);
|
||||
} else if (mOverscroll < 0 && aDisplacement > 0) {
|
||||
consumedOverscroll = 0 - std::min(-mOverscroll, aDisplacement);
|
||||
consumedOverscroll = 0.f - std::min(-mOverscroll, aDisplacement);
|
||||
}
|
||||
mOverscroll -= consumedOverscroll;
|
||||
displacement += consumedOverscroll;
|
||||
|
@ -104,7 +104,7 @@ bool Axis::AdjustDisplacement(float aDisplacement,
|
|||
return fabsf(consumedOverscroll) > EPSILON;
|
||||
}
|
||||
|
||||
float Axis::ApplyResistance(float aRequestedOverscroll) const {
|
||||
CSSCoord Axis::ApplyResistance(CSSCoord aRequestedOverscroll) const {
|
||||
// 'resistanceFactor' is a value between 0 and 1, which:
|
||||
// - tends to 1 as the existing overscroll tends to 0
|
||||
// - tends to 0 as the existing overscroll tends to the composition length
|
||||
|
@ -112,23 +112,23 @@ float Axis::ApplyResistance(float aRequestedOverscroll) const {
|
|||
// factor; this should prevent overscrolling by more than the composition
|
||||
// length.
|
||||
float resistanceFactor = 1 - fabsf(mOverscroll) / GetCompositionLength();
|
||||
return resistanceFactor < 0 ? 0 : aRequestedOverscroll * resistanceFactor;
|
||||
return resistanceFactor < 0 ? CSSCoord(0) : aRequestedOverscroll * resistanceFactor;
|
||||
}
|
||||
|
||||
void Axis::OverscrollBy(float aOverscroll) {
|
||||
void Axis::OverscrollBy(CSSCoord aOverscroll) {
|
||||
MOZ_ASSERT(CanScroll());
|
||||
aOverscroll = ApplyResistance(aOverscroll);
|
||||
if (aOverscroll > 0) {
|
||||
MOZ_ASSERT(FuzzyEqualsAdditive(GetCompositionEnd(), GetPageEnd(), COORDINATE_EPSILON));
|
||||
MOZ_ASSERT(FuzzyEqualsAdditive(GetCompositionEnd().value, GetPageEnd().value, COORDINATE_EPSILON));
|
||||
MOZ_ASSERT(mOverscroll >= 0);
|
||||
} else if (aOverscroll < 0) {
|
||||
MOZ_ASSERT(FuzzyEqualsAdditive(GetOrigin(), GetPageStart(), COORDINATE_EPSILON));
|
||||
MOZ_ASSERT(FuzzyEqualsAdditive(GetOrigin().value, GetPageStart().value, COORDINATE_EPSILON));
|
||||
MOZ_ASSERT(mOverscroll <= 0);
|
||||
}
|
||||
mOverscroll += aOverscroll;
|
||||
}
|
||||
|
||||
float Axis::GetOverscroll() const {
|
||||
CSSCoord Axis::GetOverscroll() const {
|
||||
return mOverscroll;
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ bool Axis::SampleSnapBack(const TimeDuration& aDelta) {
|
|||
}
|
||||
mOverscroll = std::max(mOverscroll + cssDisplacement, 0.0f);
|
||||
// Overscroll relieved, do not continue animation.
|
||||
if (mOverscroll == 0) {
|
||||
if (mOverscroll == 0.f) {
|
||||
mVelocity = 0;
|
||||
return false;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ bool Axis::SampleSnapBack(const TimeDuration& aDelta) {
|
|||
}
|
||||
mOverscroll = std::min(mOverscroll + cssDisplacement, 0.0f);
|
||||
// Overscroll relieved, do not continue animation.
|
||||
if (mOverscroll == 0) {
|
||||
if (mOverscroll == 0.f) {
|
||||
mVelocity = 0;
|
||||
return false;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ bool Axis::SampleSnapBack(const TimeDuration& aDelta) {
|
|||
}
|
||||
|
||||
bool Axis::IsOverscrolled() const {
|
||||
return mOverscroll != 0;
|
||||
return mOverscroll != 0.f;
|
||||
}
|
||||
|
||||
void Axis::ClearOverscroll() {
|
||||
|
@ -193,11 +193,11 @@ void Axis::ClearOverscroll() {
|
|||
}
|
||||
|
||||
float Axis::PanDistance() {
|
||||
return fabsf(mPos - mStartPos);
|
||||
return fabsf((mPos - mStartPos).value);
|
||||
}
|
||||
|
||||
float Axis::PanDistance(float aPos) {
|
||||
return fabsf(aPos - mStartPos);
|
||||
float Axis::PanDistance(ScreenIntCoord aPos) {
|
||||
return fabsf((aPos - mStartPos).value);
|
||||
}
|
||||
|
||||
void Axis::EndTouch(uint32_t aTimestampMs) {
|
||||
|
@ -252,7 +252,7 @@ bool Axis::FlingApplyFrictionOrCancel(const TimeDuration& aDelta,
|
|||
return true;
|
||||
}
|
||||
|
||||
Axis::Overscroll Axis::DisplacementWillOverscroll(float aDisplacement) {
|
||||
Axis::Overscroll Axis::DisplacementWillOverscroll(CSSCoord aDisplacement) {
|
||||
// If the current pan plus a displacement takes the window to the left of or
|
||||
// above the current page rect.
|
||||
bool minus = GetOrigin() + aDisplacement < GetPageStart();
|
||||
|
@ -271,7 +271,7 @@ Axis::Overscroll Axis::DisplacementWillOverscroll(float aDisplacement) {
|
|||
return OVERSCROLL_NONE;
|
||||
}
|
||||
|
||||
float Axis::DisplacementWillOverscrollAmount(float aDisplacement) {
|
||||
CSSCoord Axis::DisplacementWillOverscrollAmount(CSSCoord aDisplacement) {
|
||||
switch (DisplacementWillOverscroll(aDisplacement)) {
|
||||
case OVERSCROLL_MINUS: return (GetOrigin() + aDisplacement) - GetPageStart();
|
||||
case OVERSCROLL_PLUS: return (GetCompositionEnd() + aDisplacement) - GetPageEnd();
|
||||
|
@ -281,8 +281,8 @@ float Axis::DisplacementWillOverscrollAmount(float aDisplacement) {
|
|||
}
|
||||
}
|
||||
|
||||
float Axis::ScaleWillOverscrollAmount(float aScale, float aFocus) {
|
||||
float originAfterScale = (GetOrigin() + aFocus) - (aFocus / aScale);
|
||||
CSSCoord Axis::ScaleWillOverscrollAmount(float aScale, CSSCoord aFocus) {
|
||||
CSSCoord originAfterScale = (GetOrigin() + aFocus) - (aFocus / aScale);
|
||||
|
||||
bool both = ScaleWillOverscrollBothSides(aScale);
|
||||
bool minus = GetPageStart() - originAfterScale > COORDINATE_EPSILON;
|
||||
|
@ -310,29 +310,29 @@ void Axis::SetVelocity(float aVelocity) {
|
|||
mVelocity = aVelocity;
|
||||
}
|
||||
|
||||
float Axis::GetCompositionEnd() const {
|
||||
CSSCoord Axis::GetCompositionEnd() const {
|
||||
return GetOrigin() + GetCompositionLength();
|
||||
}
|
||||
|
||||
float Axis::GetPageEnd() const {
|
||||
CSSCoord Axis::GetPageEnd() const {
|
||||
return GetPageStart() + GetPageLength();
|
||||
}
|
||||
|
||||
float Axis::GetOrigin() const {
|
||||
CSSCoord Axis::GetOrigin() const {
|
||||
CSSPoint origin = GetFrameMetrics().GetScrollOffset();
|
||||
return GetPointOffset(origin);
|
||||
}
|
||||
|
||||
float Axis::GetCompositionLength() const {
|
||||
CSSCoord Axis::GetCompositionLength() const {
|
||||
return GetRectLength(GetFrameMetrics().CalculateCompositedRectInCssPixels());
|
||||
}
|
||||
|
||||
float Axis::GetPageStart() const {
|
||||
CSSCoord Axis::GetPageStart() const {
|
||||
CSSRect pageRect = GetFrameMetrics().GetExpandedScrollableRect();
|
||||
return GetRectOffset(pageRect);
|
||||
}
|
||||
|
||||
float Axis::GetPageLength() const {
|
||||
CSSCoord Axis::GetPageLength() const {
|
||||
CSSRect pageRect = GetFrameMetrics().GetExpandedScrollableRect();
|
||||
return GetRectLength(pageRect);
|
||||
}
|
||||
|
@ -357,17 +357,17 @@ AxisX::AxisX(AsyncPanZoomController* aAsyncPanZoomController)
|
|||
|
||||
}
|
||||
|
||||
float AxisX::GetPointOffset(const CSSPoint& aPoint) const
|
||||
CSSCoord AxisX::GetPointOffset(const CSSPoint& aPoint) const
|
||||
{
|
||||
return aPoint.x;
|
||||
}
|
||||
|
||||
float AxisX::GetRectLength(const CSSRect& aRect) const
|
||||
CSSCoord AxisX::GetRectLength(const CSSRect& aRect) const
|
||||
{
|
||||
return aRect.width;
|
||||
}
|
||||
|
||||
float AxisX::GetRectOffset(const CSSRect& aRect) const
|
||||
CSSCoord AxisX::GetRectOffset(const CSSRect& aRect) const
|
||||
{
|
||||
return aRect.x;
|
||||
}
|
||||
|
@ -378,17 +378,17 @@ AxisY::AxisY(AsyncPanZoomController* aAsyncPanZoomController)
|
|||
|
||||
}
|
||||
|
||||
float AxisY::GetPointOffset(const CSSPoint& aPoint) const
|
||||
CSSCoord AxisY::GetPointOffset(const CSSPoint& aPoint) const
|
||||
{
|
||||
return aPoint.y;
|
||||
}
|
||||
|
||||
float AxisY::GetRectLength(const CSSRect& aRect) const
|
||||
CSSCoord AxisY::GetRectLength(const CSSRect& aRect) const
|
||||
{
|
||||
return aRect.height;
|
||||
}
|
||||
|
||||
float AxisY::GetRectOffset(const CSSRect& aRect) const
|
||||
CSSCoord AxisY::GetRectOffset(const CSSRect& aRect) const
|
||||
{
|
||||
return aRect.y;
|
||||
}
|
||||
|
|
|
@ -55,13 +55,13 @@ 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.
|
||||
*/
|
||||
void UpdateWithTouchAtDevicePoint(int32_t aPos, uint32_t aTimestampMs);
|
||||
void UpdateWithTouchAtDevicePoint(ScreenIntCoord aPos, uint32_t aTimestampMs);
|
||||
|
||||
/**
|
||||
* Notify this Axis that a touch has begun, i.e. the user has put their finger
|
||||
* on the screen but has not yet tried to pan.
|
||||
*/
|
||||
void StartTouch(int32_t aPos, uint32_t aTimestampMs);
|
||||
void StartTouch(ScreenIntCoord aPos, uint32_t aTimestampMs);
|
||||
|
||||
/**
|
||||
* Notify this Axis that a touch has ended gracefully. This may perform
|
||||
|
@ -87,20 +87,20 @@ public:
|
|||
* displacement, and the function returns true iff internal overscroll amounts
|
||||
* were changed.
|
||||
*/
|
||||
bool AdjustDisplacement(float aDisplacement,
|
||||
float& aDisplacementOut,
|
||||
float& aOverscrollAmountOut);
|
||||
bool AdjustDisplacement(CSSCoord aDisplacement,
|
||||
CSSCoord& aDisplacementOut,
|
||||
CSSCoord& aOverscrollAmountOut);
|
||||
|
||||
/**
|
||||
* Overscrolls this axis by the requested amount in the requested direction.
|
||||
* The axis must be at the end of its scroll range in this direction.
|
||||
*/
|
||||
void OverscrollBy(float aOverscroll);
|
||||
void OverscrollBy(CSSCoord aOverscroll);
|
||||
|
||||
/**
|
||||
* Return the amount of overscroll on this axis, in CSS pixels.
|
||||
*/
|
||||
float GetOverscroll() const;
|
||||
CSSCoord GetOverscroll() const;
|
||||
|
||||
/**
|
||||
* Sample the snap-back animation to relieve overscroll.
|
||||
|
@ -129,7 +129,7 @@ public:
|
|||
* Gets the distance between the starting position of the touch supplied in
|
||||
* startTouch() and the supplied position.
|
||||
*/
|
||||
float PanDistance(float aPos);
|
||||
float PanDistance(ScreenIntCoord aPos);
|
||||
|
||||
/**
|
||||
* Applies friction during a fling, or cancels the fling if the velocity is
|
||||
|
@ -177,13 +177,13 @@ public:
|
|||
* That is to say, if the given displacement is applied, this will tell you
|
||||
* whether or not it will overscroll, and in what direction.
|
||||
*/
|
||||
Overscroll DisplacementWillOverscroll(float aDisplacement);
|
||||
Overscroll DisplacementWillOverscroll(CSSCoord aDisplacement);
|
||||
|
||||
/**
|
||||
* If a displacement will overscroll the axis, this returns the amount and in
|
||||
* what direction. Similar to GetExcess() but takes a displacement to apply.
|
||||
*/
|
||||
float DisplacementWillOverscrollAmount(float aDisplacement);
|
||||
CSSCoord DisplacementWillOverscrollAmount(CSSCoord aDisplacement);
|
||||
|
||||
/**
|
||||
* If a scale will overscroll the axis, this returns the amount and in what
|
||||
|
@ -193,7 +193,7 @@ public:
|
|||
* scroll offset in such a way that it remains in the same place on the page
|
||||
* relative.
|
||||
*/
|
||||
float ScaleWillOverscrollAmount(float aScale, float aFocus);
|
||||
CSSCoord ScaleWillOverscrollAmount(float aScale, CSSCoord aFocus);
|
||||
|
||||
/**
|
||||
* Checks if an axis will overscroll in both directions by computing the
|
||||
|
@ -204,23 +204,23 @@ public:
|
|||
*/
|
||||
bool ScaleWillOverscrollBothSides(float aScale);
|
||||
|
||||
float GetOrigin() const;
|
||||
float GetCompositionLength() const;
|
||||
float GetPageStart() const;
|
||||
float GetPageLength() const;
|
||||
float GetCompositionEnd() const;
|
||||
float GetPageEnd() const;
|
||||
CSSCoord GetOrigin() const;
|
||||
CSSCoord GetCompositionLength() const;
|
||||
CSSCoord GetPageStart() const;
|
||||
CSSCoord GetPageLength() const;
|
||||
CSSCoord GetCompositionEnd() const;
|
||||
CSSCoord GetPageEnd() const;
|
||||
|
||||
int32_t GetPos() const { return mPos; }
|
||||
ScreenIntCoord GetPos() const { return mPos; }
|
||||
|
||||
virtual float GetPointOffset(const CSSPoint& aPoint) const = 0;
|
||||
virtual float GetRectLength(const CSSRect& aRect) const = 0;
|
||||
virtual float GetRectOffset(const CSSRect& aRect) const = 0;
|
||||
virtual CSSCoord GetPointOffset(const CSSPoint& aPoint) const = 0;
|
||||
virtual CSSCoord GetRectLength(const CSSRect& aRect) const = 0;
|
||||
virtual CSSCoord GetRectOffset(const CSSRect& aRect) const = 0;
|
||||
|
||||
protected:
|
||||
int32_t mPos;
|
||||
ScreenIntCoord mPos;
|
||||
uint32_t mPosTimeMs;
|
||||
int32_t mStartPos;
|
||||
ScreenIntCoord mStartPos;
|
||||
float mVelocity;
|
||||
bool mAxisLocked; // Whether movement on this axis is locked.
|
||||
AsyncPanZoomController* mAsyncPanZoomController;
|
||||
|
@ -230,7 +230,7 @@ protected:
|
|||
// extreme allowed value in the relevant direction (that is, it must be at
|
||||
// its maximum value if mOverscroll is positive, and at its minimum value
|
||||
// if mOverscroll is negative).
|
||||
float mOverscroll;
|
||||
CSSCoord mOverscroll;
|
||||
// A queue of (timestamp, velocity) pairs; these are the historical
|
||||
// velocities at the given timestamps. Timestamps are in milliseconds,
|
||||
// velocities are in screen pixels per ms. This member can only be
|
||||
|
@ -241,23 +241,23 @@ protected:
|
|||
|
||||
// Adjust a requested overscroll amount for resistance, yielding a smaller
|
||||
// actual overscroll amount.
|
||||
float ApplyResistance(float aOverscroll) const;
|
||||
CSSCoord ApplyResistance(CSSCoord aOverscroll) const;
|
||||
};
|
||||
|
||||
class AxisX : public Axis {
|
||||
public:
|
||||
AxisX(AsyncPanZoomController* mAsyncPanZoomController);
|
||||
virtual float GetPointOffset(const CSSPoint& aPoint) const;
|
||||
virtual float GetRectLength(const CSSRect& aRect) const;
|
||||
virtual float GetRectOffset(const CSSRect& aRect) const;
|
||||
virtual CSSCoord GetPointOffset(const CSSPoint& aPoint) const;
|
||||
virtual CSSCoord GetRectLength(const CSSRect& aRect) const;
|
||||
virtual CSSCoord GetRectOffset(const CSSRect& aRect) const;
|
||||
};
|
||||
|
||||
class AxisY : public Axis {
|
||||
public:
|
||||
AxisY(AsyncPanZoomController* mAsyncPanZoomController);
|
||||
virtual float GetPointOffset(const CSSPoint& aPoint) const;
|
||||
virtual float GetRectLength(const CSSRect& aRect) const;
|
||||
virtual float GetRectOffset(const CSSRect& aRect) const;
|
||||
virtual CSSCoord GetPointOffset(const CSSPoint& aPoint) const;
|
||||
virtual CSSCoord GetRectLength(const CSSRect& aRect) const;
|
||||
virtual CSSCoord GetRectOffset(const CSSRect& aRect) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -222,8 +222,8 @@ static void DrawVelGraph(const nsIntRect& aClipRect,
|
|||
for (int32_t i = (int32_t)velocityData->mData.size() - 2; i >= 0; i--) {
|
||||
const gfx::Point& p1 = velocityData->mData[i+1].mPoint;
|
||||
const gfx::Point& p2 = velocityData->mData[i].mPoint;
|
||||
int vel = sqrt((p1.x - p2.x) * (p1.x - p2.x) +
|
||||
(p1.y - p2.y) * (p1.y - p2.y));
|
||||
int vel = sqrt((p1.x - p2.x).value * (p1.x - p2.x).value +
|
||||
(p1.y - p2.y).value * (p1.y - p2.y).value);
|
||||
Point next = Point(graphRect.width / circularBufferSize * i,
|
||||
graphRect.height - vel/yScaleFactor);
|
||||
if (first) {
|
||||
|
@ -266,11 +266,9 @@ static void PrintUniformityInfo(Layer* aLayer)
|
|||
}
|
||||
|
||||
FrameMetrics frameMetrics = aLayer->AsContainerLayer()->GetFrameMetrics();
|
||||
LayerIntPoint scrollOffset = RoundedToInt(frameMetrics.GetScrollOffsetInLayerPixels());
|
||||
const LayerPoint scrollOffset = frameMetrics.GetScrollOffsetInLayerPixels();
|
||||
const gfx::Point layerTransform = GetScrollData(aLayer);
|
||||
gfx::Point layerScroll;
|
||||
layerScroll.x = scrollOffset.x - layerTransform.x;
|
||||
layerScroll.y = scrollOffset.y - layerTransform.y;
|
||||
const gfx::Point layerScroll = scrollOffset.ToUnknownPoint() - layerTransform;
|
||||
|
||||
printf_stderr("UniformityInfo Layer_Move %llu %p %f, %f\n",
|
||||
TimeStamp::Now(), aLayer, layerScroll.x, layerScroll.y);
|
||||
|
|
|
@ -474,8 +474,8 @@ DecomposeIntoNoRepeatRects(const Rect& aRect,
|
|||
|
||||
// If we are dealing with wrapping br.x and br.y are greater than 1.0 so
|
||||
// wrap them here as well.
|
||||
br = Point(xwrap ? WrapTexCoord(br.x) : br.x,
|
||||
ywrap ? WrapTexCoord(br.y) : br.y);
|
||||
br = Point(xwrap ? WrapTexCoord(br.x) : br.x.value,
|
||||
ywrap ? WrapTexCoord(br.y) : br.y.value);
|
||||
|
||||
// If we wrap around along the x axis, we will draw first from
|
||||
// tl.x .. 1.0 and then from 0.0 .. br.x (which we just wrapped above).
|
||||
|
@ -759,8 +759,7 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
|
|||
// UI for its dynamic toolbar.
|
||||
IntPoint origin;
|
||||
if (!mTarget) {
|
||||
origin.x = -mRenderOffset.x;
|
||||
origin.y = -mRenderOffset.y;
|
||||
origin = -TruncatedToInt(mRenderOffset.ToUnknownPoint());
|
||||
}
|
||||
|
||||
mCurrentRenderTarget =
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef MOZ_UNITS_H_
|
||||
#define MOZ_UNITS_H_
|
||||
|
||||
#include "mozilla/gfx/Coord.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
#include "mozilla/gfx/ScaleFactor.h"
|
||||
|
@ -30,6 +31,8 @@ template<> struct IsPixel<LayoutDevicePixel> : TrueType {};
|
|||
template<> struct IsPixel<LayerPixel> : TrueType {};
|
||||
template<> struct IsPixel<ScreenPixel> : TrueType {};
|
||||
|
||||
typedef gfx::CoordTyped<CSSPixel> CSSCoord;
|
||||
typedef gfx::IntCoordTyped<CSSPixel> CSSIntCoord;
|
||||
typedef gfx::PointTyped<CSSPixel> CSSPoint;
|
||||
typedef gfx::IntPointTyped<CSSPixel> CSSIntPoint;
|
||||
typedef gfx::SizeTyped<CSSPixel> CSSSize;
|
||||
|
@ -39,6 +42,8 @@ typedef gfx::IntRectTyped<CSSPixel> CSSIntRect;
|
|||
typedef gfx::MarginTyped<CSSPixel> CSSMargin;
|
||||
typedef gfx::IntMarginTyped<CSSPixel> CSSIntMargin;
|
||||
|
||||
typedef gfx::CoordTyped<LayoutDevicePixel> LayoutDeviceCoord;
|
||||
typedef gfx::IntCoordTyped<LayoutDevicePixel> LayoutDeviceIntCoord;
|
||||
typedef gfx::PointTyped<LayoutDevicePixel> LayoutDevicePoint;
|
||||
typedef gfx::IntPointTyped<LayoutDevicePixel> LayoutDeviceIntPoint;
|
||||
typedef gfx::SizeTyped<LayoutDevicePixel> LayoutDeviceSize;
|
||||
|
@ -48,6 +53,8 @@ typedef gfx::IntRectTyped<LayoutDevicePixel> LayoutDeviceIntRect;
|
|||
typedef gfx::MarginTyped<LayoutDevicePixel> LayoutDeviceMargin;
|
||||
typedef gfx::IntMarginTyped<LayoutDevicePixel> LayoutDeviceIntMargin;
|
||||
|
||||
typedef gfx::CoordTyped<LayerPixel> LayerCoord;
|
||||
typedef gfx::IntCoordTyped<LayerPixel> LayerIntCoord;
|
||||
typedef gfx::PointTyped<LayerPixel> LayerPoint;
|
||||
typedef gfx::IntPointTyped<LayerPixel> LayerIntPoint;
|
||||
typedef gfx::SizeTyped<LayerPixel> LayerSize;
|
||||
|
@ -57,6 +64,8 @@ typedef gfx::IntRectTyped<LayerPixel> LayerIntRect;
|
|||
typedef gfx::MarginTyped<LayerPixel> LayerMargin;
|
||||
typedef gfx::IntMarginTyped<LayerPixel> LayerIntMargin;
|
||||
|
||||
typedef gfx::CoordTyped<ScreenPixel> ScreenCoord;
|
||||
typedef gfx::IntCoordTyped<ScreenPixel> ScreenIntCoord;
|
||||
typedef gfx::PointTyped<ScreenPixel> ScreenPoint;
|
||||
typedef gfx::IntPointTyped<ScreenPixel> ScreenIntPoint;
|
||||
typedef gfx::SizeTyped<ScreenPixel> ScreenSize;
|
||||
|
|
|
@ -1805,8 +1805,8 @@ nsBaseWidget::debug_DumpEvent(FILE * aFileOut,
|
|||
(void *) aWidget,
|
||||
aWidgetName.get(),
|
||||
aWindowID,
|
||||
aGuiEvent->refPoint.x,
|
||||
aGuiEvent->refPoint.y);
|
||||
aGuiEvent->refPoint.x.value,
|
||||
aGuiEvent->refPoint.y.value);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
/* static */ void
|
||||
|
|
Загрузка…
Ссылка в новой задаче