mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
implementing MainThreadRunnable in ScriptTask
This commit is contained in:
parent
da2231a8fa
commit
e1f34b827d
1 changed files with 8 additions and 0 deletions
|
@ -155,6 +155,10 @@ pub trait Runnable {
|
||||||
fn handler(self: Box<Self>);
|
fn handler(self: Box<Self>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait MainThreadRunnable {
|
||||||
|
fn handler(self: Box<Self>, script_task: &ScriptTask);
|
||||||
|
}
|
||||||
|
|
||||||
/// Messages used to control script event loops, such as ScriptTask and
|
/// Messages used to control script event loops, such as ScriptTask and
|
||||||
/// DedicatedWorkerGlobalScope.
|
/// DedicatedWorkerGlobalScope.
|
||||||
pub enum ScriptMsg {
|
pub enum ScriptMsg {
|
||||||
|
@ -176,6 +180,8 @@ pub enum ScriptMsg {
|
||||||
DOMMessage(StructuredCloneData),
|
DOMMessage(StructuredCloneData),
|
||||||
/// Generic message that encapsulates event handling.
|
/// Generic message that encapsulates event handling.
|
||||||
RunnableMsg(Box<Runnable+Send>),
|
RunnableMsg(Box<Runnable+Send>),
|
||||||
|
/// Generic message for running tasks in the ScriptTask
|
||||||
|
MainThreadRunnableMsg(Box<MainThreadRunnable+Send>),
|
||||||
/// A DOM object's last pinned reference was removed (dispatched to all tasks).
|
/// A DOM object's last pinned reference was removed (dispatched to all tasks).
|
||||||
RefcountCleanup(TrustedReference),
|
RefcountCleanup(TrustedReference),
|
||||||
/// The final network response for a page has arrived.
|
/// The final network response for a page has arrived.
|
||||||
|
@ -675,6 +681,8 @@ impl ScriptTask {
|
||||||
panic!("unexpected message"),
|
panic!("unexpected message"),
|
||||||
ScriptMsg::RunnableMsg(runnable) =>
|
ScriptMsg::RunnableMsg(runnable) =>
|
||||||
runnable.handler(),
|
runnable.handler(),
|
||||||
|
ScriptMsg::MainThreadRunnableMsg(runnable) =>
|
||||||
|
runnable.handler(self),
|
||||||
ScriptMsg::RefcountCleanup(addr) =>
|
ScriptMsg::RefcountCleanup(addr) =>
|
||||||
LiveDOMReferences::cleanup(self.get_cx(), addr),
|
LiveDOMReferences::cleanup(self.get_cx(), addr),
|
||||||
ScriptMsg::PageFetchComplete(id, subpage, response) =>
|
ScriptMsg::PageFetchComplete(id, subpage, response) =>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue