Bug 1259529 - Ensure that the APZ minimap for subframes remains scaled to the visible portion of the composition bounds. r?BenWa draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 24 Mar 2016 15:03:17 -0400
changeset 344506 43ba949e808549eed2c679aa0fec002d90f5af3d
parent 344505 f04ade5d45f0583b23addedb891a5844f430ff2d
child 516971 1cc3dc21ecc6db331ba2fb636117b92141c2f165
push id13841
push userkgupta@mozilla.com
push dateThu, 24 Mar 2016 19:03:41 +0000
reviewersBenWa
bugs1259529
milestone48.0a1
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
gfx/layers/composite/ContainerLayerComposite.cpp
--- 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.