aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-07-18 10:24:44 -0700
committerGitHub <noreply@github.com>2017-07-18 10:24:44 -0700
commiteb26194dd12f1430e9089512d54973d3b12b2e36 (patch)
treea74711d4e49956f751f54f2dbca7b6675bf1c066 /components/script/dom
parent66e06578ee68b98c94029fba3cfc3ae7d3782044 (diff)
parentdb044bdbef7807cd16d38a16e24935e83614980a (diff)
downloadservo-eb26194dd12f1430e9089512d54973d3b12b2e36.tar.gz
servo-eb26194dd12f1430e9089512d54973d3b12b2e36.zip
Auto merge of #17735 - ferjm:navigationstart, r=jdm
Set navigation start value according to navigation timing spec - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #17651 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17735) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/document.rs2
-rw-r--r--components/script/dom/window.rs22
2 files changed, 17 insertions, 7 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 27bd4f10004..2d95efbc294 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -3659,6 +3659,8 @@ impl DocumentMethods for Document {
// Step 10.
// TODO: prompt to unload.
+ window_from_node(self).set_navigation_start();
+
// Step 11.
// TODO: unload.
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 487bf48eaba..3c87e5f6b0b 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -184,8 +184,8 @@ pub struct Window {
history: MutNullableJS<History>,
custom_element_registry: MutNullableJS<CustomElementRegistry>,
performance: MutNullableJS<Performance>,
- navigation_start: u64,
- navigation_start_precise: f64,
+ navigation_start: Cell<u64>,
+ navigation_start_precise: Cell<f64>,
screen: MutNullableJS<Screen>,
session_storage: MutNullableJS<Storage>,
local_storage: MutNullableJS<Storage>,
@@ -702,8 +702,8 @@ impl WindowMethods for Window {
// NavigationTiming/Overview.html#sec-window.performance-attribute
fn Performance(&self) -> Root<Performance> {
self.performance.or_init(|| {
- Performance::new(self, self.navigation_start,
- self.navigation_start_precise)
+ Performance::new(self, self.navigation_start.get(),
+ self.navigation_start_precise.get())
})
}
@@ -1772,6 +1772,13 @@ impl Window {
pub fn unminified_js_dir(&self) -> Option<String> {
self.unminified_js_dir.borrow().clone()
}
+
+ pub fn set_navigation_start(&self) {
+ let current_time = time::get_time();
+ let now = (current_time.sec * 1000 + current_time.nsec as i64 / 1000000) as u64;
+ self.navigation_start.set(now);
+ self.navigation_start_precise.set(time::precise_time_ns() as f64);
+ }
}
impl Window {
@@ -1799,6 +1806,8 @@ impl Window {
parent_info: Option<(PipelineId, FrameType)>,
window_size: Option<WindowSizeData>,
origin: MutableOrigin,
+ navigation_start: u64,
+ navigation_start_precise: f64,
webvr_thread: Option<IpcSender<WebVRMsg>>)
-> Root<Window> {
let layout_rpc: Box<LayoutRPC + Send> = {
@@ -1810,7 +1819,6 @@ impl Window {
pipelineid: id,
script_chan: Arc::new(Mutex::new(control_chan)),
};
- let current_time = time::get_time();
let win = box Window {
globalscope:
GlobalScope::new_inherited(
@@ -1837,8 +1845,8 @@ impl Window {
window_proxy: Default::default(),
document: Default::default(),
performance: Default::default(),
- navigation_start: (current_time.sec * 1000 + current_time.nsec as i64 / 1000000) as u64,
- navigation_start_precise: time::precise_time_ns() as f64,
+ navigation_start: Cell::new(navigation_start),
+ navigation_start_precise: Cell::new(navigation_start_precise),
screen: Default::default(),
session_storage: Default::default(),
local_storage: Default::default(),