Consider making nsIDocument::mCachedRootElement a weak pointer

RESOLVED FIXED in mozilla10

Status

()

Core
DOM: Core & HTML
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: khuey, Assigned: khuey)

Tracking

Trunk
mozilla10
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Comment hidden (empty)
Version: unspecified → Trunk
Seems like that would allow us to make it an Element*.
Created attachment 560776 [details] [diff] [review]
Patch

This makes us store an Element*, at the cost of moving the function into nsDocument.cpp.  If that's not acceptable I can go back to the nsIContent*.
Assignee: nobody → khuey
Status: NEW → ASSIGNED
Attachment #560776 - Flags: review?(Olli.Pettay)
Back to an nsINode of course.

Comment 4

6 years ago
Comment on attachment 560776 [details] [diff] [review]
Patch

>@@ -1918,17 +1917,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
>   for (PRInt32 indx = PRInt32(tmp->mChildren.ChildCount()) - 1; 
>        indx >= 0; --indx) {
>     tmp->mChildren.ChildAt(indx)->UnbindFromTree();
>     tmp->mChildren.RemoveChildAt(indx);
>   }
>   tmp->mFirstChild = nsnull;
> 
>   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mXPathEvaluatorTearoff)
>-  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCachedRootElement)
You must add tmp->mCachedRootElement = nsnull;
otherwise it may point to a deleted object after unlinking.
Attachment #560776 - Flags: review?(Olli.Pettay) → review+
https://hg.mozilla.org/mozilla-central/rev/d0dac9811895
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in before you can comment on or make changes to this bug.