mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Send AsyncJobHandler as a MainThreadTask
This commit is contained in:
parent
4a39631eaf
commit
9a267e53fe
2 changed files with 20 additions and 2 deletions
|
@ -133,8 +133,10 @@ impl JobQueue {
|
||||||
if job_queue.is_empty() {
|
if job_queue.is_empty() {
|
||||||
let scope_url = job.scope_url.clone();
|
let scope_url = job.scope_url.clone();
|
||||||
job_queue.push(job);
|
job_queue.push(job);
|
||||||
let run_job_handler = box AsyncJobHandler::new(scope_url);
|
let _ = script_thread.dom_manipulation_task_source().queue_main_thread_task(
|
||||||
let _ = script_thread.dom_manipulation_task_source().queue(run_job_handler, global);
|
box AsyncJobHandler::new(scope_url),
|
||||||
|
global,
|
||||||
|
);
|
||||||
debug!("queued task to run newly-queued job");
|
debug!("queued task to run newly-queued job");
|
||||||
} else {
|
} else {
|
||||||
// Step 2
|
// Step 2
|
||||||
|
|
|
@ -6,6 +6,7 @@ use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::refcounted::Trusted;
|
use dom::bindings::refcounted::Trusted;
|
||||||
use dom::event::{EventBubbles, EventCancelable, EventTask, SimpleEventTask};
|
use dom::event::{EventBubbles, EventCancelable, EventTask, SimpleEventTask};
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
||||||
use script_thread::{MainThreadScriptMsg, Task, TaskCanceller};
|
use script_thread::{MainThreadScriptMsg, Task, TaskCanceller};
|
||||||
|
@ -42,6 +43,21 @@ impl TaskSource for DOMManipulationTaskSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DOMManipulationTaskSource {
|
impl DOMManipulationTaskSource {
|
||||||
|
pub fn queue_main_thread_task<T>(
|
||||||
|
&self,
|
||||||
|
task: Box<T>,
|
||||||
|
global: &GlobalScope,
|
||||||
|
) -> Result<(), ()>
|
||||||
|
where
|
||||||
|
T: Task + Send + 'static,
|
||||||
|
{
|
||||||
|
let msg = MainThreadScriptMsg::MainThreadTask(
|
||||||
|
ScriptThreadEventCategory::ScriptEvent,
|
||||||
|
global.task_canceller().wrap_task(task),
|
||||||
|
);
|
||||||
|
self.0.send(msg).map_err(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn queue_event(&self,
|
pub fn queue_event(&self,
|
||||||
target: &EventTarget,
|
target: &EventTarget,
|
||||||
name: Atom,
|
name: Atom,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue