Bug 1224061: Make Event::InitEvent infallible. r=smaug

This commit is contained in:
Kyle Huey 2015-11-13 08:09:42 +08:00
Родитель 965f61f745
Коммит bdbb2ec50a
83 изменённых файлов: 94 добавлений и 249 удалений

Просмотреть файл

@ -193,11 +193,7 @@ DOMRequest::FireEvent(const nsAString& aType, bool aBubble, bool aCancelable)
}
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
nsresult rv = event->InitEvent(aType, aBubble, aCancelable);
if (NS_FAILED(rv)) {
return;
}
event->InitEvent(aType, aBubble, aCancelable);
event->SetTrusted(true);
bool dummy;

Просмотреть файл

@ -757,12 +757,7 @@ EventSource::AnnounceConnection()
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
// it doesn't bubble, and it isn't cancelable
rv = event->InitEvent(NS_LITERAL_STRING("open"), false, false);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to init the open event!!!");
return;
}
event->InitEvent(NS_LITERAL_STRING("open"), false, false);
event->SetTrusted(true);
rv = DispatchDOMEvent(nullptr, event, nullptr, nullptr);
@ -813,12 +808,7 @@ EventSource::ReestablishConnection()
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
// it doesn't bubble, and it isn't cancelable
rv = event->InitEvent(NS_LITERAL_STRING("error"), false, false);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to init the error event!!!");
return;
}
event->InitEvent(NS_LITERAL_STRING("error"), false, false);
event->SetTrusted(true);
rv = DispatchDOMEvent(nullptr, event, nullptr, nullptr);
@ -964,12 +954,7 @@ EventSource::FailConnection()
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
// it doesn't bubble, and it isn't cancelable
rv = event->InitEvent(NS_LITERAL_STRING("error"), false, false);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to init the error event!!!");
return;
}
event->InitEvent(NS_LITERAL_STRING("error"), false, false);
event->SetTrusted(true);
rv = DispatchDOMEvent(nullptr, event, nullptr, nullptr);

Просмотреть файл

@ -1807,9 +1807,7 @@ WebSocket::CreateAndDispatchSimpleEvent(const nsAString& aName)
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
// it doesn't bubble, and it isn't cancelable
rv = event->InitEvent(aName, false, false);
NS_ENSURE_SUCCESS(rv, rv);
event->InitEvent(aName, false, false);
event->SetTrusted(true);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);

Просмотреть файл

