Skip to content

Commit 3edb33f

Browse files
committed
Update ProgressEvent to use doubles
See: whatwg/xhr#394 Signed-off-by: Sebastian C <[email protected]>
1 parent 64fe52e commit 3edb33f

File tree

5 files changed

+24
-26
lines changed

5 files changed

+24
-26
lines changed

components/script/dom/filereader.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use js::jsval::{self, JSVal};
1414
use js::rust::HandleObject;
1515
use js::typedarray::{ArrayBuffer, CreateWith};
1616
use mime::{self, Mime};
17+
use script_bindings::num::Finite;
1718
use stylo_atoms::Atom;
1819

1920
use crate::dom::bindings::cell::DomRefCell;
@@ -463,8 +464,8 @@ impl FileReader {
463464
EventBubbles::DoesNotBubble,
464465
EventCancelable::NotCancelable,
465466
total.is_some(),
466-
loaded,
467-
total.unwrap_or(0),
467+
Finite::wrap(loaded as f64),
468+
Finite::wrap(total.unwrap_or(0) as f64),
468469
can_gc,
469470
);
470471
progressevent.upcast::<Event>().fire(self.upcast(), can_gc);

components/script/dom/progressevent.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use dom_struct::dom_struct;
66
use js::rust::HandleObject;
7+
use script_bindings::num::Finite;
78
use stylo_atoms::Atom;
89

910
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
@@ -22,12 +23,16 @@ use crate::script_runtime::CanGc;
2223
pub(crate) struct ProgressEvent {
2324
event: Event,
2425
length_computable: bool,
25-
loaded: u64,
26-
total: u64,
26+
loaded: Finite<f64>,
27+
total: Finite<f64>,
2728
}
2829

2930
impl ProgressEvent {
30-
fn new_inherited(length_computable: bool, loaded: u64, total: u64) -> ProgressEvent {
31+
fn new_inherited(
32+
length_computable: bool,
33+
loaded: Finite<f64>,
34+
total: Finite<f64>,
35+
) -> ProgressEvent {
3136
ProgressEvent {
3237
event: Event::new_inherited(),
3338
length_computable,
@@ -43,8 +48,8 @@ impl ProgressEvent {
4348
can_bubble: EventBubbles,
4449
cancelable: EventCancelable,
4550
length_computable: bool,
46-
loaded: u64,
47-
total: u64,
51+
loaded: Finite<f64>,
52+
total: Finite<f64>,
4853
can_gc: CanGc,
4954
) -> DomRoot<ProgressEvent> {
5055
Self::new_with_proto(
@@ -68,8 +73,8 @@ impl ProgressEvent {
6873
can_bubble: EventBubbles,
6974
cancelable: EventCancelable,
7075
length_computable: bool,
71-
loaded: u64,
72-
total: u64,
76+
loaded: Finite<f64>,
77+
total: Finite<f64>,
7378
can_gc: CanGc,
7479
) -> DomRoot<ProgressEvent> {
7580
let ev = reflect_dom_object_with_proto(
@@ -121,12 +126,12 @@ impl ProgressEventMethods<crate::DomTypeHolder> for ProgressEvent {
121126
}
122127

123128
// https://xhr.spec.whatwg.org/#dom-progressevent-loaded
124-
fn Loaded(&self) -> u64 {
129+
fn Loaded(&self) -> Finite<f64> {
125130
self.loaded
126131
}
127132

128133
// https://xhr.spec.whatwg.org/#dom-progressevent-total
129-
fn Total(&self) -> u64 {
134+
fn Total(&self) -> Finite<f64> {
130135
self.total
131136
}
132137

components/script/dom/xmlhttprequest.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use net_traits::{
3131
FetchMetadata, FetchResponseListener, FilteredMetadata, NetworkError, ReferrerPolicy,
3232
ResourceFetchTiming, ResourceTimingType, trim_http_whitespace,
3333
};
34+
use script_bindings::num::Finite;
3435
use script_traits::DocumentActivity;
3536
use servo_url::ServoUrl;
3637
use stylo_atoms::Atom;
@@ -1235,8 +1236,8 @@ impl XMLHttpRequest {
12351236
EventBubbles::DoesNotBubble,
12361237
EventCancelable::NotCancelable,
12371238
length_computable,
1238-
loaded,
1239-
total_length,
1239+
Finite::wrap(loaded as f64),
1240+
Finite::wrap(total_length as f64),
12401241
can_gc,
12411242
);
12421243
let target = if upload {

components/script_bindings/webidls/ProgressEvent.webidl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
interface ProgressEvent : Event {
1717
[Throws] constructor(DOMString type, optional ProgressEventInit eventInitDict = {});
1818
readonly attribute boolean lengthComputable;
19-
readonly attribute unsigned long long loaded;
20-
readonly attribute unsigned long long total;
19+
readonly attribute double loaded;
20+
readonly attribute double total;
2121
};
2222

2323
dictionary ProgressEventInit : EventInit {
2424
boolean lengthComputable = false;
25-
unsigned long long loaded = 0;
26-
unsigned long long total = 0;
25+
double loaded = 0;
26+
double total = 0;
2727
};

tests/wpt/meta/xhr/progressevent-constructor.html.ini

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)