Back to index

lightning-sunbird  0.9+nobinonly
nsLSEvent.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.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Johnny Stenback <jst@mozilla.jstenback.com> (original author)
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 "nsLSEvent.h"
00040 #include "nsAutoPtr.h"
00041 #include "nsIDOMDocument.h"
00042 #include "nsIDOMDOMImplementation.h"
00043 #include "nsIDOMEventListener.h"
00044 #include "nsIDOMEventTarget.h"
00045 
00046 #include "nsIDOMClassInfo.h"
00047 
00048 #include "prtime.h"
00049 
00050 
00051 // QueryInterface implementation for nsLSEvent
00052 NS_IMPL_ISUPPORTS1(nsLSEvent, nsIDOMEvent)
00053 
00054 nsLSEvent::nsLSEvent()
00055   : mTime(PR_Now())
00056 {
00057 }
00058 
00059 nsLSEvent::~nsLSEvent()
00060 {
00061 }
00062 
00063 NS_IMETHODIMP
00064 nsLSEvent::GetType(nsAString & aType)
00065 {
00066   return GetTypeInternal(aType);
00067 }
00068 
00069 NS_IMETHODIMP
00070 nsLSEvent::GetTarget(nsIDOMEventTarget * *aTarget)
00071 {
00072   return GetTargetInternal(aTarget);
00073 }
00074 
00075 NS_IMETHODIMP
00076 nsLSEvent::GetCurrentTarget(nsIDOMEventTarget * *aCurrentTarget)
00077 {
00078   return GetTargetInternal(aCurrentTarget);
00079 }
00080 
00081 NS_IMETHODIMP
00082 nsLSEvent::GetEventPhase(PRUint16 *aEventPhase)
00083 {
00084   *aEventPhase = AT_TARGET;
00085 
00086   return NS_OK;
00087 }
00088 
00089 NS_IMETHODIMP
00090 nsLSEvent::GetBubbles(PRBool *aBubbles)
00091 {
00092   *aBubbles = PR_FALSE;
00093 
00094   return NS_OK;
00095 }
00096 
00097 NS_IMETHODIMP
00098 nsLSEvent::GetCancelable(PRBool *aCancelable)
00099 {
00100   *aCancelable = PR_FALSE;
00101 
00102   return NS_OK;
00103 }
00104 
00105 NS_IMETHODIMP
00106 nsLSEvent::GetTimeStamp(PRUint64 *aTimeStamp)
00107 {
00108   // XXX: We want to return in ms, right?
00109   LL_DIV(*aTimeStamp, mTime, PR_MSEC_PER_SEC);
00110 
00111   return NS_OK;
00112 }
00113 
00114 NS_IMETHODIMP
00115 nsLSEvent::StopPropagation()
00116 {
00117   return NS_OK;
00118 }
00119 
00120 NS_IMETHODIMP
00121 nsLSEvent::PreventDefault()
00122 {
00123   return NS_OK;
00124 }
00125 
00126 NS_IMETHODIMP
00127 nsLSEvent::InitEvent(const nsAString & eventTypeArg, PRBool canBubbleArg,
00128                      PRBool cancelableArg)
00129 {
00130   return NS_ERROR_NOT_IMPLEMENTED;
00131 }
00132 
00133 
00134 // QueryInterface implementation for nsLSParserLoadEvent
00135 NS_INTERFACE_MAP_BEGIN(nsLSParserLoadEvent)
00136   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsLSEvent)
00137   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEvent, nsLSEvent)
00138   NS_INTERFACE_MAP_ENTRY(nsIDOMLSLoadEvent)
00139   NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(LSLoadEvent)
00140 NS_INTERFACE_MAP_END
00141 
00142 
00143 NS_IMPL_ADDREF(nsLSParserLoadEvent)
00144 NS_IMPL_RELEASE(nsLSParserLoadEvent)
00145 
00146 
00147 nsresult
00148 nsLSParserLoadEvent::GetTargetInternal(nsIDOMEventTarget **aTarget)
00149 {
00150   NS_ADDREF(*aTarget = mParser.get());
00151 
00152   return NS_OK;
00153 }
00154 
00155 nsresult
00156 nsLSParserLoadEvent::GetTypeInternal(nsAString& aType)
00157 {
00158   aType.AssignLiteral("ls-load");
00159 
00160   return NS_OK;
00161 }
00162 
00163 NS_IMETHODIMP
00164 nsLSParserLoadEvent::GetNewDocument(nsIDOMDocument **aNewDocument)
00165 {
00166   return mParser->XMLHttpRequest()->GetResponseXML(aNewDocument);
00167 }
00168 
00169 NS_IMETHODIMP
00170 nsLSParserLoadEvent::GetInput(nsIDOMLSInput **aInput)
00171 {
00172   return NS_ERROR_NOT_IMPLEMENTED;
00173 }
00174