Bug 1285036 - Part 5: Consolidate the readystatechange-firing code into a function named FireReadyStateChange(). r=baku

This commit is contained in:
Thomas Wisniewski 2016-07-08 12:50:48 -04:00
Родитель fbc2d5f34d
Коммит 1bc65bb8d9
2 изменённых файлов: 7 добавлений и 14 удалений

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

@ -1272,16 +1272,13 @@ XMLHttpRequestMainThread::GetLoadGroup() const
}
nsresult
XMLHttpRequestMainThread::CreateReadystatechangeEvent(nsIDOMEvent** aDOMEvent)
XMLHttpRequestMainThread::FireReadystatechangeEvent()
{
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
event.forget(aDOMEvent);
(*aDOMEvent)->InitEvent(kLiteralString_readystatechange, false, false);
event->InitEvent(kLiteralString_readystatechange, false, false);
// We assume anyone who managed to call CreateReadystatechangeEvent is trusted
(*aDOMEvent)->SetTrusted(true);
event->SetTrusted(true);
DispatchDOMEvent(nullptr, event, nullptr, nullptr);
return NS_OK;
}
@ -3118,11 +3115,7 @@ XMLHttpRequestMainThread::ChangeState(State aState, bool aBroadcast)
if (aBroadcast && (!mFlagSynchronous ||
aState == State::opened ||
aState == State::done)) {
nsCOMPtr<nsIDOMEvent> event;
rv = CreateReadystatechangeEvent(getter_AddRefs(event));
NS_ENSURE_SUCCESS(rv, rv);
DispatchDOMEvent(nullptr, event, nullptr, nullptr);
rv = FireReadystatechangeEvent();
}
return rv;

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

@ -520,9 +520,9 @@ public:
JS::MutableHandle<JS::Value> aRetval,
ErrorResult& aRv) override;
// This creates a trusted readystatechange event, which is not cancelable and
// This fires a trusted readystatechange event, which is not cancelable and
// doesn't bubble.
nsresult CreateReadystatechangeEvent(nsIDOMEvent** aDOMEvent);
nsresult FireReadystatechangeEvent();
void DispatchProgressEvent(DOMEventTargetHelper* aTarget,
const ProgressEventType aType,
bool aLengthComputable,