aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/performancenavigation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/performancenavigation.rs')
-rw-r--r--components/script/dom/performancenavigation.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/components/script/dom/performancenavigation.rs b/components/script/dom/performancenavigation.rs
new file mode 100644
index 00000000000..f52250b815c
--- /dev/null
+++ b/components/script/dom/performancenavigation.rs
@@ -0,0 +1,41 @@
+/* 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::{
+ 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)
+ }
+}
+
+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()
+ }
+}