Back to index

lightning-sunbird  0.9+nobinonly
nsXFormsDOMEvent.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla XForms support.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * IBM Corporation
00019  * Portions created by the Initial Developer are Copyright (C) 2007
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *  Merle Sterling <msterlin@us.ibm.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "nsXFormsDOMEvent.h"
00040 
00046 // Setup the interface map so that an nsIXFormsDOMEvent can be QI'ed to
00047 // nsIDOMEvent, nsIDOMNSEvent, nsIPrivateDOMEvent, and nsISupports.
00048 //
00049 // nsISupports is ambiguous because all of the interfaces inherit from
00050 // nsISupports. NS_INTERFACE_MAP_ENTRY_AMBIGOUS will cast to the
00051 // nsISupports of nsXFormsDOMEvent.
00052 //
00053 // nsXFormsDOMEvent contains an nsIDOMEvent (mInner) and nsIDOMEvent
00054 // implements nsIDOMNSEvent and nsIPrivateDOMEvent. The event dispatcher
00055 // will QI to those interfaces. We use NS_INTERFACE_MAP_END_AGGREGATED to
00056 // forward QIs for those interfaces to mInner.
00057 
00058 NS_INTERFACE_MAP_BEGIN(nsXFormsDOMEvent)
00059   NS_INTERFACE_MAP_ENTRY(nsIXFormsDOMEvent)
00060   NS_INTERFACE_MAP_ENTRY(nsIDOMEvent)
00061   NS_INTERFACE_MAP_ENTRY(nsIDOMNSEvent)
00062   NS_INTERFACE_MAP_ENTRY(nsIPrivateDOMEvent)
00063   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXFormsDOMEvent)
00064 NS_INTERFACE_MAP_END_AGGREGATED(mInner)
00065 
00066 NS_IMPL_ADDREF(nsXFormsDOMEvent)
00067 NS_IMPL_RELEASE(nsXFormsDOMEvent)
00068 
00069 nsXFormsDOMEvent::nsXFormsDOMEvent(nsIDOMEvent *aInner,
00070                                    nsCOMArray<nsIXFormsContextInfo> *aContextInfo)
00071 {
00072   mInner = aInner;
00073   mContextInfo.Init();
00074   SetContextInfo(aContextInfo);
00075 }
00076 
00077 nsXFormsDOMEvent::~nsXFormsDOMEvent()
00078 {}
00079 
00080 nsresult
00081 nsXFormsDOMEvent::SetContextInfo(nsCOMArray<nsIXFormsContextInfo> *aContextInfo)
00082 {
00083  if (aContextInfo) {
00084    for (int i = 0; i < aContextInfo->Count(); i++) {
00085      nsCOMPtr<nsIXFormsContextInfo> ctxtInfo = aContextInfo->ObjectAt(i);
00086      nsAutoString name;
00087      ctxtInfo->GetName(name);
00088      mContextInfo.Put(name, ctxtInfo);
00089    }
00090  }
00091  return NS_OK;
00092 }
00093 
00094 NS_IMETHODIMP
00095 nsXFormsDOMEvent::GetContextInfo(const nsAString &aName,
00096                                  nsIXFormsContextInfo **aResult)
00097 {
00098   NS_ENSURE_ARG_POINTER(aResult);
00099   mContextInfo.Get(aName, aResult);
00100   return NS_OK;
00101 }
00102 
00103 // nsIDOMNSEvent interface
00104 NS_IMETHODIMP
00105 nsXFormsDOMEvent::GetOriginalTarget(nsIDOMEventTarget **aOriginalTarget)
00106 {
00107   nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(mInner);
00108   return nsevent->GetOriginalTarget(aOriginalTarget);
00109 }
00110 
00111 NS_IMETHODIMP
00112 nsXFormsDOMEvent::GetExplicitOriginalTarget(nsIDOMEventTarget **aExplicitOriginalTarget)
00113 {
00114   nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(mInner);
00115   return nsevent->GetExplicitOriginalTarget(aExplicitOriginalTarget);
00116 }
00117 
00118 NS_IMETHODIMP
00119 nsXFormsDOMEvent::GetTmpRealOriginalTarget(nsIDOMEventTarget **aTmpRealOriginalTarget)
00120 {
00121   nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(mInner);
00122   return nsevent->GetTmpRealOriginalTarget(aTmpRealOriginalTarget);
00123 }
00124 
00125 NS_IMETHODIMP
00126 nsXFormsDOMEvent::PreventBubble(void)
00127 {
00128   nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(mInner);
00129   return nsevent->PreventBubble();
00130 }
00131 
00132 NS_IMETHODIMP
00133 nsXFormsDOMEvent::PreventCapture(void)
00134 {
00135   nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(mInner);
00136   return nsevent->PreventCapture();
00137 }
00138 
00139 NS_IMETHODIMP
00140 nsXFormsDOMEvent::GetIsTrusted(PRBool *aIsTrusted)
00141 {
00142   nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(mInner);
00143   return nsevent->GetIsTrusted(aIsTrusted);
00144 }
00145 
00146 // nsIPrivateDOMEvent interface
00147 NS_METHOD
00148 nsXFormsDOMEvent::DuplicatePrivateData()
00149 {
00150   nsCOMPtr<nsIPrivateDOMEvent> privEvent = do_QueryInterface(mInner);
00151   return privEvent->DuplicatePrivateData();
00152 }
00153 
00154 NS_METHOD
00155 nsXFormsDOMEvent::SetTarget(nsIDOMEventTarget* aTarget)
00156 {
00157   nsCOMPtr<nsIPrivateDOMEvent> privEvent = do_QueryInterface(mInner);
00158   return privEvent->SetTarget(aTarget);
00159 }
00160 
00161 NS_METHOD
00162 nsXFormsDOMEvent::SetCurrentTarget(nsIDOMEventTarget* aTarget)
00163 {
00164   nsCOMPtr<nsIPrivateDOMEvent> privEvent = do_QueryInterface(mInner);
00165   return privEvent->SetCurrentTarget(aTarget);
00166 }
00167 
00168 NS_METHOD
00169 nsXFormsDOMEvent::SetOriginalTarget(nsIDOMEventTarget* aTarget)
00170 {
00171   nsCOMPtr<nsIPrivateDOMEvent> privEvent = do_QueryInterface(mInner);
00172   return privEvent->SetOriginalTarget(aTarget);
00173 }
00174 
00175 NS_METHOD
00176 nsXFormsDOMEvent::IsDispatchStopped(PRBool* aIsDispatchPrevented)
00177 {
00178   nsCOMPtr<nsIPrivateDOMEvent> privEvent = do_QueryInterface(mInner);
00179   return privEvent->IsDispatchStopped(aIsDispatchPrevented);
00180 }
00181 
00182 NS_METHOD
00183 nsXFormsDOMEvent::GetInternalNSEvent(nsEvent** aNSEvent)
00184 {
00185   nsCOMPtr<nsIPrivateDOMEvent> privEvent = do_QueryInterface(mInner);
00186   return privEvent->GetInternalNSEvent(aNSEvent);
00187 }
00188 
00189 NS_METHOD
00190 nsXFormsDOMEvent::HasOriginalTarget(PRBool* aResult)
00191 {
00192   nsCOMPtr<nsIPrivateDOMEvent> privEvent = do_QueryInterface(mInner);
00193   return privEvent->HasOriginalTarget(aResult);
00194 }
00195 
00196 NS_METHOD
00197 nsXFormsDOMEvent::SetTrusted(PRBool aTrusted)
00198 {
00199   nsCOMPtr<nsIPrivateDOMEvent> privEvent = do_QueryInterface(mInner);
00200   return privEvent->SetTrusted(aTrusted);
00201 }