Closed Bug 1440407 Opened 6 years ago Closed 6 years ago

add a method to cast nsPIDOMWindowInner to nsIGlobalObject without QI

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla60
Tracking Status
firefox60 --- fixed

People

(Reporter: bkelly, Assigned: bkelly)

References

Details

Attachments

(2 files)

Currently we have code in a number of places that QIs nsPIDOMWindowInner to nsIGlobalObject.  Since nsPIDOMWindowInner is only ever implemented by nsGlobalWindowInner and nsGlobalWindowInner implements nsIGlobalObject, then this QI can never fail.  We should perhaps instead just expose a simple cast method on nsPIDOMWindowInner to avoid this QI overhead.

I would like to use this in bug 1438211.
We can kind of already do this with nsGlobalWindowInner::Cast(), but that requires code to include nsGlobalWindowInner.h which is not really ideal.
Comment on attachment 8953199 [details] [diff] [review]
P1 Add nsPIDOMWindowInner::AsGlobal() to cheaply cast to nsIGlobalObject*. r=mystor

Nika, this patch adds the AsGlobal() cast method as we discussed.  I followed the example of AsInner() and provided both const/non-const versions.
Attachment #8953199 - Flags: review?(nika)
Comment on attachment 8953200 [details] [diff] [review]
P2 Remove some unnecessary nsPIDOMWindowInner QI to nsIGlobalObject. r=mystor

This patch converts the cases of QI from window-to-global that I could find.  Its kind of hard to search for in searchfox.

Note, some of these callsites were relying on the nullptr check post-QI to catch a nullptr window.  So I had to add some additional window checking in places.

I also fixed up some unrelated error checking like not looking for aRv.Failed() after Promise::Create(), etc.
Attachment #8953200 - Flags: review?(nika)
Attachment #8953199 - Flags: review?(nika) → review+
Comment on attachment 8953200 [details] [diff] [review]
P2 Remove some unnecessary nsPIDOMWindowInner QI to nsIGlobalObject. r=mystor

Review of attachment 8953200 [details] [diff] [review]:
-----------------------------------------------------------------

Much cleaner, thanks!
Attachment #8953200 - Flags: review?(nika) → review+
Pushed by bkelly@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/65cd02963e83
P1 Add nsPIDOMWindowInner::AsGlobal() to cheaply cast to nsIGlobalObject*. r=mystor
https://hg.mozilla.org/integration/mozilla-inbound/rev/607de876681e
P2 Remove some unnecessary nsPIDOMWindowInner QI to nsIGlobalObject. r=mystor
https://hg.mozilla.org/mozilla-central/rev/65cd02963e83
https://hg.mozilla.org/mozilla-central/rev/607de876681e
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: