servo: Merge #17258 - Reduce code duplication when adding a SessionHistoryChange (from jkl445:issue-17249); r=cbrewster

<!-- Please describe your changes on the following line: -->
Implemented add_pending_change method and refactored code to use this new method

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #17249 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 1e1b7f6ac2ff44f43d47ed0302016df106a782ee

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 4f456692d4d9706a14721a0b302668a82248a64b
This commit is contained in:
Jeroen Kleijn 2017-06-09 11:41:53 -07:00
Родитель 8c3a82a2d2
Коммит bb39cc5939
1 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -800,6 +800,12 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}
fn add_pending_change(&mut self, change: SessionHistoryChange)
{
self.handle_load_start_msg(change.new_pipeline_id);
self.pending_changes.push(change);
}
/// Handles loading pages, navigation, and granting access to the compositor
#[allow(unsafe_code)]
fn handle_request(&mut self) {
@ -1418,8 +1424,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
let sandbox = IFrameSandboxState::IFrameSandboxed;
self.new_pipeline(new_pipeline_id, browsing_context_id, top_level_browsing_context_id, parent_info,
window_size, load_data.clone(), sandbox, false);
self.handle_load_start_msg(new_pipeline_id);
self.pending_changes.push(SessionHistoryChange {
self.add_pending_change(SessionHistoryChange {
top_level_browsing_context_id: top_level_browsing_context_id,
browsing_context_id: browsing_context_id,
new_pipeline_id: new_pipeline_id,
@ -1476,8 +1481,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
load_data.clone(),
sandbox,
false);
self.handle_load_start_msg(pipeline_id);
self.pending_changes.push(SessionHistoryChange {
self.add_pending_change(SessionHistoryChange {
top_level_browsing_context_id: top_level_browsing_context_id,
browsing_context_id: browsing_context_id,
new_pipeline_id: pipeline_id,
@ -1573,8 +1577,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
};
// Create the new pipeline, attached to the parent and push to pending changes
self.handle_load_start_msg(load_info.info.new_pipeline_id);
self.pending_changes.push(SessionHistoryChange {
self.add_pending_change(SessionHistoryChange {
top_level_browsing_context_id: load_info.info.top_level_browsing_context_id,
browsing_context_id: load_info.info.browsing_context_id,
new_pipeline_id: load_info.info.new_pipeline_id,
@ -1639,8 +1642,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
assert!(!self.pipelines.contains_key(&new_pipeline_id));
self.pipelines.insert(new_pipeline_id, pipeline);
self.handle_load_start_msg(new_pipeline_id);
self.pending_changes.push(SessionHistoryChange {
self.add_pending_change(SessionHistoryChange {
top_level_browsing_context_id: top_level_browsing_context_id,
browsing_context_id: browsing_context_id,
new_pipeline_id: new_pipeline_id,
@ -1791,8 +1793,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
let new_pipeline_id = PipelineId::new();
let sandbox = IFrameSandboxState::IFrameUnsandboxed;
let replace_instant = if replace { Some(timestamp) } else { None };
self.handle_load_start_msg(new_pipeline_id);
self.pending_changes.push(SessionHistoryChange {
self.add_pending_change(SessionHistoryChange {
top_level_browsing_context_id: top_level_id,
browsing_context_id: browsing_context_id,
new_pipeline_id: new_pipeline_id,
@ -2180,8 +2181,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
};
self.new_pipeline(new_pipeline_id, browsing_context_id, top_level_id, parent_info,
window_size, load_data.clone(), sandbox, is_private);
self.handle_load_start_msg(new_pipeline_id);
self.pending_changes.push(SessionHistoryChange {
self.add_pending_change(SessionHistoryChange {
top_level_browsing_context_id: top_level_id,
browsing_context_id: browsing_context_id,
new_pipeline_id: new_pipeline_id,