mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Performance.timing should be a PerformanceTiming object.
Signed-off-by: aniebietafia <aniebietafia87@gmail.com> Performance.timing should be a PerformanceTiming object. Signed-off-by: aniebietafia <aniebietafia87@gmail.com> Performance.timing should be a PerformanceTiming object. Signed-off-by: aniebietafia <aniebietafia87@gmail.com> Performance.timing should be a PerformanceTiming object. Signed-off-by: aniebietafia <aniebietafia87@gmail.com> Performance.timing should be a PerformanceTiming object Signed-off-by: aniebietafia <aniebietafia87@gmail.com>
This commit is contained in:
parent
732f66aefb
commit
c52a45323f
3 changed files with 64 additions and 99 deletions
|
@ -2759,7 +2759,6 @@ impl Document {
|
|||
|
||||
let performance = window.Performance();
|
||||
let timing = performance.Timing();
|
||||
let start_time = (*performance.Now()).floor() as u64;
|
||||
|
||||
let event = Event::new(
|
||||
window.upcast(),
|
||||
|
@ -2770,9 +2769,8 @@ impl Document {
|
|||
);
|
||||
event.set_trusted(true);
|
||||
|
||||
let start_time = (*performance.Now()).floor() as u64;
|
||||
timing.update_load_event_start(start_time);
|
||||
window.upcast::<EventTarget>().dispatch_event(&event, CanGc::note());
|
||||
timing.update_load_event_end((*performance.Now()).floor() as u64);
|
||||
|
||||
// http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventStart
|
||||
update_with_current_instant(&document.load_event_start);
|
||||
|
@ -2780,6 +2778,7 @@ impl Document {
|
|||
debug!("About to dispatch load for {:?}", document.url());
|
||||
window.dispatch_event_with_target_override(&event, CanGc::note());
|
||||
|
||||
timing.update_load_event_end((*performance.Now()).floor() as u64);
|
||||
// http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventEnd
|
||||
update_with_current_instant(&document.load_event_end);
|
||||
|
||||
|
@ -3027,19 +3026,10 @@ impl Document {
|
|||
let window = document.window();
|
||||
let performance = window.Performance();
|
||||
let timing = performance.Timing();
|
||||
let start_time = (*performance.Now()).floor() as u64;
|
||||
|
||||
let event = Event::new(
|
||||
window.upcast(),
|
||||
atom!("DOMContentLoaded"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable,
|
||||
CanGc::note(),
|
||||
);
|
||||
event.set_trusted(true);
|
||||
|
||||
timing.update_dom_content_loaded_event_start(start_time);
|
||||
window.upcast::<EventTarget>().dispatch_event(&event, CanGc::note());
|
||||
update_with_current_instant(&document.dom_content_loaded_event_start);
|
||||
timing.update_dom_content_loaded_event_start((*performance.Now()).floor() as u64);
|
||||
document.upcast::<EventTarget>().fire_bubbling_event(atom!("DOMContentLoaded"), CanGc::note());
|
||||
timing.update_dom_content_loaded_event_end((*performance.Now()).floor() as u64);
|
||||
|
||||
update_with_current_instant(&document.dom_content_loaded_event_end);
|
||||
|
|
|
@ -157,10 +157,14 @@ impl Performance {
|
|||
(time_origin - CrossProcessInstant::epoch()).whole_milliseconds() as u64
|
||||
}
|
||||
|
||||
fn new_inherited(global: &GlobalScope, time_origin: CrossProcessInstant) -> Performance {
|
||||
fn new_inherited(
|
||||
global: &GlobalScope,
|
||||
time_origin: CrossProcessInstant,
|
||||
can_gc: CanGc,
|
||||
) -> Performance {
|
||||
let nav_start = Self::time_origin_to_millis(time_origin);
|
||||
let timing = PerformanceTiming::new(global, nav_start);
|
||||
let navigation = PerformanceNavigation::new(global, CanGc::note());
|
||||
let timing = PerformanceTiming::new(global, nav_start, can_gc);
|
||||
let navigation = PerformanceNavigation::new(global, can_gc);
|
||||
Performance {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
buffer: DomRefCell::new(PerformanceEntryList::new(Vec::new())),
|
||||
|
@ -182,7 +186,7 @@ impl Performance {
|
|||
can_gc: CanGc,
|
||||
) -> DomRoot<Performance> {
|
||||
reflect_dom_object(
|
||||
Box::new(Performance::new_inherited(global, navigation_start)),
|
||||
Box::new(Performance::new_inherited(global, navigation_start, can_gc)),
|
||||
global,
|
||||
can_gc,
|
||||
)
|
||||
|
|
|
@ -13,7 +13,7 @@ use crate::dom::globalscope::GlobalScope;
|
|||
use crate::script_runtime::CanGc;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct PerformanceTiming {
|
||||
pub(crate) struct PerformanceTiming {
|
||||
reflector_: Reflector,
|
||||
navigation_start: Cell<u64>,
|
||||
unload_event_start: Cell<u64>,
|
||||
|
@ -38,138 +38,109 @@ pub struct PerformanceTiming {
|
|||
load_event_end: Cell<u64>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct PerformanceTimingBuilder {
|
||||
navigation_start: u64,
|
||||
unload_event_start: u64,
|
||||
unload_event_end: u64,
|
||||
redirect_start: u64,
|
||||
redirect_end: u64,
|
||||
fetch_start: u64,
|
||||
domain_lookup_start: u64,
|
||||
domain_lookup_end: u64,
|
||||
connect_start: u64,
|
||||
connect_end: u64,
|
||||
secure_connection_start: u64,
|
||||
request_start: u64,
|
||||
response_start: u64,
|
||||
response_end: u64,
|
||||
dom_loading: u64,
|
||||
dom_interactive: u64,
|
||||
dom_content_loaded_event_start: u64,
|
||||
dom_content_loaded_event_end: u64,
|
||||
dom_complete: u64,
|
||||
load_event_start: u64,
|
||||
load_event_end: u64,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl PerformanceTiming {
|
||||
pub fn new_inherited(config: PerformanceTimingBuilder) -> PerformanceTiming {
|
||||
PerformanceTiming {
|
||||
reflector_: Reflector::new(),
|
||||
navigation_start: Cell::new(config.navigation_start),
|
||||
unload_event_start: Cell::new(config.unload_event_start),
|
||||
unload_event_end: Cell::new(config.unload_event_end),
|
||||
redirect_start: Cell::new(config.redirect_start),
|
||||
redirect_end: Cell::new(config.redirect_end),
|
||||
fetch_start: Cell::new(config.fetch_start),
|
||||
domain_lookup_start: Cell::new(config.domain_lookup_start),
|
||||
domain_lookup_end: Cell::new(config.domain_lookup_end),
|
||||
connect_start: Cell::new(config.connect_start),
|
||||
connect_end: Cell::new(config.connect_end),
|
||||
secure_connection_start: Cell::new(config.secure_connection_start),
|
||||
request_start: Cell::new(config.request_start),
|
||||
response_start: Cell::new(config.response_start),
|
||||
response_end: Cell::new(config.response_end),
|
||||
dom_loading: Cell::new(config.dom_loading),
|
||||
dom_interactive: Cell::new(config.dom_interactive),
|
||||
dom_content_loaded_event_start: Cell::new(config.dom_content_loaded_event_start),
|
||||
dom_content_loaded_event_end: Cell::new(config.dom_content_loaded_event_end),
|
||||
dom_complete: Cell::new(config.dom_complete),
|
||||
load_event_start: Cell::new(config.load_event_start),
|
||||
load_event_end: Cell::new(config.load_event_end),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(global: &GlobalScope, navigation_start: u64) -> DomRoot<PerformanceTiming> {
|
||||
let config = PerformanceTimingBuilder {
|
||||
navigation_start,
|
||||
..Default::default()
|
||||
};
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
navigation_start: u64,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<PerformanceTiming> {
|
||||
reflect_dom_object(
|
||||
Box::new(PerformanceTiming::new_inherited(config)),
|
||||
Box::new(PerformanceTiming {
|
||||
reflector_: Reflector::new(),
|
||||
navigation_start: Cell::new(navigation_start),
|
||||
unload_event_start: Cell::new(0),
|
||||
unload_event_end: Cell::new(0),
|
||||
redirect_start: Cell::new(0),
|
||||
redirect_end: Cell::new(0),
|
||||
fetch_start: Cell::new(0),
|
||||
domain_lookup_start: Cell::new(0),
|
||||
domain_lookup_end: Cell::new(0),
|
||||
connect_start: Cell::new(0),
|
||||
connect_end: Cell::new(0),
|
||||
secure_connection_start: Cell::new(0),
|
||||
request_start: Cell::new(0),
|
||||
response_start: Cell::new(0),
|
||||
response_end: Cell::new(0),
|
||||
dom_loading: Cell::new(0),
|
||||
dom_interactive: Cell::new(0),
|
||||
dom_content_loaded_event_start: Cell::new(0),
|
||||
dom_content_loaded_event_end: Cell::new(0),
|
||||
dom_complete: Cell::new(0),
|
||||
load_event_start: Cell::new(0),
|
||||
load_event_end: Cell::new(0),
|
||||
}),
|
||||
global,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn update_unload_event_start(&self, value: u64) {
|
||||
pub(crate) fn update_unload_event_start(&self, value: u64) {
|
||||
self.unload_event_start.set(value);
|
||||
}
|
||||
|
||||
pub fn update_unload_event_end(&self, value: u64) {
|
||||
pub(crate) fn update_unload_event_end(&self, value: u64) {
|
||||
self.unload_event_end.set(value);
|
||||
}
|
||||
|
||||
pub fn update_redirect_start(&self, value: u64) {
|
||||
pub(crate) fn update_redirect_start(&self, value: u64) {
|
||||
self.redirect_start.set(value);
|
||||
}
|
||||
|
||||
pub fn update_redirect_end(&self, value: u64) {
|
||||
pub(crate) fn update_redirect_end(&self, value: u64) {
|
||||
self.redirect_end.set(value);
|
||||
}
|
||||
|
||||
pub fn update_fetch_start(&self, value: u64) {
|
||||
pub(crate) fn update_fetch_start(&self, value: u64) {
|
||||
self.fetch_start.set(value);
|
||||
}
|
||||
|
||||
pub fn update_domain_lookup_start(&self, value: u64) {
|
||||
pub(crate) fn update_domain_lookup_start(&self, value: u64) {
|
||||
self.domain_lookup_start.set(value);
|
||||
}
|
||||
|
||||
pub fn update_domain_lookup_end(&self, value: u64) {
|
||||
pub(crate) fn update_domain_lookup_end(&self, value: u64) {
|
||||
self.domain_lookup_end.set(value);
|
||||
}
|
||||
|
||||
pub fn update_connect_start(&self, value: u64) {
|
||||
pub(crate) fn update_connect_start(&self, value: u64) {
|
||||
self.connect_start.set(value);
|
||||
}
|
||||
|
||||
pub fn update_connect_end(&self, value: u64) {
|
||||
pub(crate) fn update_connect_end(&self, value: u64) {
|
||||
self.connect_end.set(value);
|
||||
}
|
||||
pub fn update_secure_connection_start(&self, value: u64) {
|
||||
pub(crate) fn update_secure_connection_start(&self, value: u64) {
|
||||
self.secure_connection_start.set(value);
|
||||
}
|
||||
pub fn update_request_start(&self, value: u64) {
|
||||
pub(crate) fn update_request_start(&self, value: u64) {
|
||||
self.request_start.set(value);
|
||||
}
|
||||
pub fn update_response_start(&self, value: u64) {
|
||||
pub(crate) fn update_response_start(&self, value: u64) {
|
||||
self.response_start.set(value);
|
||||
}
|
||||
pub fn update_response_end(&self, value: u64) {
|
||||
pub(crate) fn update_response_end(&self, value: u64) {
|
||||
self.response_end.set(value);
|
||||
}
|
||||
pub fn update_dom_loading(&self, value: u64) {
|
||||
pub(crate) fn update_dom_loading(&self, value: u64) {
|
||||
self.dom_loading.set(value);
|
||||
}
|
||||
pub fn update_dom_interactive(&self, value: u64) {
|
||||
pub(crate) fn update_dom_interactive(&self, value: u64) {
|
||||
self.dom_interactive.set(value);
|
||||
}
|
||||
pub fn update_dom_content_loaded_event_start(&self, value: u64) {
|
||||
pub(crate) fn update_dom_content_loaded_event_start(&self, value: u64) {
|
||||
self.dom_content_loaded_event_start.set(value);
|
||||
}
|
||||
pub fn update_dom_content_loaded_event_end(&self, value: u64) {
|
||||
pub(crate) fn update_dom_content_loaded_event_end(&self, value: u64) {
|
||||
self.dom_content_loaded_event_end.set(value);
|
||||
}
|
||||
pub fn update_dom_complete(&self, value: u64) {
|
||||
pub(crate) fn update_dom_complete(&self, value: u64) {
|
||||
self.dom_complete.set(value);
|
||||
}
|
||||
pub fn update_load_event_start(&self, value: u64) {
|
||||
pub(crate) fn update_load_event_start(&self, value: u64) {
|
||||
self.load_event_start.set(value);
|
||||
}
|
||||
pub fn update_load_event_end(&self, value: u64) {
|
||||
pub(crate) fn update_load_event_end(&self, value: u64) {
|
||||
self.load_event_end.set(value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue