Bug 1259529 - Ensure that the APZ minimap for subframes remains scaled to the visible portion of the composition bounds. r?BenWa
MozReview-Commit-ID: 3WR4Sxqjnsb
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -515,22 +515,32 @@ RenderMinimap(ContainerT* aContainer, La
return;
}
// Compute a scale with an appropriate aspect ratio
// We allocate up to 100px of width and the height of this layer.
float scaleFactor;
float scaleFactorX;
float scaleFactorY;
- scaleFactorX = 100.f / scrollRect.width;
- scaleFactorY = ((viewRect.height) - 2 * verticalPadding) / scrollRect.height;
+ Rect dest = Rect(aClipRect.ToUnknownRect());
+ if (aLayer->GetEffectiveClipRect()) {
+ dest = Rect(aLayer->GetEffectiveClipRect().value().ToUnknownRect());
+ } else {
+ dest = aContainer->GetEffectiveTransform().Inverse().TransformBounds(dest);
+ }
+ dest = dest.Intersect(compositionBounds.ToUnknownRect());
+ scaleFactorX = std::min(100.f, dest.width - (2 * horizontalPadding)) / scrollRect.width;
+ scaleFactorY = (dest.height - (2 * verticalPadding)) / scrollRect.height;
scaleFactor = std::min(scaleFactorX, scaleFactorY);
+ if (scaleFactor <= 0) {
+ return;
+ }
Matrix4x4 transform = Matrix4x4::Scaling(scaleFactor, scaleFactor, 1);
- transform.PostTranslate(horizontalPadding + compositionBounds.x, verticalPadding + compositionBounds.y, 0);
+ transform.PostTranslate(horizontalPadding + dest.x, verticalPadding + dest.y, 0);
Rect transformedScrollRect = transform.TransformBounds(scrollRect.ToUnknownRect());
Rect clipRect = aContainer->GetEffectiveTransform().TransformBounds(transformedScrollRect);
clipRect.width++;
clipRect.height++;
// Render the scrollable area.