Bug 442715. Invalidate the whole border-box when an element's size changes and its background is being clipped by a border-radius. r=dbaron

--HG--
extra : rebase_source : b9e738ebd64cbcc871a7d1a7178e1eccf64e66f1
This commit is contained in:
Robert O'Callahan 2009-09-25 11:52:13 +12:00
parent 32bcb4af4e
commit 64435aeacc
5 changed files with 59 additions and 8 deletions

View File

@ -3947,8 +3947,7 @@ nsIFrame::CheckInvalidateSizeChange(const nsRect& aOldRect,
const nsRect& aOldOverflowRect,
const nsSize& aNewDesiredSize)
{
if (aNewDesiredSize.width == aOldRect.width &&
aNewDesiredSize.height == aOldRect.height)
if (aNewDesiredSize == aOldRect.Size())
return;
// Below, we invalidate the old frame area (or, in the case of
@ -3992,13 +3991,25 @@ nsIFrame::CheckInvalidateSizeChange(const nsRect& aOldRect,
}
}
// Invalidate the old frame background if the frame has a background
// whose position depends on the size of the frame
const nsStyleBackground *bg = GetStyleBackground();
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, bg) {
const nsStyleBackground::Layer &layer = bg->mLayers[i];
if (!layer.mImage.IsEmpty() &&
(layer.mPosition.mXIsPercent || layer.mPosition.mYIsPercent)) {
if (!bg->IsTransparent()) {
// Invalidate the old frame background if the frame has a background
// whose position depends on the size of the frame
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, bg) {
const nsStyleBackground::Layer &layer = bg->mLayers[i];
if (!layer.mImage.IsEmpty() &&
(layer.mPosition.mXIsPercent || layer.mPosition.mYIsPercent)) {
Invalidate(nsRect(0, 0, aOldRect.width, aOldRect.height));
return;
}
}
// Invalidate the old frame background if the frame has a background
// that is being clipped by border-radius, since the old or new area
// clipped off by the radius is not necessarily in the area that has
// already been invalidated (even if only the top-left corner has a
// border radius).
if (nsLayoutUtils::HasNonZeroCorner(border->mBorderRadius)) {
Invalidate(nsRect(0, 0, aOldRect.width, aOldRect.height));
return;
}

View File

@ -0,0 +1,7 @@
<!DOCTYPE HTML>
<html>
<body>
<div id="d" style="background:blue; -moz-border-radius:50px; width:200px; height:200px;">
</div>
</body>
</html>

View File

@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<body>
<div id="d" style="background:blue; -moz-border-radius:50px; width:200px; height:100px;">
</div>
<script>
function doTest() {
var d = document.getElementById("d");
d.style.height = "200px";
document.documentElement.className = "";
}
window.addEventListener("MozReftestInvalidate", doTest, false);
</script>
</body>
</html>

View File

@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<html class="reftest-wait">
<body>
<div id="d" style="background:blue; -moz-border-radius:50px; width:100px; height:200px;">
</div>
<script>
function doTest() {
var d = document.getElementById("d");
d.style.width = "200px";
document.documentElement.className = "";
}
window.addEventListener("MozReftestInvalidate", doTest, false);
</script>
</body>
</html>

View File

@ -16,3 +16,6 @@
# more serious tests, using SVG reference
== border-circle-2.html border-circle-2-ref.xhtml
== invalidate-1a.html invalidate-1-ref.html
== invalidate-1b.html invalidate-1-ref.html