Bug 641770. Apply correct clip rect to a layerized image. r=tnikkel

This commit is contained in:
Robert O'Callahan 2011-04-01 10:33:46 +13:00
parent 4bd5d3cedf
commit d13eeaf01c
4 changed files with 29 additions and 1 deletions

View File

@ -282,6 +282,10 @@ protected:
* convert this to an ImageLayer.
*/
nsDisplayImage* mImage;
/**
* Stores the clip that we need to apply to the image.
*/
FrameLayerBuilder::Clip mImageClip;
};
/**
@ -917,7 +921,7 @@ ContainerState::FindOpaqueBackgroundColorFor(PRInt32 aThebesLayerIndex)
nsRefPtr<ImageContainer>
ContainerState::ThebesLayerData::CanOptimizeImageLayer(LayerManager* aManager)
{
if (!mImage) {
if (!mImage || !mImageClip.mRoundedClipRects.IsEmpty()) {
return nsnull;
}
@ -942,6 +946,15 @@ ContainerState::PopThebesLayerData()
nsRefPtr<ImageLayer> imageLayer = CreateOrRecycleImageLayer();
imageLayer->SetContainer(imageContainer);
data->mImage->ConfigureLayer(imageLayer);
NS_ASSERTION(data->mImageClip.mRoundedClipRects.IsEmpty(),
"How did we get rounded clip rects here?");
if (data->mImageClip.mHaveClipRect) {
nsPresContext* presContext = mContainerFrame->PresContext();
nscoord appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
nsIntRect clip = data->mImageClip.mClipRect.ToNearestPixels(appUnitsPerDevPixel);
imageLayer->IntersectClipRect(
data->mImageClip.mClipRect.ToNearestPixels(appUnitsPerDevPixel));
}
layer = imageLayer;
} else {
nsRefPtr<ColorLayer> colorLayer = CreateOrRecycleColorLayer();
@ -1118,6 +1131,7 @@ ContainerState::ThebesLayerData::Accumulate(nsDisplayListBuilder* aBuilder,
*/
if (aItem->GetType() == nsDisplayItem::TYPE_IMAGE && mVisibleRegion.IsEmpty()) {
mImage = static_cast<nsDisplayImage*>(aItem);
mImageClip = aClip;
} else {
mImage = nsnull;
}

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="position:absolute; background:green; width:1500px; height:1500px;"></div>
</body>
</html>

View File

@ -0,0 +1,7 @@
<!DOCTYPE HTML>
<html>
<body>
<img style="position:fixed; width:1500px;" src="repeatable-diagonal-gradient.png">
<div style="position:absolute; background:green; width:1500px; height:1500px;"></div>
</body>
</html>

View File

@ -1623,4 +1623,5 @@ fails-if(Android) == 634232-1.html 634232-1-ref.html
fails-if(Android) == 635302-1.html 635302-1-ref.html
HTTP(..) == 635639-1.html 635639-1-ref.html
HTTP(..) == 635639-2.html 635639-2-ref.html
== 641770-1.html 641770-1-ref.html
== 641856-1.html 641856-1-ref.html