Bug 1205511 - Use nsPresContext::DevToCSSPixelScale() where appropriate. r=kats

This commit is contained in:
Botond Ballo 2015-09-28 20:14:26 -04:00
parent e6e57a165f
commit 6f5d9f43e2
4 changed files with 11 additions and 18 deletions

View File

@ -7838,9 +7838,7 @@ nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
// pixel an integer, and we want the adjusted value.
float fullZoom = context ? context->DeviceContext()->GetFullZoom() : 1.0;
fullZoom = (fullZoom == 0.0) ? 1.0 : fullZoom;
CSSToLayoutDeviceScale layoutDeviceScale(
(float)nsPresContext::AppUnitsPerCSSPixel() /
context->AppUnitsPerDevPixel());
CSSToLayoutDeviceScale layoutDeviceScale = context->CSSToDevPixelScale();
CSSToScreenScale defaultScale = layoutDeviceScale
* LayoutDeviceToScreenScale(1.0);

View File

@ -118,8 +118,8 @@ MobileViewportManager::UpdateResolution(const nsViewportInfo& aViewportInfo,
const CSSSize& aViewport,
const Maybe<float>& aDisplayWidthChangeRatio)
{
CSSToLayoutDeviceScale cssToDev((float)nsPresContext::AppUnitsPerCSSPixel()
/ mPresShell->GetPresContext()->AppUnitsPerDevPixel());
CSSToLayoutDeviceScale cssToDev =
mPresShell->GetPresContext()->CSSToDevPixelScale();
LayoutDeviceToLayerScale res(nsLayoutUtils::GetResolution(mPresShell));
if (mIsFirstPaint) {

View File

@ -207,9 +207,8 @@ ZoomConstraintsClient::RefreshZoomConstraints()
if (zoomConstraints.mAllowDoubleTapZoom) {
// If the CSS viewport is narrower than the screen (i.e. width <= device-width)
// then we disable double-tap-to-zoom behaviour.
int32_t auPerDevPixel = mPresShell->GetPresContext()->AppUnitsPerDevPixel();
CSSToLayoutDeviceScale scale(
(float)nsPresContext::AppUnitsPerCSSPixel() / auPerDevPixel);
CSSToLayoutDeviceScale scale =
mPresShell->GetPresContext()->CSSToDevPixelScale();
if ((viewportInfo.GetSize() * scale).width <= screenSize.width) {
zoomConstraints.mAllowDoubleTapZoom = false;
}

View File

@ -2486,12 +2486,10 @@ nsLayoutUtils::TransformPoints(nsIFrame* aFromFrame, nsIFrame* aToFrame,
}
downToDest.Invert();
Matrix4x4 upToAncestor = GetTransformToAncestor(aFromFrame, nearestCommonAncestor);
CSSToLayoutDeviceScale devPixelsPerCSSPixelFromFrame(
double(nsPresContext::AppUnitsPerCSSPixel())/
aFromFrame->PresContext()->AppUnitsPerDevPixel());
CSSToLayoutDeviceScale devPixelsPerCSSPixelToFrame(
double(nsPresContext::AppUnitsPerCSSPixel())/
aToFrame->PresContext()->AppUnitsPerDevPixel());
CSSToLayoutDeviceScale devPixelsPerCSSPixelFromFrame =
aFromFrame->PresContext()->CSSToDevPixelScale();
CSSToLayoutDeviceScale devPixelsPerCSSPixelToFrame =
aToFrame->PresContext()->CSSToDevPixelScale();
for (uint32_t i = 0; i < aPointCount; ++i) {
LayoutDevicePoint devPixels = aPoints[i] * devPixelsPerCSSPixelFromFrame;
// What should the behaviour be if some of the points aren't invertible
@ -2970,8 +2968,7 @@ nsLayoutUtils::CalculateBasicFrameMetrics(nsIScrollableFrame* aScrollFrame) {
FrameMetrics metrics;
nsPresContext* presContext = frame->PresContext();
nsIPresShell* presShell = presContext->PresShell();
CSSToLayoutDeviceScale deviceScale(float(nsPresContext::AppUnitsPerCSSPixel())
/ presContext->AppUnitsPerDevPixel());
CSSToLayoutDeviceScale deviceScale = presContext->CSSToDevPixelScale();
float resolution = 1.0f;
if (frame == presShell->GetRootScrollFrame()) {
// Only the root scrollable frame for a given presShell should pick up
@ -8399,8 +8396,7 @@ nsLayoutUtils::ComputeFrameMetrics(nsIFrame* aForFrame,
* nsLayoutUtils::GetTransformToAncestorScale(aScrollFrame ? aScrollFrame : aForFrame));
metrics.SetExtraResolution(metrics.GetCumulativeResolution() / resolutionToScreen);
metrics.SetDevPixelsPerCSSPixel(CSSToLayoutDeviceScale(
(float)nsPresContext::AppUnitsPerCSSPixel() / auPerDevPixel));
metrics.SetDevPixelsPerCSSPixel(presContext->CSSToDevPixelScale());
// Initially, AsyncPanZoomController should render the content to the screen
// at the painted resolution.