1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2007
20 * the Initial Developer. All Rights Reserved.
23 * Jeff Walden <jwalden+code@mit.edu> (original author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "nsDOMMessageEvent.h"
40 #include "nsContentUtils.h"
42 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMessageEvent
)
44 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMessageEvent
, nsDOMEvent
)
45 NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSource
)
46 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
48 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMMessageEvent
, nsDOMEvent
)
49 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSource
)
50 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
52 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMMessageEvent
)
53 NS_INTERFACE_MAP_ENTRY(nsIDOMMessageEvent
)
54 NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(MessageEvent
)
55 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent
)
57 NS_IMPL_ADDREF_INHERITED(nsDOMMessageEvent
, nsDOMEvent
)
58 NS_IMPL_RELEASE_INHERITED(nsDOMMessageEvent
, nsDOMEvent
)
61 nsDOMMessageEvent::GetData(nsAString
& aData
)
68 nsDOMMessageEvent::GetOrigin(nsAString
& aOrigin
)
75 nsDOMMessageEvent::GetSource(nsIDOMWindow
** aSource
)
77 NS_IF_ADDREF(*aSource
= mSource
);
82 nsDOMMessageEvent::InitMessageEvent(const nsAString
& aType
,
85 const nsAString
& aData
,
86 const nsAString
& aOrigin
,
87 nsIDOMWindow
* aSource
)
89 nsresult rv
= nsDOMEvent::InitEvent(aType
, aCanBubble
, aCancelable
);
90 NS_ENSURE_SUCCESS(rv
, rv
);
100 nsDOMMessageEvent::InitMessageEventNS(const nsAString
& aNamespaceURI
,
101 const nsAString
& aType
,
104 const nsAString
& aData
,
105 const nsAString
& aOrigin
,
106 nsIDOMWindow
* aSource
)
108 return NS_ERROR_NOT_IMPLEMENTED
;
112 NS_NewDOMMessageEvent(nsIDOMEvent
** aInstancePtrResult
,
113 nsPresContext
* aPresContext
,
116 nsDOMMessageEvent
* it
= new nsDOMMessageEvent(aPresContext
, aEvent
);
118 return NS_ERROR_OUT_OF_MEMORY
;
120 return CallQueryInterface(it
, aInstancePtrResult
);