diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 82fc9267d31ba..b2b34668109f4 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -2359,9 +2359,13 @@ static Rect TransformGfxRectToAncestor( } const nsIFrame* ancestor = aOutAncestor ? *aOutAncestor : aAncestor.mFrame; float factor = ancestor->PresContext()->AppUnitsPerDevPixel(); + // Caller is expected to properly clamp if the result is to be converted to + // app units. Technically, the clipping bound here is infinite, but that + // causes clipping to become unpredictable due to floating point errors. + const auto boundsAppUnits = Rect::MaxIntRect(); Rect maxBounds = - Rect(float(nscoord_MIN) / factor * 0.5, float(nscoord_MIN) / factor * 0.5, - float(nscoord_MAX) / factor, float(nscoord_MAX) / factor); + Rect(boundsAppUnits.x / factor, boundsAppUnits.y / factor, + boundsAppUnits.width / factor, boundsAppUnits.height / factor); return ctm.TransformAndClipBounds(aRect, maxBounds); } diff --git a/layout/generic/test/mochitest.ini b/layout/generic/test/mochitest.ini index a9b0e09398c28..818c1b9808c54 100644 --- a/layout/generic/test/mochitest.ini +++ b/layout/generic/test/mochitest.ini @@ -164,3 +164,4 @@ support-files = [test_scroll_on_display_contents.html] support-files = !/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js [test_bug1803209.html] +[test_bug1831148.html] diff --git a/layout/generic/test/test_bug1831148.html b/layout/generic/test/test_bug1831148.html new file mode 100644 index 0000000000000..c3653332cafe9 --- /dev/null +++ b/layout/generic/test/test_bug1831148.html @@ -0,0 +1,46 @@ + + + + + +Mozilla Bug 1831148 +
+