Bug 851996, Simplify MessageEvent's jsval handling, r=mccr8

--HG--
extra : rebase_source : d9c6b59555d6672c03068e9c5bae65712007515a
This commit is contained in:
Olli Pettay 2013-03-18 16:50:37 +01:00
Родитель 9ecef0e905
Коммит a4c4387df0
2 изменённых файлов: 3 добавлений и 31 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsIDOMWindow> mSource;