From a4c4387df0b62a637a755c83de4776b80e2cfa6f Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Mon, 18 Mar 2013 16:50:37 +0100 Subject: [PATCH] Bug 851996, Simplify MessageEvent's jsval handling, r=mccr8 --HG-- extra : rebase_source : d9c6b59555d6672c03068e9c5bae65712007515a --- content/events/src/nsDOMMessageEvent.cpp | 30 +++--------------------- content/events/src/nsDOMMessageEvent.h | 4 ---- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/content/events/src/nsDOMMessageEvent.cpp b/content/events/src/nsDOMMessageEvent.cpp index e859208db818..9ffc20883489 100644 --- a/content/events/src/nsDOMMessageEvent.cpp +++ b/content/events/src/nsDOMMessageEvent.cpp @@ -9,9 +9,7 @@ #include "nsDOMClassInfoID.h" NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent) - if (tmp->mDataRooted) { - tmp->UnrootData(); - } + tmp->mData = JSVAL_VOID; NS_IMPL_CYCLE_COLLECTION_UNLINK(mSource) NS_IMPL_CYCLE_COLLECTION_UNLINK_END @@ -37,31 +35,13 @@ nsDOMMessageEvent::nsDOMMessageEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, nsEvent* aEvent) : nsDOMEvent(aOwner, aPresContext, aEvent), - mData(JSVAL_VOID), - mDataRooted(false) + mData(JSVAL_VOID) { SetIsDOMBinding(); } nsDOMMessageEvent::~nsDOMMessageEvent() { - if (mDataRooted) - UnrootData(); -} - -void -nsDOMMessageEvent::RootData() -{ - NS_ASSERTION(!mDataRooted, "..."); - NS_HOLD_JS_OBJECTS(this, nsDOMMessageEvent); - mDataRooted = true; -} - -void -nsDOMMessageEvent::UnrootData() -{ - NS_ASSERTION(mDataRooted, "..."); - mDataRooted = false; mData = JSVAL_VOID; NS_DROP_JS_OBJECTS(this, nsDOMMessageEvent); } @@ -108,12 +88,8 @@ nsDOMMessageEvent::InitMessageEvent(const nsAString& aType, nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable); NS_ENSURE_SUCCESS(rv, rv); - // Allowing double-initialization seems a little silly, but we have a test - // for it so it might be important ... - if (mDataRooted) - UnrootData(); mData = aData; - RootData(); + NS_HOLD_JS_OBJECTS(this, nsDOMMessageEvent); mOrigin = aOrigin; mLastEventId = aLastEventId; mSource = aSource; diff --git a/content/events/src/nsDOMMessageEvent.h b/content/events/src/nsDOMMessageEvent.h index 8ef9242affd0..64681cf7fd23 100644 --- a/content/events/src/nsDOMMessageEvent.h +++ b/content/events/src/nsDOMMessageEvent.h @@ -36,9 +36,6 @@ public: // Forward to base class NS_FORWARD_TO_NSDOMEVENT - void RootData(); - void UnrootData(); - virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope) { return mozilla::dom::MessageEventBinding::Wrap(aCx, aScope, this); @@ -73,7 +70,6 @@ public: private: JS::Value mData; - bool mDataRooted; nsString mOrigin; nsString mLastEventId; nsCOMPtr mSource;