diff --git a/mozilla/content/base/public/nsINode.h b/mozilla/content/base/public/nsINode.h index c33674d0b02..95d29e783ab 100644 --- a/mozilla/content/base/public/nsINode.h +++ b/mozilla/content/base/public/nsINode.h @@ -59,7 +59,6 @@ class nsIMutationObserver; class nsChildContentList; class nsNodeWeakReference; class nsNodeSupportsWeakRefTearoff; -class nsDOMNodeAllocator; enum { // This bit will be set if the node doesn't have nsSlots @@ -123,8 +122,8 @@ inline nsINode* NODE_FROM(C& aContent, D& aDocument) // IID for the nsINode interface #define NS_INODE_IID \ -{ 0xcf677826, 0xd7f1, 0x4ec5, \ - { 0xbf, 0x3a, 0xd4, 0x18, 0x11, 0xac, 0x58, 0x46 } } +{ 0xd1c2e967, 0x854a, 0x436b, \ + { 0xbf, 0xa5, 0xf6, 0xa4, 0x9a, 0x97, 0x46, 0x74 } } /** * An internal interface that abstracts some DOMNode-related parts that both @@ -573,11 +572,6 @@ public: * Weak reference to this node */ nsNodeWeakReference* mWeakReference; - - void* operator new(size_t aSize, nsDOMNodeAllocator* aAllocator); - void operator delete(void* aPtr, size_t aSize); -private: - void* operator new(size_t aSize) CPP_THROW_NEW; }; /** @@ -636,13 +630,6 @@ private: #endif } - // Returns nsnull only when called on an nsIDocument object. - virtual nsDOMNodeAllocator* GetAllocator() = 0; - - void* operator new(size_t aSize, nsINodeInfo* aNodeInfo); - void operator delete(void* aPtr, size_t aSize); -private: - void* operator new(size_t aSize) CPP_THROW_NEW; protected: // Override this function to create a custom slots class. diff --git a/mozilla/content/base/src/contentbase.gqi b/mozilla/content/base/src/contentbase.gqi index 231f4bb1cc6..ee675301619 100644 --- a/mozilla/content/base/src/contentbase.gqi +++ b/mozilla/content/base/src/contentbase.gqi @@ -18,7 +18,7 @@ %import-idl "nsIDOMXPathEvaluator.idl" %pseudo-iid nsIContent fba9aa39-016e-4d5d-ab62-22a1b84a3c7b -%pseudo-iid nsINode cf677826-d7f1-4ec5-bf3a-d41811ac5846 +%pseudo-iid nsINode d1c2e967-854a-436b-bfa5-f6a49a974674 %pseudo-iid nsPIDOMEventTarget 44a6597b-9fc3-4a8d-b7a4-d9009abf9d15 %pseudo-iid nsIDocument 626d86d2-615f-4a12-94d8-e3db3a298372 %pseudo-iid nsIScriptObjectPrincipal 3eedba38-8d22-41e1-817a-0e43e165b664 diff --git a/mozilla/content/base/src/nsAttrAndChildArray.cpp b/mozilla/content/base/src/nsAttrAndChildArray.cpp index 9d1d7e27306..f26e7c769a4 100644 --- a/mozilla/content/base/src/nsAttrAndChildArray.cpp +++ b/mozilla/content/base/src/nsAttrAndChildArray.cpp @@ -119,28 +119,20 @@ GetIndexFromCache(const nsAttrAndChildArray* aArray) #define NS_IMPL_EXTRA_SIZE \ ((sizeof(Impl) - sizeof(mImpl->mBuffer)) / sizeof(void*)) -nsAttrAndChildArray::nsAttrAndChildArray(nsDOMNodeAllocator* aAllocator) - : mImpl(nsnull), mAllocator(aAllocator) +nsAttrAndChildArray::nsAttrAndChildArray() + : mImpl(nsnull) { - NS_IF_ADDREF(mAllocator); } nsAttrAndChildArray::~nsAttrAndChildArray() { - if (mImpl) { - Clear(); - mAllocator->Free((mImpl->mBufferSize + NS_IMPL_EXTRA_SIZE) * sizeof(void*), - mImpl); + if (!mImpl) { + return; } - NS_IF_RELEASE(mAllocator); -} + Clear(); -void -nsAttrAndChildArray::SetAllocator(nsDOMNodeAllocator* aAllocator) -{ - NS_ASSERTION(!mAllocator, "Allocator already set!"); - NS_ADDREF(mAllocator = aAllocator); + PR_Free(mImpl); } nsIContent* @@ -601,6 +593,39 @@ nsAttrAndChildArray::WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker) } } +void +nsAttrAndChildArray::Compact() +{ + if (!mImpl) { + return; + } + + // First compress away empty attrslots + PRUint32 slotCount = AttrSlotCount(); + PRUint32 attrCount = NonMappedAttrCount(); + PRUint32 childCount = ChildCount(); + + if (attrCount < slotCount) { + memmove(mImpl->mBuffer + attrCount * ATTRSIZE, + mImpl->mBuffer + slotCount * ATTRSIZE, + childCount * sizeof(nsIContent*)); + SetAttrSlotCount(attrCount); + } + + // Then resize or free buffer + PRUint32 newSize = attrCount * ATTRSIZE + childCount; + if (!newSize && !mImpl->mMappedAttrs) { + PR_Free(mImpl); + mImpl = nsnull; + } + else if (newSize < mImpl->mBufferSize) { + mImpl = static_cast(PR_Realloc(mImpl, (newSize + NS_IMPL_EXTRA_SIZE) * sizeof(nsIContent*))); + NS_ASSERTION(mImpl, "failed to reallocate to smaller buffer"); + + mImpl->mBufferSize = newSize; + } +} + void nsAttrAndChildArray::Clear() { @@ -730,17 +755,16 @@ nsAttrAndChildArray::GrowBy(PRUint32 aGrowSize) size = PR_BIT(PR_CeilingLog2(minSize)); } - Impl* newImpl = static_cast(mAllocator->Alloc(size * sizeof(void*))); + Impl* newImpl = static_cast + (mImpl ? PR_Realloc(mImpl, size * sizeof(void*)) : + PR_Malloc(size * sizeof(void*))); NS_ENSURE_TRUE(newImpl, PR_FALSE); + Impl* oldImpl = mImpl; mImpl = newImpl; - if (oldImpl) { - PRUint32 oldSize = - (oldImpl->mBufferSize + NS_IMPL_EXTRA_SIZE) * sizeof(void*); - memcpy(newImpl, oldImpl, oldSize); - mAllocator->Free(oldSize, oldImpl); - } else { - // Set initial counts if we didn't have a buffer before + + // Set initial counts if we didn't have a buffer before + if (!oldImpl) { mImpl->mMappedAttrs = nsnull; SetAttrSlotAndChildCount(0, 0); } diff --git a/mozilla/content/base/src/nsAttrAndChildArray.h b/mozilla/content/base/src/nsAttrAndChildArray.h index 31fe69c049b..2d6834ca5af 100644 --- a/mozilla/content/base/src/nsAttrAndChildArray.h +++ b/mozilla/content/base/src/nsAttrAndChildArray.h @@ -75,10 +75,8 @@ class nsMappedAttributeElement; class nsAttrAndChildArray { public: - nsAttrAndChildArray(nsDOMNodeAllocator* aAllocator); + nsAttrAndChildArray(); ~nsAttrAndChildArray(); - void SetAllocator(nsDOMNodeAllocator* aAllocator); - nsDOMNodeAllocator* Allocator() { return mAllocator; } PRUint32 ChildCount() const { @@ -125,6 +123,8 @@ public: nsresult SetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet); void WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker); + void Compact(); + private: nsAttrAndChildArray(const nsAttrAndChildArray& aOther); // Not to be implemented nsAttrAndChildArray& operator=(const nsAttrAndChildArray& aOther); // Not to be implemented @@ -186,8 +186,7 @@ private: void* mBuffer[1]; }; - Impl* mImpl; - nsDOMNodeAllocator* mAllocator; + Impl* mImpl; }; #endif diff --git a/mozilla/content/base/src/nsCommentNode.cpp b/mozilla/content/base/src/nsCommentNode.cpp index 0c0bba499e9..65060ef586f 100644 --- a/mozilla/content/base/src/nsCommentNode.cpp +++ b/mozilla/content/base/src/nsCommentNode.cpp @@ -88,7 +88,7 @@ NS_NewCommentNode(nsIContent** aInstancePtrResult, nsCOMPtr ni = aNodeInfoManager->GetCommentNodeInfo(); NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY); - nsCommentNode *instance = new (ni) nsCommentNode(ni); + nsCommentNode *instance = new nsCommentNode(ni); if (!instance) { return NS_ERROR_OUT_OF_MEMORY; } @@ -163,7 +163,7 @@ nsCommentNode::GetNodeType(PRUint16* aNodeType) nsGenericDOMDataNode* nsCommentNode::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const { - nsCommentNode *it = new (aNodeInfo) nsCommentNode(aNodeInfo); + nsCommentNode *it = new nsCommentNode(aNodeInfo); if (it && aCloneText) { it->mText = mText; } diff --git a/mozilla/content/base/src/nsDOMAttribute.cpp b/mozilla/content/base/src/nsDOMAttribute.cpp index ce739403558..2a2e889d9b1 100644 --- a/mozilla/content/base/src/nsDOMAttribute.cpp +++ b/mozilla/content/base/src/nsDOMAttribute.cpp @@ -64,9 +64,7 @@ PRBool nsDOMAttribute::sInitialized; nsDOMAttribute::nsDOMAttribute(nsDOMAttributeMap *aAttrMap, nsINodeInfo *aNodeInfo, const nsAString &aValue) - : nsIAttribute(aAttrMap, aNodeInfo), - mAllocator(aNodeInfo->NodeInfoManager()->NodeAllocator()), - mValue(aValue) + : nsIAttribute(aAttrMap, aNodeInfo), mValue(aValue) { NS_ABORT_IF_FALSE(mNodeInfo, "We must get a nodeinfo here!"); @@ -374,7 +372,7 @@ nsDOMAttribute::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const nsAutoString value; const_cast(this)->GetValue(value); - *aResult = new (aNodeInfo) nsDOMAttribute(nsnull, aNodeInfo, value); + *aResult = new nsDOMAttribute(nsnull, aNodeInfo, value); if (!*aResult) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/base/src/nsDOMAttribute.h b/mozilla/content/base/src/nsDOMAttribute.h index 415673a2371..8a725d24bb7 100644 --- a/mozilla/content/base/src/nsDOMAttribute.h +++ b/mozilla/content/base/src/nsDOMAttribute.h @@ -108,7 +108,6 @@ public: const nsIID& aIID); virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup); virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - virtual nsDOMNodeAllocator* GetAllocator() { return mAllocator; } static void Initialize(); static void Shutdown(); @@ -121,7 +120,6 @@ protected: private: nsresult EnsureChildState(PRBool aSetText, PRBool &aHasChild) const; - nsDOMNodeAllocator* mAllocator; nsString mValue; // XXX For now, there's only a single child - a text // element representing the value diff --git a/mozilla/content/base/src/nsDOMAttributeMap.cpp b/mozilla/content/base/src/nsDOMAttributeMap.cpp index 6f77b5216b4..53f6fdffa7d 100644 --- a/mozilla/content/base/src/nsDOMAttributeMap.cpp +++ b/mozilla/content/base/src/nsDOMAttributeMap.cpp @@ -179,8 +179,8 @@ nsDOMAttributeMap::GetAttribute(nsINodeInfo* aNodeInfo, // the attribute node. mContent->GetAttr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom(), value); } - nsCOMPtr newAttr = - new (aNodeInfo) nsDOMAttribute(aRemove ? nsnull : this, aNodeInfo, value); + nsCOMPtr newAttr = new nsDOMAttribute(aRemove ? nsnull : this, + aNodeInfo, value); if (!newAttr) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/base/src/nsDOMDocumentType.cpp b/mozilla/content/base/src/nsDOMDocumentType.cpp index 95bcbd64d29..f221894b522 100644 --- a/mozilla/content/base/src/nsDOMDocumentType.cpp +++ b/mozilla/content/base/src/nsDOMDocumentType.cpp @@ -89,8 +89,8 @@ NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType, kNameSpaceID_None, getter_AddRefs(ni)); NS_ENSURE_SUCCESS(rv, rv); - *aDocType = new (ni) nsDOMDocumentType(ni, aName, aEntities, aNotations, - aPublicId, aSystemId, aInternalSubset); + *aDocType = new nsDOMDocumentType(ni, aName, aEntities, aNotations, + aPublicId, aSystemId, aInternalSubset); if (!*aDocType) { return NS_ERROR_OUT_OF_MEMORY; } @@ -235,9 +235,8 @@ nsDOMDocumentType::GetNodeType(PRUint16* aNodeType) nsGenericDOMDataNode* nsDOMDocumentType::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const { - return new (aNodeInfo) nsDOMDocumentType(aNodeInfo, mName, mEntities, - mNotations, mPublicId, mSystemId, - mInternalSubset); + return new nsDOMDocumentType(aNodeInfo, mName, mEntities, mNotations, + mPublicId, mSystemId, mInternalSubset); } nsresult diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 6e011a25753..48eda1ab942 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -768,7 +768,6 @@ nsDOMImplementation::Init(nsIURI* aDocumentURI, nsIURI* aBaseURI, nsDocument::nsDocument(const char* aContentType) : nsIDocument(), - mChildren(nsnull), mVisible(PR_TRUE) { mContentType = aContentType; @@ -1055,19 +1054,6 @@ nsDocument::Init() NS_ENSURE_TRUE(bindingManager, NS_ERROR_OUT_OF_MEMORY); NS_ADDREF(mBindingManager = bindingManager); - mNodeInfoManager = new nsNodeInfoManager(); - NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_OUT_OF_MEMORY); - - NS_ADDREF(mNodeInfoManager); - - nsresult rv = mNodeInfoManager->Init(this); - NS_ENSURE_SUCCESS(rv, rv); - - mChildren.SetAllocator(mNodeInfoManager->NodeAllocator()); - - mNodeInfo = mNodeInfoManager->GetDocumentNodeInfo(); - NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_OUT_OF_MEMORY); - nsINode::nsSlots* slots = GetSlots(); NS_ENSURE_TRUE(slots,NS_ERROR_OUT_OF_MEMORY); @@ -1088,6 +1074,17 @@ nsDocument::Init() mCSSLoader->SetCaseSensitive(PR_TRUE); mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards); + mNodeInfoManager = new nsNodeInfoManager(); + NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_OUT_OF_MEMORY); + + NS_ADDREF(mNodeInfoManager); + + nsresult rv = mNodeInfoManager->Init(this); + NS_ENSURE_SUCCESS(rv, rv); + + mNodeInfo = mNodeInfoManager->GetDocumentNodeInfo(); + NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_OUT_OF_MEMORY); + NS_ASSERTION(GetOwnerDoc() == this, "Our nodeinfo is busted!"); mScriptLoader = new nsScriptLoader(this); @@ -1096,13 +1093,6 @@ nsDocument::Init() return NS_OK; } -nsINode::nsSlots* -nsDocument::CreateSlots() -{ - return - new (mNodeInfo->NodeInfoManager()->NodeAllocator()) nsSlots(mFlagsOrSlots); -} - nsresult nsDocument::AddXMLEventsContent(nsIContent *aXMLEventsElement) { @@ -3094,7 +3084,7 @@ nsDocument::CreateAttribute(const nsAString& aName, getter_AddRefs(nodeInfo)); NS_ENSURE_SUCCESS(rv, rv); - attribute = new (nodeInfo) nsDOMAttribute(nsnull, nodeInfo, value); + attribute = new nsDOMAttribute(nsnull, nodeInfo, value); NS_ENSURE_TRUE(attribute, NS_ERROR_OUT_OF_MEMORY); return CallQueryInterface(attribute, aReturn); @@ -3116,8 +3106,7 @@ nsDocument::CreateAttributeNS(const nsAString & aNamespaceURI, NS_ENSURE_SUCCESS(rv, rv); nsAutoString value; - nsDOMAttribute* attribute = - new (nodeInfo) nsDOMAttribute(nsnull, nodeInfo, value); + nsDOMAttribute* attribute = new nsDOMAttribute(nsnull, nodeInfo, value); NS_ENSURE_TRUE(attribute, NS_ERROR_OUT_OF_MEMORY); return CallQueryInterface(attribute, aResult); diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index 815cc7b9dff..d3b6d472d85 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -536,7 +536,6 @@ public: { return NS_ERROR_NOT_IMPLEMENTED; } - virtual nsDOMNodeAllocator* GetAllocator() { return nsnull; } // nsIRadioGroupContainer NS_IMETHOD WalkRadioGroup(const nsAString& aName, @@ -659,7 +658,6 @@ public: const nsAString& aClasses, nsIDOMNodeList** aReturn); protected: - virtual nsINode::nsSlots* CreateSlots(); /** * Check that aId is not empty and log a message to the console diff --git a/mozilla/content/base/src/nsDocumentFragment.cpp b/mozilla/content/base/src/nsDocumentFragment.cpp index 582c6b7c7dd..e229acd8c11 100644 --- a/mozilla/content/base/src/nsDocumentFragment.cpp +++ b/mozilla/content/base/src/nsDocumentFragment.cpp @@ -171,7 +171,7 @@ NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult, getter_AddRefs(nodeInfo)); NS_ENSURE_SUCCESS(rv, rv); - nsDocumentFragment *it = new (nodeInfo) nsDocumentFragment(nodeInfo); + nsDocumentFragment *it = new nsDocumentFragment(nodeInfo); if (!it) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/base/src/nsGenConImageContent.cpp b/mozilla/content/base/src/nsGenConImageContent.cpp index e2430a64ee1..0880203d8e8 100644 --- a/mozilla/content/base/src/nsGenConImageContent.cpp +++ b/mozilla/content/base/src/nsGenConImageContent.cpp @@ -81,7 +81,7 @@ NS_NewGenConImageContent(nsIContent** aResult, nsINodeInfo* aNodeInfo, imgIRequest* aImageRequest) { NS_PRECONDITION(aImageRequest, "Must have request!"); - nsGenConImageContent *it = new (aNodeInfo) nsGenConImageContent(aNodeInfo); + nsGenConImageContent *it = new nsGenConImageContent(aNodeInfo); if (!it) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(*aResult = it); diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 36c842186ea..171d22daf1c 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -66,7 +66,7 @@ #include "prprf.h" nsGenericDOMDataNode::nsGenericDOMDataNode(nsINodeInfo *aNodeInfo) - : nsIContent(aNodeInfo), mText(aNodeInfo->NodeInfoManager()->NodeAllocator()) + : nsIContent(aNodeInfo) { } @@ -864,7 +864,7 @@ nsGenericDOMDataNode::IsLink(nsIURI** aURI) const nsINode::nsSlots* nsGenericDOMDataNode::CreateSlots() { - return new (GetAllocator()) nsDataSlots(mFlagsOrSlots); + return new nsDataSlots(mFlagsOrSlots); } //---------------------------------------------------------------------- diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h index 2c50f6bb229..efeb7fc9cfb 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.h +++ b/mozilla/content/base/src/nsGenericDOMDataNode.h @@ -187,7 +187,6 @@ public: virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID); virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup); - virtual nsDOMNodeAllocator* GetAllocator() { return mText.Allocator(); } // Implementation for nsIContent virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index b3e6d925307..3a0224ec11b 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -171,44 +171,8 @@ nsINode::nsSlots::~nsSlots() } } -void* -nsINode::nsSlots::operator new(size_t aSize, nsDOMNodeAllocator* aAllocator) -{ - void* result = aAllocator->Alloc(aSize); - if (result) { - NS_ADDREF(aAllocator); - } - return result; -} - -void -nsINode::nsSlots::operator delete(void* aPtr, size_t aSize) -{ - size_t* szPtr = static_cast(aPtr); - *szPtr = aSize; -} - //---------------------------------------------------------------------- -void* -nsINode::operator new(size_t aSize, nsINodeInfo* aNodeInfo) -{ - nsDOMNodeAllocator* allocator = - aNodeInfo->NodeInfoManager()->NodeAllocator(); - void* result = allocator->Alloc(aSize); - if (result) { - NS_ADDREF(allocator); - } - return result; -} - -void -nsINode::operator delete(void* aPtr, size_t aSize) -{ - size_t* szPtr = static_cast(aPtr); - *szPtr = aSize; -} - nsINode::~nsINode() { NS_ASSERTION(!HasSlots(), "nsNodeUtils::LastRelease was not called?"); @@ -312,7 +276,7 @@ nsGenericElement::GetSystemEventGroup(nsIDOMEventGroup** aGroup) nsINode::nsSlots* nsINode::CreateSlots() { - return new (GetAllocator()) nsSlots(mFlagsOrSlots); + return new nsSlots(mFlagsOrSlots); } void @@ -1158,8 +1122,7 @@ nsGenericElement::nsDOMSlots::~nsDOMSlots() } nsGenericElement::nsGenericElement(nsINodeInfo *aNodeInfo) - : nsIContent(aNodeInfo), - mAttrsAndChildren(aNodeInfo->NodeInfoManager()->NodeAllocator()) + : nsIContent(aNodeInfo) { // Set the default scriptID to JS - but skip SetScriptTypeID as it // does extra work we know isn't necessary here... @@ -4218,7 +4181,7 @@ nsGenericElement::IndexOf(nsINode* aPossibleChild) const nsINode::nsSlots* nsGenericElement::CreateSlots() { - return new (GetAllocator()) nsDOMSlots(mFlagsOrSlots); + return new nsDOMSlots(mFlagsOrSlots); } PRBool diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index 8edf7ca27a5..c14c39d2160 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -376,10 +376,6 @@ public: virtual nsresult RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID); virtual nsresult GetSystemEventGroup(nsIDOMEventGroup** aGroup); - virtual nsDOMNodeAllocator* GetAllocator() - { - return mAttrsAndChildren.Allocator(); - } // nsIContent interface methods virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, @@ -1014,7 +1010,7 @@ _elementName::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const \ { \ *aResult = nsnull; \ \ - _elementName *it = new (aNodeInfo) _elementName(aNodeInfo); \ + _elementName *it = new _elementName(aNodeInfo); \ if (!it) { \ return NS_ERROR_OUT_OF_MEMORY; \ } \ @@ -1034,7 +1030,7 @@ _elementName::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const \ { \ *aResult = nsnull; \ \ - _elementName *it = new (aNodeInfo) _elementName(aNodeInfo); \ + _elementName *it = new _elementName(aNodeInfo); \ if (!it) { \ return NS_ERROR_OUT_OF_MEMORY; \ } \ diff --git a/mozilla/content/base/src/nsNodeInfoManager.cpp b/mozilla/content/base/src/nsNodeInfoManager.cpp index a6a239e22a1..dc8719bacac 100644 --- a/mozilla/content/base/src/nsNodeInfoManager.cpp +++ b/mozilla/content/base/src/nsNodeInfoManager.cpp @@ -51,175 +51,8 @@ #include "nsReadableUtils.h" #include "nsGkAtoms.h" #include "nsComponentManagerUtils.h" -#include "prbit.h" -#include "plarena.h" -#include "nsMemory.h" #include "nsLayoutStatics.h" -#define NS_SMALL_NODE_ARENA_SIZE \ - (512 * (sizeof(void*)/4)) - -#define NS_LARGE_NODE_ARENA_SIZE \ - (4096 * (sizeof(void*)/4)) - -#define NS_MAX_NODE_RECYCLE_SIZE \ - (NS_NODE_RECYCLER_SIZE * sizeof(void*)) - -#ifdef DEBUG -static PRUint32 gDOMNodeAllocators = 0; -// Counts the number of non-freed allocations. -static size_t gDOMNodeAllocations = 0; -static PRUint32 gDOMNodeRecyclerCounters[NS_NODE_RECYCLER_SIZE]; -static PRUint32 gDOMNodeNormalAllocations = 0; -class nsDOMNodeAllocatorTester -{ -public: - nsDOMNodeAllocatorTester() - { - memset(gDOMNodeRecyclerCounters, 0, sizeof(gDOMNodeRecyclerCounters)); - } - ~nsDOMNodeAllocatorTester() - { -#ifdef DEBUG_smaug - for (PRInt32 i = 0 ; i < NS_NODE_RECYCLER_SIZE; ++i) { - if (gDOMNodeRecyclerCounters[i]) { - printf("DOMNodeAllocator, arena allocation: %u bytes %u times\n", - static_cast((i + 1) * sizeof(void*)), - gDOMNodeRecyclerCounters[i]); - } - } - if (gDOMNodeNormalAllocations) { - printf("DOMNodeAllocator, normal allocations: %i times \n", - gDOMNodeNormalAllocations); - } -#endif - if (gDOMNodeAllocations != 0) { - printf("nsDOMNodeAllocator leaked %u bytes \n", - static_cast(gDOMNodeAllocations)); - } - } -}; -nsDOMNodeAllocatorTester gDOMAllocatorTester; -#endif - -nsDOMNodeAllocator::~nsDOMNodeAllocator() -{ - if (mSmallPool) { - PL_FinishArenaPool(mSmallPool); - delete mSmallPool; - } - if (mLargePool) { - PL_FinishArenaPool(mLargePool); - delete mLargePool; - } -#ifdef DEBUG - --gDOMNodeAllocators; -#endif -} - -nsresult -nsDOMNodeAllocator::Init() -{ -#ifdef DEBUG - ++gDOMNodeAllocators; -#endif - memset(mRecyclers, 0, sizeof(mRecyclers)); - return NS_OK; -} - -nsrefcnt -nsDOMNodeAllocator::Release() -{ - NS_PRECONDITION(0 != mRefCnt, "dup release"); - --mRefCnt; - NS_LOG_RELEASE(this, mRefCnt, "nsDOMNodeAllocator"); - if (mRefCnt == 0) { - mRefCnt = 1; /* stabilize */ - delete this; - return 0; - } - return mRefCnt; -} - -void* -nsDOMNodeAllocator::Alloc(size_t aSize) -{ - void* result = nsnull; - - // Ensure we have correct alignment for pointers. - aSize = aSize ? PR_ROUNDUP(aSize, sizeof(void*)) : sizeof(void*); - // Check recyclers first - if (aSize <= NS_MAX_NODE_RECYCLE_SIZE) { - const PRInt32 index = (aSize / sizeof(void*)) - 1; - result = mRecyclers[index]; - if (result) { - // Need to move to the next object - void* next = *((void**)result); - mRecyclers[index] = next; - } - if (!result) { - if ((mSmallPoolAllocated + aSize) > NS_LARGE_NODE_ARENA_SIZE) { - if (!mLargePool) { - mLargePool = new PLArenaPool(); - NS_ENSURE_TRUE(mLargePool, nsnull); - PL_InitArenaPool(mLargePool, "nsDOMNodeAllocator-large", - NS_LARGE_NODE_ARENA_SIZE, 0); - } - // Allocate a new chunk from the 'large' arena - PL_ARENA_ALLOCATE(result, mLargePool, aSize); - } else { - if (!mSmallPool) { - mSmallPool = new PLArenaPool(); - NS_ENSURE_TRUE(mSmallPool, nsnull); - PL_InitArenaPool(mSmallPool, "nsDOMNodeAllocator-small", - NS_SMALL_NODE_ARENA_SIZE, 0); - } - // Allocate a new chunk from the 'small' arena - PL_ARENA_ALLOCATE(result, mSmallPool, aSize); - if (result) { - mSmallPoolAllocated += aSize; - } - } - } -#ifdef DEBUG - ++gDOMNodeRecyclerCounters[index]; -#endif - } else { - result = nsMemory::Alloc(aSize); -#ifdef DEBUG - ++gDOMNodeNormalAllocations; -#endif - } - -#ifdef DEBUG - gDOMNodeAllocations += aSize; -#endif - return result; -} - -void -nsDOMNodeAllocator::Free(size_t aSize, void* aPtr) -{ - if (!aPtr) { - return; - } - // Ensure we have correct alignment for pointers. - aSize = aSize ? PR_ROUNDUP(aSize, sizeof(void*)) : sizeof(void*); - // See if it's a size that we recycle - if (aSize <= NS_MAX_NODE_RECYCLE_SIZE) { - const PRInt32 index = (aSize / sizeof(void*)) - 1; - void* currentTop = mRecyclers[index]; - mRecyclers[index] = aPtr; - *((void**)aPtr) = currentTop; - } else { - nsMemory::Free(aPtr); - } - -#ifdef DEBUG - gDOMNodeAllocations -= aSize; -#endif -} - PLHashNumber nsNodeInfoManager::GetNodeInfoInnerHashValue(const void *key) { @@ -307,10 +140,6 @@ nsNodeInfoManager::Init(nsIDocument *aDocument) { NS_ENSURE_TRUE(mNodeInfoHash, NS_ERROR_OUT_OF_MEMORY); - mNodeAllocator = new nsDOMNodeAllocator(); - NS_ENSURE_TRUE(mNodeAllocator && NS_SUCCEEDED(mNodeAllocator->Init()), - NS_ERROR_OUT_OF_MEMORY); - NS_PRECONDITION(!mPrincipal, "Being inited when we already have a principal?"); nsresult rv = CallCreateInstance("@mozilla.org/nullprincipal;1", diff --git a/mozilla/content/base/src/nsNodeInfoManager.h b/mozilla/content/base/src/nsNodeInfoManager.h index 4b7cf31f6f4..d41e5f36d8a 100644 --- a/mozilla/content/base/src/nsNodeInfoManager.h +++ b/mozilla/content/base/src/nsNodeInfoManager.h @@ -44,7 +44,6 @@ #include "nsCOMPtr.h" // for already_AddRefed #include "plhash.h" -#include "nsAutoPtr.h" class nsIAtom; class nsIDocument; @@ -58,42 +57,6 @@ class nsIDOMDocument; class nsAString; class nsIDOMNamedNodeMap; class nsXULPrototypeDocument; -class nsNodeInfoManager; -struct PLArenaPool; - -// The size of mRecyclers array. The max size of recycled memory is -// sizeof(void*) * NS_NODE_RECYCLER_SIZE. -#define NS_NODE_RECYCLER_SIZE 64 - -class nsDOMNodeAllocator -{ -public: - nsDOMNodeAllocator() - : mSmallPool(nsnull), mLargePool(nsnull), mSmallPoolAllocated(0) {} - ~nsDOMNodeAllocator(); - - nsrefcnt AddRef() - { - NS_ASSERTION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); - ++mRefCnt; - NS_LOG_ADDREF(this, mRefCnt, "nsDOMNodeAllocator", sizeof(*this)); - return mRefCnt; - } - nsrefcnt Release(); - - void* Alloc(size_t aSize); - void Free(size_t aSize, void* aPtr); -protected: - friend class nsNodeInfoManager; - nsresult Init(); - nsAutoRefCnt mRefCnt; - PLArenaPool* mSmallPool; - PLArenaPool* mLargePool; - size_t mSmallPoolAllocated; - // The recycler array points to recycled memory, where the size of - // block is index*sizeof(void*), i.e., 0, 4, 8, 12, 16, ... or 0, 8, 16, ... - void* mRecyclers[NS_NODE_RECYCLER_SIZE]; -}; class nsNodeInfoManager { @@ -160,7 +123,6 @@ public: void RemoveNodeInfo(nsNodeInfo *aNodeInfo); - nsDOMNodeAllocator* NodeAllocator() { return mNodeAllocator; } protected: friend class nsDocument; friend class nsXULPrototypeDocument; @@ -196,8 +158,6 @@ private: nsINodeInfo *mTextNodeInfo; // WEAK to avoid circular ownership nsINodeInfo *mCommentNodeInfo; // WEAK to avoid circular ownership nsINodeInfo *mDocumentNodeInfo; // WEAK to avoid circular ownership - - nsRefPtr mNodeAllocator; }; #endif /* nsNodeInfoManager_h___ */ diff --git a/mozilla/content/base/src/nsNodeUtils.cpp b/mozilla/content/base/src/nsNodeUtils.cpp index 61856df5377..445e25d1184 100755 --- a/mozilla/content/base/src/nsNodeUtils.cpp +++ b/mozilla/content/base/src/nsNodeUtils.cpp @@ -188,7 +188,6 @@ void nsNodeUtils::LastRelease(nsINode* aNode) { nsINode::nsSlots* slots = aNode->GetExistingSlots(); - nsRefPtr allocator = aNode->GetAllocator(); if (slots) { if (!slots->mMutationObservers.IsEmpty()) { NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(slots->mMutationObservers, @@ -197,14 +196,7 @@ nsNodeUtils::LastRelease(nsINode* aNode) } PtrBits flags = slots->mFlags | NODE_DOESNT_HAVE_SLOTS; - delete slots; // Calls destructor and sets size to *slots. - NS_ASSERTION(allocator || aNode->IsNodeOfType(nsINode::eDOCUMENT), - "Should have allocator or document!"); - nsDOMNodeAllocator* slotsAllocator = allocator ? - allocator.get() : aNode->mNodeInfo->NodeInfoManager()->NodeAllocator(); - size_t* sz = reinterpret_cast(slots); - slotsAllocator->Free(*sz, static_cast(slots)); - NS_RELEASE(slotsAllocator); + delete slots; aNode->mFlagsOrSlots = flags; } @@ -243,16 +235,7 @@ nsNodeUtils::LastRelease(nsINode* aNode) aNode->UnsetFlags(NODE_HAS_LISTENERMANAGER); } - if (aNode->IsNodeOfType(nsINode::eDOCUMENT)) { - delete aNode; - } else { - NS_ASSERTION(allocator, "Should have allocator here!"); - delete aNode; // Calls destructor and sets size to *aNode. - size_t* sz = reinterpret_cast(aNode); - allocator->Free(*sz, static_cast(aNode)); - nsDOMNodeAllocator* tmpAlloc = allocator; - NS_RELEASE(tmpAlloc); - } + delete aNode; } static nsresult diff --git a/mozilla/content/base/src/nsTextFragment.cpp b/mozilla/content/base/src/nsTextFragment.cpp index 7fdca8fa685..a09f40d121f 100644 --- a/mozilla/content/base/src/nsTextFragment.cpp +++ b/mozilla/content/base/src/nsTextFragment.cpp @@ -45,9 +45,9 @@ #include "nsString.h" #include "nsCRT.h" #include "nsReadableUtils.h" +#include "nsMemory.h" #include "nsBidiUtils.h" #include "nsUnicharUtils.h" -#include "nsNodeInfoManager.h" #define TEXTFRAG_WHITE_AFTER_NEWLINE 50 #define TEXTFRAG_MAX_NEWLINES 7 @@ -102,27 +102,16 @@ nsTextFragment::Shutdown() } } -nsTextFragment::nsTextFragment(nsDOMNodeAllocator* aAllocator) - : m1b(nsnull), mAllBits(0), mAllocator(aAllocator) -{ - NS_ADDREF(mAllocator); - NS_ASSERTION(sizeof(FragmentBits) == 4, "Bad field packing!"); -} - nsTextFragment::~nsTextFragment() { ReleaseText(); - NS_RELEASE(mAllocator); } void nsTextFragment::ReleaseText() { if (mState.mLength && m1b && mState.mInHeap) { - // m1b == m2b as far as memory is concerned - mAllocator->Free(mState.mLength * - (mState.mIs2b ? sizeof(PRUnichar) : sizeof(char)), - m2b); + nsMemory::Free(m2b); // m1b == m2b as far as nsMemory is concerned } m1b = nsnull; @@ -131,16 +120,6 @@ nsTextFragment::ReleaseText() mAllBits = 0; } -void* -nsTextFragment::CloneMemory(const void* aPtr, PRSize aSize) -{ - void* newPtr = mAllocator->Alloc(aSize); - if (newPtr) { - memcpy(newPtr, aPtr, aSize); - } - return newPtr; -} - nsTextFragment& nsTextFragment::operator=(const nsTextFragment& aOther) { @@ -151,11 +130,9 @@ nsTextFragment::operator=(const nsTextFragment& aOther) m1b = aOther.m1b; // This will work even if aOther is using m2b } else { - m2b = - static_cast - (CloneMemory(aOther.m2b, aOther.mState.mLength * - (aOther.mState.mIs2b ? - sizeof(PRUnichar) : sizeof(char)))); + m2b = static_cast + (nsMemory::Clone(aOther.m2b, aOther.mState.mLength * + (aOther.mState.mIs2b ? sizeof(PRUnichar) : sizeof(char)))); } if (m1b) { @@ -236,13 +213,14 @@ nsTextFragment::SetTo(const PRUnichar* aBuffer, PRInt32 aLength) if (need2) { // Use ucs2 storage because we have to - m2b = (PRUnichar *)CloneMemory(aBuffer, aLength * sizeof(PRUnichar)); + m2b = (PRUnichar *)nsMemory::Clone(aBuffer, + aLength * sizeof(PRUnichar)); if (!m2b) { return; } } else { // Use 1 byte storage because we can - char* buff = (char *)mAllocator->Alloc(aLength * sizeof(char)); + char* buff = (char *)nsMemory::Alloc(aLength * sizeof(char)); if (!buff) { return; } @@ -323,20 +301,15 @@ nsTextFragment::Append(const PRUnichar* aBuffer, PRUint32 aLength) if (mState.mIs2b) { // Already a 2-byte string so the result will be too - PRUnichar* buff = - (PRUnichar*)mAllocator->Alloc((mState.mLength + aLength) * - sizeof(PRUnichar)); + PRUnichar* buff = (PRUnichar*)nsMemory::Realloc(m2b, (mState.mLength + aLength) * sizeof(PRUnichar)); if (!buff) { return; } - memcpy(buff, m2b, mState.mLength * sizeof(PRUnichar)); + memcpy(buff + mState.mLength, aBuffer, aLength * sizeof(PRUnichar)); - if (mState.mInHeap) { - mAllocator->Free(mState.mLength * sizeof(PRUnichar), m2b); - } mState.mLength += aLength; m2b = buff; - mState.mInHeap = PR_TRUE; + return; } @@ -356,8 +329,8 @@ nsTextFragment::Append(const PRUnichar* aBuffer, PRUint32 aLength) if (need2) { // The old data was 1-byte, but the new is not so we have to expand it // all to 2-byte - PRUnichar* buff = (PRUnichar*)mAllocator->Alloc((mState.mLength + aLength) * - sizeof(PRUnichar)); + PRUnichar* buff = (PRUnichar*)nsMemory::Alloc((mState.mLength + aLength) * + sizeof(PRUnichar)); if (!buff) { return; } @@ -369,34 +342,42 @@ nsTextFragment::Append(const PRUnichar* aBuffer, PRUint32 aLength) memcpy(buff + mState.mLength, aBuffer, aLength * sizeof(PRUnichar)); - if (mState.mInHeap) { - mAllocator->Free(mState.mLength * sizeof(char), m2b); - } mState.mLength += aLength; mState.mIs2b = PR_TRUE; + + if (mState.mInHeap) { + nsMemory::Free(m2b); + } m2b = buff; + mState.mInHeap = PR_TRUE; return; } // The new and the old data is all 1-byte - char* buff = - (char*)mAllocator->Alloc((mState.mLength + aLength) * sizeof(char)); - if (!buff) { - return; + char* buff; + if (mState.mInHeap) { + buff = (char*)nsMemory::Realloc(const_cast(m1b), + (mState.mLength + aLength) * sizeof(char)); + if (!buff) { + return; + } } + else { + buff = (char*)nsMemory::Alloc((mState.mLength + aLength) * sizeof(char)); + if (!buff) { + return; + } - memcpy(buff, m1b, mState.mLength); - + memcpy(buff, m1b, mState.mLength); + mState.mInHeap = PR_TRUE; + } + for (PRUint32 i = 0; i < aLength; ++i) { buff[mState.mLength + i] = (char)aBuffer[i]; } - if (mState.mInHeap) { - mAllocator->Free(mState.mLength * sizeof(char), const_cast(m1b)); - } - mState.mInHeap = PR_TRUE; m1b = buff; mState.mLength += aLength; diff --git a/mozilla/content/base/src/nsTextFragment.h b/mozilla/content/base/src/nsTextFragment.h index 91fd1ece596..6c65e147f9f 100644 --- a/mozilla/content/base/src/nsTextFragment.h +++ b/mozilla/content/base/src/nsTextFragment.h @@ -47,7 +47,6 @@ #include "nsAString.h" class nsString; class nsCString; -class nsDOMNodeAllocator; // XXX should this normalize the code to keep a \u0000 at the end? @@ -86,12 +85,14 @@ public: /** * Default constructor. Initialize the fragment to be empty. */ - nsTextFragment(nsDOMNodeAllocator* aAllocator); + nsTextFragment() + : m1b(nsnull), mAllBits(0) + { + NS_ASSERTION(sizeof(FragmentBits) == 4, "Bad field packing!"); + } ~nsTextFragment(); - nsDOMNodeAllocator* Allocator() { return mAllocator; } - /** * Change the contents of this fragment to be a copy of the * the argument fragment. @@ -204,7 +205,6 @@ public: private: void ReleaseText(); - void* CloneMemory(const void* aPtr, PRSize aSize); union { PRUnichar *m2b; @@ -215,7 +215,6 @@ private: PRUint32 mAllBits; FragmentBits mState; }; - nsDOMNodeAllocator* mAllocator; }; #endif /* nsTextFragment_h___ */ diff --git a/mozilla/content/base/src/nsTextNode.cpp b/mozilla/content/base/src/nsTextNode.cpp index 6d155aa6d9d..4f30768a338 100644 --- a/mozilla/content/base/src/nsTextNode.cpp +++ b/mozilla/content/base/src/nsTextNode.cpp @@ -114,9 +114,9 @@ public: virtual nsGenericDOMDataNode *CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const { - nsAttributeTextNode *it = new (aNodeInfo) nsAttributeTextNode(aNodeInfo, - mNameSpaceID, - mAttrName); + nsAttributeTextNode *it = new nsAttributeTextNode(aNodeInfo, + mNameSpaceID, + mAttrName); if (it && aCloneText) { it->mText = mText; } @@ -154,7 +154,7 @@ NS_NewTextNode(nsIContent** aInstancePtrResult, return NS_ERROR_OUT_OF_MEMORY; } - nsIContent *instance = new (ni) nsTextNode(ni); + nsIContent *instance = new nsTextNode(ni); if (!instance) { return NS_ERROR_OUT_OF_MEMORY; } @@ -220,7 +220,7 @@ nsTextNode::IsNodeOfType(PRUint32 aFlags) const nsGenericDOMDataNode* nsTextNode::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const { - nsTextNode *it = new (aNodeInfo) nsTextNode(aNodeInfo); + nsTextNode *it = new nsTextNode(aNodeInfo); if (it && aCloneText) { it->mText = mText; } @@ -280,8 +280,8 @@ NS_NewAttributeContent(nsNodeInfoManager *aNodeInfoManager, return NS_ERROR_OUT_OF_MEMORY; } - nsAttributeTextNode* textNode = new (ni) nsAttributeTextNode(ni, aNameSpaceID, - aAttrName); + nsAttributeTextNode* textNode = new nsAttributeTextNode(ni, aNameSpaceID, + aAttrName); if (!textNode) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/events/src/nsXMLEventsElement.cpp b/mozilla/content/events/src/nsXMLEventsElement.cpp index 30deb24165f..37c07a419d7 100644 --- a/mozilla/content/events/src/nsXMLEventsElement.cpp +++ b/mozilla/content/events/src/nsXMLEventsElement.cpp @@ -87,7 +87,7 @@ NS_IMPL_ELEMENT_CLONE(nsXMLEventsElement) nsresult NS_NewXMLEventsElement(nsIContent** aInstancePtrResult, nsINodeInfo *aNodeInfo) { - nsXMLEventsElement* it = new (aNodeInfo) nsXMLEventsElement(aNodeInfo); + nsXMLEventsElement* it = new nsXMLEventsElement(aNodeInfo); if (!it) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index 5bec70702a2..3945948af3f 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -232,6 +232,7 @@ public: nsresult GetHrefURIForAnchors(nsIURI** aURI) const; // HTML element methods + void Compact() { mAttrsAndChildren.Compact(); } const nsAttrValue* GetParsedAttr(nsIAtom* aAttr) const { return mAttrsAndChildren.GetAttr(aAttr); @@ -972,15 +973,14 @@ private: nsGenericHTMLElement* \ NS_NewHTML##_elementName##Element(nsINodeInfo *aNodeInfo, PRBool aFromParser)\ { \ - return new (aNodeInfo) nsHTML##_elementName##Element(aNodeInfo); \ + return new nsHTML##_elementName##Element(aNodeInfo); \ } #define NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(_elementName) \ nsGenericHTMLElement* \ NS_NewHTML##_elementName##Element(nsINodeInfo *aNodeInfo, PRBool aFromParser)\ { \ - return \ - new (aNodeInfo) nsHTML##_elementName##Element(aNodeInfo, aFromParser); \ + return new nsHTML##_elementName##Element(aNodeInfo, aFromParser); \ } diff --git a/mozilla/content/html/content/src/nsHTMLCanvasElement.cpp b/mozilla/content/html/content/src/nsHTMLCanvasElement.cpp index 42a6160e9c8..b2a6157af7c 100644 --- a/mozilla/content/html/content/src/nsHTMLCanvasElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLCanvasElement.cpp @@ -135,7 +135,7 @@ public: nsGenericHTMLElement* NS_NewHTMLCanvasElement(nsINodeInfo *aNodeInfo, PRBool aFromParser) { - return new (aNodeInfo) nsHTMLCanvasElement(aNodeInfo); + return new nsHTMLCanvasElement(aNodeInfo); } nsHTMLCanvasElement::nsHTMLCanvasElement(nsINodeInfo *aNodeInfo) diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp index 94be9f11ce0..9f812e119e7 100644 --- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -461,7 +461,7 @@ ShouldBeInElements(nsIFormControl* aFormControl) nsGenericHTMLElement* NS_NewHTMLFormElement(nsINodeInfo *aNodeInfo, PRBool aFromParser) { - nsHTMLFormElement* it = new (aNodeInfo) nsHTMLFormElement(aNodeInfo); + nsHTMLFormElement* it = new nsHTMLFormElement(aNodeInfo); if (!it) { return nsnull; } diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp index 91e87bdefbe..265cd1342c7 100644 --- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp @@ -172,7 +172,7 @@ NS_NewHTMLImageElement(nsINodeInfo *aNodeInfo, PRBool aFromParser) NS_ENSURE_SUCCESS(rv, nsnull); } - return new (nodeInfo) nsHTMLImageElement(nodeInfo); + return new nsHTMLImageElement(nodeInfo); } nsHTMLImageElement::nsHTMLImageElement(nsINodeInfo *aNodeInfo) diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index fa5f03bf67c..661f1e70ed9 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -430,8 +430,7 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const { *aResult = nsnull; - nsHTMLInputElement *it = - new (aNodeInfo) nsHTMLInputElement(aNodeInfo, PR_FALSE); + nsHTMLInputElement *it = new nsHTMLInputElement(aNodeInfo, PR_FALSE); if (!it) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp index 27cfd36a508..43213edbe5a 100644 --- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -157,7 +157,7 @@ NS_NewHTMLOptionElement(nsINodeInfo *aNodeInfo, PRBool aFromParser) NS_ENSURE_SUCCESS(rv, nsnull); } - return new (nodeInfo) nsHTMLOptionElement(nodeInfo); + return new nsHTMLOptionElement(nodeInfo); } nsHTMLOptionElement::nsHTMLOptionElement(nsINodeInfo *aNodeInfo) diff --git a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp index 541621078ec..64c3b888c13 100644 --- a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp @@ -420,8 +420,7 @@ nsHTMLScriptElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const { *aResult = nsnull; - nsHTMLScriptElement* it = - new (aNodeInfo) nsHTMLScriptElement(aNodeInfo, PR_FALSE); + nsHTMLScriptElement* it = new nsHTMLScriptElement(aNodeInfo, PR_FALSE); if (!it) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index ebfb4cb6d42..326dc861c6b 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -931,6 +931,7 @@ SinkContext::CloseContainer(const nsHTMLTag aTag, PRBool aMalformed) nsGenericHTMLElement* content = mStack[mStackPos].mContent; + content->Compact(); // If we're in a state where we do append notifications as // we go up the tree, and we're at the level where the next diff --git a/mozilla/content/mathml/content/src/nsMathMLElementFactory.cpp b/mozilla/content/mathml/content/src/nsMathMLElementFactory.cpp index 006546f5af8..4dabc4a6c9e 100644 --- a/mozilla/content/mathml/content/src/nsMathMLElementFactory.cpp +++ b/mozilla/content/mathml/content/src/nsMathMLElementFactory.cpp @@ -47,7 +47,7 @@ NS_NewMathMLElement(nsIContent** aResult, nsINodeInfo* aNodeInfo) { aNodeInfo->SetIDAttributeAtom(nsGkAtoms::id); - nsMathMLElement* it = new (aNodeInfo) nsMathMLElement(aNodeInfo); + nsMathMLElement* it = new nsMathMLElement(aNodeInfo); NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY); NS_ADDREF(*aResult = it); diff --git a/mozilla/content/svg/content/src/nsSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGElement.cpp index 92734ef23e1..094531cef18 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGElement.cpp @@ -97,9 +97,7 @@ nsSVGEnumMapping nsSVGElement::sSVGUnitTypesMap[] = { }; nsSVGElement::nsSVGElement(nsINodeInfo *aNodeInfo) - : nsSVGElementBase(aNodeInfo), - mMappedAttributes(aNodeInfo->NodeInfoManager()->NodeAllocator()), - mSuppressNotification(PR_FALSE) + : nsSVGElementBase(aNodeInfo), mSuppressNotification(PR_FALSE) { } diff --git a/mozilla/content/svg/content/src/nsSVGElement.h b/mozilla/content/svg/content/src/nsSVGElement.h index 2de3c314105..c6fde17c77e 100644 --- a/mozilla/content/svg/content/src/nsSVGElement.h +++ b/mozilla/content/svg/content/src/nsSVGElement.h @@ -322,7 +322,7 @@ NS_NewSVG##_elementName##Element(nsIContent **aResult, \ nsINodeInfo *aNodeInfo) \ { \ nsSVG##_elementName##Element *it = \ - new (aNodeInfo) nsSVG##_elementName##Element(aNodeInfo); \ + new nsSVG##_elementName##Element(aNodeInfo); \ if (!it) \ return NS_ERROR_OUT_OF_MEMORY; \ \ diff --git a/mozilla/content/svg/content/src/nsSVGUseElement.cpp b/mozilla/content/svg/content/src/nsSVGUseElement.cpp index e481928b5f9..36103ac671a 100644 --- a/mozilla/content/svg/content/src/nsSVGUseElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGUseElement.cpp @@ -133,7 +133,7 @@ nsSVGUseElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const { *aResult = nsnull; - nsSVGUseElement *it = new (aNodeInfo) nsSVGUseElement(aNodeInfo); + nsSVGUseElement *it = new nsSVGUseElement(aNodeInfo); if (!it) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/xml/content/src/nsXMLCDATASection.cpp b/mozilla/content/xml/content/src/nsXMLCDATASection.cpp index d0663b06b59..8a4eb89fdbd 100644 --- a/mozilla/content/xml/content/src/nsXMLCDATASection.cpp +++ b/mozilla/content/xml/content/src/nsXMLCDATASection.cpp @@ -86,7 +86,7 @@ NS_NewXMLCDATASection(nsIContent** aInstancePtrResult, getter_AddRefs(ni)); NS_ENSURE_SUCCESS(rv, rv); - nsXMLCDATASection *instance = new (ni) nsXMLCDATASection(ni); + nsXMLCDATASection *instance = new nsXMLCDATASection(ni); if (!instance) { return NS_ERROR_OUT_OF_MEMORY; } @@ -154,7 +154,7 @@ nsXMLCDATASection::GetNodeType(PRUint16* aNodeType) nsGenericDOMDataNode* nsXMLCDATASection::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) const { - nsXMLCDATASection *it = new (aNodeInfo) nsXMLCDATASection(aNodeInfo); + nsXMLCDATASection *it = new nsXMLCDATASection(aNodeInfo); if (it && aCloneText) { it->mText = mText; } diff --git a/mozilla/content/xml/content/src/nsXMLElement.cpp b/mozilla/content/xml/content/src/nsXMLElement.cpp index 10c10f149f0..5fb4f6765dd 100644 --- a/mozilla/content/xml/content/src/nsXMLElement.cpp +++ b/mozilla/content/xml/content/src/nsXMLElement.cpp @@ -47,7 +47,7 @@ nsresult NS_NewXMLElement(nsIContent** aInstancePtrResult, nsINodeInfo *aNodeInfo) { - nsXMLElement* it = new (aNodeInfo) nsXMLElement(aNodeInfo); + nsXMLElement* it = new nsXMLElement(aNodeInfo); if (!it) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp b/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp index 29575941dbc..04a7ac7489f 100644 --- a/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp +++ b/mozilla/content/xml/content/src/nsXMLProcessingInstruction.cpp @@ -65,7 +65,7 @@ NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult, NS_ENSURE_SUCCESS(rv, rv); nsXMLProcessingInstruction *instance = - new (ni) nsXMLProcessingInstruction(ni, aTarget, aData); + new nsXMLProcessingInstruction(ni, aTarget, aData); if (!instance) { return NS_ERROR_OUT_OF_MEMORY; } @@ -176,7 +176,7 @@ nsXMLProcessingInstruction::CloneDataNode(nsINodeInfo *aNodeInfo, nsAutoString data; nsGenericDOMDataNode::GetData(data); - return new (aNodeInfo) nsXMLProcessingInstruction(aNodeInfo, mTarget, data); + return new nsXMLProcessingInstruction(aNodeInfo, mTarget, data); } #ifdef DEBUG diff --git a/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp b/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp index cf61ca08bd5..e9bcd263908 100644 --- a/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp +++ b/mozilla/content/xml/content/src/nsXMLStylesheetPI.cpp @@ -246,7 +246,7 @@ nsXMLStylesheetPI::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) cons nsAutoString data; nsGenericDOMDataNode::GetData(data); - return new (aNodeInfo) nsXMLStylesheetPI(aNodeInfo, data); + return new nsXMLStylesheetPI(aNodeInfo, data); } nsresult @@ -265,7 +265,7 @@ NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult, getter_AddRefs(ni)); NS_ENSURE_SUCCESS(rv, rv); - nsXMLStylesheetPI *instance = new (ni) nsXMLStylesheetPI(ni, aData); + nsXMLStylesheetPI *instance = new nsXMLStylesheetPI(ni, aData); if (!instance) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/xtf/src/nsXTFElementWrapper.cpp b/mozilla/content/xtf/src/nsXTFElementWrapper.cpp index 2c7d5ab4cf2..3c0dc1d2a38 100644 --- a/mozilla/content/xtf/src/nsXTFElementWrapper.cpp +++ b/mozilla/content/xtf/src/nsXTFElementWrapper.cpp @@ -1003,8 +1003,7 @@ NS_NewXTFElementWrapper(nsIXTFElement* aXTFElement, *aResult = nsnull; NS_ENSURE_ARG(aXTFElement); - nsXTFElementWrapper* result = - new (aNodeInfo) nsXTFElementWrapper(aNodeInfo, aXTFElement); + nsXTFElementWrapper* result = new nsXTFElementWrapper(aNodeInfo, aXTFElement); if (!result) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index ce69690e6d0..ebe7ecc5937 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -262,7 +262,7 @@ nsXULElement::nsXULSlots::~nsXULSlots() nsINode::nsSlots* nsXULElement::CreateSlots() { - return new (GetAllocator()) nsXULSlots(mFlagsOrSlots); + return new nsXULSlots(mFlagsOrSlots); } /* static */ @@ -270,7 +270,7 @@ already_AddRefed nsXULElement::Create(nsXULPrototypeElement* aPrototype, nsINodeInfo *aNodeInfo, PRBool aIsScriptable) { - nsXULElement *element = new (aNodeInfo) nsXULElement(aNodeInfo); + nsXULElement *element = new nsXULElement(aNodeInfo); if (element) { NS_ADDREF(element); @@ -351,7 +351,7 @@ NS_NewXULElement(nsIContent** aResult, nsINodeInfo *aNodeInfo) *aResult = nsnull; // Create an nsXULElement with the specified namespace and tag. - nsXULElement* element = new (aNodeInfo) nsXULElement(aNodeInfo); + nsXULElement* element = new nsXULElement(aNodeInfo); NS_ENSURE_TRUE(element, NS_ERROR_OUT_OF_MEMORY); NS_ADDREF(*aResult = element); @@ -431,7 +431,7 @@ nsXULElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const "Didn't get the default language from proto?"); } else { - element = new (aNodeInfo) nsXULElement(aNodeInfo); + element = new nsXULElement(aNodeInfo); if (element) { // If created from a prototype, we will already have the script // language specified by the proto - otherwise copy it directly