Bug 463204. Be more careful about snapping the anchor point. We must transform the anchor point to match the snapping of the fill rect before we actually snap it to device pixels. r+sr=dbaron

This commit is contained in:
Robert O'Callahan 2008-11-07 13:58:42 +13:00
Родитель ee00d290e8
Коммит 77ae7c8abe
5 изменённых файлов: 54 добавлений и 10 удалений

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

@ -2678,7 +2678,7 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
const nsPoint& aAnchor,
const nsRect& aDirty)
{
if (aDest.IsEmpty())
if (aDest.IsEmpty() || aFill.IsEmpty())
return NS_OK;
nsCOMPtr<nsIDeviceContext> dc;
@ -2687,14 +2687,15 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
gfxContext *ctx = aRenderingContext->ThebesContext();
// Compute the pixel-snapped area that should be drawn
gfxRect fill(aFill.x/appUnitsPerDevPixel,
aFill.y/appUnitsPerDevPixel,
aFill.width/appUnitsPerDevPixel,
aFill.height/appUnitsPerDevPixel);
gfxRect devPixelFill(aFill.x/appUnitsPerDevPixel,
aFill.y/appUnitsPerDevPixel,
aFill.width/appUnitsPerDevPixel,
aFill.height/appUnitsPerDevPixel);
PRBool ignoreScale = PR_FALSE;
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
ignoreScale = PR_TRUE;
#endif
gfxRect fill = devPixelFill;
PRBool didSnap = ctx->UserToDevicePixelSnapped(fill, ignoreScale);
// Compute dirty rect in gfx space
@ -2735,7 +2736,13 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
gfxMatrix currentMatrix = ctx->CurrentMatrix();
gfxRect finalFillRect = fill;
if (didSnap) {
ctx->UserToDevicePixelSnapped(anchorPoint, ignoreScale);
NS_ASSERTION(!currentMatrix.HasNonAxisAlignedTransform(),
"How did we snap, then?");
anchorPoint.x = fill.pos.x +
(anchorPoint.x - devPixelFill.pos.x)*fill.size.width/devPixelFill.size.width;
anchorPoint.y = fill.pos.y +
(anchorPoint.y - devPixelFill.pos.y)*fill.size.height/devPixelFill.size.height;
anchorPoint.Round();
// This form of Transform is safe to call since non-axis-aligned
// transforms wouldn't be snapped.

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

@ -28,8 +28,8 @@
<div>
<div class="cell"><p>32 x 32</p><div style="width:32px; background-position:-16px -16px;" class="image"></div></div>
<div class="cell"><p>32.1 x 32</p><div style="width:32px; background-position:-16px -16px;" class="image"></div></div>
<div class="cell"><p>32.5 x 32</p><div style="width:33px; background-position:-16px -16px;" class="image"></div></div>
<div class="cell"><p>32.8 x 32</p><div style="width:33px; background-position:-16px -16px;" class="image"></div></div>
<div class="cell"><p>32.5 x 32</p><div style="width:33px; background-position:-15px -16px;" class="image"></div></div>
<div class="cell"><p>32.8 x 32</p><div style="width:33px; background-position:-15px -16px;" class="image"></div></div>
</div>
<div>
@ -42,8 +42,8 @@
<div>
<div class="cell"><p>32 x 32 </p><div style="height:32px; background-position:-16px -16px;" class="image"></div></div>
<div class="cell"><p>32 x 32.1 </p><div style="height:32px; background-position:-16px -16px;" class="image"></div></div>
<div class="cell"><p>32 x 32.5 </p><div style="height:33px; background-position:-16px -16px;" class="image"></div></div>
<div class="cell"><p>32 x 32.8 </p><div style="height:33px; background-position:-16px -16px;" class="image"></div></div>
<div class="cell"><p>32 x 32.5 </p><div style="height:33px; background-position:-16px -15px;" class="image"></div></div>
<div class="cell"><p>32 x 32.8 </p><div style="height:33px; background-position:-16px -15px;" class="image"></div></div>
</div>
</body></html>

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

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
span {
background-image: url(data:image/gif;base64,R0lGODlhEwATAKIAAP//AMzMADMzAP8AAAAAAP///wAAAAAAACH5BAEAAAUALAAAAAATABMAAANWWLrUTisyEoC1oUlFr8dQRHykFRad+Y0gdzlv86KVKdsskOUAjHu312rFK5FuxaMNIMgYe85GrVfKZVDAR7DHmVoG4IHn6vqEgZLU90xOq8OazUS7SQAAOw==);
display: inline-block;
width: 19px;
height: 19px;
margin-left: 1px;
}
</style>
</head>
<body>
<span></span>
</body>
</html>

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

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
span {
background-image: url(data:image/gif;base64,R0lGODlhEwATAKIAAP//AMzMADMzAP8AAAAAAP///wAAAAAAACH5BAEAAAUALAAAAAATABMAAANWWLrUTisyEoC1oUlFr8dQRHykFRad+Y0gdzlv86KVKdsskOUAjHu312rFK5FuxaMNIMgYe85GrVfKZVDAR7DHmVoG4IHn6vqEgZLU90xOq8OazUS7SQAAOw==);
display: inline-block;
background-repeat: no-repeat;
background-position: center center;
width: 19px;
height: 19px;
margin-left: 0.6px;
}
</style>
</head>
<body>
<span></span>
</body>
</html>

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

@ -958,3 +958,4 @@ fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 456147.xul 456147-ref.html # bug 456147
== 458487-5b.html 458487-5-ref.html
== 461266-1.html 461266-1-ref.html
fails == 461512-1.html 461512-1-ref.html # Bug 461512
== 463204-1.html 463204-1-ref.html