Bug 1389460 - Remove @deprecated nsIDOMEventTarget.DispatchDOMEvent. r=smaug

MozReview-Commit-ID: E88DZK5sfwx

--HG--
extra : rebase_source : 63300d87c0496394d3f75cb76bc47c75d640d369
This commit is contained in:
Masatoshi Kimura 2017-08-07 02:28:52 +09:00
parent 404331515e
commit 58d29db70b
20 changed files with 61 additions and 106 deletions

View File

@ -1501,8 +1501,8 @@ EventSourceImpl::DispatchAllMessageEvents()
Sequence<OwningNonNull<MessagePort>>());
event->SetTrusted(true);
rv = mEventSource->DispatchDOMEvent(nullptr, static_cast<Event*>(event),
nullptr, nullptr);
bool dummy;
rv = mEventSource->DispatchEvent(static_cast<Event*>(event), &dummy);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch the message event!!!");
return;
@ -1940,7 +1940,8 @@ EventSource::CreateAndDispatchSimpleEvent(const nsAString& aName)
// it doesn't bubble, and it isn't cancelable
event->InitEvent(aName, false, false);
event->SetTrusted(true);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
return DispatchEvent(event, &dummy);
}
/* static */ already_AddRefed<EventSource>

View File

@ -1937,7 +1937,8 @@ WebSocket::CreateAndDispatchSimpleEvent(const nsAString& aName)
event->InitEvent(aName, false, false);
event->SetTrusted(true);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
return DispatchEvent(event, &dummy);
}
nsresult
@ -2020,8 +2021,8 @@ WebSocket::CreateAndDispatchMessageEvent(const nsACString& aData,
Sequence<OwningNonNull<MessagePort>>());
event->SetTrusted(true);
return DispatchDOMEvent(nullptr, static_cast<Event*>(event), nullptr,
nullptr);
bool dummy;
return DispatchEvent(static_cast<Event*>(event), &dummy);
}
nsresult
@ -2055,7 +2056,8 @@ WebSocket::CreateAndDispatchCloseEvent(bool aWasClean,
CloseEvent::Constructor(this, CLOSE_EVENT_STRING, init);
event->SetTrusted(true);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
return DispatchEvent(event, &dummy);
}
nsresult

View File

@ -4553,10 +4553,10 @@ nsContentUtils::DispatchChromeEvent(nsIDocument *aDoc,
if (!piTarget)
return NS_ERROR_INVALID_ARG;
nsEventStatus status = nsEventStatus_eIgnore;
rv = piTarget->DispatchDOMEvent(nullptr, event, nullptr, &status);
bool defaultActionEnabled;
rv = piTarget->DispatchEvent(event, &defaultActionEnabled);
if (aDefaultAction) {
*aDefaultAction = (status != nsEventStatus_eConsumeNoDefault);
*aDefaultAction = defaultActionEnabled;
}
return rv;
}

View File

@ -422,7 +422,8 @@ nsDOMDataChannel::DoOnMessageAvailable(const nsACString& aData,
event->SetTrusted(true);
LOG(("%p(%p): %s - Dispatching\n",this,(void*)mDataChannel,__FUNCTION__));
rv = DispatchDOMEvent(nullptr, static_cast<Event*>(event), nullptr, nullptr);
bool dummy;
rv = DispatchEvent(static_cast<Event*>(event), &dummy);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch the message event!!!");
}
@ -460,7 +461,8 @@ nsDOMDataChannel::OnSimpleEvent(nsISupports* aContext, const nsAString& aName)
event->InitEvent(aName, false, false);
event->SetTrusted(true);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
return DispatchEvent(event, &dummy);
}
nsresult

View File

@ -4015,17 +4015,6 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor)
return NS_OK;
}
nsresult
nsGlobalWindow::DispatchDOMEvent(WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
return EventDispatcher::DispatchDOMEvent(static_cast<nsPIDOMWindow*>(this),
aEvent, aDOMEvent, aPresContext,
aEventStatus);
}
void
nsGlobalWindow::PoisonOuterWindowProxy(JSObject *aObject)
{

View File

@ -1354,16 +1354,6 @@ nsINode::PostHandleEvent(EventChainPostVisitor& /*aVisitor*/)
return NS_OK;
}
nsresult
nsINode::DispatchDOMEvent(WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
return EventDispatcher::DispatchDOMEvent(this, aEvent, aDOMEvent,
aPresContext, aEventStatus);
}
EventListenerManager*
nsINode::GetOrCreateListenerManager()
{

View File

@ -94,17 +94,6 @@ nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt, bool *aRetVal)
return rv;
}
nsresult
nsWindowRoot::DispatchDOMEvent(WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
return EventDispatcher::DispatchDOMEvent(static_cast<EventTarget*>(this),
aEvent, aDOMEvent,
aPresContext, aEventStatus);
}
NS_IMETHODIMP
nsWindowRoot::AddEventListener(const nsAString& aType,
nsIDOMEventListener *aListener,

View File

@ -344,16 +344,6 @@ DOMEventTargetHelper::PostHandleEvent(EventChainPostVisitor& aVisitor)
return NS_OK;
}
nsresult
DOMEventTargetHelper::DispatchDOMEvent(WidgetEvent* aEvent,
nsIDOMEvent* aDOMEvent,
nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
return EventDispatcher::DispatchDOMEvent(this, aEvent, aDOMEvent,
aPresContext, aEventStatus);
}
EventListenerManager*
DOMEventTargetHelper::GetOrCreateListenerManager()
{

View File

@ -619,7 +619,8 @@ FileReader::DispatchProgressEvent(const nsAString& aType)
ProgressEvent::Constructor(this, aType, init);
event->SetTrusted(true);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
return DispatchEvent(event, &dummy);
}
// nsITimerCallback

