From 6bcbbfa24eafffde60e4cf64dc8ef641e69a110f Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Wed, 9 Sep 2015 14:41:38 -0400 Subject: [PATCH] Bug 1191539 - DisplayPort should ForceInside frameRect to match compositor DisplayPort. r=kats --- layout/base/nsLayoutUtils.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index aea72dc4d9e6..65c1e15dc112 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -920,6 +920,9 @@ GetDisplayPortFromMarginsData(nsIContent* aContent, ScreenRect screenRect = LayoutDeviceRect::FromAppUnits(base, auPerDevPixel) * parentRes; + nsRect expandedScrollableRect = + nsLayoutUtils::CalculateExpandedScrollableRect(frame); + if (gfxPrefs::LayersTilesEnabled()) { // Note on the correctness of applying the alignment in Screen space: // The correct space to apply the alignment in would be Layer space, but @@ -955,12 +958,20 @@ GetDisplayPortFromMarginsData(nsIContent* aContent, * res; screenRect += scrollPosScreen; + // Round-out the display port to the nearest alignment (tiles) float x = alignmentX * floor(screenRect.x / alignmentX); float y = alignmentY * floor(screenRect.y / alignmentY); - float w = alignmentX * ceil(screenRect.XMost() / alignmentX) - x; - float h = alignmentY * ceil(screenRect.YMost() / alignmentY) - y; + float w = alignmentX * ceil(screenRect.width / alignmentX + 1); + float h = alignmentY * ceil(screenRect.height / alignmentY + 1); screenRect = ScreenRect(x, y, w, h); screenRect -= scrollPosScreen; + + ScreenRect screenExpScrollableRect = + LayoutDeviceRect::FromAppUnits(expandedScrollableRect, + auPerDevPixel) * res; + + // Make sure the displayport remains within the scrollable rect. + screenRect = screenRect.ForceInside(screenExpScrollableRect - scrollPosScreen); } else { nscoord maxSizeInAppUnits = GetMaxDisplayPortSize(aContent); if (maxSizeInAppUnits == nscoord_MAX) { @@ -1001,7 +1012,6 @@ GetDisplayPortFromMarginsData(nsIContent* aContent, result = ApplyRectMultiplier(result, aMultiplier); // Finally, clamp it to the expanded scrollable rect. - nsRect expandedScrollableRect = nsLayoutUtils::CalculateExpandedScrollableRect(frame); result = expandedScrollableRect.Intersect(result + scrollPos) - scrollPos; return result;