mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1377999 - Make Attribute to adapt the DOMArena changes r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D57700 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
2d1f2db82e
commit
28bbd32a07
@ -93,7 +93,12 @@ NS_INTERFACE_TABLE_HEAD(Attr)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(Attr)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(Attr, LastRelease())
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE_AND_DESTROY(Attr,
|
||||
LastRelease(),
|
||||
Destroy())
|
||||
|
||||
NS_IMPL_DOMARENA_DESTROY(Attr)
|
||||
|
||||
void Attr::SetMap(nsDOMAttributeMap* aMap) {
|
||||
if (mAttrMap && !aMap && sInitialized) {
|
||||
@ -173,8 +178,9 @@ void Attr::SetNodeValueInternal(const nsAString& aNodeValue,
|
||||
nsresult Attr::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const {
|
||||
nsAutoString value;
|
||||
const_cast<Attr*>(this)->GetValue(value);
|
||||
*aResult = new (aNodeInfo->NodeInfoManager())
|
||||
Attr(nullptr, do_AddRef(aNodeInfo), value);
|
||||
|
||||
*aResult = new Attr(nullptr, do_AddRef(aNodeInfo), value);
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -34,7 +34,9 @@ class Attr final : public nsINode {
|
||||
Attr(nsDOMAttributeMap* aAttrMap, already_AddRefed<dom::NodeInfo>&& aNodeInfo,
|
||||
const nsAString& aValue);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS_FINAL_DELETECYCLECOLLECTABLE
|
||||
|
||||
NS_DECL_DOMARENA_DESTROY
|
||||
|
||||
NS_IMPL_FROMNODE_HELPER(Attr, IsAttr())
|
||||
|
||||
|
@ -7851,7 +7851,8 @@ already_AddRefed<Attr> Document::CreateAttribute(const nsAString& aName,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Attr> attribute = new Attr(nullptr, nodeInfo.forget(), EmptyString());
|
||||
RefPtr<Attr> attribute =
|
||||
new (mNodeInfoManager) Attr(nullptr, nodeInfo.forget(), EmptyString());
|
||||
return attribute.forget();
|
||||
}
|
||||
|
||||
@ -7866,7 +7867,8 @@ already_AddRefed<Attr> Document::CreateAttributeNS(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Attr> attribute = new Attr(nullptr, nodeInfo.forget(), EmptyString());
|
||||
RefPtr<Attr> attribute =
|
||||
new (mNodeInfoManager) Attr(nullptr, nodeInfo.forget(), EmptyString());
|
||||
return attribute.forget();
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,8 @@ Attr* nsDOMAttributeMap::GetAttribute(mozilla::dom::NodeInfo* aNodeInfo) {
|
||||
if (!node) {
|
||||
// Newly inserted entry!
|
||||
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
||||
entryValue = new Attr(this, ni.forget(), EmptyString());
|
||||
auto* nim = ni->NodeInfoManager();
|
||||
entryValue = new (nim) Attr(this, ni.forget(), EmptyString());
|
||||
node = entryValue;
|
||||
}
|
||||
|
||||
|
@ -864,6 +864,30 @@ class ThreadSafeAutoRefCnt {
|
||||
} \
|
||||
NS_IMETHODIMP_(void) _class::DeleteCycleCollectable(void) { delete this; }
|
||||
|
||||
// This macro is same as NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE
|
||||
// except it doesn't have DeleteCycleCollectable.
|
||||
#define NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE_AND_DESTROY( \
|
||||
_class, _last, _destroy) \
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) _class::Release(void) { \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
NS_ASSERT_OWNINGTHREAD(_class); \
|
||||
bool shouldDelete = false; \
|
||||
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
|
||||
nsrefcnt count = mRefCnt.decr(base, &shouldDelete); \
|
||||
NS_LOG_RELEASE(this, count, #_class); \
|
||||
if (count == 0) { \
|
||||
mRefCnt.incr(base); \
|
||||
_last; \
|
||||
mRefCnt.decr(base); \
|
||||
if (shouldDelete) { \
|
||||
mRefCnt.stabilizeForDeletion(); \
|
||||
DeleteCycleCollectable(); \
|
||||
} \
|
||||
} \
|
||||
return count; \
|
||||
} \
|
||||
NS_IMETHODIMP_(void) _class::DeleteCycleCollectable(void) { _destroy; }
|
||||
|
||||
#define NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE(_class) \
|
||||
NS_IMETHODIMP_(MozExternalRefCountType) _class::Release(void) { \
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release"); \
|
||||
|
Loading…
Reference in New Issue
Block a user