Closed Bug 1227377 Opened 7 years ago Closed 7 years ago

Change ImageRequest::mRequests to use nsIDocument as a key, instead of nsISupports


(Core :: CSS Parsing and Computation, defect)

Not set



Tracking Status
firefox45 --- fixed


(Reporter: dholbert, Assigned: dholbert)




(1 file)

struct ImageValue has a hash table as a member-var, "mRequests".

For some reason, the key to this hash table is nsPtrHashKey<nsISupports>, but we always seem to use a nsIDocument* as the actual key.  And in the destructor, we static_cast the key to be a nsIDocument* (and assert that this is valid).

Seems like we should just make the key based on nsIDocument, rather than nsISupports.

I'm guessing that this is the way it is because this hash table was originally added (in bug 697230) with the following type:
>  nsInterfaceHashtable<nsISupportsHashKey, imgIRequest> mRequests;

That type (nsInterfaceHashtable/nsISupportsHashKey) presumably didn't have a nsIDocument-specific variant (not sure).  Anyway, nowadays this hash table just has the following type:
> nsRefPtrHashtable<nsPtrHashKey<nsISupports>, imgRequestProxy> mRequests;

...and it seems like we can swap in nsIDocument there & remove our now-unnecessary static-casts & assertions, for better type-safety.
Assignee: nobody → dholbert
Attached patch fix v1Splinter Review
Tagging khuey to review, since he added this hash table in bug 697230.

Note that this patch layers on top of attachment 8691150 [details] [diff] [review] (njn's bug 1187144 part 4).
Attachment #8691194 - Flags: review?(khuey)
I haven't tested this patch beyond
 (1) verifying that it builds successfully.
 (2) verifying that all users of this hash-table (ImageLoader.cpp in particular) seem to be passing in nsIDocument* pointers [which really must be the case, or else it wouldn't have built successfully]
Try run looks good. I noticed that I copypasted the wrong bug number into the commit message, too; fixed that locally.
Thanks! I'll land this once njn's bug 1187144 has landed (since this layers on top of that, and I don't want cause bitrot for him).
Flags: needinfo?(dholbert)
Flags: needinfo?(dholbert) → in-testsuite-
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.