Bug 1071367 - Fix the composition bounds for the root content document on OS X. r=tn

According to roc the content viewer position doesn't mean much; only the size is
set to anything meaningful. Therefore using the position from the content viewer
bounds is not a good idea, and we should use the position from the frame bounds
instead. This patch also changes GetContentViewerBounds to GetContentViewerSize
so that it's harder to accidentally use the position in other places.
This commit is contained in:
Kartikaya Gupta 2014-09-23 12:17:36 -04:00
parent ab23cc4fba
commit cb12b9a2a4
3 changed files with 17 additions and 17 deletions

View File

@ -815,14 +815,14 @@ nsDisplayScrollLayer::ComputeFrameMetrics(nsIFrame* aForFrame,
}
#endif
} else {
LayoutDeviceIntRect contentBounds;
if (nsLayoutUtils::GetContentViewerBounds(presContext, contentBounds)) {
LayoutDeviceIntSize contentSize;
if (nsLayoutUtils::GetContentViewerSize(presContext, contentSize)) {
LayoutDeviceToParentLayerScale scale(1.0f);
if (presContext->GetParentPresContext()) {
gfxSize res = presContext->GetParentPresContext()->PresShell()->GetCumulativeResolution();
scale = LayoutDeviceToParentLayerScale(res.width, res.height);
}
metrics.mCompositionBounds = LayoutDeviceRect(contentBounds) * scale;
metrics.mCompositionBounds.SizeTo(contentSize * scale);
}
}
}

View File

@ -6698,8 +6698,8 @@ nsLayoutUtils::UpdateImageVisibilityForFrame(nsIFrame* aImageFrame)
}
/* static */ bool
nsLayoutUtils::GetContentViewerBounds(nsPresContext* aPresContext,
LayoutDeviceIntRect& aOutRect)
nsLayoutUtils::GetContentViewerSize(nsPresContext* aPresContext,
LayoutDeviceIntSize& aOutSize)
{
nsCOMPtr<nsIDocShell> docShell = aPresContext->GetDocShell();
if (!docShell) {
@ -6714,7 +6714,7 @@ nsLayoutUtils::GetContentViewerBounds(nsPresContext* aPresContext,
nsIntRect bounds;
cv->GetBounds(bounds);
aOutRect = LayoutDeviceIntRect::FromUntyped(bounds);
aOutSize = LayoutDeviceIntRect::FromUntyped(bounds).Size();
return true;
}
@ -6752,9 +6752,9 @@ nsLayoutUtils::CalculateCompositionSizeForFrame(nsIFrame* aFrame)
}
#endif
} else {
LayoutDeviceIntRect contentBounds;
if (nsLayoutUtils::GetContentViewerBounds(presContext, contentBounds)) {
size = LayoutDevicePixel::ToAppUnits(contentBounds.Size(), auPerDevPixel);
LayoutDeviceIntSize contentSize;
if (nsLayoutUtils::GetContentViewerSize(presContext, contentSize)) {
size = LayoutDevicePixel::ToAppUnits(contentSize, auPerDevPixel);
}
}
}
@ -6820,14 +6820,14 @@ nsLayoutUtils::CalculateRootCompositionSize(nsIFrame* aFrame,
}
#endif
} else {
LayoutDeviceIntRect contentBounds;
if (nsLayoutUtils::GetContentViewerBounds(rootPresContext, contentBounds)) {
LayoutDeviceIntSize contentSize;
if (nsLayoutUtils::GetContentViewerSize(rootPresContext, contentSize)) {
LayoutDeviceToLayerScale scale(1.0f);
if (rootPresContext->GetParentPresContext()) {
gfxSize res = rootPresContext->GetParentPresContext()->PresShell()->GetCumulativeResolution();
scale = LayoutDeviceToLayerScale(res.width, res.height);
}
rootCompositionSize = contentBounds.Size() * scale;
rootCompositionSize = contentSize * scale;
}
}
}

View File

@ -130,7 +130,7 @@ public:
typedef mozilla::CSSPoint CSSPoint;
typedef mozilla::CSSSize CSSSize;
typedef mozilla::LayerMargin LayerMargin;
typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
/**
* Finds previously assigned ViewID for the given content element, if any.
@ -2175,13 +2175,13 @@ public:
UpdateImageVisibilityForFrame(nsIFrame* aImageFrame);
/**
* Populate aOutRect with the bounds of the content viewer corresponding
* to the given prescontext. Return true if the bounds were set, false
* Populate aOutSize with the size of the content viewer corresponding
* to the given prescontext. Return true if the size was set, false
* otherwise.
*/
static bool
GetContentViewerBounds(nsPresContext* aPresContext,
LayoutDeviceIntRect& aOutRect);
GetContentViewerSize(nsPresContext* aPresContext,
LayoutDeviceIntSize& aOutSize);
/**
* Calculate the compostion size for a frame. See FrameMetrics.h for