diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 7306602b923..9e5120a2d10 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -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 ContainerState::ThebesLayerData::CanOptimizeImageLayer(LayerManager* aManager) { - if (!mImage) { + if (!mImage || !mImageClip.mRoundedClipRects.IsEmpty()) { return nsnull; } @@ -942,6 +946,15 @@ ContainerState::PopThebesLayerData() nsRefPtr 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 = CreateOrRecycleColorLayer(); @@ -1118,6 +1131,7 @@ ContainerState::ThebesLayerData::Accumulate(nsDisplayListBuilder* aBuilder, */ if (aItem->GetType() == nsDisplayItem::TYPE_IMAGE && mVisibleRegion.IsEmpty()) { mImage = static_cast(aItem); + mImageClip = aClip; } else { mImage = nsnull; } diff --git a/layout/reftests/bugs/641770-1-ref.html b/layout/reftests/bugs/641770-1-ref.html new file mode 100644 index 00000000000..fcbe8a905aa --- /dev/null +++ b/layout/reftests/bugs/641770-1-ref.html @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/layout/reftests/bugs/641770-1.html b/layout/reftests/bugs/641770-1.html new file mode 100644 index 00000000000..fac0a4ea001 --- /dev/null +++ b/layout/reftests/bugs/641770-1.html @@ -0,0 +1,7 @@ + + + + +
+ + diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index a4f0e700961..0f0e7a4be77 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -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