Bug 782040 - Move ProgressEvent to event impl codegen; r=smaug

This commit is contained in:
Ms2ger 2012-09-06 09:14:49 +02:00
parent 76a28d46c7
commit 36d93492da
11 changed files with 38 additions and 147 deletions

View File

@ -3888,7 +3888,7 @@ nsXMLHttpProgressEvent::nsXMLHttpProgressEvent(nsIDOMProgressEvent* aInner,
nsPIDOMWindow* aWindow)
: mWindow(aWindow)
{
mInner = static_cast<nsDOMProgressEvent*>(aInner);
mInner = aInner;
mCurProgress = aCurrentProgress;
mMaxProgress = aMaxProgress;
}
@ -3918,8 +3918,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXMLHttpProgressEvent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXMLHttpProgressEvent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mInner,
nsIDOMProgressEvent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mInner)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mWindow);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

View File

@ -27,7 +27,7 @@
#include "nsIJSNativeInitializer.h"
#include "nsIDOMLSProgressEvent.h"
#include "nsITimer.h"
#include "nsDOMProgressEvent.h"
#include "nsIDOMProgressEvent.h"
#include "nsDOMEventTargetHelper.h"
#include "nsContentUtils.h"
#include "nsDOMFile.h"
@ -682,9 +682,7 @@ public:
protected:
void WarnAboutLSProgressEvent(nsIDocument::DeprecatedOperations);
// Use nsDOMProgressEvent so that we can forward
// most of the method calls easily.
nsRefPtr<nsDOMProgressEvent> mInner;
nsCOMPtr<nsIDOMProgressEvent> mInner;
nsCOMPtr<nsPIDOMWindow> mWindow;
uint64_t mCurProgress;
uint64_t mMaxProgress;

View File

@ -50,7 +50,6 @@ CPPSRCS = \
nsIMEStateManager.cpp \
nsContentEventHandler.cpp \
nsEventListenerService.cpp \
nsDOMProgressEvent.cpp \
nsDOMDataTransfer.cpp \
nsDOMNotifyPaintEvent.cpp \
nsDOMNotifyAudioAvailableEvent.cpp \

View File

@ -1,69 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsDOMClassInfoID.h"
#include "nsDOMProgressEvent.h"
DOMCI_DATA(ProgressEvent, nsDOMProgressEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMProgressEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMProgressEvent)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ProgressEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMPL_ADDREF_INHERITED(nsDOMProgressEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMProgressEvent, nsDOMEvent)
NS_IMETHODIMP
nsDOMProgressEvent::GetLengthComputable(bool* aLengthComputable)
{
*aLengthComputable = mLengthComputable;
return NS_OK;
}
NS_IMETHODIMP
nsDOMProgressEvent::GetLoaded(uint64_t* aLoaded)
{
*aLoaded = mLoaded;
return NS_OK;
}
NS_IMETHODIMP
nsDOMProgressEvent::GetTotal(uint64_t* aTotal)
{
*aTotal = mTotal;
return NS_OK;
}
NS_IMETHODIMP
nsDOMProgressEvent::InitProgressEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
bool aLengthComputable,
uint64_t aLoaded,
uint64_t aTotal)
{
nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
mLoaded = aLoaded;
mLengthComputable = aLengthComputable;
mTotal = aTotal;
return NS_OK;
}
nsresult
NS_NewDOMProgressEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsEvent* aEvent)
{
nsDOMProgressEvent* it = new nsDOMProgressEvent(aPresContext, aEvent);
if (nullptr == it)
return NS_ERROR_OUT_OF_MEMORY;
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -1,41 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsDOMProgressEvent_h__
#define nsDOMProgressEvent_h__
#include "nsIDOMProgressEvent.h"
#include "nsDOMEvent.h"
/**
* Implements the ProgressEvent event, used for progress events from the media
* elements.
* See http://www.whatwg.org/specs/web-apps/current-work/#progress0 for
* further details.
*/
class nsDOMProgressEvent : public nsDOMEvent,
public nsIDOMProgressEvent
{
public:
nsDOMProgressEvent(nsPresContext* aPresContext, nsEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent)
{
}
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMPROGRESSEVENT
// Forward to base class
NS_FORWARD_TO_NSDOMEVENT
private:
bool mLengthComputable;
uint64_t mLoaded;
uint64_t mTotal;
};
#endif // nsDOMProgressEvent_h__

View File

@ -1524,9 +1524,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#endif
NS_DEFINE_CLASSINFO_DATA(ProgressEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(XMLHttpRequestUpload, nsEventTargetSH,
EVENTTARGET_SCRIPTABLE_FLAGS)
@ -4197,11 +4194,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_END
#endif
DOM_CLASSINFO_MAP_BEGIN(ProgressEvent, nsIDOMProgressEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMProgressEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(XMLHttpRequestUpload, nsIXMLHttpRequestUpload)
DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestUpload)

View File

@ -430,8 +430,6 @@ DOMCI_CLASS(TimeRanges)
DOMCI_CLASS(MediaStream)
#endif
DOMCI_CLASS(ProgressEvent)
DOMCI_CLASS(XMLHttpRequestUpload)
// DOM Traversal NodeIterator class

View File

@ -11,7 +11,7 @@
#include "nsContentUtils.h"
#include "nsEventDispatcher.h"
#include "nsError.h"
#include "nsDOMProgressEvent.h"
#include "nsIDOMProgressEvent.h"
#include "nsDOMClassInfoID.h"
#include "FileHelper.h"
#include "LockedFile.h"
@ -138,9 +138,16 @@ FileRequest::FireProgressEvent(uint64_t aLoaded, uint64_t aTotal)
return;
}
nsRefPtr<nsDOMProgressEvent> event = new nsDOMProgressEvent(nullptr, nullptr);
nsresult rv = event->InitProgressEvent(NS_LITERAL_STRING("progress"),
false, false, false, aLoaded, aTotal);
nsCOMPtr<nsIDOMEvent> event;
nsresult rv = NS_NewDOMProgressEvent(getter_AddRefs(event), nullptr, nullptr);
if (NS_FAILED(rv)) {
return;
}
nsCOMPtr<nsIDOMProgressEvent> progress = do_QueryInterface(event);
MOZ_ASSERT(progress);
rv = progress->InitProgressEvent(NS_LITERAL_STRING("progress"), false, false,
false, aLoaded, aTotal);
if (NS_FAILED(rv)) {
return;
}
@ -151,7 +158,7 @@ FileRequest::FireProgressEvent(uint64_t aLoaded, uint64_t aTotal)
}
bool dummy;
rv = DispatchEvent(static_cast<nsIDOMProgressEvent*>(event), &dummy);
rv = DispatchEvent(event, &dummy);
if (NS_FAILED(rv)) {
return;
}

