import from UXP: Make extra sure Compositables don't refer back to layers after reassignment. (706ac5f0)

This commit is contained in:
2022-04-03 15:33:46 +08:00
parent cbcf006b9f
commit 64861dcbaf
3 changed files with 19 additions and 5 deletions
@@ -43,9 +43,13 @@ bool
CanvasLayerComposite::SetCompositableHost(CompositableHost* aHost)
{
switch (aHost->GetType()) {
case CompositableType::IMAGE:
case CompositableType::IMAGE: {
if (mCompositableHost && aHost != mCompositableHost) {
mCompositableHost->Detach(this);
}
mCompositableHost = aHost;
return true;
}
default:
return false;
}
+7 -2
View File
@@ -50,9 +50,14 @@ bool
ImageLayerComposite::SetCompositableHost(CompositableHost* aHost)
{
switch (aHost->GetType()) {
case CompositableType::IMAGE:
mImageHost = static_cast<ImageHost*>(aHost);
case CompositableType::IMAGE: {
ImageHost* newImageHost = static_cast<ImageHost*>(aHost);
if (mImageHost && newImageHost != mImageHost) {
mImageHost->Detach(this);
}
mImageHost = newImageHost;
return true;
}
default:
return false;
}
@@ -50,9 +50,14 @@ PaintedLayerComposite::SetCompositableHost(CompositableHost* aHost)
switch (aHost->GetType()) {
case CompositableType::CONTENT_TILED:
case CompositableType::CONTENT_SINGLE:
case CompositableType::CONTENT_DOUBLE:
mBuffer = static_cast<ContentHost*>(aHost);
case CompositableType::CONTENT_DOUBLE: {
ContentHost* newBuffer = static_cast<ContentHost*>(aHost);
if (mBuffer && newBuffer != mBuffer) {
mBuffer->Detach(this);
}
mBuffer = newBuffer;
return true;
}
default:
return false;
}