@ -3756,9 +3756,7 @@ nsresult GetEventAndTarget(nsIDocument* aDoc, nsISupports* aTarget,
domDoc->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
NS_ENSURE_SUCCESS(rv, rv);
rv = event->InitEvent(aEventName, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
event->InitEvent(aEventName, aCanBubble, aCancelable);
event->SetTrusted(aTrusted);
rv = event->SetTarget(target);

Просмотреть файл

@ -455,9 +455,7 @@ nsDOMDataChannel::OnSimpleEvent(nsISupports* aContext, const nsAString& aName)
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
rv = event->InitEvent(aName, false, false);
NS_ENSURE_SUCCESS(rv,rv);
event->InitEvent(aName, false, false);
event->SetTrusted(true);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);

Просмотреть файл

@ -9122,10 +9122,7 @@ DispatchCustomEventWithFlush(nsINode* aTarget, const nsAString& aEventType,
bool aBubbles, bool aOnlyChromeDispatch)
{
RefPtr<Event> event = NS_NewDOMEvent(aTarget, nullptr, nullptr);
nsresult rv = event->InitEvent(aEventType, aBubbles, false);
if (NS_FAILED(rv)) {
return;
}
event->InitEvent(aEventType, aBubbles, false);
event->SetTrusted(true);
if (aOnlyChromeDispatch) {
event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true;

Просмотреть файл

@ -11028,13 +11028,11 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
}
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
nsresult rv = event->InitEvent(
event->InitEvent(
!nsCRT::strcmp(aTopic, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC)
? NETWORK_UPLOAD_EVENT_NAME
: NETWORK_DOWNLOAD_EVENT_NAME,
false, false);
NS_ENSURE_SUCCESS(rv, rv);
event->SetTrusted(true);
bool dummy;
@ -11064,9 +11062,7 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
}
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
nsresult rv = event->InitEvent(NS_LITERAL_STRING("languagechange"), false, false);
NS_ENSURE_SUCCESS(rv, rv);
event->InitEvent(NS_LITERAL_STRING("languagechange"), false, false);
event->SetTrusted(true);
bool dummy;

Просмотреть файл

@ -483,11 +483,7 @@ nsPerformance::DispatchBufferFullEvent()
{
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
// it bubbles, and it isn't cancelable
nsresult rv = event->InitEvent(NS_LITERAL_STRING("resourcetimingbufferfull"),
true, false);
if (NS_FAILED(rv)) {
return;
}
event->InitEvent(NS_LITERAL_STRING("resourcetimingbufferfull"), true, false);
event->SetTrusted(true);
DispatchDOMEvent(nullptr, event, nullptr, nullptr);
}

Просмотреть файл

@ -15977,7 +15977,7 @@ class CGEventMethod(CGNativeMember):
self.args.insert(0, Argument("JSContext*", "aCx"))
if not self.isInit:
self.args.insert(0, Argument("const GlobalObject&", "aGlobal"))
self.args.append(Argument('ErrorResult&', 'aRv'))
self.args.append(Argument('ErrorResult&', 'aRv'))
return constructorForNativeCaller + CGNativeMember.declare(self, cgClass)
def defineInit(self, cgClass):
@ -15999,11 +15999,7 @@ class CGEventMethod(CGNativeMember):
self.body = fill(
"""
nsresult rv = InitEvent(${typeArg}, ${bubblesArg}, ${cancelableArg});
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
}
InitEvent(${typeArg}, ${bubblesArg}, ${cancelableArg});
${members}
""",
typeArg=self.args[0].name,
@ -16011,8 +16007,6 @@ class CGEventMethod(CGNativeMember):
cancelableArg=self.args[2].name,
members=members)
self.args.append(Argument('ErrorResult&', 'aRv'))
return CGNativeMember.define(self, cgClass)
def define(self, cgClass):

Просмотреть файл

@ -44,7 +44,7 @@ AnimationEvent::Constructor(const GlobalObject& aGlobal,
RefPtr<AnimationEvent> e = new AnimationEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
InternalAnimationEvent* internalEvent = e->mEvent->AsAnimationEvent();
internalEvent->animationName = aParam.mAnimationName;

Просмотреть файл

@ -40,8 +40,7 @@ AsyncEventDispatcher::Run()
RefPtr<Event> event = mEvent ? mEvent->InternalDOMEvent() : nullptr;
if (!event) {
event = NS_NewDOMEvent(mTarget, nullptr, nullptr);
nsresult rv = event->InitEvent(mEventType, mBubbles, false);
NS_ENSURE_SUCCESS(rv, rv);
event->InitEvent(mEventType, mBubbles, false);
event->SetTrusted(true);
}
if (mOnlyChromeDispatch) {

Просмотреть файл

@ -43,7 +43,7 @@ ClipboardEvent::InitClipboardEvent(const nsAString& aType,
// Null clipboardData is OK
ErrorResult rv;
InitClipboardEvent(aType, aCanBubble, aCancelable, clipboardData, rv);
InitClipboardEvent(aType, aCanBubble, aCancelable, clipboardData);
return rv.StealNSResult();
}
@ -51,14 +51,9 @@ ClipboardEvent::InitClipboardEvent(const nsAString& aType,
void
ClipboardEvent::InitClipboardEvent(const nsAString& aType, bool aCanBubble,
bool aCancelable,
DataTransfer* aClipboardData,
ErrorResult& aError)
DataTransfer* aClipboardData)
{
aError = Event::InitEvent(aType, aCanBubble, aCancelable);
if (aError.Failed()) {
return;
}
Event::InitEvent(aType, aCanBubble, aCancelable);
mEvent->AsClipboardEvent()->clipboardData = aClipboardData;
}
@ -86,7 +81,7 @@ ClipboardEvent::Constructor(const GlobalObject& aGlobal,
}
e->InitClipboardEvent(aType, aParam.mBubbles, aParam.mCancelable,
clipboardData, aRv);
clipboardData);
e->SetTrusted(trusted);
return e.forget();
}

Просмотреть файл

@ -46,8 +46,7 @@ public:
void InitClipboardEvent(const nsAString& aType, bool aCanBubble,
bool aCancelable,
DataTransfer* aClipboardData,
ErrorResult& aError);
DataTransfer* aClipboardData);
protected:
~ClipboardEvent() {}

Просмотреть файл

@ -51,8 +51,7 @@ CommandEvent::InitCommandEvent(const nsAString& aTypeArg,
bool aCancelableArg,
const nsAString& aCommand)
{
nsresult rv = Event::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
Event::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
mEvent->AsCommandEvent()->command = do_GetAtom(aCommand);
return NS_OK;

Просмотреть файл

@ -66,8 +66,7 @@ CustomEvent::InitCustomEvent(const nsAString& aType,
bool aCancelable,
nsIVariant* aDetail)
{
nsresult rv = Event::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
Event::InitEvent(aType, aCanBubble, aCancelable);
mDetail = aDetail;
return NS_OK;
}
@ -89,7 +88,7 @@ CustomEvent::InitCustomEvent(JSContext* aCx,
aRv.Throw(NS_ERROR_FAILURE);
return;
}
aRv = InitCustomEvent(aType, aCanBubble, aCancelable, detail);
InitCustomEvent(aType, aCanBubble, aCancelable, detail);
}
NS_IMETHODIMP

Просмотреть файл

@ -263,8 +263,7 @@ nsresult
DOMEventTargetHelper::DispatchTrustedEvent(const nsAString& aEventName)
{
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
nsresult rv = event->InitEvent(aEventName, false, false);
NS_ENSURE_SUCCESS(rv, rv);
event->InitEvent(aEventName, false, false);
return DispatchTrustedEvent(event);
}

Просмотреть файл

@ -33,13 +33,9 @@ DeviceMotionEvent::InitDeviceMotionEvent(
const DeviceAccelerationInit& aAcceleration,
const DeviceAccelerationInit& aAccelIncludingGravity,
const DeviceRotationRateInit& aRotationRate,
Nullable<double> aInterval,
ErrorResult& aRv)
Nullable<double> aInterval)
{
aRv = Event::InitEvent(aType, aCanBubble, aCancelable);
if (aRv.Failed()) {
return;
}
Event::InitEvent(aType, aCanBubble, aCancelable);
mAcceleration = new DeviceAcceleration(this, aAcceleration.mX,
aAcceleration.mY,
@ -64,10 +60,7 @@ DeviceMotionEvent::Constructor(const GlobalObject& aGlobal,
{
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
RefPtr<DeviceMotionEvent> e = new DeviceMotionEvent(t, nullptr, nullptr);
aRv = e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
if (aRv.Failed()) {
return nullptr;
}
e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
bool trusted = e->Init(t);
e->mAcceleration = new DeviceAcceleration(e,

Просмотреть файл

@ -128,8 +128,7 @@ public:
const DeviceAccelerationInit& aAcceleration,
const DeviceAccelerationInit& aAccelerationIncludingGravity,
const DeviceRotationRateInit& aRotationRate,
Nullable<double> aInterval,
ErrorResult& aRv);
Nullable<double> aInterval);
static already_AddRefed<DeviceMotionEvent>
Constructor(const GlobalObject& aGlobal,

Просмотреть файл

@ -414,7 +414,7 @@ Event::Constructor(const GlobalObject& aGlobal,
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
RefPtr<Event> e = new Event(t, nullptr, nullptr);
bool trusted = e->Init(t);
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
e->SetTrusted(trusted);
return e.forget();
}
@ -572,13 +572,13 @@ Event::SetEventType(const nsAString& aEventTypeArg)
}
}
NS_IMETHODIMP
void
Event::InitEvent(const nsAString& aEventTypeArg,
bool aCanBubbleArg,
bool aCancelableArg)
{
// Make sure this event isn't already being dispatched.
NS_ENSURE_TRUE(!mEvent->mFlags.mIsBeingDispatched, NS_OK);
NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
if (IsTrusted()) {
// Ensure the caller is permitted to dispatch trusted DOM events.
@ -600,7 +600,6 @@ Event::InitEvent(const nsAString& aEventTypeArg,
// re-dispatching it.
mEvent->target = nullptr;
mEvent->originalTarget = nullptr;
return NS_OK;
}
NS_IMETHODIMP
@ -1190,8 +1189,7 @@ Event::Deserialize(const IPC::Message* aMsg, void** aIter)
bool trusted = false;
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &trusted), false);
nsresult rv = InitEvent(type, bubbles, cancelable);
NS_ENSURE_SUCCESS(rv, false);
InitEvent(type, bubbles, cancelable);
SetTrusted(trusted);
return true;

Просмотреть файл

@ -206,12 +206,6 @@ public:
double TimeStamp() const;
void InitEvent(const nsAString& aType, bool aBubbles, bool aCancelable,
ErrorResult& aRv)
{
aRv = InitEvent(aType, aBubbles, aCancelable);
}
EventTarget* GetOriginalTarget() const;
EventTarget* GetExplicitOriginalTarget() const;
EventTarget* GetComposedTarget() const;
@ -312,7 +306,7 @@ private:
NS_IMETHOD StopPropagation(void) override { return _to StopPropagation(); } \
NS_IMETHOD StopCrossProcessForwarding(void) override { return _to StopCrossProcessForwarding(); } \
NS_IMETHOD PreventDefault(void) override { return _to PreventDefault(); } \
NS_IMETHOD InitEvent(const nsAString& eventTypeArg, bool canBubbleArg, bool cancelableArg) override { return _to InitEvent(eventTypeArg, canBubbleArg, cancelableArg); } \
void InitEvent(const nsAString& eventTypeArg, bool canBubbleArg, bool cancelableArg) override { _to InitEvent(eventTypeArg, canBubbleArg, cancelableArg); } \
NS_IMETHOD GetDefaultPrevented(bool* aDefaultPrevented) override { return _to GetDefaultPrevented(aDefaultPrevented); } \
NS_IMETHOD StopImmediatePropagation(void) override { return _to StopImmediatePropagation(); } \
NS_IMETHOD GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget) override { return _to GetOriginalTarget(aOriginalTarget); } \

Просмотреть файл

@ -131,11 +131,7 @@ MessageEvent::Constructor(EventTarget* aEventTarget,
{
RefPtr<MessageEvent> event = new MessageEvent(aEventTarget, nullptr, nullptr);
aRv = event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
if (aRv.Failed()) {
return nullptr;
}
event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
bool trusted = event->Init(aEventTarget);
event->SetTrusted(trusted);
@ -182,9 +178,7 @@ MessageEvent::InitMessageEvent(const nsAString& aType,
const nsAString& aLastEventId,
nsIDOMWindow* aSource)
{
nsresult rv = Event::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
Event::InitEvent(aType, aCanBubble, aCancelable);
mData = aData;
mozilla::HoldJSObjects(this);
mOrigin = aOrigin;
@ -201,14 +195,9 @@ MessageEvent::InitMessageEvent(JSContext* aCx, const nsAString& aType,
const nsAString& aOrigin,
const nsAString& aLastEventId,
const Nullable<WindowProxyOrMessagePort>& aSource,
const Nullable<Sequence<OwningNonNull<MessagePort>>>& aPorts,
ErrorResult& aRv)
const Nullable<Sequence<OwningNonNull<MessagePort>>>& aPorts)
{
aRv = Event::InitEvent(aType, aCanBubble, aCancelable);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
Event::InitEvent(aType, aCanBubble, aCancelable);
mData = aData;
mozilla::HoldJSObjects(this);
mOrigin = aOrigin;

Просмотреть файл

@ -83,8 +83,7 @@ public:
bool aCancelable, JS::Handle<JS::Value> aData,
const nsAString& aOrigin, const nsAString& aLastEventId,
const Nullable<WindowProxyOrMessagePort>& aSource,
const Nullable<Sequence<OwningNonNull<MessagePort>>>& aPorts,
ErrorResult& aRv);
const Nullable<Sequence<OwningNonNull<MessagePort>>>& aPorts);
protected:
~MessageEvent();

Просмотреть файл

@ -96,8 +96,7 @@ MutationEvent::InitMutationEvent(const nsAString& aTypeArg,
const nsAString& aAttrNameArg,
uint16_t aAttrChangeArg)
{
nsresult rv = Event::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
Event::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
InternalMutationEvent* mutation = mEvent->AsMutationEvent();
mutation->mRelatedNode = aRelatedNodeArg;

Просмотреть файл

@ -29,7 +29,7 @@ SpeechRecognitionError::Constructor(const GlobalObject& aGlobal,
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
RefPtr<SpeechRecognitionError> e = new SpeechRecognitionError(t, nullptr, nullptr);
bool trusted = e->Init(t);
e->InitSpeechRecognitionError(aType, aParam.mBubbles, aParam.mCancelable, aParam.mError, aParam.mMessage, aRv);
e->InitSpeechRecognitionError(aType, aParam.mBubbles, aParam.mCancelable, aParam.mError, aParam.mMessage);
e->SetTrusted(trusted);
return e.forget();
}
@ -39,15 +39,11 @@ SpeechRecognitionError::InitSpeechRecognitionError(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
SpeechRecognitionErrorCode aError,
const nsAString& aMessage,
ErrorResult& aRv)
const nsAString& aMessage)
{
aRv = Event::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_TRUE_VOID(!aRv.Failed());
Event::InitEvent(aType, aCanBubble, aCancelable);
mError = aError;
mMessage = aMessage;
return;
}
} // namespace dom

Просмотреть файл

@ -49,8 +49,7 @@ public:
bool aCanBubble,
bool aCancelable,
SpeechRecognitionErrorCode aError,
const nsAString& aMessage,
ErrorResult& aRv);
const nsAString& aMessage);
protected:
SpeechRecognitionErrorCode mError;

