Back out bug 1019248 due to test failures.

This commit is contained in:
Kyle Huey 2014-06-02 20:18:17 -07:00
parent b33fbbad7a
commit 34957a3bed
10 changed files with 96 additions and 65 deletions

View File

@ -8,7 +8,7 @@
#include "nsDOMFile.h"
#include "nsError.h"
#include "nsIDOMEvent.h"
#include "mozilla/dom/ProgressEvent.h"
#include "nsIDOMProgressEvent.h"
#include "nsComponentManagerUtils.h"
#define ERROR_STR "error"
@ -105,21 +105,27 @@ FileIOObject::DispatchError(nsresult rv, nsAString& finalEvent)
nsresult
FileIOObject::DispatchProgressEvent(const nsAString& aType)
{
ProgressEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mLoaded = mTransferred;
nsCOMPtr<nsIDOMEvent> event;
nsresult rv = NS_NewDOMProgressEvent(getter_AddRefs(event), this,
nullptr, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
if (mTotal != kUnknownSize) {
init.mLengthComputable = true;
init.mTotal = mTotal;
} else {
init.mLengthComputable = false;
init.mTotal = 0;
}
nsRefPtr<ProgressEvent> event =
ProgressEvent::Constructor(this, aType, init);
event->SetTrusted(true);
nsCOMPtr<nsIDOMProgressEvent> progress = do_QueryInterface(event);
NS_ENSURE_TRUE(progress, NS_ERROR_UNEXPECTED);
bool known;
uint64_t size;
if (mTotal != kUnknownSize) {
known = true;
size = mTotal;
} else {
known = false;
size = 0;
}
rv = progress->InitProgressEvent(aType, false, false, known,
mTransferred, size);
NS_ENSURE_SUCCESS(rv, rv);
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
}

View File

@ -16,7 +16,7 @@
#include "mozilla/MemoryReporting.h"
#include "nsDOMBlobBuilder.h"
#include "nsIDOMDocument.h"
#include "mozilla/dom/ProgressEvent.h"
#include "nsIDOMProgressEvent.h"
#include "nsIJARChannel.h"
#include "nsIJARURI.h"
#include "nsLayoutCID.h"
@ -1465,15 +1465,21 @@ nsXMLHttpRequest::DispatchProgressEvent(DOMEventTargetHelper* aTarget,
aType.EqualsLiteral(TIMEOUT_STR) ||
aType.EqualsLiteral(ABORT_STR);
ProgressEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mLengthComputable = aLengthComputable;
init.mLoaded = aLoaded;
init.mTotal = (aTotal == UINT64_MAX) ? 0 : aTotal;
nsCOMPtr<nsIDOMEvent> event;
nsresult rv = NS_NewDOMProgressEvent(getter_AddRefs(event), this,
nullptr, nullptr);
if (NS_FAILED(rv)) {
return;
}
nsCOMPtr<nsIDOMProgressEvent> progress = do_QueryInterface(event);
if (!progress) {
return;
}
progress->InitProgressEvent(aType, false, false, aLengthComputable,
aLoaded, (aTotal == UINT64_MAX) ? 0 : aTotal);
nsRefPtr<ProgressEvent> event =
ProgressEvent::Constructor(aTarget, aType, init);
event->SetTrusted(true);
aTarget->DispatchDOMEvent(nullptr, event, nullptr, nullptr);

View File

@ -27,7 +27,7 @@
#include "nsContentCID.h"
#include "nsIComponentManager.h"
#include "nsIDOMHTMLFormElement.h"
#include "mozilla/dom/ProgressEvent.h"
#include "nsIDOMProgressEvent.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsPresContext.h"
@ -2725,19 +2725,25 @@ HTMLInputElement::DispatchProgressEvent(const nsAString& aType,
{
NS_ASSERTION(!aType.IsEmpty(), "missing event type");
ProgressEventInit init;
init.mBubbles = false;
init.mCancelable = true; // XXXkhuey why?
init.mLengthComputable = aLengthComputable;
init.mLoaded = aLoaded;
init.mTotal = (aTotal == UINT64_MAX) ? 0 : aTotal;
nsCOMPtr<nsIDOMEvent> event;
nsresult rv = NS_NewDOMProgressEvent(getter_AddRefs(event), this,
nullptr, nullptr);
if (NS_FAILED(rv)) {
return;
}
nsCOMPtr<nsIDOMProgressEvent> progress = do_QueryInterface(event);
if (!progress) {
return;
}
progress->InitProgressEvent(aType, false, true, aLengthComputable,
aLoaded, (aTotal == UINT64_MAX) ? 0 : aTotal);
nsRefPtr<ProgressEvent> event =
ProgressEvent::Constructor(this, aType, init);
event->SetTrusted(true);
bool doDefaultAction;
nsresult rv = DispatchEvent(event, &doDefaultAction);
rv = DispatchEvent(event, &doDefaultAction);
if (NS_SUCCEEDED(rv) && !doDefaultAction) {
CancelDirectoryPickerScanIfRunning();
}

View File

@ -25,6 +25,7 @@
#include "nsITimer.h"
#include "nsIDOMProgressEvent.h"
#include "MediaError.h"
#include "MediaDecoder.h"
#include "mozilla/Preferences.h"

View File

@ -18,7 +18,7 @@
#include "nsDebug.h"
#include "nsError.h"
#include "nsIDOMEvent.h"
#include "mozilla/dom/ProgressEvent.h"
#include "nsIDOMProgressEvent.h"
#include "nsIScriptContext.h"
#include "nsLiteralString.h"
@ -135,15 +135,21 @@ FileRequest::FireProgressEvent(uint64_t aLoaded, uint64_t aTotal)
return;
}
ProgressEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mLengthComputable = false;
init.mLoaded = aLoaded;
init.mTotal = aTotal;
nsCOMPtr<nsIDOMEvent> event;
nsresult rv = NS_NewDOMProgressEvent(getter_AddRefs(event), this,
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;
}
nsRefPtr<ProgressEvent> event =
ProgressEvent::Constructor(this, NS_LITERAL_STRING("progress"), init);
DispatchTrustedEvent(event);
}

View File

@ -327,6 +327,11 @@ NS_NewDOMMessageEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent);
nsresult
NS_NewDOMProgressEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetEvent* aEvent);
// This empties aInvalidateRequests.
nsresult
NS_NewDOMNotifyPaintEvent(nsIDOMEvent** aResult,

View File

@ -4,7 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Constructor(DOMString type, optional ProgressEventInit eventInitDict)]
[Constructor(DOMString type, optional ProgressEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
interface ProgressEvent : Event
{
readonly attribute boolean lengthComputable;

View File

@ -641,7 +641,6 @@ GENERATED_EVENTS_WEBIDL_FILES = [
'MozInterAppMessageEvent.webidl',
'MozOtaStatusEvent.webidl',
'MozStkCommandEvent.webidl',
'ProgressEvent.webidl',
'RTCDataChannelEvent.webidl',
'RTCPeerConnectionIceEvent.webidl',
'RTCPeerConnectionIdentityErrorEvent.webidl',

View File

@ -16,7 +16,6 @@
#include "jsfriendapi.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/dom/Exceptions.h"
#include "mozilla/dom/ProgressEvent.h"
#include "nsComponentManagerUtils.h"
#include "nsContentUtils.h"
#include "nsCxPusher.h"
@ -1344,14 +1343,13 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
nsCOMPtr<nsIDOMEvent> event;
if (mProgressEvent) {
ProgressEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mLengthComputable = mLengthComputable;
init.mLoaded = mLoaded;
init.mTotal = mTotal;
NS_NewDOMProgressEvent(getter_AddRefs(event), target, nullptr, nullptr);
nsCOMPtr<nsIDOMProgressEvent> progress = do_QueryInterface(event);
event = ProgressEvent::Constructor(target, mType, init);
if (progress) {
progress->InitProgressEvent(mType, false, false, mLengthComputable,
mLoaded, mTotal);
}
}
else {
NS_NewDOMEvent(getter_AddRefs(event), target, nullptr, nullptr);
@ -1741,20 +1739,23 @@ XMLHttpRequest::DispatchPrematureAbortEvent(EventTarget* aTarget,
}
}
else {
ProgressEventInit init;
init.mBubbles = false;
init.mCancelable = false;
if (aUploadTarget) {
init.mLengthComputable = mProxy->mLastUploadLengthComputable;
init.mLoaded = mProxy->mLastUploadLoaded;
init.mTotal = mProxy->mLastUploadTotal;
NS_NewDOMProgressEvent(getter_AddRefs(event), aTarget, nullptr, nullptr);
nsCOMPtr<nsIDOMProgressEvent> progress = do_QueryInterface(event);
if (progress) {
if (aUploadTarget) {
progress->InitProgressEvent(aEventType, false, false,
mProxy->mLastUploadLengthComputable,
mProxy->mLastUploadLoaded,
mProxy->mLastUploadTotal);
}
else {
progress->InitProgressEvent(aEventType, false, false,
mProxy->mLastLengthComputable,
mProxy->mLastLoaded,
mProxy->mLastTotal);
}
}
else {
init.mLengthComputable = mProxy->mLastLengthComputable;
init.mLoaded = mProxy->mLastLoaded;
init.mTotal = mProxy->mLastTotal;
}
event = ProgressEvent::Constructor(aTarget, aEventType, init);
}
if (!event) {

View File

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