diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-11-16 09:54:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-16 09:54:40 -0500 |
commit | a2937d948818665ecda16a06fe6c8fa751d265fd (patch) | |
tree | 7c925d0d1517807e56963847da4c3ca25d7b2626 /components/script/stylesheet_loader.rs | |
parent | 050b2bca70b09a84901de84b4538f19da3250eee (diff) | |
parent | 75eb94afcaae2f868ecccba5b5dcea4066998d7a (diff) | |
download | servo-a2937d948818665ecda16a06fe6c8fa751d265fd.tar.gz servo-a2937d948818665ecda16a06fe6c8fa751d265fd.zip |
Auto merge of #21804 - AgustinCB:unify-task-source-canceller-api, r=gterzian
Unify the task source and task canceller API
To do so, I created a struct `TaskManagement(TaskSource,
TaskCanceller)` and made `*_task_source` return that instead of just
the task source.
Next, I refactored all places in which `task_canceller` by basically
removing them in favour of a previously called `*_task_source`.
I tried to make `task_canceller` a private method in `Window`, with the
hope of enforcing the use of `*_task_source`. However, it's used in
components/script/dom/globalscope.rs:575 in such a way that will make it
harder to avoid. I decided to leave it that way.
It'd be possible to unify `*_task_source` in such a way that we would
have only one method. However, I decided not to do it because one of the
`TaskSource` implementations is special:
`history_traversal_task_source`. Not wanting to over complicate things,
I decided to leave the structure this way.
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #21154 (github issue number if applicable).
- [x] These changes do not require tests because it's refactoring code that should already be tested.
<!-- 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/21804)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/stylesheet_loader.rs')
-rw-r--r-- | components/script/stylesheet_loader.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs index 29144d48836..43d9cb3bb92 100644 --- a/components/script/stylesheet_loader.rs +++ b/components/script/stylesheet_loader.rs @@ -13,7 +13,6 @@ use crate::dom::htmlelement::HTMLElement; use crate::dom::htmllinkelement::{HTMLLinkElement, RequestGenerationId}; use crate::dom::node::{document_from_node, window_from_node}; use crate::network_listener::{NetworkListener, PreInvoke}; -use crate::task_source::TaskSourceName; use cssparser::SourceLocation; use encoding_rs::UTF_8; use ipc_channel::ipc; @@ -245,10 +244,14 @@ impl<'a> StylesheetLoader<'a> { })); let (action_sender, action_receiver) = ipc::channel().unwrap(); + let (task_source, canceller) = document + .window() + .task_manager() + .networking_task_source_with_canceller(); let listener = NetworkListener { - context: context, - task_source: document.window().networking_task_source(), - canceller: Some(document.window().task_canceller(TaskSourceName::Networking)), + context, + task_source, + canceller: Some(canceller), }; ROUTER.add_route( action_receiver.to_opaque(), |