View File

@ -257,29 +257,6 @@ interface nsIDOMEventTarget : nsISupports
[noscript, nostdcall]
void PostHandleEvent(in EventChainPostVisitorRef aVisitor);
/**
* Dispatch an event.
* @param aEvent the event that is being dispatched.
* @param aDOMEvent the event that is being dispatched, use if you want to
* dispatch nsIDOMEvent, not only WidgetEvent.
* @param aPresContext the current presentation context, can be nullptr.
* @param aEventStatus the status returned from the function, can be nullptr.
*
* @note If both aEvent and aDOMEvent are used, aEvent must be the internal
* event of the aDOMEvent.
*
* If aDOMEvent is not nullptr (in which case aEvent can be nullptr) it is used
* for dispatching, otherwise aEvent is used.
*
* @deprecated This method is here just until all the callers outside Gecko
* have been converted to use nsIDOMEventTarget::dispatchEvent.
*/
[noscript, nostdcall]
void DispatchDOMEvent(in WidgetEventPtr aEvent,
in nsIDOMEvent aDOMEvent,
in nsPresContextPtr aPresContext,
in nsEventStatusPtr aEventStatus);
/**
* Get the script context in which the event handlers should be run.
* May return null.

View File

@ -1363,7 +1363,8 @@ MediaRecorder::CreateAndDispatchBlobEvent(already_AddRefed<nsIDOMBlob>&& aBlob)
NS_LITERAL_STRING("dataavailable"),
init);
event->SetTrusted(true);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
return DispatchEvent(event, &dummy);
}
void
@ -1379,7 +1380,8 @@ MediaRecorder::DispatchSimpleEvent(const nsAString & aStr)
event->InitEvent(aStr, false, false);
event->SetTrusted(true);
rv = DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
rv = DispatchEvent(event, &dummy);
if (NS_FAILED(rv)) {
NS_ERROR("Failed to dispatch the event!!!");
return;
@ -1415,7 +1417,8 @@ MediaRecorder::NotifyError(nsresult aRv)
RecordErrorEvent::Constructor(this, NS_LITERAL_STRING("error"), init);
event->SetTrusted(true);
rv = DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
rv = DispatchEvent(event, &dummy);
if (NS_FAILED(rv)) {
NS_ERROR("Failed to dispatch the error event!!!");
}

View File

@ -159,7 +159,8 @@ DesktopNotification::DispatchNotificationEvent(const nsString& aName)
// it doesn't bubble, and it isn't cancelable
event->InitEvent(aName, false, false);
event->SetTrusted(true);
DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
DispatchEvent(event, &dummy);
}
nsresult

View File

@ -1302,7 +1302,8 @@ Notification::DispatchNotificationClickEvent()
event->SetTrusted(true);
WantsPopupControlCheck popupControlCheck(event);
target->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
target->DispatchEvent(event, &dummy);
// We always return false since in case of dispatching on the serviceworker,
// there is no well defined window to focus. The script may use the
// Client.focus() API if it wishes.

View File

@ -614,7 +614,8 @@ PaymentRequest::DispatchUpdateEvent(const nsAString& aType)
event->SetTrusted(true);
event->SetRequest(this);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
return DispatchEvent(event, &dummy);
}
already_AddRefed<PaymentAddress>

View File

@ -91,7 +91,8 @@ PerformanceMainThread::DispatchBufferFullEvent()
// it bubbles, and it isn't cancelable
event->InitEvent(NS_LITERAL_STRING("resourcetimingbufferfull"), true, false);
event->SetTrusted(true);
DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
DispatchEvent(event, &dummy);
}
PerformanceNavigation*

View File

@ -459,7 +459,8 @@ public:
aEvent->SetKeepAliveHandler(keepAliveHandler);
ErrorResult result;
result = aWorkerScope->DispatchDOMEvent(nullptr, aEvent, nullptr, nullptr);
bool dummy;
result = aWorkerScope->DispatchEvent(aEvent, &dummy);
if (NS_WARN_IF(result.Failed())) {
result.SuppressException();
return NS_ERROR_FAILURE;

View File

@ -570,8 +570,8 @@ private:
EventInit());
event->SetTrusted(true);
nsEventStatus status = nsEventStatus_eIgnore;
aWorkerPrivate->DispatchDOMEvent(nullptr, event, nullptr, &status);
bool dummy;
aWorkerPrivate->DispatchEvent(event, &dummy);
return true;
}
};
@ -778,8 +778,8 @@ public:
domEvent->SetTrusted(true);
nsEventStatus dummy = nsEventStatus_eIgnore;
aTarget->DispatchDOMEvent(nullptr, domEvent, nullptr, &dummy);
bool dummy;
aTarget->DispatchEvent(domEvent, &dummy);
return true;
}
@ -854,8 +854,8 @@ private:
event->SetTrusted(true);
nsCOMPtr<nsIDOMEvent> domEvent = do_QueryObject(event);
nsEventStatus status = nsEventStatus_eIgnore;
globalScope->DispatchDOMEvent(nullptr, domEvent, nullptr, &status);
bool dummy;
globalScope->DispatchEvent(domEvent, &dummy);
return true;
}
};
@ -1037,10 +1037,10 @@ public:
ErrorEvent::Constructor(aTarget, NS_LITERAL_STRING("error"), init);
event->SetTrusted(true);
nsEventStatus status = nsEventStatus_eIgnore;
aTarget->DispatchDOMEvent(nullptr, event, nullptr, &status);
bool defaultActionEnabled;
aTarget->DispatchEvent(event, &defaultActionEnabled);
if (status == nsEventStatus_eConsumeNoDefault) {
if (!defaultActionEnabled) {
return;
}
}
@ -3625,7 +3625,8 @@ WorkerPrivate::OfflineStatusChangeEventInternal(bool aIsOffline)
event->InitEvent(eventType, false, false);
event->SetTrusted(true);
globalScope->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
globalScope->DispatchEvent(event, &dummy);
}
template <class Derived>
@ -6982,8 +6983,8 @@ WorkerPrivate::ConnectMessagePort(JSContext* aCx,
nsCOMPtr<nsIDOMEvent> domEvent = do_QueryObject(event);
nsEventStatus dummy = nsEventStatus_eIgnore;
globalScope->DispatchDOMEvent(nullptr, domEvent, nullptr, &dummy);
bool dummy;
globalScope->DispatchEvent(domEvent, &dummy);
return true;
}

View File

@ -1457,7 +1457,8 @@ XMLHttpRequestMainThread::DispatchOrStoreEvent(DOMEventTargetHelper* aTarget,
return;
}
aTarget->DispatchDOMEvent(nullptr, aEvent, nullptr, nullptr);
bool dummy;
aTarget->DispatchEvent(aEvent, &dummy);
}
void
@ -1477,8 +1478,8 @@ XMLHttpRequestMainThread::ResumeEventDispatching()
pendingEvents.SwapElements(mPendingEvents);
for (uint32_t i = 0; i < pendingEvents.Length(); ++i) {
pendingEvents[i].mTarget->
DispatchDOMEvent(nullptr, pendingEvents[i].mEvent, nullptr, nullptr);
bool dummy;
pendingEvents[i].mTarget->DispatchEvent(pendingEvents[i].mEvent, &dummy);
}
}

View File

@ -1355,7 +1355,8 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
event->SetTrusted(true);
target->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
target->DispatchEvent(event, &dummy);
// After firing the event set mResponse to JSVAL_NULL for chunked response
// types.
@ -1757,7 +1758,8 @@ XMLHttpRequestWorker::DispatchPrematureAbortEvent(EventTarget* aTarget,
event->SetTrusted(true);
aTarget->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
bool dummy;
aTarget->DispatchEvent(event, &dummy);
}
void

View File

@ -68,6 +68,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/MouseEvents.h"
#include "nsPIWindowRoot.h"
@ -333,7 +334,8 @@ nsWebShellWindow::RequestWindowClose(nsIWidget* aWidget)
nsEventStatus status = nsEventStatus_eIgnore;
WidgetMouseEvent event(true, eClose, nullptr,
WidgetMouseEvent::eReal);
if (NS_SUCCEEDED(eventTarget->DispatchDOMEvent(&event, nullptr, presContext, &status)) &&
if (NS_SUCCEEDED(EventDispatcher::Dispatch(eventTarget, presContext,
&event, nullptr, &status)) &&
status == nsEventStatus_eConsumeNoDefault)
return false;
}
@ -716,8 +718,8 @@ bool nsWebShellWindow::ExecuteCloseHandler()
WidgetMouseEvent event(true, eClose, nullptr,
WidgetMouseEvent::eReal);
nsresult rv =
eventTarget->DispatchDOMEvent(&event, nullptr, presContext, &status);
nsresult rv = EventDispatcher::Dispatch(eventTarget, presContext,
&event, nullptr, &status);
if (NS_SUCCEEDED(rv) && status == nsEventStatus_eConsumeNoDefault)
return true;
// else fall through and return false