diff options
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/mod.rs | 1 | ||||
-rw-r--r-- | components/script/dom/performance.rs | 6 | ||||
-rw-r--r-- | components/script/dom/performancenavigation.rs | 45 | ||||
-rw-r--r-- | components/script/dom/webidls/Performance.webidl | 5 | ||||
-rw-r--r-- | components/script/dom/webidls/PerformanceNavigation.webidl | 18 |
5 files changed, 75 insertions, 0 deletions
diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index d20b68c92b7..0a654f93c57 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -428,6 +428,7 @@ pub mod performance; pub mod performanceentry; pub mod performancemark; pub mod performancemeasure; +pub mod performancenavigation; pub mod performancenavigationtiming; pub mod performanceobserver; pub mod performanceobserverentrylist; diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs index 9dff17fd872..b29858fdca5 100644 --- a/components/script/dom/performance.rs +++ b/components/script/dom/performance.rs @@ -19,6 +19,7 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::performanceentry::PerformanceEntry; use crate::dom::performancemark::PerformanceMark; use crate::dom::performancemeasure::PerformanceMeasure; +use crate::dom::performancenavigation::PerformanceNavigation; use crate::dom::performancenavigationtiming::PerformanceNavigationTiming; use crate::dom::performanceobserver::PerformanceObserver as DOMPerformanceObserver; use crate::dom::window::Window; @@ -372,6 +373,11 @@ impl PerformanceMethods for Performance { unreachable!("Are we trying to expose Performance.timing in workers?"); } + // https://w3c.github.io/navigation-timing/#dom-performance-navigation + fn Navigation(&self) -> DomRoot<PerformanceNavigation> { + PerformanceNavigation::new(&self.global()) + } + // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighResolutionTime/Overview.html#dom-performance-now fn Now(&self) -> DOMHighResTimeStamp { Finite::wrap(self.now()) diff --git a/components/script/dom/performancenavigation.rs b/components/script/dom/performancenavigation.rs new file mode 100644 index 00000000000..db93441480f --- /dev/null +++ b/components/script/dom/performancenavigation.rs @@ -0,0 +1,45 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +use crate::dom::bindings::codegen::Bindings::PerformanceNavigationBinding::{ + self, PerformanceNavigationConstants, PerformanceNavigationMethods, +}; +use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; +use crate::dom::bindings::root::DomRoot; +use crate::dom::globalscope::GlobalScope; +use dom_struct::dom_struct; + +#[dom_struct] +pub struct PerformanceNavigation { + reflector_: Reflector, +} + +impl PerformanceNavigation { + fn new_inherited() -> PerformanceNavigation { + PerformanceNavigation { + reflector_: Reflector::new(), + } + } + + pub fn new(global: &GlobalScope) -> DomRoot<PerformanceNavigation> { + reflect_dom_object( + Box::new(PerformanceNavigation::new_inherited()), + global, + PerformanceNavigationBinding::Wrap, + ) + } +} + +impl PerformanceNavigationMethods for PerformanceNavigation { + // https://w3c.github.io/navigation-timing/#dom-performancenavigation-type + fn Type(&self) -> u16 { + PerformanceNavigationConstants::TYPE_NAVIGATE + } + + // https://w3c.github.io/navigation-timing/#dom-performancenavigation-redirectcount + fn RedirectCount(&self) -> u16 { + self.global().as_window().Document().get_redirect_count() + } +} diff --git a/components/script/dom/webidls/Performance.webidl b/components/script/dom/webidls/Performance.webidl index 45358ffa6e8..77bca4392e7 100644 --- a/components/script/dom/webidls/Performance.webidl +++ b/components/script/dom/webidls/Performance.webidl @@ -49,3 +49,8 @@ partial interface Performance { partial interface Performance { PerformanceNavigationTiming timing(); }; +// https://w3c.github.io/navigation-timing/#extensions-to-the-performance-interface +partial interface Performance { + [SameObject, Exposed=Window] + readonly attribute PerformanceNavigation navigation; +}; diff --git a/components/script/dom/webidls/PerformanceNavigation.webidl b/components/script/dom/webidls/PerformanceNavigation.webidl new file mode 100644 index 00000000000..5a1ccba61f1 --- /dev/null +++ b/components/script/dom/webidls/PerformanceNavigation.webidl @@ -0,0 +1,18 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +/* + * The origin of this IDL file is + * https://w3c.github.io/navigation-timing/#the-performancenavigation-interface + */ + +[Exposed=Window] +interface PerformanceNavigation { + const unsigned short TYPE_NAVIGATE = 0; + const unsigned short TYPE_RELOAD = 1; + const unsigned short TYPE_BACK_FORWARD = 2; + const unsigned short TYPE_RESERVED = 255; + readonly attribute unsigned short type; + readonly attribute unsigned short redirectCount; + // [Default] object toJSON(); +}; |