Closed Bug 1275945 Opened 4 years ago Closed 4 years ago

Don't create the AutoJSContext in nsNodeUtils::CloneAndAdopt if we don't have an aReparentScope

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(1 file)

The changes in bug 839467 made CloneAndAdopt always push stuff on the JSContext stack.  This isn't very desirable, both for performance reasons and because it lands a null-compartment thing on the stack.

In practice, we only use this AutoJSContext when aReparentScope is non-null, so we should only construct it in that case.
This prevents us from pushing stuff on the JSContext stack unnecessarily when
we're just cloning, not adopting.  It's OK that we're doing it in a narrow scope
that doesn't include our recursion into children, because in practice when
aReparentScope is non-null we came from nsIDocument::AdoptNode which already
does AutoJSContext.  So we're not going to continuously push/pop the JSContext
stack in that situation, since something already got pushed on it.
Attachment #8756900 - Flags: review?(mrbkap)
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Attachment #8756900 - Flags: review?(mrbkap) → review+
https://hg.mozilla.org/mozilla-central/rev/72ea7eafc5e5
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.