diff options
author | Iulian Gabriel Radu <iulian.radu67@gmail.com> | 2019-04-11 00:26:01 +0300 |
---|---|---|
committer | Iulian Gabriel Radu <iulian.radu67@gmail.com> | 2019-06-26 02:07:24 +0300 |
commit | 62f0785c2c042b809400c704eda7a76bae954b5a (patch) | |
tree | 1d5461e7f6dd116358c47cd1f3fc3117d8d8c783 /components/script/dom/performancenavigation.rs | |
parent | e100af57a5bd95701b5310871e9909e3726539f0 (diff) | |
download | servo-62f0785c2c042b809400c704eda7a76bae954b5a.tar.gz servo-62f0785c2c042b809400c704eda7a76bae954b5a.zip |
Implement PerformanceNavigation interface
Diffstat (limited to 'components/script/dom/performancenavigation.rs')
-rw-r--r-- | components/script/dom/performancenavigation.rs | 45 |
1 files changed, 45 insertions, 0 deletions
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() + } +} |