servo/components/script
Agustin Chiappe Berrini 75eb94afca Unify the task source and task canceller API
I moved away from the `Window` struct all the logic to handle task
sources, into a new struct called `TaskManager`. In a happy world, I'd
be able to just have there two functions, of the types:

```rust
fn task_source<T: TaskSource>(&self, name: TaskSourceName) -> Box<T>
fn task_source_with_canceller<T: TaskSource>(&self, name: TaskSourceName)
  -> (Box<T>, TaskSourceCanceller)
```

And not so much duplicated code. However, because TaskSource can't be a
trait object (because it has generic type parameters), that's not
possible. Instead, I decided to reduce duplicated logic through macros.

For reasons[1], I have to pass both the name of the function with
canceller and the name of the function without, as I'm not able to
concatenate them in the macro itself. I could probably use
`concat_idents` to create both types already defined and reduce the
amount of arguments by one, but that macro is nightly only. At the same
time, not being able to declare macros inside `impl` forces me to pass
`self` as an argument.

All this makes this solution more verbose than it would be ideally. It
does reduce duplication, but it doesn't reduce the size of the file.

[1](https://github.com/rust-lang/rust/issues/29599)
2018-11-14 06:36:44 -05:00
..
docs Replace http with https in docs 2018-11-06 11:39:09 +01:00
dom Unify the task source and task canceller API 2018-11-14 06:36:44 -05:00
task_source Unify the task source and task canceller API 2018-11-14 06:36:44 -05:00
body.rs Format remaining files 2018-11-06 22:30:31 +01:00
build.rs Remove useless use crate_name; imports. 2018-11-08 09:29:52 +01:00
Cargo.toml Use keyboard-types::webdriver::send_keys 2018-11-11 21:57:45 +01:00
clipboard_provider.rs Reorder imports 2018-11-06 22:35:07 +01:00
CMakeLists.txt build(cmake): detect python binary for specified version 2018-03-13 09:25:06 -07:00
devtools.rs Reorder imports 2018-11-06 22:35:07 +01:00
document_loader.rs Reorder imports 2018-11-06 22:35:07 +01:00
fetch.rs Reorder imports 2018-11-06 22:35:07 +01:00
layout_image.rs Unify the task source and task canceller API 2018-11-14 06:36:44 -05:00
lib.rs Unify the task source and task canceller API 2018-11-14 06:36:44 -05:00
mem.rs Format script component 2018-09-19 17:40:47 -04:00
microtask.rs Sort use statements 2018-11-06 15:26:02 +01:00
network_listener.rs Reorder imports 2018-11-06 22:35:07 +01:00
script_runtime.rs Implement TaskSource for HistoryTraversal 2018-11-13 14:18:51 -05:00
script_thread.rs Unify the task source and task canceller API 2018-11-14 06:36:44 -05:00
serviceworker_manager.rs Reorder imports 2018-11-06 22:35:07 +01:00
serviceworkerjob.rs Reorder imports 2018-11-06 22:35:07 +01:00
stylesheet_loader.rs Unify the task source and task canceller API 2018-11-14 06:36:44 -05:00
task.rs cargo fix --edition-idioms 2018-11-08 09:28:00 +01:00
task_manager.rs Unify the task source and task canceller API 2018-11-14 06:36:44 -05:00
task_queue.rs cargo fix --edition-idioms 2018-11-08 09:28:00 +01:00
test.rs Reorder imports 2018-11-06 22:35:07 +01:00
textinput.rs Correct select all 2018-11-07 18:58:51 +01:00
timers.rs Reorder imports 2018-11-06 22:35:07 +01:00
unpremultiplytable.rs Format script component 2018-09-19 17:40:47 -04:00
webdriver_handlers.rs cargo fix --edition-idioms 2018-11-08 09:28:00 +01:00