Просмотреть файл

@ -85,14 +85,9 @@ StorageEvent::InitStorageEvent(const nsAString& aType, bool aCanBubble,
const nsAString& aOldValue,
const nsAString& aNewValue,
const nsAString& aURL,
DOMStorage* aStorageArea,
ErrorResult& aRv)
DOMStorage* aStorageArea)
{
aRv = InitEvent(aType, aCanBubble, aCancelable);
if (aRv.Failed()) {
return;
}
InitEvent(aType, aCanBubble, aCancelable);
mKey = aKey;
mOldValue = aOldValue;
mNewValue = aNewValue;

Просмотреть файл

@ -57,8 +57,7 @@ public:
const nsAString& aOldValue,
const nsAString& aNewValue,
const nsAString& aURL,
DOMStorage* aStorageArea,
ErrorResult& aRv);
DOMStorage* aStorageArea);
void GetKey(nsString& aRetVal) const
{

Просмотреть файл

@ -102,14 +102,9 @@ TouchEvent::InitTouchEvent(const nsAString& aType,
bool aMetaKey,
TouchList* aTouches,
TouchList* aTargetTouches,
TouchList* aChangedTouches,
ErrorResult& aRv)
TouchList* aChangedTouches)
{
aRv = UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
if (aRv.Failed()) {
return;
}
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
mEvent->AsInputEvent()->InitBasicModifiers(aCtrlKey, aAltKey,
aShiftKey, aMetaKey);
mTouches = aTouches;

Просмотреть файл

@ -115,8 +115,7 @@ public:
bool aMetaKey,
TouchList* aTouches,
TouchList* aTargetTouches,
TouchList* aChangedTouches,
ErrorResult& aRv);
TouchList* aChangedTouches);
static bool PrefEnabled(JSContext* aCx = nullptr,
JSObject* aGlobal = nullptr);

