Bug 794582 - Rename nsINode::GetSlots() to nsINode::Slots() and remove null-checks; r=mounir

This commit is contained in:
Peter Van der Beken 2012-08-11 00:27:28 +02:00
parent b8bde31475
commit 5d0ed87cc3
8 changed files with 21 additions and 34 deletions

View File

@ -410,7 +410,7 @@ protected:
nsDOMSlots *DOMSlots()
{
return static_cast<nsDOMSlots*>(GetSlots());
return static_cast<nsDOMSlots*>(Slots());
}
nsDOMSlots *GetExistingDOMSlots() const

View File

@ -789,13 +789,11 @@ public:
*/
void AddMutationObserver(nsIMutationObserver* aMutationObserver)
{
nsSlots* s = GetSlots();
if (s) {
NS_ASSERTION(s->mMutationObservers.IndexOf(aMutationObserver) ==
nsTArray<int>::NoIndex,
"Observer already in the list");
s->mMutationObservers.AppendElement(aMutationObserver);
}
nsSlots* s = Slots();
NS_ASSERTION(s->mMutationObservers.IndexOf(aMutationObserver) ==
nsTArray<int>::NoIndex,
"Observer already in the list");
s->mMutationObservers.AppendElement(aMutationObserver);
}
/**
@ -804,10 +802,8 @@ public:
*/
void AddMutationObserverUnlessExists(nsIMutationObserver* aMutationObserver)
{
nsSlots* s = GetSlots();
if (s) {
s->mMutationObservers.AppendElementUnlessExists(aMutationObserver);
}
nsSlots* s = Slots();
s->mMutationObservers.AppendElementUnlessExists(aMutationObserver);
}
/**
@ -893,7 +889,7 @@ public:
#ifdef DEBUG
nsSlots* DebugGetSlots()
{
return GetSlots();
return Slots();
}
#endif
@ -1419,6 +1415,7 @@ public:
protected:
// Override this function to create a custom slots class.
// Must not return null.
virtual nsINode::nsSlots* CreateSlots();
bool HasSlots() const
@ -1431,10 +1428,11 @@ protected:
return mSlots;
}
nsSlots* GetSlots()
nsSlots* Slots()
{
if (!HasSlots()) {
mSlots = CreateSlots();
MOZ_ASSERT(mSlots);
}
return GetExistingSlots();
}

View File

@ -482,10 +482,9 @@ NS_IMPL_ISUPPORTS1(nsNodeWeakReference,
nsNodeWeakReference::~nsNodeWeakReference()
{
if (mNode) {
NS_ASSERTION(mNode->GetSlots() &&
mNode->GetSlots()->mWeakReference == this,
NS_ASSERTION(mNode->Slots()->mWeakReference == this,
"Weak reference has wrong value");
mNode->GetSlots()->mWeakReference = nullptr;
mNode->Slots()->mWeakReference = nullptr;
}
}
@ -509,9 +508,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsNodeSupportsWeakRefTearoff)
NS_IMETHODIMP
nsNodeSupportsWeakRefTearoff::GetWeakReference(nsIWeakReference** aInstancePtr)
{
nsINode::nsSlots* slots = mNode->GetSlots();
NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);
nsINode::nsSlots* slots = mNode->Slots();
if (!slots->mWeakReference) {
slots->mWeakReference = new nsNodeWeakReference(mNode);
NS_ENSURE_TRUE(slots->mWeakReference, NS_ERROR_OUT_OF_MEMORY);

View File

@ -1986,7 +1986,7 @@ nsDocument::Init()
mRadioGroups.Init();
// Force initialization.
nsINode::nsSlots* slots = GetSlots();
nsINode::nsSlots* slots = Slots();
// Prepend self as mutation-observer whether we need it or not (some
// subclasses currently do, other don't). This is because the code in

View File

@ -458,15 +458,12 @@ nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
// First set the binding parent
if (aBindingParent) {
nsDataSlots *slots = GetDataSlots();
NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);
NS_ASSERTION(IsRootOfNativeAnonymousSubtree() ||
!HasFlag(NODE_IS_IN_ANONYMOUS_SUBTREE) ||
(aParent && aParent->IsInNativeAnonymousSubtree()),
"Trying to re-bind content from native anonymous subtree to "
"non-native anonymous parent!");
slots->mBindingParent = aBindingParent; // Weak, so no addref happens.
DataSlots()->mBindingParent = aBindingParent; // Weak, so no addref happens.
if (aParent->IsInNativeAnonymousSubtree()) {
SetFlags(NODE_IS_IN_ANONYMOUS_SUBTREE);
}

View File

@ -269,9 +269,9 @@ protected:
// Override from nsINode
virtual nsINode::nsSlots* CreateSlots();
nsDataSlots *GetDataSlots()
nsDataSlots* DataSlots()
{
return static_cast<nsDataSlots*>(GetSlots());
return static_cast<nsDataSlots*>(Slots());
}
nsDataSlots *GetExistingDataSlots() const

View File

@ -311,11 +311,7 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell)
nsINodeList*
nsINode::GetChildNodesList()
{
nsSlots *slots = GetSlots();
if (!slots) {
return nullptr;
}
nsSlots* slots = Slots();
if (!slots->mChildNodes) {
slots->mChildNodes = new nsChildContentList(this);
if (slots->mChildNodes) {

View File

@ -1376,8 +1376,7 @@ nsXULElement::LoadSrc()
NodeInfo()->Equals(nsGkAtoms::overlay, kNameSpaceID_XUL)) {
return NS_OK;
}
nsXULSlots* slots = static_cast<nsXULSlots*>(GetSlots());
NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);
nsXULSlots* slots = static_cast<nsXULSlots*>(Slots());
if (!slots->mFrameLoader) {
// false as the last parameter so that xul:iframe/browser/editor
// session history handling works like dynamic html:iframes.