Bug 1329091 - Keep mask style value to determine whether cached mask layer is corrupt. r=mstange

MozReview-Commit-ID: J2CFFi5pN7H

--HG--
extra : rebase_source : 44f6568e986bee87582558791d29dd7c0d63b29b
This commit is contained in:
cku 2017-01-06 17:53:30 +08:00
Родитель b8d8e17b15
Коммит 06b5fc97f9
3 изменённых файлов: 93 добавлений и 16 удалений

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

@ -1576,29 +1576,24 @@ struct MaskLayerUserData : public LayerUserData
struct CSSMaskLayerUserData : public LayerUserData
{
CSSMaskLayerUserData()
: mFrame(nullptr)
: mMaskStyle(nsStyleImageLayers::LayerType::Mask)
{ }
CSSMaskLayerUserData(nsIFrame* aFrame, const nsIntSize& aMaskSize)
: mFrame(aFrame),
mMaskSize(aMaskSize)
{ }
CSSMaskLayerUserData& operator=(const CSSMaskLayerUserData& aOther)
: mMaskSize(aMaskSize),
mMaskStyle(aFrame->StyleSVGReset()->mMask)
{
mFrame = aOther.mFrame;
mMaskSize = aOther.mMaskSize;
}
return *this;
void operator=(CSSMaskLayerUserData&& aOther)
{
mMaskSize = aOther.mMaskSize;
mMaskStyle = Move(aOther.mMaskStyle);
}
bool
operator==(const CSSMaskLayerUserData& aOther) const
{
if (mFrame != aOther.mFrame) {
return false;
}
// Even if the frame is valid, check the size of the display item's
// boundary is still necessary. For example, if we scale the masked frame
// by adding a transform property on it, the masked frame is valid itself
@ -1608,12 +1603,12 @@ struct CSSMaskLayerUserData : public LayerUserData
return false;
}
return true;
return mMaskStyle == aOther.mMaskStyle;
}
private:
nsIFrame* mFrame;
nsIntSize mMaskSize;
nsStyleImageLayers mMaskStyle;
};
/*
@ -3933,7 +3928,7 @@ ContainerState::SetupMaskLayerForCSSMask(Layer* aLayer,
}
maskLayer->SetContainer(imgContainer);
*oldUserData = newUserData;
*oldUserData = Move(newUserData);
aLayer->SetMaskLayer(maskLayer);
}

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

@ -2603,6 +2603,79 @@ nsStyleImageLayers::operator=(const nsStyleImageLayers& aOther)
return *this;
}
nsStyleImageLayers&
nsStyleImageLayers::operator=(nsStyleImageLayers&& aOther)
{
mAttachmentCount = aOther.mAttachmentCount;
mClipCount = aOther.mClipCount;
mOriginCount = aOther.mOriginCount;
mRepeatCount = aOther.mRepeatCount;
mPositionXCount = aOther.mPositionXCount;
mPositionYCount = aOther.mPositionYCount;
mImageCount = aOther.mImageCount;
mSizeCount = aOther.mSizeCount;
mMaskModeCount = aOther.mMaskModeCount;
mBlendModeCount = aOther.mBlendModeCount;
mCompositeCount = aOther.mCompositeCount;
mLayers = Move(aOther.mLayers);
uint32_t count = mLayers.Length();
if (count != aOther.mLayers.Length()) {
NS_WARNING("truncating counts due to out-of-memory");
mAttachmentCount = std::max(mAttachmentCount, count);
mClipCount = std::max(mClipCount, count);
mOriginCount = std::max(mOriginCount, count);
mRepeatCount = std::max(mRepeatCount, count);
mPositionXCount = std::max(mPositionXCount, count);
mPositionYCount = std::max(mPositionYCount, count);
mImageCount = std::max(mImageCount, count);
mSizeCount = std::max(mSizeCount, count);
mMaskModeCount = std::max(mMaskModeCount, count);
mBlendModeCount = std::max(mBlendModeCount, count);
mCompositeCount = std::max(mCompositeCount, count);
}
return *this;
}
bool nsStyleImageLayers::operator==(const nsStyleImageLayers& aOther) const
{
if (mAttachmentCount != aOther.mAttachmentCount ||
mClipCount != aOther.mClipCount ||
mOriginCount != aOther.mOriginCount ||
mRepeatCount != aOther.mRepeatCount ||
mPositionXCount != aOther.mPositionXCount ||
mPositionYCount != aOther.mPositionYCount ||
mImageCount != aOther.mImageCount ||
mSizeCount != aOther.mSizeCount ||
mMaskModeCount != aOther.mMaskModeCount ||
mBlendModeCount != aOther.mBlendModeCount) {
return false;
}
if (mLayers.Length() != aOther.mLayers.Length()) {
return false;
}
for (uint32_t i = 0; i < mLayers.Length(); i++) {
if (mLayers[i].mPosition != aOther.mLayers[i].mPosition ||
!DefinitelyEqualURIs(mLayers[i].mSourceURI, aOther.mLayers[i].mSourceURI) ||
mLayers[i].mImage != aOther.mLayers[i].mImage ||
mLayers[i].mSize != aOther.mLayers[i].mSize ||
mLayers[i].mClip != aOther.mLayers[i].mClip ||
mLayers[i].mOrigin != aOther.mLayers[i].mOrigin ||
mLayers[i].mAttachment != aOther.mLayers[i].mAttachment ||
mLayers[i].mBlendMode != aOther.mLayers[i].mBlendMode ||
mLayers[i].mComposite != aOther.mLayers[i].mComposite ||
mLayers[i].mMaskMode != aOther.mLayers[i].mMaskMode ||
mLayers[i].mRepeat != aOther.mLayers[i].mRepeat) {
return false;
}
}
return true;
}
bool
nsStyleImageLayers::IsInitialPositionForLayerType(Position aPosition, LayerType aType)
{

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

@ -625,6 +625,13 @@ public:
return !(*this == aOther);
}
nsStyleAutoArray& operator=(nsStyleAutoArray&& aOther) {
mFirstElement = aOther.mFirstElement;
mOtherElements.SwapElements(aOther.mOtherElements);
return *this;
}
size_t Length() const {
return mOtherElements.Length() + 1;
}
@ -899,6 +906,8 @@ struct nsStyleImageLayers {
bool HasLayerWithImage() const;
nsStyleImageLayers& operator=(const nsStyleImageLayers& aOther);
nsStyleImageLayers& operator=(nsStyleImageLayers&& aOther);
bool operator==(const nsStyleImageLayers& aOther) const;
static const nsCSSPropertyID kBackgroundLayerTable[];
static const nsCSSPropertyID kMaskLayerTable[];