Remove entries for removed iframes

Notify history changed after a navigation

Add history drop test
This commit is contained in:
Connor Brewster 2018-04-06 21:20:14 -05:00
parent ae117be752
commit 787ec4b209
5 changed files with 64 additions and 4 deletions

View file

@ -2453,13 +2453,13 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
self.trim_history(top_level_id);
}
self.notify_history_changed(change.top_level_browsing_context_id);
self.update_frame_tree_if_active(change.top_level_browsing_context_id);
}
fn trim_history(&mut self, top_level_browsing_context_id: TopLevelBrowsingContextId) {
let pipelines_to_evict = {
let session_history = self.joint_session_histories.entry(top_level_browsing_context_id)
.or_insert(JointSessionHistory::new());
let session_history = self.get_joint_session_history(top_level_browsing_context_id);
let history_length = PREFS.get("session-history.max-length").as_u64().unwrap_or(20) as usize;
@ -2493,8 +2493,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
self.close_pipeline(evicted_id, DiscardBrowsingContext::No, ExitPipelineMode::Normal);
}
let session_history = self.joint_session_histories.entry(top_level_browsing_context_id)
.or_insert(JointSessionHistory::new());
let session_history = self.get_joint_session_history(top_level_browsing_context_id);
for (alive_id, dead) in dead_pipelines {
session_history.replace(NeedsToReload::No(alive_id), dead);
@ -2778,6 +2777,11 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
Some(browsing_context) => browsing_context,
};
{
let session_history = self.get_joint_session_history(browsing_context.top_level_id);
session_history.remove_entries_for_browsing_context(browsing_context_id);
}
if BrowsingContextId::from(browsing_context.top_level_id) == browsing_context_id {
self.event_loops.remove(&browsing_context.top_level_id);
}
@ -2905,6 +2909,10 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}
fn get_joint_session_history(&mut self, top_level_id: TopLevelBrowsingContextId) -> &mut JointSessionHistory {
self.joint_session_histories.entry(top_level_id).or_insert(JointSessionHistory::new())
}
// Convert a browsing context to a sendable form to pass to the compositor
fn browsing_context_to_sendable(&self, browsing_context_id: BrowsingContextId) -> Option<SendableFrameTree> {
self.browsing_contexts.get(&browsing_context_id).and_then(|browsing_context| {

View file

@ -42,6 +42,15 @@ impl JointSessionHistory {
diff.replace(&old_reloader, &new_reloader);
}
}
pub fn remove_entries_for_browsing_context(&mut self, context_id: BrowsingContextId) {
self.past.retain(|&SessionHistoryDiff::BrowsingContextDiff { browsing_context_id, .. }| {
browsing_context_id != context_id
});
self.future.retain(|&SessionHistoryDiff::BrowsingContextDiff { browsing_context_id, .. }| {
browsing_context_id != context_id
});
}
}
/// Represents a pending change in a session history, that will be applied