From 722a5b8f40b7f906db53ff8421a52827a9a920fe Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Wed, 14 May 2003 00:44:38 +0000 Subject: [PATCH] Bug 199897. Fix regression by being smarter about how we clip border painting to the dirty rect. r=bernd,sr=dbaron,a=asa git-svn-id: svn://10.0.0.236/trunk@142402 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSRendering.cpp | 36 +++++++++++-------- .../layout/html/style/src/nsCSSRendering.cpp | 36 +++++++++++-------- 2 files changed, 44 insertions(+), 28 deletions(-) diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index 9db1d63e0a7..d09b80d86c4 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -1820,27 +1820,35 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext, // Border leaks out of the dirty rectangle - lets clip it but with care if (innerRect.y < aDirtyRect.y) { aSkipSides |= (1 << NS_SIDE_TOP); - innerRect.height -= aDirtyRect.y - innerRect.y; - innerRect.y = aDirtyRect.y; - outerRect.height -= innerRect.y - outerRect.y; - outerRect.y = innerRect.y; + PRUint32 shortenBy = + PR_MIN(innerRect.height, aDirtyRect.y - innerRect.y); + innerRect.y += shortenBy; + innerRect.height -= shortenBy; + outerRect.y += shortenBy; + outerRect.height -= shortenBy; } - if (innerRect.YMost() > aDirtyRect.YMost()) { + if (aDirtyRect.YMost() < innerRect.YMost()) { aSkipSides |= (1 << NS_SIDE_BOTTOM); - innerRect.height = aDirtyRect.YMost() - innerRect.y; - outerRect.height = aDirtyRect.YMost() - outerRect.y; + PRUint32 shortenBy = + PR_MIN(innerRect.height, innerRect.YMost() - aDirtyRect.YMost()); + innerRect.height -= shortenBy; + outerRect.height -= shortenBy; } if (innerRect.x < aDirtyRect.x) { aSkipSides |= (1 << NS_SIDE_LEFT); - innerRect.width -= aDirtyRect.x - innerRect.x; - innerRect.x = aDirtyRect.x; - outerRect.width -= innerRect.x - outerRect.x; - outerRect.x = innerRect.x; + PRUint32 shortenBy = + PR_MIN(innerRect.width, aDirtyRect.x - innerRect.x); + innerRect.x += shortenBy; + innerRect.width -= shortenBy; + outerRect.x += shortenBy; + outerRect.width -= shortenBy; } - if (innerRect.XMost() > aDirtyRect.XMost()) { + if (aDirtyRect.XMost() < innerRect.XMost()) { aSkipSides |= (1 << NS_SIDE_RIGHT); - innerRect.width = aDirtyRect.XMost() - innerRect.x; - outerRect.width = aDirtyRect.XMost() - outerRect.x; + PRUint32 shortenBy = + PR_MIN(innerRect.width, innerRect.XMost() - aDirtyRect.XMost()); + innerRect.width -= shortenBy; + outerRect.width -= shortenBy; } } /* Get our conversion values */ diff --git a/mozilla/layout/html/style/src/nsCSSRendering.cpp b/mozilla/layout/html/style/src/nsCSSRendering.cpp index 9db1d63e0a7..d09b80d86c4 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.cpp +++ b/mozilla/layout/html/style/src/nsCSSRendering.cpp @@ -1820,27 +1820,35 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext, // Border leaks out of the dirty rectangle - lets clip it but with care if (innerRect.y < aDirtyRect.y) { aSkipSides |= (1 << NS_SIDE_TOP); - innerRect.height -= aDirtyRect.y - innerRect.y; - innerRect.y = aDirtyRect.y; - outerRect.height -= innerRect.y - outerRect.y; - outerRect.y = innerRect.y; + PRUint32 shortenBy = + PR_MIN(innerRect.height, aDirtyRect.y - innerRect.y); + innerRect.y += shortenBy; + innerRect.height -= shortenBy; + outerRect.y += shortenBy; + outerRect.height -= shortenBy; } - if (innerRect.YMost() > aDirtyRect.YMost()) { + if (aDirtyRect.YMost() < innerRect.YMost()) { aSkipSides |= (1 << NS_SIDE_BOTTOM); - innerRect.height = aDirtyRect.YMost() - innerRect.y; - outerRect.height = aDirtyRect.YMost() - outerRect.y; + PRUint32 shortenBy = + PR_MIN(innerRect.height, innerRect.YMost() - aDirtyRect.YMost()); + innerRect.height -= shortenBy; + outerRect.height -= shortenBy; } if (innerRect.x < aDirtyRect.x) { aSkipSides |= (1 << NS_SIDE_LEFT); - innerRect.width -= aDirtyRect.x - innerRect.x; - innerRect.x = aDirtyRect.x; - outerRect.width -= innerRect.x - outerRect.x; - outerRect.x = innerRect.x; + PRUint32 shortenBy = + PR_MIN(innerRect.width, aDirtyRect.x - innerRect.x); + innerRect.x += shortenBy; + innerRect.width -= shortenBy; + outerRect.x += shortenBy; + outerRect.width -= shortenBy; } - if (innerRect.XMost() > aDirtyRect.XMost()) { + if (aDirtyRect.XMost() < innerRect.XMost()) { aSkipSides |= (1 << NS_SIDE_RIGHT); - innerRect.width = aDirtyRect.XMost() - innerRect.x; - outerRect.width = aDirtyRect.XMost() - outerRect.x; + PRUint32 shortenBy = + PR_MIN(innerRect.width, innerRect.XMost() - aDirtyRect.XMost()); + innerRect.width -= shortenBy; + outerRect.width -= shortenBy; } } /* Get our conversion values */