Просмотреть файл

@ -44,7 +44,7 @@ TransitionEvent::Constructor(const GlobalObject& aGlobal,
RefPtr<TransitionEvent> e = new TransitionEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
InternalTransitionEvent* internalEvent = e->mEvent->AsTransitionEvent();
internalEvent->propertyName = aParam.mPropertyName;

Просмотреть файл

@ -161,9 +161,7 @@ UIEvent::InitUIEvent(const nsAString& typeArg,
nsCOMPtr<nsPIDOMWindow> view = do_QueryInterface(viewArg);
NS_ENSURE_TRUE(view, NS_ERROR_INVALID_ARG);
}
nsresult rv = Event::InitEvent(typeArg, canBubbleArg, cancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
Event::InitEvent(typeArg, canBubbleArg, cancelableArg);
mDetail = detailArg;
mView = viewArg;

Просмотреть файл

@ -35,10 +35,9 @@ CreateGenericEvent(EventTarget* aOwner,
{
RefPtr<Event> event = new Event(aOwner, nullptr, nullptr);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
event->InitEvent(aType,
aBubbles == eDoesBubble ? true : false,
aCancelable == eCancelable ? true : false)));
event->InitEvent(aType,
aBubbles == eDoesBubble ? true : false,
aCancelable == eCancelable ? true : false);
event->SetTrusted(true);
@ -58,7 +57,7 @@ IDBVersionChangeEvent::CreateInternal(EventTarget* aOwner,
event->mNewVersion.SetValue(aNewVersion.Value());
}
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(event->InitEvent(aType, false, false)));
event->InitEvent(aType, false, false);
event->SetTrusted(true);

Просмотреть файл

@ -11,7 +11,7 @@
* http://dev.w3.org/csswg/css3-animations/#animation-events-
*/
[builtinclass, uuid(b1bea1bc-689b-4e07-8cbc-ef342725f9a6)]
[builtinclass, uuid(772c7069-3f7d-42cf-97ab-b32f1c0b83da)]
interface nsIDOMAnimationEvent : nsIDOMEvent {
readonly attribute DOMString animationName;
readonly attribute float elapsedTime;

Просмотреть файл

@ -15,7 +15,7 @@
*
*/
[builtinclass, uuid(ee7b8943-440e-4cc3-b25e-c17c8a821d8b)]
[builtinclass, uuid(96abf41b-32a8-4ff6-a0d6-4ade4ddebf89)]
interface nsIDOMBeforeUnloadEvent : nsIDOMEvent
{
/**

Просмотреть файл

@ -8,7 +8,7 @@
interface nsIDOMDataTransfer;
[builtinclass, uuid(8D92944A-F2E5-41F4-9CF3-D85043B90CAC)]
[builtinclass, uuid(4ef84980-52c2-425c-b41a-2ee75ec5d497)]
interface nsIDOMClipboardEvent : nsIDOMEvent
{
readonly attribute nsIDOMDataTransfer clipboardData;

Просмотреть файл

@ -5,7 +5,7 @@
#include "nsIDOMEvent.idl"
[builtinclass, uuid(3fdc07cb-3b2e-4c6e-a054-008a4f302202)]
[builtinclass, uuid(7efbe68a-811a-4159-801c-226948cfd08f)]
interface nsIDOMCommandEvent : nsIDOMEvent
{
readonly attribute DOMString command;

Просмотреть файл

@ -6,7 +6,7 @@
#include "nsIDOMUIEvent.idl"
[builtinclass, uuid(ef545b90-a5f4-471c-b4f8-03b5e0f6fda2)]
[builtinclass, uuid(5adfd99b-d3c7-4c6d-92d1-527264a71b50)]
interface nsIDOMCompositionEvent : nsIDOMUIEvent
{
readonly attribute DOMString data;

Просмотреть файл

@ -6,7 +6,7 @@
#include "nsIDOMEvent.idl"
interface nsIVariant;
[builtinclass, uuid(b56ae6ca-c822-489e-be71-2a9f3c56082e)]
[builtinclass, uuid(55fa3a13-4812-45a7-98b7-3be6cec2df43)]
interface nsIDOMCustomEvent : nsIDOMEvent
{

Просмотреть файл

@ -6,7 +6,7 @@
#include "nsIDOMEvent.idl"
#include "nsIVariant.idl"
[builtinclass, uuid(dc6b39da-87ff-4b6f-b065-b52602602e06)]
[builtinclass, uuid(31ceb43e-5f49-43bf-9a18-3b60a535c814)]
interface nsIDOMDataContainerEvent : nsIDOMEvent
{
/**

Просмотреть файл

@ -8,7 +8,7 @@
interface nsIDOMDataTransfer;
[builtinclass, uuid(4d0fe952-7ca7-4730-a163-4454e39ed187)]
[builtinclass, uuid(12aabbe9-7c70-4bf9-b133-a8d6a120679e)]
interface nsIDOMDragEvent : nsIDOMMouseEvent
{
readonly attribute nsIDOMDataTransfer dataTransfer;

Просмотреть файл

@ -40,7 +40,7 @@ class EventTarget;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[builtinclass, uuid(63857daf-c084-4ea6-a8b9-6812e3176991)]
[builtinclass, uuid(f58daacf-4d1a-4002-8fd7-06b614dfbcf6)]
interface nsIDOMEvent : nsISupports
{
// PhaseType
@ -161,6 +161,7 @@ interface nsIDOMEvent : nsISupports
* @param cancelableArg Specifies whether or not the event's default
* action can be prevented.
*/
[notxpcom]
void initEvent(in DOMString eventTypeArg,
in boolean canBubbleArg,
in boolean cancelableArg);

Просмотреть файл

@ -5,7 +5,7 @@
#include "nsIDOMUIEvent.idl"
[builtinclass, uuid(4faecbd6-1bcd-42d8-bc66-ec6b95050063)]
[builtinclass, uuid(f2606aee-1801-4e4c-9700-af99e435c02c)]
interface nsIDOMFocusEvent : nsIDOMUIEvent
{
readonly attribute nsIDOMEventTarget relatedTarget;

Просмотреть файл

@ -5,7 +5,7 @@
#include "nsIDOMUIEvent.idl"
[builtinclass, uuid(d2b3e35f-8627-4732-a92d-cda54c8f8054)]
[builtinclass, uuid(f4082a63-73c0-49ad-86e0-c406a54573f7)]
interface nsIDOMKeyEvent : nsIDOMUIEvent
{
const unsigned long DOM_VK_CANCEL = 0x03;

Просмотреть файл

@ -12,7 +12,7 @@
* For more information on this interface, please see
* http://www.whatwg.org/specs/web-apps/current-work/#messageevent
*/
[builtinclass, uuid(bb869a03-5fc0-4a1b-838a-342e5025fc05)]
[builtinclass, uuid(4408a2f5-614f-40a3-8786-e16bd3f74e32)]
interface nsIDOMMessageEvent : nsIDOMEvent
{
/**

Просмотреть файл

@ -13,7 +13,7 @@
* http://www.w3.org/TR/DOM-Level-2-Events/
*/
[builtinclass, uuid(df068636-9a5b-11e3-b71f-2c27d728e7f9)]
[builtinclass, uuid(dbebc4be-75c9-47ca-aee8-0a8b4ae14a87)]
interface nsIDOMMouseEvent : nsIDOMUIEvent
{
readonly attribute long screenX;

Просмотреть файл

@ -5,7 +5,7 @@
#include "nsIDOMMouseEvent.idl"
[builtinclass, uuid(2bce5c03-5bed-4c22-8a6a-a3ac8f5563d7)]
[builtinclass, uuid(00404ebe-4598-4c4e-a60a-d7491922f9db)]
interface nsIDOMMouseScrollEvent : nsIDOMMouseEvent
{
const long HORIZONTAL_AXIS = 1;

Просмотреть файл

@ -5,7 +5,7 @@
#include "nsIDOMEvent.idl"
[builtinclass, uuid(982d9800-1402-46e5-8ad2-56fb0f4905ef)]
[builtinclass, uuid(df7e4cd9-e41f-4c8e-a764-2e3191d2f463)]
interface nsIDOMMutationEvent : nsIDOMEvent
{
const unsigned short MODIFICATION = 1;

Просмотреть файл

@ -12,7 +12,7 @@ interface nsIDOMPaintRequestList;
* event, which fires at a window when painting has happened in
* that window.
*/
[builtinclass, uuid(ef68f0d5-5b55-4198-9e59-a5e2c57d3adc)]
[builtinclass, uuid(550f660c-65a5-4e17-b828-3dbec7c44304)]
interface nsIDOMNotifyPaintEvent : nsIDOMEvent
{
/**

Просмотреть файл

@ -5,7 +5,7 @@
#include "nsIDOMUIEvent.idl"
[builtinclass, uuid(49ab3d1d-f549-4cdb-904c-f6b6d3a0ec9e)]
[builtinclass, uuid(05aaf2cf-27c3-4d3d-9e55-4c6a4cf700ec)]
interface nsIDOMScrollAreaEvent : nsIDOMUIEvent
{
// Scroll area client rect

Просмотреть файл

@ -104,7 +104,7 @@
* consuming events.
*/
[builtinclass, uuid(d78656ab-9d68-4f03-83f9-7c7bee071aa7)]
[builtinclass, uuid(1b9afbf0-2cf0-4a7b-99bc-cd35dbd5b637)]
interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent
{
/* Swipe direction constants */

Просмотреть файл

@ -11,7 +11,7 @@
* http://dev.w3.org/csswg/css3-transitions/#transition-events-
*/
[builtinclass, uuid(a37171e0-9f43-41ea-a25c-0b78a3329683)]
[builtinclass, uuid(acb69403-0dcb-4db0-9ffc-8a22cc56c4eb)]
interface nsIDOMTransitionEvent : nsIDOMEvent {
readonly attribute DOMString propertyName;
readonly attribute float elapsedTime;

Просмотреть файл

@ -13,7 +13,7 @@
* http://www.w3.org/TR/DOM-Level-2-Events/
*/
[builtinclass, uuid(d73852f8-7bd6-477d-8233-117dbf83860b)]
[builtinclass, uuid(db058d10-1db9-4cf9-bb4c-483c304a137f)]
interface nsIDOMUIEvent : nsIDOMEvent
{
readonly attribute nsIDOMWindow view;

Просмотреть файл

@ -6,7 +6,7 @@
#include "nsIDOMMouseEvent.idl"
[builtinclass, uuid(86e2b577-7e61-4ed5-8ddd-c1533bf07137)]
[builtinclass, uuid(f1ca2983-8559-43d1-be0e-1af8331755fd)]
interface nsIDOMWheelEvent : nsIDOMMouseEvent
{
const unsigned long DOM_DELTA_PIXEL = 0x00;

Просмотреть файл

@ -13,7 +13,7 @@
* http://www.w3.org/TR/SVG/animate.html#InterfaceTimeEvent
*/
[builtinclass, uuid(4a5a5fa6-2783-4171-b8bb-cae4ab06e6ff)]
[builtinclass, uuid(7a1dc95e-2c05-4171-8bde-275f094dda1d)]
interface nsIDOMTimeEvent : nsIDOMEvent
{
readonly attribute long detail;

Просмотреть файл

@ -11,7 +11,7 @@
#include "nsIDOMUIEvent.idl"
[builtinclass, uuid(2d5b6e19-74bb-40af-9aac-59a1e53e3fcc)]
[builtinclass, uuid(8aa1b009-4a88-4c85-bfba-87ee32fd789f)]
interface nsIDOMXULCommandEvent : nsIDOMUIEvent
{
/**

Просмотреть файл

@ -1075,13 +1075,7 @@ MediaRecorder::DispatchSimpleEvent(const nsAString & aStr)
}
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
rv = event->InitEvent(aStr, false, false);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to init the error event!!!");
return;
}
event->InitEvent(aStr, false, false);
event->SetTrusted(true);
rv = DispatchDOMEvent(nullptr, event, nullptr, nullptr);

Просмотреть файл

@ -165,12 +165,7 @@ TextTrackList::CreateAndDispatchChangeEvent()
{
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
nsresult rv = event->InitEvent(NS_LITERAL_STRING("change"), false, false);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to init the change event!");
return;
}
event->InitEvent(NS_LITERAL_STRING("change"), false, false);
event->SetTrusted(true);
nsCOMPtr<nsIRunnable> eventRunner = new TrackEventRunner(this, event);

Просмотреть файл

@ -870,9 +870,8 @@ SpeechRecognition::DispatchError(EventType aErrorType,
RefPtr<SpeechRecognitionError> srError =
new SpeechRecognitionError(nullptr, nullptr, nullptr);
ErrorResult err;
srError->InitSpeechRecognitionError(NS_LITERAL_STRING("error"), true, false,
aErrorCode, aMessage, err);
aErrorCode, aMessage);
RefPtr<SpeechEvent> event = new SpeechEvent(this, aErrorType);
event->mError = srError;

Просмотреть файл

@ -159,8 +159,7 @@ TCPServerSocket::OnStopListening(nsIServerSocket* aServer, nsresult aStatus)
{
if (aStatus != NS_BINDING_ABORTED) {
RefPtr<Event> event = new Event(GetOwner());
nsresult rv = event->InitEvent(NS_LITERAL_STRING("error"), false, false);
NS_ENSURE_SUCCESS(rv, rv);
event->InitEvent(NS_LITERAL_STRING("error"), false, false);
event->SetTrusted(true);
bool dummy;
DispatchEvent(event, &dummy);

Просмотреть файл

@ -175,10 +175,7 @@ DesktopNotification::DispatchNotificationEvent(const nsString& aName)
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
// it doesn't bubble, and it isn't cancelable
nsresult rv = event->InitEvent(aName, false, false);
if (NS_FAILED(rv)) {
return;
}
event->InitEvent(aName, false, false);
event->SetTrusted(true);
DispatchDOMEvent(nullptr, event, nullptr, nullptr);
}

Просмотреть файл

@ -1110,8 +1110,7 @@ Notification::DispatchClickEvent()
{
AssertIsOnTargetThread();
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
nsresult rv = event->InitEvent(NS_LITERAL_STRING("click"), false, true);
NS_ENSURE_SUCCESS(rv, false);
event->InitEvent(NS_LITERAL_STRING("click"), false, true);
event->SetTrusted(true);
WantsPopupControlCheck popupControlCheck(event);
bool doDefaultAction = true;

Просмотреть файл

@ -64,9 +64,8 @@ TimeEvent::InitTimeEvent(const nsAString& aTypeArg,
nsIDOMWindow* aViewArg,
int32_t aDetailArg)
{
nsresult rv = Event::InitEvent(aTypeArg, false /*doesn't bubble*/,
false /*can't cancel*/);
NS_ENSURE_SUCCESS(rv, rv);
Event::InitEvent(aTypeArg, false /*doesn't bubble*/,
false /*can't cancel*/);
mDetail = aDetailArg;
mView = aViewArg;

Просмотреть файл

@ -47,12 +47,6 @@ public:
return mView;
}
void InitTimeEvent(const nsAString& aType, nsIDOMWindow* aView,
int32_t aDetail, ErrorResult& aRv)
{
aRv = InitTimeEvent(aType, aView, aDetail);
}
private:
~TimeEvent() {}

Просмотреть файл

@ -387,15 +387,13 @@ nsDeviceSensors::FireDOMMotionEvent(nsIDOMDocument *domdoc,
DeviceMotionEvent* me = static_cast<DeviceMotionEvent*>(event.get());
ErrorResult rv;
me->InitDeviceMotionEvent(NS_LITERAL_STRING("devicemotion"),
true,
false,
*mLastAcceleration,
*mLastAccelerationIncludingGravity,
*mLastRotationRate,
Nullable<double>(DEFAULT_SENSOR_POLL),
rv);
Nullable<double>(DEFAULT_SENSOR_POLL));
event->SetTrusted(true);

Просмотреть файл

@ -17,7 +17,6 @@ interface CompositionEvent : UIEvent
partial interface CompositionEvent
{
[Throws]
void initCompositionEvent(DOMString typeArg,
boolean canBubbleArg,
boolean cancelableArg,

Просмотреть файл

@ -47,7 +47,6 @@ dictionary DeviceMotionEventInit : EventInit {
// Mozilla extensions.
partial interface DeviceMotionEvent {
[Throws]
void initDeviceMotionEvent(DOMString type,
boolean canBubble,
boolean cancelable,

Просмотреть файл

@ -13,7 +13,6 @@ interface DeviceOrientationEvent : Event
readonly attribute boolean absolute;
// initDeviceOrientationEvent is a Gecko specific deprecated method.
[Throws]
void initDeviceOrientationEvent(DOMString type,
boolean canBubble,
boolean cancelable,

Просмотреть файл

@ -9,7 +9,6 @@ interface DragEvent : MouseEvent
{
readonly attribute DataTransfer? dataTransfer;
[Throws]
void initDragEvent(DOMString type,
boolean canBubble,
boolean cancelable,

Просмотреть файл

@ -43,7 +43,6 @@ interface Event {
[Pure]
readonly attribute DOMHighResTimeStamp timeStamp;
[Throws]
void initEvent(DOMString type, boolean bubbles, boolean cancelable);
};

Просмотреть файл

@ -10,7 +10,6 @@ interface HashChangeEvent : Event
readonly attribute DOMString? oldURL;
readonly attribute DOMString? newURL;
[Throws]
void initHashChangeEvent(DOMString typeArg,
boolean canBubbleArg,
boolean cancelableArg,

Просмотреть файл

@ -224,7 +224,6 @@ interface KeyEvent
// for compatibility with the other web browsers on Windows.
const unsigned long DOM_VK_WIN_OEM_CLEAR = 0xFE;
[Throws]
void initKeyEvent(DOMString type,
boolean canBubble,
boolean cancelable,

Просмотреть файл

@ -42,7 +42,6 @@ interface MessageEvent : Event {
*/
readonly attribute MessagePortList? ports;
[Throws]
void initMessageEvent(DOMString type, boolean bubbles, boolean cancelable,
any data, DOMString origin, DOMString lastEventId,
(WindowProxy or MessagePort)? source,

Просмотреть файл

@ -32,7 +32,6 @@ interface MouseEvent : UIEvent {
readonly attribute long movementY;
// Deprecated in DOM Level 3:
[Throws]
void initMouseEvent(DOMString typeArg,
boolean canBubbleArg,
boolean cancelableArg,
@ -91,7 +90,6 @@ partial interface MouseEvent
readonly attribute unsigned short mozInputSource;
[Throws]
void initNSMouseEvent(DOMString typeArg,
boolean canBubbleArg,
boolean cancelableArg,

Просмотреть файл

@ -11,7 +11,6 @@ interface MouseScrollEvent : MouseEvent
readonly attribute long axis;
[Throws]
void initMouseScrollEvent(DOMString type,
boolean canBubble,
boolean cancelable,

Просмотреть файл

@ -11,7 +11,6 @@ interface ScrollAreaEvent : UIEvent
readonly attribute float width;
readonly attribute float height;
[Throws]
void initScrollAreaEvent(DOMString type,
boolean canBubble,
boolean cancelable,

Просмотреть файл

@ -24,7 +24,6 @@ interface SimpleGestureEvent : MouseEvent
readonly attribute unsigned long clickCount;
[Throws]
void initSimpleGestureEvent(DOMString typeArg,
boolean canBubbleArg,
boolean cancelableArg,

Просмотреть файл

@ -20,7 +20,6 @@ interface StorageEvent : Event
readonly attribute Storage? storageArea;
// Bug 1016053 - This is not spec compliant.
[Throws]
void initStorageEvent(DOMString type,
boolean canBubble,
boolean cancelable,

Просмотреть файл

@ -15,7 +15,6 @@ interface TouchEvent : UIEvent {
readonly attribute boolean ctrlKey;
readonly attribute boolean shiftKey;
[Throws]
void initTouchEvent(DOMString type,
boolean canBubble,
boolean cancelable,

Просмотреть файл

@ -14,7 +14,6 @@ interface XULCommandEvent : UIEvent
readonly attribute Event? sourceEvent;
[Throws]
void initCommandEvent(DOMString type,
boolean canBubble,
boolean cancelable,

Просмотреть файл

@ -142,10 +142,7 @@ ServiceWorkerMessageEvent::Constructor(EventTarget* aEventTarget,
RefPtr<ServiceWorkerMessageEvent> event =
new ServiceWorkerMessageEvent(aEventTarget, nullptr, nullptr);
aRv = event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
bool trusted = event->Init(aEventTarget);
event->SetTrusted(trusted);

Просмотреть файл

@ -572,12 +572,7 @@ private:
RefPtr<Event> event = NS_NewDOMEvent(globalScope, nullptr, nullptr);
nsresult rv = event->InitEvent(NS_LITERAL_STRING("close"), false, false);
if (NS_FAILED(rv)) {
Throw(aCx, rv);
return false;
}
event->InitEvent(NS_LITERAL_STRING("close"), false, false);
event->SetTrusted(true);
globalScope->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
@ -3073,9 +3068,7 @@ WorkerPrivate::OfflineStatusChangeEventInternal(JSContext* aCx, bool aIsOffline)
RefPtr<Event> event = NS_NewDOMEvent(globalScope, nullptr, nullptr);
nsresult rv = event->InitEvent(eventType, false, false);
NS_ENSURE_SUCCESS_VOID(rv);
event->InitEvent(eventType, false, false);
event->SetTrusted(true);
globalScope->DispatchDOMEvent(nullptr, event, nullptr, nullptr);

Просмотреть файл

@ -61,9 +61,7 @@ nsAutoWindowStateHelper::DispatchEventToChrome(const char* aEventName)
if (rv.Failed()) {
return false;
}
NS_ENSURE_TRUE(NS_SUCCEEDED(event->InitEvent(
NS_ConvertASCIItoUTF16(aEventName), true, true)),
false);
event->InitEvent(NS_ConvertASCIItoUTF16(aEventName), true, true);
event->SetTrusted(true);
event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true;

Просмотреть файл

@ -1064,6 +1064,7 @@ nsDocumentViewer::PermitUnloadInternal(bool *aShouldPrompt,
{
AutoDontWarnAboutSyncXHR disableSyncXHRWarning;
nsresult rv = NS_OK;
*aPermitUnload = true;
if (!mDocument
@ -1103,9 +1104,7 @@ nsDocumentViewer::PermitUnloadInternal(bool *aShouldPrompt,
getter_AddRefs(event));
nsCOMPtr<nsIDOMBeforeUnloadEvent> beforeUnload = do_QueryInterface(event);
NS_ENSURE_STATE(beforeUnload);
nsresult rv = event->InitEvent(NS_LITERAL_STRING("beforeunload"),
false, true);
NS_ENSURE_SUCCESS(rv, rv);
event->InitEvent(NS_LITERAL_STRING("beforeunload"), false, true);
// Dispatching to |window|, but using |document| as the target.
event->SetTarget(mDocument);