Closed Bug 1019248 Opened 6 years ago Closed 6 years ago

Convert ProgressEvent to WebIDL codegen

Categories

(Core :: DOM: Events, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: khuey, Assigned: khuey)

Details

Attachments

(1 file)

Comment on attachment 8432838 [details] [diff] [review]
Patch

> nsresult
> FileIOObject::DispatchProgressEvent(const nsAString& aType)
> {
>-  nsCOMPtr<nsIDOMEvent> event;
>-  nsresult rv = NS_NewDOMProgressEvent(getter_AddRefs(event), this,
>-                                       nullptr, nullptr);
>-  NS_ENSURE_SUCCESS(rv, rv);
>+  ProgressEventInit init;
>+  init.mBubbles = false;
>+  init.mCancelable = false;
>+  init.mTotal = mTransferred;
> 
>+  if (mTotal != kUnknownSize) {
>+    init.mLengthComputable = true;
>+    init.mLoaded = mTotal;
>+  } else {
>+    init.mLengthComputable = false;
>+    init.mLoaded = 0;
>+  }

You have mTotal and mLoaded the wrong way here.



>+  ProgressEventInit init;
>+  init.mBubbles = false;
>+  init.mCancelable = true; // XXXkhuey why?
IIRC there was a plan to be able to cancel directory scanning. Did that not end up to a spec.

>+    ProgressEventInit init;
>+    init.mBubbles = false;
>+    init.mCancelable = false;
>+    if (aUploadTarget) {
>+      init.mLengthComputable = mProxy->mLastUploadLengthComputable;
>+      init.mLoaded = mProxy->mLastUploadLoaded;
>+      init.mTotal = mProxy->mLastUploadTotal;
>     }
>+    else {
Nit, should be
} else {
Attachment #8432838 - Flags: review?(bugs) → review+
(In reply to Olli Pettay [:smaug] from comment #2)
> You have mTotal and mLoaded the wrong way here.

Indeed.  Thanks for catching that.

> IIRC there was a plan to be able to cancel directory scanning. Did that not
> end up to a spec.

I don't think there's a spec for directories at all.  But perhaps I just failed to find it.

> Nit, should be
> } else {

Style in bent's code (e.g. workers) is half cuddled elses :/
I had to back this out.  The QI at http://mxr.mozilla.org/mozilla-central/source/dom/workers/XMLHttpRequest.cpp#1043 fails now so the worker XHR code can't get any progress information.  What's the right way to fix this?  Just static_cast here?

https://hg.mozilla.org/integration/mozilla-inbound/rev/d69a0de220ae
Flags: needinfo?(bugs)
Oh, the patch was missing removal of nsIDOMProgressEvent.idl.

In order to replace QIs, just add 
virtual ProgressEvent* AsProgressEvent()
{
  return nullptr;
}
to class Event.
Generated code for ProgressEvent will have 
virtual ProgressEvent* AsProgressEvent()
{
  return this;
}
Flags: needinfo?(bugs)
https://hg.mozilla.org/mozilla-central/rev/4febe53fc262
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in before you can comment on or make changes to this bug.