From cd813e35bbc2fc511dbcdaa72a70d4f20ca866e0 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Sun, 4 May 2014 23:18:18 -0500 Subject: [PATCH] Bug 1000423. Properly convert from appunits/layout device pixels to layer pixels for composition bounds calculation. r=botond To get layer pixels (doesn't matter which layer, they are all the same to layout because there is no async transform) you need to multiply by the cumulative resolution. The fact that our units system says that multiplying by the parent resolution will work is a problem with our units system. --- layout/base/nsDisplayList.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 3d28136877a..98c616ed2ee 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -717,6 +717,11 @@ static void RecordFrameMetrics(nsIFrame* aForFrame, } } + LayoutDeviceToParentLayerScale layoutToParentLayerScale = + // The ScreenToParentLayerScale should be mTransformScale which is not calculated yet, + // but we don't yet handle CSS transforms, so we assume it's 1 here. + metrics.mCumulativeResolution * LayerToScreenScale(1.0) * ScreenToParentLayerScale(1.0); + // Calculate the composition bounds as the size of the scroll frame and // its origin relative to the reference frame. // If aScrollFrame is null, we are in a document without a root scroll frame, @@ -725,7 +730,8 @@ static void RecordFrameMetrics(nsIFrame* aForFrame, nsRect compositionBounds(frameForCompositionBoundsCalculation->GetOffsetToCrossDoc(aReferenceFrame), frameForCompositionBoundsCalculation->GetSize()); metrics.mCompositionBounds = RoundedToInt(LayoutDeviceRect::FromAppUnits(compositionBounds, auPerDevPixel) - * metrics.GetParentResolution()); + * layoutToParentLayerScale); + // For the root scroll frame of the root content document, the above calculation // will yield the size of the viewport frame as the composition bounds, which @@ -742,7 +748,8 @@ static void RecordFrameMetrics(nsIFrame* aForFrame, if (nsView* view = rootFrame->GetView()) { nsRect viewBoundsAppUnits = view->GetBounds() + rootFrame->GetOffsetToCrossDoc(aReferenceFrame); ParentLayerIntRect viewBounds = RoundedToInt(LayoutDeviceRect::FromAppUnits(viewBoundsAppUnits, auPerDevPixel) - * metrics.GetParentResolution()); + * layoutToParentLayerScale); + // On Android, we need to do things a bit differently to get things // right (see bug 983208, bug 988882). We use the bounds of the nearest // widget, but clamp the height to the view bounds height. This clamping