mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Pass the timing information to PerformanceTiming rather than exposing methods.
This commit is contained in:
parent
d67bcfa7ce
commit
e4dc6ca2ec
3 changed files with 22 additions and 16 deletions
|
@ -20,15 +20,23 @@ pub struct Performance {
|
|||
}
|
||||
|
||||
impl Performance {
|
||||
fn new_inherited(window: JSRef<Window>) -> Performance {
|
||||
fn new_inherited(window: JSRef<Window>,
|
||||
navigation_start: u64,
|
||||
navigation_start_precise: f64) -> Performance {
|
||||
Performance {
|
||||
reflector_: Reflector::new(),
|
||||
timing: JS::from_rooted(PerformanceTiming::new(window)),
|
||||
timing: JS::from_rooted(PerformanceTiming::new(window,
|
||||
navigation_start,
|
||||
navigation_start_precise)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(window: JSRef<Window>) -> Temporary<Performance> {
|
||||
reflect_dom_object(box Performance::new_inherited(window),
|
||||
pub fn new(window: JSRef<Window>,
|
||||
navigation_start: u64,
|
||||
navigation_start_precise: f64) -> Temporary<Performance> {
|
||||
reflect_dom_object(box Performance::new_inherited(window,
|
||||
navigation_start,
|
||||
navigation_start_precise),
|
||||
global::Window(window),
|
||||
PerformanceBinding::Wrap)
|
||||
}
|
||||
|
|
|
@ -27,9 +27,12 @@ impl PerformanceTiming {
|
|||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(window: JSRef<Window>) -> Temporary<PerformanceTiming> {
|
||||
let timing = PerformanceTiming::new_inherited(window.navigation_start(),
|
||||
window.navigation_start_precise());
|
||||
pub fn new(window: JSRef<Window>,
|
||||
navigation_start: u64,
|
||||
navigation_start_precise: f64)
|
||||
-> Temporary<PerformanceTiming> {
|
||||
let timing = PerformanceTiming::new_inherited(navigation_start,
|
||||
navigation_start_precise);
|
||||
reflect_dom_object(box timing, global::Window(window),
|
||||
PerformanceTimingBinding::Wrap)
|
||||
}
|
||||
|
|
|
@ -98,14 +98,6 @@ impl Window {
|
|||
&*self.page
|
||||
}
|
||||
|
||||
pub fn navigation_start(&self) -> u64 {
|
||||
self.navigation_start
|
||||
}
|
||||
|
||||
pub fn navigation_start_precise(&self) -> f64 {
|
||||
self.navigation_start_precise
|
||||
}
|
||||
|
||||
pub fn get_url(&self) -> Url {
|
||||
self.page().get_url()
|
||||
}
|
||||
|
@ -267,7 +259,10 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
|||
}
|
||||
|
||||
fn Performance(self) -> Temporary<Performance> {
|
||||
self.performance.or_init(|| Performance::new(self))
|
||||
self.performance.or_init(|| {
|
||||
Performance::new(self, self.navigation_start,
|
||||
self.navigation_start_precise)
|
||||
})
|
||||
}
|
||||
|
||||
global_event_handlers!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue