diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 4141e04d803..1b5c217bea2 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -772,6 +772,7 @@ impl Constellation self.all_descendant_browsing_contexts_iter(BrowsingContextId::from(top_level_browsing_context_id)) } + #[cfg(feature = "unstable")] /// The joint session future is the merge of the session future of every /// browsing_context, sorted chronologically. fn joint_session_future<'a>(&'a self, top_level_browsing_context_id: TopLevelBrowsingContextId) @@ -782,12 +783,26 @@ impl Constellation .kmerge_by(|a, b| a.instant.cmp(&b.instant) == Ordering::Less) } + #[cfg(not(feature = "unstable"))] + /// The joint session future is the merge of the session future of every + /// browsing_context, sorted chronologically. + fn joint_session_future<'a>(&'a self, top_level_browsing_context_id: TopLevelBrowsingContextId) + -> Box + 'a> + { + Box::new( + self.all_browsing_contexts_iter(top_level_browsing_context_id) + .map(|browsing_context| browsing_context.next.iter().rev()) + .kmerge_by(|a, b| a.instant.cmp(&b.instant) == Ordering::Less) + ) + } + /// Is the joint session future empty? fn joint_session_future_is_empty(&self, top_level_browsing_context_id: TopLevelBrowsingContextId) -> bool { self.all_browsing_contexts_iter(top_level_browsing_context_id) .all(|browsing_context| browsing_context.next.is_empty()) } + #[cfg(feature = "unstable")] /// The joint session past is the merge of the session past of every /// browsing_context, sorted reverse chronologically. fn joint_session_past<'a>(&'a self, top_level_browsing_context_id: TopLevelBrowsingContextId) @@ -804,6 +819,25 @@ impl Constellation .map(|(_, entry)| entry) } + #[cfg(not(feature = "unstable"))] + /// The joint session past is the merge of the session past of every + /// browsing_context, sorted reverse chronologically. + fn joint_session_past<'a>(&'a self, top_level_browsing_context_id: TopLevelBrowsingContextId) + -> Box + 'a> + { + Box::new( + self.all_browsing_contexts_iter(top_level_browsing_context_id) + .map(|browsing_context| browsing_context.prev.iter().rev() + .scan(browsing_context.instant, |prev_instant, entry| { + let instant = *prev_instant; + *prev_instant = entry.instant; + Some((instant, entry)) + })) + .kmerge_by(|a, b| a.0.cmp(&b.0) == Ordering::Greater) + .map(|(_, entry)| entry) + ) + } + /// Is the joint session past empty? fn joint_session_past_is_empty(&self, top_level_browsing_context_id: TopLevelBrowsingContextId) -> bool { self.all_browsing_contexts_iter(top_level_browsing_context_id) diff --git a/components/constellation/lib.rs b/components/constellation/lib.rs index 0258702cec9..a0fd36325a8 100644 --- a/components/constellation/lib.rs +++ b/components/constellation/lib.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] -#![feature(conservative_impl_trait)] +#![cfg_attr(feature = "unstable", feature(conservative_impl_trait))] #![feature(mpsc_select)] extern crate backtrace;