Bug 1412272 - Have ComputePartialPrerenderArea() handle the cases where aDirtyRect is larger than aPrerenderSize. r=mstange
Rendering at least aDirtyRect is more important than staying under
aPrerenderSize, so that's what we do.
MozReview-Commit-ID: 8Ze1biaNzqX
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -9802,18 +9802,18 @@ nsLayoutUtils::GetCumulativeApzCallbackT
/* static */ nsRect
nsLayoutUtils::ComputePartialPrerenderArea(const nsRect& aDirtyRect,
const nsRect& aOverflow,
const nsSize& aPrerenderSize)
{
// Simple calculation for now: center the pre-render area on the dirty rect,
// and clamp to the overflow area. Later we can do more advanced things like
// redistributing from one axis to another, or from one side to another.
- nscoord xExcess = aPrerenderSize.width - aDirtyRect.width;
- nscoord yExcess = aPrerenderSize.height - aDirtyRect.height;
+ nscoord xExcess = std::max(aPrerenderSize.width - aDirtyRect.width, 0);
+ nscoord yExcess = std::max(aPrerenderSize.height - aDirtyRect.height, 0);
nsRect result = aDirtyRect;
result.Inflate(xExcess / 2, yExcess / 2);
return result.MoveInsideAndClamp(aOverflow);
}
static
bool
LineHasNonEmptyContentWorker(nsIFrame* aFrame)
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -3039,17 +3039,20 @@ public:
/**
* Compute a rect to pre-render in cases where we want to render more of
* something than what is visible (usually to support async transformation).
* @param aDirtyRect the area that's visible
* @param aOverflow the total size of the thing we're rendering
* @param aPrerenderSize how large of an area we're willing to render
* @return A rectangle that includes |aDirtyRect|, is clamped to |aOverflow|,
- * and is no larger than |aPrerenderSize|.
+ * and is no larger than |aPrerenderSize| (unless |aPrerenderSize|
+ * is smaller than |aDirtyRect|, in which case the returned rect
+ * will still include |aDirtyRect| and thus be larger than
+ * |aPrerenderSize|).
*/
static nsRect ComputePartialPrerenderArea(const nsRect& aDirtyRect,
const nsRect& aOverflow,
const nsSize& aPrerenderSize);
/*
* Checks whether a node is an invisible break.
* If not, returns the first frame on the next line if such a next line exists.