зеркало из 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);
|
RemoveChild(mFirstChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
template<class Container>
|
||||||
void
|
static void
|
||||||
ContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter)
|
ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter)
|
||||||
{
|
{
|
||||||
aChild->SetParent(this);
|
aChild->SetParent(aContainer);
|
||||||
if (!aAfter) {
|
if (!aAfter) {
|
||||||
Layer *oldFirstChild = GetFirstChild();
|
Layer *oldFirstChild = aContainer->GetFirstChild();
|
||||||
mFirstChild = aChild;
|
aContainer->mFirstChild = aChild;
|
||||||
aChild->SetNextSibling(oldFirstChild);
|
aChild->SetNextSibling(oldFirstChild);
|
||||||
aChild->SetPrevSibling(nullptr);
|
aChild->SetPrevSibling(nullptr);
|
||||||
if (oldFirstChild) {
|
if (oldFirstChild) {
|
||||||
oldFirstChild->SetPrevSibling(aChild);
|
oldFirstChild->SetPrevSibling(aChild);
|
||||||
} else {
|
} else {
|
||||||
mLastChild = aChild;
|
aContainer->mLastChild = aChild;
|
||||||
}
|
}
|
||||||
NS_ADDREF(aChild);
|
NS_ADDREF(aChild);
|
||||||
DidInsertChild(aChild);
|
aContainer->DidInsertChild(aChild);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Layer *child = GetFirstChild();
|
for (Layer *child = aContainer->GetFirstChild();
|
||||||
child; child = child->GetNextSibling()) {
|
child; child = child->GetNextSibling()) {
|
||||||
if (aAfter == child) {
|
if (aAfter == child) {
|
||||||
Layer *oldNextSibling = child->GetNextSibling();
|
Layer *oldNextSibling = child->GetNextSibling();
|
||||||
|
@ -56,36 +56,37 @@ ContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter)
|
||||||
if (oldNextSibling) {
|
if (oldNextSibling) {
|
||||||
oldNextSibling->SetPrevSibling(aChild);
|
oldNextSibling->SetPrevSibling(aChild);
|
||||||
} else {
|
} else {
|
||||||
mLastChild = aChild;
|
aContainer->mLastChild = aChild;
|
||||||
}
|
}
|
||||||
aChild->SetPrevSibling(child);
|
aChild->SetPrevSibling(child);
|
||||||
NS_ADDREF(aChild);
|
NS_ADDREF(aChild);
|
||||||
DidInsertChild(aChild);
|
aContainer->DidInsertChild(aChild);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NS_WARNING("Failed to find aAfter layer!");
|
NS_WARNING("Failed to find aAfter layer!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
template<class Container>
|
||||||
ContainerLayerD3D10::RemoveChild(Layer *aChild)
|
static void
|
||||||
|
ContainerRemoveChild(Container* aContainer, Layer* aChild)
|
||||||
{
|
{
|
||||||
if (GetFirstChild() == aChild) {
|
if (aContainer->GetFirstChild() == aChild) {
|
||||||
mFirstChild = GetFirstChild()->GetNextSibling();
|
aContainer->mFirstChild = aContainer->GetFirstChild()->GetNextSibling();
|
||||||
if (mFirstChild) {
|
if (aContainer->mFirstChild) {
|
||||||
mFirstChild->SetPrevSibling(nullptr);
|
aContainer->mFirstChild->SetPrevSibling(nullptr);
|
||||||
} else {
|
} else {
|
||||||
mLastChild = nullptr;
|
aContainer->mLastChild = nullptr;
|
||||||
}
|
}
|
||||||
aChild->SetNextSibling(nullptr);
|
aChild->SetNextSibling(nullptr);
|
||||||
aChild->SetPrevSibling(nullptr);
|
aChild->SetPrevSibling(nullptr);
|
||||||
aChild->SetParent(nullptr);
|
aChild->SetParent(nullptr);
|
||||||
DidRemoveChild(aChild);
|
aContainer->DidRemoveChild(aChild);
|
||||||
NS_RELEASE(aChild);
|
NS_RELEASE(aChild);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Layer *lastChild = nullptr;
|
Layer *lastChild = nullptr;
|
||||||
for (Layer *child = GetFirstChild(); child;
|
for (Layer *child = aContainer->GetFirstChild(); child;
|
||||||
child = child->GetNextSibling()) {
|
child = child->GetNextSibling()) {
|
||||||
if (child == aChild) {
|
if (child == aChild) {
|
||||||
// We're sure this is not our first child. So lastChild != NULL.
|
// We're sure this is not our first child. So lastChild != NULL.
|
||||||
|
@ -93,12 +94,12 @@ ContainerLayerD3D10::RemoveChild(Layer *aChild)
|
||||||
if (child->GetNextSibling()) {
|
if (child->GetNextSibling()) {
|
||||||
child->GetNextSibling()->SetPrevSibling(lastChild);
|
child->GetNextSibling()->SetPrevSibling(lastChild);
|
||||||
} else {
|
} else {
|
||||||
mLastChild = lastChild;
|
aContainer->mLastChild = lastChild;
|
||||||
}
|
}
|
||||||
child->SetNextSibling(nullptr);
|
child->SetNextSibling(nullptr);
|
||||||
child->SetPrevSibling(nullptr);
|
child->SetPrevSibling(nullptr);
|
||||||
child->SetParent(nullptr);
|
child->SetParent(nullptr);
|
||||||
DidRemoveChild(aChild);
|
aContainer->DidRemoveChild(aChild);
|
||||||
NS_RELEASE(aChild);
|
NS_RELEASE(aChild);
|
||||||
return;
|
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*
|
Layer*
|
||||||
ContainerLayerD3D10::GetLayer()
|
ContainerLayerD3D10::GetLayer()
|
||||||
{
|
{
|
||||||
|
@ -368,18 +381,23 @@ ShadowContainerLayerD3D10::ShadowContainerLayerD3D10(LayerManagerD3D10 *aManager
|
||||||
mImplData = static_cast<LayerD3D10*>(this);
|
mImplData = static_cast<LayerD3D10*>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShadowContainerLayerD3D10::~ShadowContainerLayerD3D10() {}
|
ShadowContainerLayerD3D10::~ShadowContainerLayerD3D10()
|
||||||
|
{
|
||||||
|
while (mFirstChild) {
|
||||||
|
RemoveChild(mFirstChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShadowContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter)
|
ShadowContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter)
|
||||||
{
|
{
|
||||||
mFirstChild = aChild;
|
ContainerInsertAfter(this, aChild, aAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShadowContainerLayerD3D10::RemoveChild(Layer* aChild)
|
ShadowContainerLayerD3D10::RemoveChild(Layer* aChild)
|
||||||
{
|
{
|
||||||
|
ContainerRemoveChild(this, aChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -409,6 +427,10 @@ ShadowContainerLayerD3D10::Validate()
|
||||||
void
|
void
|
||||||
ShadowContainerLayerD3D10::LayerManagerDestroyed()
|
ShadowContainerLayerD3D10::LayerManagerDestroyed()
|
||||||
{
|
{
|
||||||
|
while (mFirstChild) {
|
||||||
|
GetFirstChildD3D10()->LayerManagerDestroyed();
|
||||||
|
RemoveChild(mFirstChild);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* layers */
|
} /* layers */
|
||||||
|
|
|
@ -11,9 +11,18 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace layers {
|
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,
|
class ContainerLayerD3D10 : public ContainerLayer,
|
||||||
public LayerD3D10
|
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:
|
public:
|
||||||
ContainerLayerD3D10(LayerManagerD3D10 *aManager);
|
ContainerLayerD3D10(LayerManagerD3D10 *aManager);
|
||||||
~ContainerLayerD3D10();
|
~ContainerLayerD3D10();
|
||||||
|
@ -47,6 +56,10 @@ public:
|
||||||
class ShadowContainerLayerD3D10 : public ShadowContainerLayer,
|
class ShadowContainerLayerD3D10 : public ShadowContainerLayer,
|
||||||
public LayerD3D10
|
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:
|
public:
|
||||||
ShadowContainerLayerD3D10(LayerManagerD3D10 *aManager);
|
ShadowContainerLayerD3D10(LayerManagerD3D10 *aManager);
|
||||||
~ShadowContainerLayerD3D10();
|
~ShadowContainerLayerD3D10();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче