mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1198435 - MediaElementTableCount now checks that the element is not present for URIs other than the expected one. r=rillian
This commit is contained in:
parent
8094440dd0
commit
0a65112461
@ -1944,26 +1944,43 @@ typedef nsTHashtable<MediaElementSetForURI> MediaElementURITable;
|
||||
static MediaElementURITable* gElementTable;
|
||||
|
||||
#ifdef DEBUG
|
||||
static bool
|
||||
URISafeEquals(nsIURI* a1, nsIURI* a2)
|
||||
{
|
||||
if (!a1 || !a2) {
|
||||
// Consider two empty URIs *not* equal!
|
||||
return false;
|
||||
}
|
||||
bool equal = false;
|
||||
nsresult rv = a1->Equals(a2, &equal);
|
||||
return NS_SUCCEEDED(rv) && equal;
|
||||
}
|
||||
// Returns the number of times aElement appears in the media element table
|
||||
// for aURI. If this returns other than 0 or 1, there's a bug somewhere!
|
||||
static unsigned
|
||||
MediaElementTableCount(HTMLMediaElement* aElement, nsIURI* aURI)
|
||||
{
|
||||
if (!gElementTable || !aElement || !aURI) {
|
||||
if (!gElementTable || !aElement) {
|
||||
return 0;
|
||||
}
|
||||
MediaElementSetForURI* entry = gElementTable->GetEntry(aURI);
|
||||
if (!entry) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t count = 0;
|
||||
for (uint32_t i = 0; i < entry->mElements.Length(); ++i) {
|
||||
HTMLMediaElement* elem = entry->mElements[i];
|
||||
if (elem == aElement) {
|
||||
count++;
|
||||
uint32_t uriCount = 0;
|
||||
uint32_t otherCount = 0;
|
||||
for (auto it = gElementTable->ConstIter(); !it.Done(); it.Next()) {
|
||||
MediaElementSetForURI* entry = it.Get();
|
||||
uint32_t count = 0;
|
||||
for (const auto& elem : entry->mElements) {
|
||||
if (elem == aElement) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (URISafeEquals(aURI, entry->GetKey())) {
|
||||
uriCount = count;
|
||||
} else {
|
||||
otherCount += count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
NS_ASSERTION(otherCount == 0, "Should not have entries for unknown URIs");
|
||||
return uriCount;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user