зеркало из https://github.com/mozilla/gecko-dev.git
Bug 539356 - Part 30 - Make ShadowContainerLayerD3D10 hold references to child layers. r=roc
This commit is contained in:
Родитель
8aaca49080
Коммит
6ac4dc5746
|
@ -28,26 +28,26 @@ ContainerLayerD3D10::~ContainerLayerD3D10()
|
|||
RemoveChild(mFirstChild);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter)
|
||||
template<class Container>
|
||||
static void
|
||||
ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter)
|
||||
{
|
||||
aChild->SetParent(this);
|
||||
aChild->SetParent(aContainer);
|
||||
if (!aAfter) {
|
||||
Layer *oldFirstChild = GetFirstChild();
|
||||
mFirstChild = aChild;
|
||||
Layer *oldFirstChild = aContainer->GetFirstChild();
|
||||
aContainer->mFirstChild = aChild;
|
||||
aChild->SetNextSibling(oldFirstChild);
|
||||
aChild->SetPrevSibling(nullptr);
|
||||
if (oldFirstChild) {
|
||||
oldFirstChild->SetPrevSibling(aChild);
|
||||
} else {
|
||||
mLastChild = aChild;
|
||||
aContainer->mLastChild = aChild;
|
||||
}
|
||||
NS_ADDREF(aChild);
|
||||
DidInsertChild(aChild);
|
||||
aContainer->DidInsertChild(aChild);
|
||||
return;
|
||||
}
|
||||
for (Layer *child = GetFirstChild();
|
||||
for (Layer *child = aContainer->GetFirstChild();
|
||||
child; child = child->GetNextSibling()) {
|
||||
if (aAfter == child) {
|
||||
Layer *oldNextSibling = child->GetNextSibling();
|
||||
|
@ -56,36 +56,37 @@ ContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter)
|
|||
if (oldNextSibling) {
|
||||
oldNextSibling->SetPrevSibling(aChild);
|
||||
} else {
|
||||
mLastChild = aChild;
|
||||
aContainer->mLastChild = aChild;
|
||||
}
|
||||
aChild->SetPrevSibling(child);
|
||||
NS_ADDREF(aChild);
|
||||
DidInsertChild(aChild);
|
||||
aContainer->DidInsertChild(aChild);
|
||||
return;
|
||||
}
|
||||
}
|
||||
NS_WARNING("Failed to find aAfter layer!");
|
||||
}
|
||||
|
||||
void
|
||||
ContainerLayerD3D10::RemoveChild(Layer *aChild)
|
||||
template<class Container>
|
||||
static void
|
||||
ContainerRemoveChild(Container* aContainer, Layer* aChild)
|
||||
{
|
||||
if (GetFirstChild() == aChild) {
|
||||
mFirstChild = GetFirstChild()->GetNextSibling();
|
||||
if (mFirstChild) {
|
||||
mFirstChild->SetPrevSibling(nullptr);
|
||||
if (aContainer->GetFirstChild() == aChild) {
|
||||
aContainer->mFirstChild = aContainer->GetFirstChild()->GetNextSibling();
|
||||
if (aContainer->mFirstChild) {
|
||||
aContainer->mFirstChild->SetPrevSibling(nullptr);
|
||||
} else {
|
||||
mLastChild = nullptr;
|
||||
aContainer->mLastChild = nullptr;
|
||||
}
|
||||
aChild->SetNextSibling(nullptr);
|
||||
aChild->SetPrevSibling(nullptr);
|
||||
aChild->SetParent(nullptr);
|
||||
DidRemoveChild(aChild);
|
||||
aContainer->DidRemoveChild(aChild);
|
||||
NS_RELEASE(aChild);
|
||||
return;
|
||||
}
|
||||
Layer *lastChild = nullptr;
|
||||
for (Layer *child = GetFirstChild(); child;
|
||||
for (Layer *child = aContainer->GetFirstChild(); child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child == aChild) {
|
||||
// We're sure this is not our first child. So lastChild != NULL.
|
||||
|
@ -93,12 +94,12 @@ ContainerLayerD3D10::RemoveChild(Layer *aChild)
|
|||
if (child->GetNextSibling()) {
|
||||
child->GetNextSibling()->SetPrevSibling(lastChild);
|
||||
} else {
|
||||
mLastChild = lastChild;
|
||||
aContainer->mLastChild = lastChild;
|
||||
}
|
||||
child->SetNextSibling(nullptr);
|
||||
child->SetPrevSibling(nullptr);
|
||||
child->SetParent(nullptr);
|
||||
DidRemoveChild(aChild);
|
||||
aContainer->DidRemoveChild(aChild);
|
||||
NS_RELEASE(aChild);
|
||||
return;
|
||||
}
|
||||
|
@ -106,6 +107,18 @@ ContainerLayerD3D10::RemoveChild(Layer *aChild)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter)
|
||||
{
|
||||
ContainerInsertAfter(this, aChild, aAfter);
|
||||
}
|
||||
|
||||
void
|
||||
ContainerLayerD3D10::RemoveChild(Layer *aChild)
|
||||
{
|
||||
ContainerRemoveChild(this, aChild);
|
||||
}
|
||||
|
||||
Layer*
|
||||
ContainerLayerD3D10::GetLayer()
|
||||
{
|
||||
|
@ -368,18 +381,23 @@ ShadowContainerLayerD3D10::ShadowContainerLayerD3D10(LayerManagerD3D10 *aManager
|
|||
mImplData = static_cast<LayerD3D10*>(this);
|
||||
}
|
||||
|
||||
ShadowContainerLayerD3D10::~ShadowContainerLayerD3D10() {}
|
||||
ShadowContainerLayerD3D10::~ShadowContainerLayerD3D10()
|
||||
{
|
||||
while (mFirstChild) {
|
||||
RemoveChild(mFirstChild);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShadowContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter)
|
||||
{
|
||||
mFirstChild = aChild;
|
||||
ContainerInsertAfter(this, aChild, aAfter);
|
||||
}
|
||||
|
||||
void
|
||||
ShadowContainerLayerD3D10::RemoveChild(Layer* aChild)
|
||||
{
|
||||
|
||||
ContainerRemoveChild(this, aChild);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -409,6 +427,10 @@ ShadowContainerLayerD3D10::Validate()
|
|||
void
|
||||
ShadowContainerLayerD3D10::LayerManagerDestroyed()
|
||||
{
|
||||
while (mFirstChild) {
|
||||
GetFirstChildD3D10()->LayerManagerDestroyed();
|
||||
RemoveChild(mFirstChild);
|
||||
}
|
||||
}
|
||||
|
||||
} /* layers */
|
||||
|
|
|
@ -11,9 +11,18 @@
|
|||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
template<class Container>
|
||||
static void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter);
|
||||
template<class Container>
|
||||
static void ContainerRemoveChild(Container* aContainer, Layer* aChild);
|
||||
|
||||
class ContainerLayerD3D10 : public ContainerLayer,
|
||||
public LayerD3D10
|
||||
{
|
||||
template<class Container>
|
||||
friend void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter);
|
||||
template<class Container>
|
||||
friend void ContainerRemoveChild(Container* aContainer, Layer* aChild);
|
||||
public:
|
||||
ContainerLayerD3D10(LayerManagerD3D10 *aManager);
|
||||
~ContainerLayerD3D10();
|
||||
|
@ -47,6 +56,10 @@ public:
|
|||
class ShadowContainerLayerD3D10 : public ShadowContainerLayer,
|
||||
public LayerD3D10
|
||||
{
|
||||
template<class Container>
|
||||
friend void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter);
|
||||
template<class Container>
|
||||
friend void ContainerRemoveChild(Container* aContainer, Layer* aChild);
|
||||
public:
|
||||
ShadowContainerLayerD3D10(LayerManagerD3D10 *aManager);
|
||||
~ShadowContainerLayerD3D10();
|
||||
|
|
Загрузка…
Ссылка в новой задаче