"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dom/base/nsNodeInfoManager.cpp" between
UXP-2019.03.27.tar.gz and UXP-2019.06.08.tar.gz

About: Basilisk is a full-featured, optimized browser derived from the code behind the pre-Servo Firefox browser (29–56 era). UXP = Unified XUL Platform. Source code.

nsNodeInfoManager.cpp  (UXP-2019.03.27):nsNodeInfoManager.cpp  (UXP-2019.06.08)
skipping to change at line 113 skipping to change at line 113
} }
static PLHashAllocOps allocOps = static PLHashAllocOps allocOps =
{ AllocTable, FreeTable, AllocEntry, FreeEntry }; { AllocTable, FreeTable, AllocEntry, FreeEntry };
nsNodeInfoManager::nsNodeInfoManager() nsNodeInfoManager::nsNodeInfoManager()
: mDocument(nullptr), : mDocument(nullptr),
mNonDocumentNodeInfos(0), mNonDocumentNodeInfos(0),
mTextNodeInfo(nullptr), mTextNodeInfo(nullptr),
mCommentNodeInfo(nullptr), mCommentNodeInfo(nullptr),
mDocumentNodeInfo(nullptr) mDocumentNodeInfo(nullptr),
mRecentlyUsedNodeInfos{}
{ {
nsLayoutStatics::AddRef(); nsLayoutStatics::AddRef();
if (gNodeInfoManagerLeakPRLog) if (gNodeInfoManagerLeakPRLog)
MOZ_LOG(gNodeInfoManagerLeakPRLog, LogLevel::Debug, MOZ_LOG(gNodeInfoManagerLeakPRLog, LogLevel::Debug,
("NODEINFOMANAGER %p created", this)); ("NODEINFOMANAGER %p created", this));
mNodeInfoHash = PL_NewHashTable(32, GetNodeInfoInnerHashValue, mNodeInfoHash = PL_NewHashTable(32, GetNodeInfoInnerHashValue,
NodeInfoInnerKeyCompare, NodeInfoInnerKeyCompare,
PL_CompareValues, &allocOps, nullptr); PL_CompareValues, &allocOps, nullptr);
skipping to change at line 231 skipping to change at line 232
already_AddRefed<mozilla::dom::NodeInfo> already_AddRefed<mozilla::dom::NodeInfo>
nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
int32_t aNamespaceID, uint16_t aNodeType, int32_t aNamespaceID, uint16_t aNodeType,
nsIAtom* aExtraName /* = nullptr */) nsIAtom* aExtraName /* = nullptr */)
{ {
CheckValidNodeInfo(aNodeType, aName, aNamespaceID, aExtraName); CheckValidNodeInfo(aNodeType, aName, aNamespaceID, aExtraName);
NodeInfo::NodeInfoInner tmpKey(aName, aPrefix, aNamespaceID, aNodeType, NodeInfo::NodeInfoInner tmpKey(aName, aPrefix, aNamespaceID, aNodeType,
aExtraName); aExtraName);
uint32_t index =
GetNodeInfoInnerHashValue(&tmpKey) % RECENTLY_USED_NODEINFOS_SIZE;
NodeInfo* ni = mRecentlyUsedNodeInfos[index];
if (ni && NodeInfoInnerKeyCompare(&(ni->mInner), &tmpKey)) {
RefPtr<NodeInfo> nodeInfo = ni;
return nodeInfo.forget();
}
void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey); void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey);
if (node) { if (node) {
RefPtr<NodeInfo> nodeInfo = static_cast<NodeInfo*>(node); RefPtr<NodeInfo> nodeInfo = static_cast<NodeInfo*>(node);
mRecentlyUsedNodeInfos[index] = nodeInfo;
return nodeInfo.forget(); return nodeInfo.forget();
} }
RefPtr<NodeInfo> newNodeInfo = RefPtr<NodeInfo> newNodeInfo =
new NodeInfo(aName, aPrefix, aNamespaceID, aNodeType, aExtraName, this); new NodeInfo(aName, aPrefix, aNamespaceID, aNodeType, aExtraName, this);
DebugOnly<PLHashEntry*> he = DebugOnly<PLHashEntry*> he =
PL_HashTableAdd(mNodeInfoHash, &newNodeInfo->mInner, newNodeInfo); PL_HashTableAdd(mNodeInfoHash, &newNodeInfo->mInner, newNodeInfo);
MOZ_ASSERT(he, "PL_HashTableAdd() failed"); MOZ_ASSERT(he, "PL_HashTableAdd() failed");
// Have to do the swap thing, because already_AddRefed<nsNodeInfo> // Have to do the swap thing, because already_AddRefed<nsNodeInfo>
// doesn't cast to already_AddRefed<mozilla::dom::NodeInfo> // doesn't cast to already_AddRefed<mozilla::dom::NodeInfo>
++mNonDocumentNodeInfos; ++mNonDocumentNodeInfos;
if (mNonDocumentNodeInfos == 1) { if (mNonDocumentNodeInfos == 1) {
NS_IF_ADDREF(mDocument); NS_IF_ADDREF(mDocument);
} }
mRecentlyUsedNodeInfos[index] = newNodeInfo;
return newNodeInfo.forget(); return newNodeInfo.forget();
} }
nsresult nsresult
nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
int32_t aNamespaceID, uint16_t aNodeType, int32_t aNamespaceID, uint16_t aNodeType,
NodeInfo** aNodeInfo) NodeInfo** aNodeInfo)
{ {
#ifdef DEBUG #ifdef DEBUG
{ {
nsCOMPtr<nsIAtom> nameAtom = NS_Atomize(aName); nsCOMPtr<nsIAtom> nameAtom = NS_Atomize(aName);
CheckValidNodeInfo(aNodeType, nameAtom, aNamespaceID, nullptr); CheckValidNodeInfo(aNodeType, nameAtom, aNamespaceID, nullptr);
} }
#endif #endif
NodeInfo::NodeInfoInner tmpKey(aName, aPrefix, aNamespaceID, aNodeType); NodeInfo::NodeInfoInner tmpKey(aName, aPrefix, aNamespaceID, aNodeType);
uint32_t index =
GetNodeInfoInnerHashValue(&tmpKey) % RECENTLY_USED_NODEINFOS_SIZE;
NodeInfo* ni = mRecentlyUsedNodeInfos[index];
if (ni && NodeInfoInnerKeyCompare(&(ni->mInner), &tmpKey)) {
RefPtr<NodeInfo> nodeInfo = ni;
nodeInfo.forget(aNodeInfo);
return NS_OK;
}
void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey); void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey);
if (node) { if (node) {
RefPtr<NodeInfo> nodeInfo = static_cast<NodeInfo*>(node); RefPtr<NodeInfo> nodeInfo = static_cast<NodeInfo*>(node);
mRecentlyUsedNodeInfos[index] = nodeInfo;
nodeInfo.forget(aNodeInfo); nodeInfo.forget(aNodeInfo);
return NS_OK; return NS_OK;
} }
nsCOMPtr<nsIAtom> nameAtom = NS_Atomize(aName); nsCOMPtr<nsIAtom> nameAtom = NS_AtomizeMainThread(aName);
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
RefPtr<NodeInfo> newNodeInfo = RefPtr<NodeInfo> newNodeInfo =
new NodeInfo(nameAtom, aPrefix, aNamespaceID, aNodeType, nullptr, this); new NodeInfo(nameAtom, aPrefix, aNamespaceID, aNodeType, nullptr, this);
NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY);
PLHashEntry *he; PLHashEntry *he;
he = PL_HashTableAdd(mNodeInfoHash, &newNodeInfo->mInner, newNodeInfo); he = PL_HashTableAdd(mNodeInfoHash, &newNodeInfo->mInner, newNodeInfo);
NS_ENSURE_TRUE(he, NS_ERROR_FAILURE); NS_ENSURE_TRUE(he, NS_ERROR_FAILURE);
++mNonDocumentNodeInfos; ++mNonDocumentNodeInfos;
if (mNonDocumentNodeInfos == 1) { if (mNonDocumentNodeInfos == 1) {
NS_IF_ADDREF(mDocument); NS_IF_ADDREF(mDocument);
} }
mRecentlyUsedNodeInfos[index] = newNodeInfo;
newNodeInfo.forget(aNodeInfo); newNodeInfo.forget(aNodeInfo);
return NS_OK; return NS_OK;
} }
nsresult nsresult
nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix, nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
const nsAString& aNamespaceURI, const nsAString& aNamespaceURI,
uint16_t aNodeType, uint16_t aNodeType,
NodeInfo** aNodeInfo) NodeInfo** aNodeInfo)
skipping to change at line 418 skipping to change at line 439
} }
// Drop weak reference if needed // Drop weak reference if needed
if (aNodeInfo == mTextNodeInfo) { if (aNodeInfo == mTextNodeInfo) {
mTextNodeInfo = nullptr; mTextNodeInfo = nullptr;
} }
else if (aNodeInfo == mCommentNodeInfo) { else if (aNodeInfo == mCommentNodeInfo) {
mCommentNodeInfo = nullptr; mCommentNodeInfo = nullptr;
} }
} }
uint32_t index =
GetNodeInfoInnerHashValue(&aNodeInfo->mInner) % RECENTLY_USED_NODEINFOS_SIZE
;
if (mRecentlyUsedNodeInfos[index] == aNodeInfo) {
mRecentlyUsedNodeInfos[index] = nullptr;
}
#ifdef DEBUG #ifdef DEBUG
bool ret = bool ret =
#endif #endif
PL_HashTableRemove(mNodeInfoHash, &aNodeInfo->mInner); PL_HashTableRemove(mNodeInfoHash, &aNodeInfo->mInner);
NS_POSTCONDITION(ret, "Can't find mozilla::dom::NodeInfo to remove!!!"); NS_POSTCONDITION(ret, "Can't find mozilla::dom::NodeInfo to remove!!!");
} }
 End of changes. 9 change blocks. 
3 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)