Closed Bug 1131801 Opened 9 years ago Closed 9 years ago

remove use of parent in XPCWrappedNative's RescueOrphans

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38
Tracking Status
firefox38 --- fixed

People

(Reporter: sfink, Assigned: bzbarsky)

References

Details

Attachments

(3 files)

Split out from bug 805052, item 12: RescueOrphans in XPCWrappedNative, which has a cross-compartment wrapper as parent??
OK, so RescueOrphans is meant to deal with an XPCWrappedNative whose parent gets reparented.

For an XPCWrappedNative to have an interesting (non-global-object) parent, it needs to have a PreCreate hook.

We have the following PreCreate hooks in our codebase:

1) nsDOMConstructorSH::PreCreate, which calls nsDOMConstructor::PreCreate, which does SetParentToWindow(win, parentObj), so the parent always ends up being a window.

2) nsEventTargetSH::PreCreate which does:

   *parentObj = native_parent ? native_parent->GetGlobalJSObject() : globalObj;

where native_parent is an nsIScriptGlobalObject and globalObj is the aGlobalObj that was passed in.

3) nsDOMClassInfo::PreCreate, which does "*parentObj = globalObj;".

4) ComponentsSH::PreCreate, which does:

  *parentObj = self->GetScope()->GetGlobalJSObject();

5)  BackstagePass::PreCreate which sets *parentObj to global->GetGlobalJSObject(), where global is an nsIGlobalObject.

That's it.  So the parent always ends up being a global, and those of course never get reparented.

Given that, we can just kill off RescueOrphans entirely.
Assignee: nobody → bzbarsky
Depends on: 1131887
Blocks: 1132184
Blocks: 1127475
No longer blocks: 1127475
Attachment #8562984 - Flags: review?(peterv) → review+
Attachment #8562985 - Flags: review?(peterv) → review+
Attachment #8562986 - Flags: review?(peterv) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: