mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Bug 885030 - Move CalculateIntrinsicScale to FrameMetrics. r=kentuckyfriedtakahe
This commit is contained in:
parent
6c5d882abe
commit
75b7aa0a24
@ -602,8 +602,7 @@ TabChild::HandlePossibleViewportChange()
|
||||
nsresult rv = utils->GetIsFirstPaint(&isFirstPaint);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
if (NS_FAILED(rv) || isFirstPaint) {
|
||||
CSSToScreenScale intrinsicScale =
|
||||
AsyncPanZoomController::CalculateIntrinsicScale(metrics);
|
||||
CSSToScreenScale intrinsicScale = metrics.CalculateIntrinsicScale();
|
||||
// FIXME/bug 799585(?): GetViewportInfo() returns a defaultZoom of
|
||||
// 0.0 to mean "did not calculate a zoom". In that case, we default
|
||||
// it to the intrinsic scale.
|
||||
|
@ -94,6 +94,15 @@ public:
|
||||
return mScrollOffset * LayersPixelsPerCSSPixel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the scale factor needed to fit the viewport
|
||||
* into its composition bounds.
|
||||
*/
|
||||
CSSToScreenScale CalculateIntrinsicScale() const
|
||||
{
|
||||
return CSSToScreenScale(float(mCompositionBounds.width) / float(mViewport.width));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The following metrics are all in widget space/device pixels.
|
||||
//
|
||||
|
@ -579,8 +579,8 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
|
||||
// either axis such that we don't overscroll the boundaries when zooming.
|
||||
gfx::Point neededDisplacement;
|
||||
|
||||
float maxZoom = mMaxZoom / CalculateIntrinsicScale(mFrameMetrics).scale;
|
||||
float minZoom = mMinZoom / CalculateIntrinsicScale(mFrameMetrics).scale;
|
||||
float maxZoom = mMaxZoom / mFrameMetrics.CalculateIntrinsicScale().scale;
|
||||
float minZoom = mMinZoom / mFrameMetrics.CalculateIntrinsicScale().scale;
|
||||
|
||||
bool doScale = (spanRatio > 1.0 && userZoom < maxZoom) ||
|
||||
(spanRatio < 1.0 && userZoom > minZoom);
|
||||
@ -970,17 +970,10 @@ const CSSRect AsyncPanZoomController::CalculatePendingDisplayPort(
|
||||
return scrollableRect.ClampRect(shiftedDisplayPort) - scrollOffset;
|
||||
}
|
||||
|
||||
/*static*/ CSSToScreenScale
|
||||
AsyncPanZoomController::CalculateIntrinsicScale(const FrameMetrics& aMetrics)
|
||||
{
|
||||
return CSSToScreenScale(gfxFloat(aMetrics.mCompositionBounds.width) /
|
||||
gfxFloat(aMetrics.mViewport.width));
|
||||
}
|
||||
|
||||
/*static*/ CSSToScreenScale
|
||||
AsyncPanZoomController::CalculateResolution(const FrameMetrics& aMetrics)
|
||||
{
|
||||
return CalculateIntrinsicScale(aMetrics) * aMetrics.mZoom;
|
||||
return aMetrics.CalculateIntrinsicScale() * aMetrics.mZoom;
|
||||
}
|
||||
|
||||
/*static*/ CSSRect
|
||||
@ -1310,7 +1303,7 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) {
|
||||
CSSPoint scrollOffset = mFrameMetrics.mScrollOffset;
|
||||
float currentZoom = mFrameMetrics.mZoom.scale;
|
||||
float targetZoom;
|
||||
float intrinsicScale = CalculateIntrinsicScale(mFrameMetrics).scale;
|
||||
float intrinsicScale = mFrameMetrics.CalculateIntrinsicScale().scale;
|
||||
|
||||
// The minimum zoom to prevent over-zoom-out.
|
||||
// If the zoom factor is lower than this (i.e. we are zoomed more into the page),
|
||||
|
@ -223,12 +223,6 @@ public:
|
||||
const gfx::Point& aAcceleration,
|
||||
double aEstimatedPaintDuration);
|
||||
|
||||
/**
|
||||
* Return the scale factor needed to fit the viewport in |aMetrics|
|
||||
* into its composition bounds.
|
||||
*/
|
||||
static CSSToScreenScale CalculateIntrinsicScale(const FrameMetrics& aMetrics);
|
||||
|
||||
/**
|
||||
* Return the resolution that content should be rendered at given
|
||||
* the configuration in aFrameMetrics: viewport dimensions, zoom
|
||||
|
Loading…
Reference in New Issue
Block a user