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

This commit is contained in:
Botond Ballo
2014-10-20 15:53:29 -04:00
parent 3bfa8dbb30
commit 44b608d976
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 // Only the size of the composition bounds is relevant to the
// displayport calculation, not its origin. // displayport calculation, not its origin.
nsSize compositionSize = nsLayoutUtils::CalculateCompositionSizeForFrame(aScrollFrame); 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 metrics.mCompositionBounds
= LayoutDeviceRect::FromAppUnits(nsRect(nsPoint(0, 0), compositionSize), = LayoutDeviceRect::FromAppUnits(nsRect(nsPoint(0, 0), compositionSize),
presContext->AppUnitsPerDevPixel()) 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( metrics.SetRootCompositionSize(
nsLayoutUtils::CalculateRootCompositionSize(aScrollFrame, false, metrics)); nsLayoutUtils::CalculateRootCompositionSize(aScrollFrame, false, metrics));
@@ -6988,13 +6997,12 @@ nsLayoutUtils::CalculateRootCompositionSize(nsIFrame* aFrame,
// TODO: Reuse that code here. // TODO: Reuse that code here.
nsIPresShell* rootPresShell = rootPresContext->PresShell(); nsIPresShell* rootPresShell = rootPresContext->PresShell();
if (nsIFrame* rootFrame = rootPresShell->GetRootFrame()) { if (nsIFrame* rootFrame = rootPresShell->GetRootFrame()) {
LayoutDeviceToParentLayerScale parentResolution( LayoutDeviceToLayerScale cumulativeResolution(
rootPresShell->GetCumulativeResolution().width rootPresShell->GetCumulativeResolution().width);
/ rootPresShell->GetResolution().width);
int32_t rootAUPerDevPixel = rootPresContext->AppUnitsPerDevPixel(); int32_t rootAUPerDevPixel = rootPresContext->AppUnitsPerDevPixel();
LayerSize frameSize = ViewAs<LayerPixel>( LayerSize frameSize =
(LayoutDeviceRect::FromAppUnits(rootFrame->GetRect(), rootAUPerDevPixel) (LayoutDeviceRect::FromAppUnits(rootFrame->GetRect(), rootAUPerDevPixel)
* parentResolution).Size(), PixelCastJustification::ParentLayerToLayerForRootComposition); * cumulativeResolution).Size();
rootCompositionSize = frameSize; rootCompositionSize = frameSize;
#ifdef MOZ_WIDGET_ANDROID #ifdef MOZ_WIDGET_ANDROID
nsIWidget* widget = rootFrame->GetNearestWidget(); nsIWidget* widget = rootFrame->GetNearestWidget();

View File

@@ -2251,6 +2251,11 @@ public:
/** /**
* Calculate the compostion size for a frame. See FrameMetrics.h for * Calculate the compostion size for a frame. See FrameMetrics.h for
* defintion of composition size (or bounds). * 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 static nsSize
CalculateCompositionSizeForFrame(nsIFrame* aFrame); CalculateCompositionSizeForFrame(nsIFrame* aFrame);