Bug 707564 part 2. Add a way to enumerate navigator names on the script namespace manager. r=smaug

This commit is contained in:
Boris Zbarsky 2013-08-03 23:38:54 -04:00
parent 3bcc77ed3a
commit f2e67b21c9
2 changed files with 19 additions and 10 deletions

View File

@ -787,27 +787,34 @@ nsScriptNameSpaceManager::RegisterNavigatorDOMConstructor(
}
}
struct GlobalNameClosure
struct NameClosure
{
nsScriptNameSpaceManager::GlobalNameEnumerator enumerator;
nsScriptNameSpaceManager::NameEnumerator enumerator;
void* closure;
};
static PLDHashOperator
EnumerateGlobalName(PLDHashTable*, PLDHashEntryHdr *hdr, uint32_t,
void* aClosure)
EnumerateName(PLDHashTable*, PLDHashEntryHdr *hdr, uint32_t, void* aClosure)
{
GlobalNameMapEntry *entry = static_cast<GlobalNameMapEntry *>(hdr);
GlobalNameClosure* closure = static_cast<GlobalNameClosure*>(aClosure);
NameClosure* closure = static_cast<NameClosure*>(aClosure);
return closure->enumerator(entry->mKey, closure->closure);
}
void
nsScriptNameSpaceManager::EnumerateGlobalNames(GlobalNameEnumerator aEnumerator,
nsScriptNameSpaceManager::EnumerateGlobalNames(NameEnumerator aEnumerator,
void* aClosure)
{
GlobalNameClosure closure = { aEnumerator, aClosure };
PL_DHashTableEnumerate(&mGlobalNames, EnumerateGlobalName, &closure);
NameClosure closure = { aEnumerator, aClosure };
PL_DHashTableEnumerate(&mGlobalNames, EnumerateName, &closure);
}
void
nsScriptNameSpaceManager::EnumerateNavigatorNames(NameEnumerator aEnumerator,
void* aClosure)
{
NameClosure closure = { aEnumerator, aClosure };
PL_DHashTableEnumerate(&mNavigatorNames, EnumerateName, &closure);
}
static size_t

View File

@ -152,10 +152,12 @@ public:
mozilla::dom::ConstructorEnabled* aConstructorEnabled);
typedef PLDHashOperator
(* GlobalNameEnumerator)(const nsAString& aGlobalName, void* aClosure);
(* NameEnumerator)(const nsAString& aGlobalName, void* aClosure);
void EnumerateGlobalNames(GlobalNameEnumerator aEnumerator,
void EnumerateGlobalNames(NameEnumerator aEnumerator,
void* aClosure);
void EnumerateNavigatorNames(NameEnumerator aEnumerator,
void* aClosure);
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);