Bug 1223639. Use ForceInside to constrain the displayport rect to the scrollable rect instead of intersect. r=botond

ForceInside shifts the rect first, and then clamps if needed. So the displayport doesn't get shrunk unnecessarily.

Bug 1191539 fixed this bug by applying ForceInside to the screen rect of the display port, which happens before the incorrect Intersect call.

It's better to remove the Intersect call and just do ForceInside once at the end to the final display port rect.

Bug 957668 introduced this bug by using Intersect instead of ForceInside when copying the code from AsyncPanZoomController::CalculatePendingDisplayPort when creating the code that computed a displayport rect from displayport margins.
This commit is contained in:
Timothy Nikkel 2015-11-11 16:38:24 -06:00
Родитель 2e6d1e7dfb
Коммит 518ea0ea30
1 изменённых файлов: 4 добавлений и 13 удалений

Просмотреть файл

@ -988,10 +988,6 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
ScreenRect screenRect = LayoutDeviceRect::FromAppUnits(base, auPerDevPixel)
* parentRes;
nsRect expandedScrollableRect =
nsLayoutUtils::CalculateExpandedScrollableRect(frame);
// Note on the correctness of applying the alignment in Screen space:
// The correct space to apply the alignment in would be Layer space, but
// we don't necessarily know the scale to convert to Layer space at this
@ -1079,21 +1075,16 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
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);
// Convert the aligned rect back into app units.
nsRect result = LayoutDeviceRect::ToAppUnits(screenRect / res, auPerDevPixel);
// Expand it for the low-res buffer if needed
result = ApplyRectMultiplier(result, aMultiplier);
// Finally, clamp it to the expanded scrollable rect.
result = expandedScrollableRect.Intersect(result + scrollPos) - scrollPos;
// Make sure the displayport remains within the scrollable rect.
nsRect expandedScrollableRect =
nsLayoutUtils::CalculateExpandedScrollableRect(frame);
result = result.ForceInside(expandedScrollableRect - scrollPos);
return result;
}