mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 968833 - 1/2 - Make PLayerTransaction check actual layer types before casting - r=jrmuizel
This commit is contained in:
parent
863f076e76
commit
755940561f
@ -268,7 +268,8 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
MOZ_LAYERS_LOG(("[ParentSide] SetLayerAttributes"));
|
||||
|
||||
const OpSetLayerAttributes& osla = edit.get_OpSetLayerAttributes();
|
||||
Layer* layer = AsLayerComposite(osla)->AsLayer();
|
||||
ShadowLayerParent* layerParent = AsLayerComposite(osla);
|
||||
Layer* layer = layerParent->AsLayer();
|
||||
const LayerAttributes& attrs = osla.attrs();
|
||||
|
||||
const CommonLayerAttributes& common = attrs.common();
|
||||
@ -306,8 +307,10 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
case Specific::TThebesLayerAttributes: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] thebes layer"));
|
||||
|
||||
ThebesLayerComposite* thebesLayer =
|
||||
static_cast<ThebesLayerComposite*>(layer);
|
||||
ThebesLayerComposite* thebesLayer = layerParent->AsThebesLayerComposite();
|
||||
if (!thebesLayer) {
|
||||
return false;
|
||||
}
|
||||
const ThebesLayerAttributes& attrs =
|
||||
specific.get_ThebesLayerAttributes();
|
||||
|
||||
@ -318,8 +321,10 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
case Specific::TContainerLayerAttributes: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] container layer"));
|
||||
|
||||
ContainerLayer* containerLayer =
|
||||
static_cast<ContainerLayer*>(layer);
|
||||
ContainerLayerComposite* containerLayer = layerParent->AsContainerLayerComposite();
|
||||
if (!containerLayer) {
|
||||
return false;
|
||||
}
|
||||
const ContainerLayerAttributes& attrs =
|
||||
specific.get_ContainerLayerAttributes();
|
||||
containerLayer->SetFrameMetrics(attrs.metrics());
|
||||
@ -327,35 +332,45 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
containerLayer->SetInheritedScale(attrs.inheritedXScale(), attrs.inheritedYScale());
|
||||
break;
|
||||
}
|
||||
case Specific::TColorLayerAttributes:
|
||||
case Specific::TColorLayerAttributes: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] color layer"));
|
||||
|
||||
static_cast<ColorLayer*>(layer)->SetColor(
|
||||
specific.get_ColorLayerAttributes().color().value());
|
||||
static_cast<ColorLayer*>(layer)->SetBounds(
|
||||
specific.get_ColorLayerAttributes().bounds());
|
||||
ColorLayerComposite* colorLayer = layerParent->AsColorLayerComposite();
|
||||
if (!colorLayer) {
|
||||
return false;
|
||||
}
|
||||
colorLayer->SetColor(specific.get_ColorLayerAttributes().color().value());
|
||||
colorLayer->SetBounds(specific.get_ColorLayerAttributes().bounds());
|
||||
break;
|
||||
|
||||
case Specific::TCanvasLayerAttributes:
|
||||
}
|
||||
case Specific::TCanvasLayerAttributes: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] canvas layer"));
|
||||
|
||||
static_cast<CanvasLayer*>(layer)->SetFilter(
|
||||
specific.get_CanvasLayerAttributes().filter());
|
||||
static_cast<CanvasLayerComposite*>(layer)->SetBounds(
|
||||
specific.get_CanvasLayerAttributes().bounds());
|
||||
CanvasLayerComposite* canvasLayer = layerParent->AsCanvasLayerComposite();
|
||||
if (!canvasLayer) {
|
||||
return false;
|
||||
}
|
||||
canvasLayer->SetFilter(specific.get_CanvasLayerAttributes().filter());
|
||||
canvasLayer->SetBounds(specific.get_CanvasLayerAttributes().bounds());
|
||||
break;
|
||||
|
||||
case Specific::TRefLayerAttributes:
|
||||
}
|
||||
case Specific::TRefLayerAttributes: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] ref layer"));
|
||||
|
||||
static_cast<RefLayer*>(layer)->SetReferentId(
|
||||
specific.get_RefLayerAttributes().id());
|
||||
RefLayerComposite* refLayer = layerParent->AsRefLayerComposite();
|
||||
if (!refLayer) {
|
||||
return false;
|
||||
}
|
||||
refLayer->SetReferentId(specific.get_RefLayerAttributes().id());
|
||||
break;
|
||||
|
||||
}
|
||||
case Specific::TImageLayerAttributes: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] image layer"));
|
||||
|
||||
ImageLayer* imageLayer = static_cast<ImageLayer*>(layer);
|
||||
ImageLayerComposite* imageLayer = layerParent->AsImageLayerComposite();
|
||||
if (!imageLayer) {
|
||||
return false;
|
||||
}
|
||||
const ImageLayerAttributes& attrs = specific.get_ImageLayerAttributes();
|
||||
imageLayer->SetFilter(attrs.filter());
|
||||
imageLayer->SetScaleToSize(attrs.scaleToSize(), attrs.scaleMode());
|
||||
@ -382,7 +397,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
MOZ_LAYERS_LOG(("[ParentSide] InsertAfter"));
|
||||
|
||||
const OpInsertAfter& oia = edit.get_OpInsertAfter();
|
||||
ShadowContainer(oia)->AsContainer()->InsertAfter(
|
||||
ShadowContainer(oia)->AsContainerLayerComposite()->InsertAfter(
|
||||
ShadowChild(oia)->AsLayer(), ShadowAfter(oia)->AsLayer());
|
||||
break;
|
||||
}
|
||||
@ -390,7 +405,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
MOZ_LAYERS_LOG(("[ParentSide] AppendChild"));
|
||||
|
||||
const OpAppendChild& oac = edit.get_OpAppendChild();
|
||||
ShadowContainer(oac)->AsContainer()->InsertAfter(
|
||||
ShadowContainer(oac)->AsContainerLayerComposite()->InsertAfter(
|
||||
ShadowChild(oac)->AsLayer(), nullptr);
|
||||
break;
|
||||
}
|
||||
@ -399,14 +414,14 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
|
||||
const OpRemoveChild& orc = edit.get_OpRemoveChild();
|
||||
Layer* childLayer = ShadowChild(orc)->AsLayer();
|
||||
ShadowContainer(orc)->AsContainer()->RemoveChild(childLayer);
|
||||
ShadowContainer(orc)->AsContainerLayerComposite()->RemoveChild(childLayer);
|
||||
break;
|
||||
}
|
||||
case Edit::TOpRepositionChild: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] RepositionChild"));
|
||||
|
||||
const OpRepositionChild& orc = edit.get_OpRepositionChild();
|
||||
ShadowContainer(orc)->AsContainer()->RepositionChild(
|
||||
ShadowContainer(orc)->AsContainerLayerComposite()->RepositionChild(
|
||||
ShadowChild(orc)->AsLayer(), ShadowAfter(orc)->AsLayer());
|
||||
break;
|
||||
}
|
||||
@ -414,7 +429,7 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
||||
MOZ_LAYERS_LOG(("[ParentSide] RaiseToTopChild"));
|
||||
|
||||
const OpRaiseToTopChild& rtc = edit.get_OpRaiseToTopChild();
|
||||
ShadowContainer(rtc)->AsContainer()->RepositionChild(
|
||||
ShadowContainer(rtc)->AsContainerLayerComposite()->RepositionChild(
|
||||
ShadowChild(rtc)->AsLayer(), nullptr);
|
||||
break;
|
||||
}
|
||||
|
@ -10,6 +10,12 @@
|
||||
#include "nsDebug.h" // for NS_RUNTIMEABORT
|
||||
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
|
||||
|
||||
#include "mozilla/layers/ThebesLayerComposite.h"
|
||||
#include "mozilla/layers/CanvasLayerComposite.h"
|
||||
#include "mozilla/layers/ColorLayerComposite.h"
|
||||
#include "mozilla/layers/ImageLayerComposite.h"
|
||||
#include "mozilla/layers/ContainerLayerComposite.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
@ -39,10 +45,52 @@ ShadowLayerParent::Destroy()
|
||||
}
|
||||
}
|
||||
|
||||
ContainerLayer*
|
||||
ShadowLayerParent::AsContainer() const
|
||||
ContainerLayerComposite*
|
||||
ShadowLayerParent::AsContainerLayerComposite() const
|
||||
{
|
||||
return static_cast<ContainerLayer*>(AsLayer());
|
||||
return mLayer && mLayer->GetType() == Layer::TYPE_CONTAINER
|
||||
? static_cast<ContainerLayerComposite*>(mLayer.get())
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
CanvasLayerComposite*
|
||||
ShadowLayerParent::AsCanvasLayerComposite() const
|
||||
{
|
||||
return mLayer && mLayer->GetType() == Layer::TYPE_CANVAS
|
||||
? static_cast<CanvasLayerComposite*>(mLayer.get())
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
ColorLayerComposite*
|
||||
ShadowLayerParent::AsColorLayerComposite() const
|
||||
{
|
||||
return mLayer && mLayer->GetType() == Layer::TYPE_COLOR
|
||||
? static_cast<ColorLayerComposite*>(mLayer.get())
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
ImageLayerComposite*
|
||||
ShadowLayerParent::AsImageLayerComposite() const
|
||||
{
|
||||
return mLayer && mLayer->GetType() == Layer::TYPE_IMAGE
|
||||
? static_cast<ImageLayerComposite*>(mLayer.get())
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
RefLayerComposite*
|
||||
ShadowLayerParent::AsRefLayerComposite() const
|
||||
{
|
||||
return mLayer && mLayer->GetType() == Layer::TYPE_REF
|
||||
? static_cast<RefLayerComposite*>(mLayer.get())
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
ThebesLayerComposite*
|
||||
ShadowLayerParent::AsThebesLayerComposite() const
|
||||
{
|
||||
return mLayer && mLayer->GetType() == Layer::TYPE_THEBES
|
||||
? static_cast<ThebesLayerComposite*>(mLayer.get())
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -20,6 +20,13 @@ class ContainerLayer;
|
||||
class Layer;
|
||||
class LayerManager;
|
||||
|
||||
class CanvasLayerComposite;
|
||||
class ColorLayerComposite;
|
||||
class ContainerLayerComposite;
|
||||
class ImageLayerComposite;
|
||||
class RefLayerComposite;
|
||||
class ThebesLayerComposite;
|
||||
|
||||
class ShadowLayerParent : public PLayerParent
|
||||
{
|
||||
public:
|
||||
@ -31,7 +38,13 @@ public:
|
||||
void Destroy();
|
||||
|
||||
Layer* AsLayer() const { return mLayer; }
|
||||
ContainerLayer* AsContainer() const;
|
||||
|
||||
ContainerLayerComposite* AsContainerLayerComposite() const;
|
||||
CanvasLayerComposite* AsCanvasLayerComposite() const;
|
||||
ColorLayerComposite* AsColorLayerComposite() const;
|
||||
ImageLayerComposite* AsImageLayerComposite() const;
|
||||
RefLayerComposite* AsRefLayerComposite() const;
|
||||
ThebesLayerComposite* AsThebesLayerComposite() const;
|
||||
|
||||
private:
|
||||
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
||||
|
Loading…
Reference in New Issue
Block a user