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
4 : *
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/
9 : *
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
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is the Mozilla Corporation.
18 : * Portions created by the Initial Developer are Copyright (C) 2009
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Alternatively, the contents of this file may be used under the terms of
22 : * either of the GNU General Public License Version 2 or later (the "GPL"),
23 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
24 : * in which case the provisions of the GPL or the LGPL are applicable instead
25 : * of those above. If you wish to allow use of your version of this file only
26 : * under the terms of either the GPL or the LGPL, and not to allow others to
27 : * use your version of this file under the terms of the MPL, indicate your
28 : * decision by deleting the provisions above and replace them with the notice
29 : * and other provisions required by the GPL or the LGPL. If you do not delete
30 : * the provisions above, a recipient may use your version of this file under
31 : * the terms of any one of the MPL, the GPL or the LGPL.
32 : *
33 : * ***** END LICENSE BLOCK ***** */
34 :
35 : #include "nsDOMPopStateEvent.h"
36 : #include "nsCycleCollectionParticipant.h"
37 : #include "nsDOMClassInfoID.h"
38 : #include "nsIClassInfo.h"
39 : #include "nsIXPCScriptable.h"
40 : #include "DictionaryHelpers.h"
41 :
42 1464 : NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMPopStateEvent)
43 :
44 0 : NS_IMPL_ADDREF_INHERITED(nsDOMPopStateEvent, nsDOMEvent)
45 0 : NS_IMPL_RELEASE_INHERITED(nsDOMPopStateEvent, nsDOMEvent)
46 :
47 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMPopStateEvent, nsDOMEvent)
48 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mState)
49 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
50 :
51 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMPopStateEvent, nsDOMEvent)
52 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mState)
53 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
54 :
55 : DOMCI_DATA(PopStateEvent, nsDOMPopStateEvent)
56 :
57 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMPopStateEvent)
58 0 : NS_INTERFACE_MAP_ENTRY(nsIDOMPopStateEvent)
59 0 : NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PopStateEvent)
60 0 : NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
61 :
62 0 : nsDOMPopStateEvent::~nsDOMPopStateEvent()
63 : {
64 0 : }
65 :
66 : NS_IMETHODIMP
67 0 : nsDOMPopStateEvent::GetState(nsIVariant **aState)
68 : {
69 0 : NS_PRECONDITION(aState, "null state arg");
70 0 : NS_IF_ADDREF(*aState = mState);
71 0 : return NS_OK;
72 : }
73 :
74 : NS_IMETHODIMP
75 0 : nsDOMPopStateEvent::InitPopStateEvent(const nsAString &aTypeArg,
76 : bool aCanBubbleArg,
77 : bool aCancelableArg,
78 : nsIVariant *aStateArg)
79 : {
80 0 : nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
81 0 : NS_ENSURE_SUCCESS(rv, rv);
82 :
83 0 : mState = aStateArg;
84 0 : return NS_OK;
85 : }
86 :
87 : nsresult
88 0 : nsDOMPopStateEvent::InitFromCtor(const nsAString& aType,
89 : JSContext* aCx, jsval* aVal)
90 : {
91 0 : mozilla::dom::PopStateEventInit d;
92 0 : nsresult rv = d.Init(aCx, aVal);
93 0 : NS_ENSURE_SUCCESS(rv, rv);
94 0 : return InitPopStateEvent(aType, d.bubbles, d.cancelable, d.state);
95 : }
96 :
97 0 : nsresult NS_NewDOMPopStateEvent(nsIDOMEvent** aInstancePtrResult,
98 : nsPresContext* aPresContext,
99 : nsEvent* aEvent)
100 : {
101 : nsDOMPopStateEvent* event =
102 0 : new nsDOMPopStateEvent(aPresContext, aEvent);
103 :
104 0 : if (!event) {
105 0 : return NS_ERROR_OUT_OF_MEMORY;
106 : }
107 :
108 0 : return CallQueryInterface(event, aInstancePtrResult);
109 4392 : }
|