Closed Bug 339774 Opened 18 years ago Closed 18 years ago

nsDOMEvent::DuplicatePrivateData should copy more things from the original event

Categories

(Core :: DOM: Events, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: smaug, Assigned: smaug)

References

Details

Attachments

(2 files)

Currently for example keyCode and charCode are set to 0, not copied from the
original event.
This is not needed once nsEvent is gone (and this may take still some time), 
but before that I'd like it to work properly.
Blocks: 339697
This is a bit ugly, but so is everything related to ::DuplicatePrivateData.
I decided to copy all possible members of nsEvent-classes. Members which
refer to some external object are set to nsnull (by the constructors of the 
nsEvent classes). nsTextEvent is a bit different, it really can't be copied,
and nsPopupBlockedEvent is used always only with DOM Events (otherwise the 
handling of the two owning pointers wouldn't really work)
Because of Bug 339697 this is needed also in branch.
The branch patch will be a bit different, mainly just the handling of the 
target of the event.
Attachment #223963 - Flags: superreview?(jst)
Attachment #223963 - Flags: review?(jst)
And I removed that invalid comment about trusted events.
Event will be trusted after duplication, but not perhaps after Init()
Status: NEW → ASSIGNED
Comment on attachment 223963 [details] [diff] [review]
ugly, but still proposed patch

r+sr=jst
Attachment #223963 - Flags: superreview?(jst)
Attachment #223963 - Flags: superreview+
Attachment #223963 - Flags: review?(jst)
Attachment #223963 - Flags: review+
Checking in nsDOMEvent.cpp;
/cvsroot/mozilla/content/events/src/nsDOMEvent.cpp,v  <--  nsDOMEvent.cpp
new revision: 1.210; previous revision: 1.209
done
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
prometheus didn't like this
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
It just needed curly brackets.
Checking in nsDOMEvent.cpp;
/cvsroot/mozilla/content/events/src/nsDOMEvent.cpp,v  <--  nsDOMEvent.cpp
new revision: 1.212; previous revision: 1.211
done
Status: REOPENED → RESOLVED
Closed: 18 years ago18 years ago
Resolution: --- → FIXED
Balsa showed some leaks.
I checked in the following to see whether it helps
-      NS_STATIC_CAST(nsXULCommandEvent*, newEvent)->sourceEvent =
-        NS_STATIC_CAST(nsXULCommandEvent*, mEvent)->sourceEvent;
+      /* Disabling for now. This creates some leaks.
+       NS_STATIC_CAST(nsXULCommandEvent*, newEvent)->sourceEvent =
+         NS_STATIC_CAST(nsXULCommandEvent*, mEvent)->sourceEvent; */
At least locally I did see that with that code nsDOMXULCommandEvents
were leaked, which means also their targets were leaked.
Er... That sounds like we leak nsEvent structs.  Could we add some CTOR/DTOR logging to nsEvent and see what balsa shows?  I can't believe we don't have any such logging now...
I commented out the code related to mutation events.
That helps too (at least locally). Otherwise nsDOMAttributes are leaked.
still investigating.
Attached patch fixes leaksSplinter Review
This re-enables proper DuplicatePrivateData for mutation and command events and
fixes the leaks.
Attachment #224419 - Flags: superreview?(bzbarsky)
Attachment #224419 - Flags: review?(bzbarsky)
Comment on attachment 224419 [details] [diff] [review]
fixes leaks

Looks good, I guess.  When we move away to combining nsEvent and nsDOMEvent, this fragility will hopefully go away...
Attachment #224419 - Flags: superreview?(bzbarsky)
Attachment #224419 - Flags: superreview+
Attachment #224419 - Flags: review?(bzbarsky)
Attachment #224419 - Flags: review+
Comment on attachment 224419 [details] [diff] [review]
fixes leaks

Checked in. Leaks ok.
Blocks: 281859
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: