mirror of
https://github.com/servo/servo.git
synced 2025-06-15 20:04:28 +00:00
Update ProgressEvent to use doubles (#36487)
See: https://github.com/whatwg/xhr/pull/394 Testing: WPT tests exist for this Signed-off-by: Sebastian C <sebsebmc@gmail.com>
This commit is contained in:
parent
4c55104b36
commit
85bd0918f2
5 changed files with 24 additions and 26 deletions
|
@ -14,6 +14,7 @@ use js::jsval::{self, JSVal};
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
use js::typedarray::{ArrayBuffer, CreateWith};
|
use js::typedarray::{ArrayBuffer, CreateWith};
|
||||||
use mime::{self, Mime};
|
use mime::{self, Mime};
|
||||||
|
use script_bindings::num::Finite;
|
||||||
use stylo_atoms::Atom;
|
use stylo_atoms::Atom;
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
|
@ -463,8 +464,8 @@ impl FileReader {
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable,
|
EventCancelable::NotCancelable,
|
||||||
total.is_some(),
|
total.is_some(),
|
||||||
loaded,
|
Finite::wrap(loaded as f64),
|
||||||
total.unwrap_or(0),
|
Finite::wrap(total.unwrap_or(0) as f64),
|
||||||
can_gc,
|
can_gc,
|
||||||
);
|
);
|
||||||
progressevent.upcast::<Event>().fire(self.upcast(), can_gc);
|
progressevent.upcast::<Event>().fire(self.upcast(), can_gc);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
|
use script_bindings::num::Finite;
|
||||||
use stylo_atoms::Atom;
|
use stylo_atoms::Atom;
|
||||||
|
|
||||||
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
|
@ -22,12 +23,16 @@ use crate::script_runtime::CanGc;
|
||||||
pub(crate) struct ProgressEvent {
|
pub(crate) struct ProgressEvent {
|
||||||
event: Event,
|
event: Event,
|
||||||
length_computable: bool,
|
length_computable: bool,
|
||||||
loaded: u64,
|
loaded: Finite<f64>,
|
||||||
total: u64,
|
total: Finite<f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProgressEvent {
|
impl ProgressEvent {
|
||||||
fn new_inherited(length_computable: bool, loaded: u64, total: u64) -> ProgressEvent {
|
fn new_inherited(
|
||||||
|
length_computable: bool,
|
||||||
|
loaded: Finite<f64>,
|
||||||
|
total: Finite<f64>,
|
||||||
|
) -> ProgressEvent {
|
||||||
ProgressEvent {
|
ProgressEvent {
|
||||||
event: Event::new_inherited(),
|
event: Event::new_inherited(),
|
||||||
length_computable,
|
length_computable,
|
||||||
|
@ -43,8 +48,8 @@ impl ProgressEvent {
|
||||||
can_bubble: EventBubbles,
|
can_bubble: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
length_computable: bool,
|
length_computable: bool,
|
||||||
loaded: u64,
|
loaded: Finite<f64>,
|
||||||
total: u64,
|
total: Finite<f64>,
|
||||||
can_gc: CanGc,
|
can_gc: CanGc,
|
||||||
) -> DomRoot<ProgressEvent> {
|
) -> DomRoot<ProgressEvent> {
|
||||||
Self::new_with_proto(
|
Self::new_with_proto(
|
||||||
|
@ -68,8 +73,8 @@ impl ProgressEvent {
|
||||||
can_bubble: EventBubbles,
|
can_bubble: EventBubbles,
|
||||||
cancelable: EventCancelable,
|
cancelable: EventCancelable,
|
||||||
length_computable: bool,
|
length_computable: bool,
|
||||||
loaded: u64,
|
loaded: Finite<f64>,
|
||||||
total: u64,
|
total: Finite<f64>,
|
||||||
can_gc: CanGc,
|
can_gc: CanGc,
|
||||||
) -> DomRoot<ProgressEvent> {
|
) -> DomRoot<ProgressEvent> {
|
||||||
let ev = reflect_dom_object_with_proto(
|
let ev = reflect_dom_object_with_proto(
|
||||||
|
@ -121,12 +126,12 @@ impl ProgressEventMethods<crate::DomTypeHolder> for ProgressEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-progressevent-loaded
|
// https://xhr.spec.whatwg.org/#dom-progressevent-loaded
|
||||||
fn Loaded(&self) -> u64 {
|
fn Loaded(&self) -> Finite<f64> {
|
||||||
self.loaded
|
self.loaded
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-progressevent-total
|
// https://xhr.spec.whatwg.org/#dom-progressevent-total
|
||||||
fn Total(&self) -> u64 {
|
fn Total(&self) -> Finite<f64> {
|
||||||
self.total
|
self.total
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ use net_traits::{
|
||||||
FetchMetadata, FetchResponseListener, FilteredMetadata, NetworkError, ReferrerPolicy,
|
FetchMetadata, FetchResponseListener, FilteredMetadata, NetworkError, ReferrerPolicy,
|
||||||
ResourceFetchTiming, ResourceTimingType, trim_http_whitespace,
|
ResourceFetchTiming, ResourceTimingType, trim_http_whitespace,
|
||||||
};
|
};
|
||||||
|
use script_bindings::num::Finite;
|
||||||
use script_traits::DocumentActivity;
|
use script_traits::DocumentActivity;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use stylo_atoms::Atom;
|
use stylo_atoms::Atom;
|
||||||
|
@ -1235,8 +1236,8 @@ impl XMLHttpRequest {
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable,
|
EventCancelable::NotCancelable,
|
||||||
length_computable,
|
length_computable,
|
||||||
loaded,
|
Finite::wrap(loaded as f64),
|
||||||
total_length,
|
Finite::wrap(total_length as f64),
|
||||||
can_gc,
|
can_gc,
|
||||||
);
|
);
|
||||||
let target = if upload {
|
let target = if upload {
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
interface ProgressEvent : Event {
|
interface ProgressEvent : Event {
|
||||||
[Throws] constructor(DOMString type, optional ProgressEventInit eventInitDict = {});
|
[Throws] constructor(DOMString type, optional ProgressEventInit eventInitDict = {});
|
||||||
readonly attribute boolean lengthComputable;
|
readonly attribute boolean lengthComputable;
|
||||||
readonly attribute unsigned long long loaded;
|
readonly attribute double loaded;
|
||||||
readonly attribute unsigned long long total;
|
readonly attribute double total;
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary ProgressEventInit : EventInit {
|
dictionary ProgressEventInit : EventInit {
|
||||||
boolean lengthComputable = false;
|
boolean lengthComputable = false;
|
||||||
unsigned long long loaded = 0;
|
double loaded = 0;
|
||||||
unsigned long long total = 0;
|
double total = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
[progressevent-constructor.html]
|
|
||||||
[Decimal number test.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Mixed integer and decimal number test.]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Negative number.]
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue