Bug 1085569 - When calculating the composition bounds based on the frame size, use the cumulative resolution rather than the parent resolution everywhere. r=tn

--HG--
extra : amend_source : c72888ce19795e203e5dafa7d0b68065d6b668eb
This commit is contained in:
Botond Ballo 2014-10-20 15:53:29 -04:00
parent 834ac112fc
commit c9de17f39c
2 changed files with 21 additions and 8 deletions

View File

@ -2764,13 +2764,22 @@ CalculateFrameMetricsForDisplayPort(nsIFrame* aScrollFrame,
// Only the size of the composition bounds is relevant to the
// displayport calculation, not its origin.
nsSize compositionSize = nsLayoutUtils::CalculateCompositionSizeForFrame(aScrollFrame);
LayoutDeviceToParentLayerScale compBoundsScale(1.0f);
if (aScrollFrame == presShell->GetRootScrollFrame() && presContext->IsRootContentDocument()) {
if (presContext->GetParentPresContext()) {
gfxSize res = presContext->GetParentPresContext()->PresShell()->GetCumulativeResolution();
compBoundsScale = LayoutDeviceToParentLayerScale(res.width, res.height);
}
} else {
compBoundsScale = cumulativeResolution
* LayerToScreenScale(1.0f)
* ScreenToParentLayerScale(1.0f);
}
metrics.mCompositionBounds
= LayoutDeviceRect::FromAppUnits(nsRect(nsPoint(0, 0), compositionSize),
presContext->AppUnitsPerDevPixel())
* (cumulativeResolution / resolution);
* compBoundsScale;
// This function is used for setting a display port for subframes, so
// aScrollFrame will not be the root content document's root scroll frame.
metrics.SetRootCompositionSize(
nsLayoutUtils::CalculateRootCompositionSize(aScrollFrame, false, metrics));
@ -6988,13 +6997,12 @@ nsLayoutUtils::CalculateRootCompositionSize(nsIFrame* aFrame,
// TODO: Reuse that code here.
nsIPresShell* rootPresShell = rootPresContext->PresShell();
if (nsIFrame* rootFrame = rootPresShell->GetRootFrame()) {
LayoutDeviceToParentLayerScale parentResolution(
rootPresShell->GetCumulativeResolution().width
/ rootPresShell->GetResolution().width);
LayoutDeviceToLayerScale cumulativeResolution(
rootPresShell->GetCumulativeResolution().width);
int32_t rootAUPerDevPixel = rootPresContext->AppUnitsPerDevPixel();
LayerSize frameSize = ViewAs<LayerPixel>(
LayerSize frameSize =
(LayoutDeviceRect::FromAppUnits(rootFrame->GetRect(), rootAUPerDevPixel)
* parentResolution).Size(), PixelCastJustification::ParentLayerToLayerForRootComposition);
* cumulativeResolution).Size();
rootCompositionSize = frameSize;
#ifdef MOZ_WIDGET_ANDROID
nsIWidget* widget = rootFrame->GetNearestWidget();

View File

@ -2251,6 +2251,11 @@ public:
/**
* Calculate the compostion size for a frame. See FrameMetrics.h for
* defintion of composition size (or bounds).
* Note that for the root content document's root scroll frame (RCD-RSF),
* the returned size does not change as the document's resolution changes,
* but for all other frames it does. This means that callers that pass in
* a frame that may or may not be the RCD-RSF (which is most callers),
* are likely to need special-case handling of the RCD-RSF.
*/
static nsSize
CalculateCompositionSizeForFrame(nsIFrame* aFrame);