Skip to content

Commit

Permalink
Auto merge of #17258 - jkl445:issue-17249, r=cbrewster
Browse files Browse the repository at this point in the history
Reduce code duplication when adding a SessionHistoryChange

<!-- 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. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17258)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jun 9, 2017
2 parents 88b47b0 + bca052e commit 1e1b7f6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions components/constellation/constellation.rs
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1e1b7f6

Please sign in to comment.