View File

@ -7,10 +7,7 @@
#include "nsIDOMEvent.idl"
/**
* The nsIDOMProgressEvent is used in the media elements (<video> and <audio>
* to inform of the progress of the media download. It is currently undefined
* in the HTML5 specification. This implementation is a placeholder until
* the specification is complete and is compatible with the WebKit ProgressEvent.
* ProgressEvent can be used for measuring progress.
*/
[scriptable, builtinclass, uuid(c5b7ec31-b846-4a9f-b81e-859e76a74f6b)]
@ -26,3 +23,9 @@ interface nsIDOMProgressEvent : nsIDOMEvent
in unsigned long long loadedArg,
in unsigned long long totalArg);
};
dictionary ProgressEventInit : EventInit {
boolean lengthComputable;
unsigned long long loaded;
unsigned long long total;
};

View File

@ -305,16 +305,6 @@ def write_getter(a, iface, fd):
fd.write(" JSBool b;\n")
fd.write(" MOZ_ALWAYS_TRUE(JS_ValueToBoolean(aCx, v, &b));\n")
fd.write(" aDict.%s = b;\n" % a.name)
elif realtype.count("uint32_t"):
fd.write(" NS_ENSURE_STATE(JS_ValueToECMAUint32(aCx, v, &aDict.%s));\n" % a.name)
elif realtype.count("int32_t"):
fd.write(" NS_ENSURE_STATE(JS_ValueToECMAInt32(aCx, v, &aDict.%s));\n" % a.name)
elif realtype.count("double"):
fd.write(" NS_ENSURE_STATE(JS_ValueToNumber(aCx, v, &aDict.%s));\n" % a.name)
elif realtype.count("float"):
fd.write(" double d;\n")
fd.write(" NS_ENSURE_STATE(JS_ValueToNumber(aCx, v, &d));")
fd.write(" aDict.%s = (float) d;\n" % a.name)
elif realtype.count("uint16_t"):
fd.write(" uint32_t u;\n")
fd.write(" NS_ENSURE_STATE(JS_ValueToECMAUint32(aCx, v, &u));\n")
@ -323,6 +313,20 @@ def write_getter(a, iface, fd):
fd.write(" int32_t i;\n")
fd.write(" NS_ENSURE_STATE(JS_ValueToECMAInt32(aCx, v, &i));\n")
fd.write(" aDict.%s = i;\n" % a.name)
elif realtype.count("uint32_t"):
fd.write(" NS_ENSURE_STATE(JS_ValueToECMAUint32(aCx, v, &aDict.%s));\n" % a.name)
elif realtype.count("int32_t"):
fd.write(" NS_ENSURE_STATE(JS_ValueToECMAInt32(aCx, v, &aDict.%s));\n" % a.name)
elif realtype.count("uint64_t"):
fd.write(" NS_ENSURE_STATE(JS::ToUint64(aCx, v, &aDict.%s));\n" % a.name)
elif realtype.count("int64_t"):
fd.write(" NS_ENSURE_STATE(JS::ToInt64(aCx, v, &aDict.%s));\n" % a.name)
elif realtype.count("double"):
fd.write(" NS_ENSURE_STATE(JS_ValueToNumber(aCx, v, &aDict.%s));\n" % a.name)
elif realtype.count("float"):
fd.write(" double d;\n")
fd.write(" NS_ENSURE_STATE(JS_ValueToNumber(aCx, v, &d));")
fd.write(" aDict.%s = (float) d;\n" % a.name)
elif realtype.count("nsAString"):
if a.nullable:
fd.write(" xpc_qsDOMString d(aCx, v, &v, xpc_qsDOMString::eNull, xpc_qsDOMString::eNull);\n")

View File

@ -8,6 +8,7 @@
<name>Init dictionary for the event constructor. """
simple_events = [
'ProgressEvent',
'StorageEvent',
'DeviceProximityEvent',
'MozSettingsEvent',