diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-05-07 13:22:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-07 13:22:23 -0400 |
commit | 1d8283e01059710737f55531e777a4f19adb6f9e (patch) | |
tree | 1466d8d62367c5d641436b5c568db500a80b5a0e /components/script/script_thread.rs | |
parent | dc17b32cebc956385084288765c9f5a78e60ee28 (diff) | |
parent | 29d1cf6270b56af65971f27af4aa47c549eef788 (diff) | |
download | servo-1d8283e01059710737f55531e777a4f19adb6f9e.tar.gz servo-1d8283e01059710737f55531e777a4f19adb6f9e.zip |
Auto merge of #20329 - gterzian:before_unload, r=cbrewster
Implement beforeunload event and infrastructure
<!-- Please describe your changes on the following line: -->
Implementation of:
1. https://html.spec.whatwg.org/multipage/#prompt-to-unload-a-document, and
2. https://html.spec.whatwg.org/multipage/#unload-a-document
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #10787 and fix #20485 and fix #20588 and fix #20496 (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/20329)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 6ee0ec46d33..613918f6a76 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1157,6 +1157,7 @@ impl ScriptThread { AttachLayout(ref new_layout_info) => Some(new_layout_info.new_pipeline_id), Resize(id, ..) => Some(id), ResizeInactive(id, ..) => Some(id), + UnloadDocument(id) => Some(id), ExitPipeline(id, ..) => Some(id), ExitScriptThread => None, SendEvent(id, ..) => Some(id), @@ -1275,6 +1276,8 @@ impl ScriptThread { }, ConstellationControlMsg::Navigate(parent_pipeline_id, browsing_context_id, load_data, replace) => self.handle_navigate(parent_pipeline_id, Some(browsing_context_id), load_data, replace), + ConstellationControlMsg::UnloadDocument(pipeline_id) => + self.handle_unload_document(pipeline_id), ConstellationControlMsg::SendEvent(id, event) => self.handle_event(id, event), ConstellationControlMsg::ResizeInactive(id, new_size) => @@ -1668,6 +1671,13 @@ impl ScriptThread { } } + fn handle_unload_document(&self, pipeline_id: PipelineId) { + let document = self.documents.borrow().find_document(pipeline_id); + if let Some(document) = document { + document.unload(false, false); + } + } + fn handle_update_pipeline_id(&self, parent_pipeline_id: PipelineId, browsing_context_id: BrowsingContextId, |