Bug 1265256 - Use the canvas positioning area when computing the background-attachment:fixed rect for canvas frames. r=mstange

This commit is contained in:
Matt Woodrow 2016-04-22 17:50:11 +12:00
Родитель 37ad6cbc0c
Коммит 083b9cd7fc
4 изменённых файлов: 40 добавлений и 27 удалений

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

@ -2586,30 +2586,6 @@ nsDisplayBackgroundImage::ComputeShouldTreatAsFixed(bool isTransformedFixed) con
return !isTransformedFixed;
}
bool
nsDisplayBackgroundImage::IsSingleFixedPositionImage(nsDisplayListBuilder* aBuilder,
const nsRect& aClipRect,
gfxRect* aDestRect)
{
if (!mBackgroundStyle)
return false;
if (mBackgroundStyle->mImage.mLayers.Length() != 1)
return false;
if (!ShouldTreatAsFixed())
return false;
// We only care about images here, not gradients.
if (!mIsRasterImage)
return false;
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
*aDestRect = nsLayoutUtils::RectToGfxRect(mFillRect, appUnitsPerDevPixel);
return true;
}
bool
nsDisplayBackgroundImage::IsNonEmptyFixedImage() const
{

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

@ -2736,9 +2736,6 @@ protected:
typedef class mozilla::layers::ImageLayer ImageLayer;
bool TryOptimizeToImageLayer(LayerManager* aManager, nsDisplayListBuilder* aBuilder);
bool IsSingleFixedPositionImage(nsDisplayListBuilder* aBuilder,
const nsRect& aClipRect,
gfxRect* aDestRect);
bool IsNonEmptyFixedImage() const;
nsRect GetBoundsInternal(nsDisplayListBuilder* aBuilder);
bool ShouldTreatAsFixed() const;

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

@ -326,6 +326,42 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
PaintInternal(aBuilder, aCtx, mVisibleRect, &bgClipRect);
}
bool
nsDisplayCanvasBackgroundImage::IsSingleFixedPositionImage(nsDisplayListBuilder* aBuilder,
const nsRect& aClipRect,
gfxRect* aDestRect)
{
if (!mBackgroundStyle)
return false;
if (mBackgroundStyle->mImage.mLayers.Length() != 1)
return false;
nsPresContext* presContext = mFrame->PresContext();
uint32_t flags = aBuilder->GetBackgroundPaintFlags();
nsRect borderArea = nsRect(ToReferenceFrame(), mFrame->GetSize());
const nsStyleImageLayers::Layer &layer = mBackgroundStyle->mImage.mLayers[mLayer];
if (layer.mAttachment != NS_STYLE_IMAGELAYER_ATTACHMENT_FIXED)
return false;
nsBackgroundLayerState state =
nsCSSRendering::PrepareImageLayer(presContext, mFrame, flags,
borderArea, aClipRect, layer);
// We only care about images here, not gradients.
if (!mIsRasterImage)
return false;
int32_t appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
*aDestRect = nsLayoutUtils::RectToGfxRect(state.mFillArea, appUnitsPerDevPixel);
return true;
}
void
nsDisplayCanvasThemedBackground::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)

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

@ -228,6 +228,10 @@ public:
// so we can't support this yet.
virtual bool SupportsOptimizingToImage() override { return false; }
bool IsSingleFixedPositionImage(nsDisplayListBuilder* aBuilder,
const nsRect& aClipRect,
gfxRect* aDestRect);
NS_DISPLAY_DECL_NAME("CanvasBackgroundImage", TYPE_CANVAS_BACKGROUND_IMAGE)
};