mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Move boxing to runnable initialization
This commit is contained in:
parent
5f7324a9a5
commit
ad30275d04
10 changed files with 20 additions and 20 deletions
|
@ -73,7 +73,7 @@ impl VirtualMethods for HTMLDetailsElement {
|
|||
let window = window_from_node(self);
|
||||
let task_source = window.dom_manipulation_task_source();
|
||||
let details = Trusted::new(self);
|
||||
let runnable = DetailsNotificationRunnable {
|
||||
let runnable = box DetailsNotificationRunnable {
|
||||
element: details,
|
||||
toggle_number: counter
|
||||
};
|
||||
|
|
|
@ -474,7 +474,7 @@ impl HTMLFormElement {
|
|||
self.generation_id.set(GenerationId(prev_id + 1));
|
||||
|
||||
// Step 2
|
||||
let nav = PlannedNavigation {
|
||||
let nav = box PlannedNavigation {
|
||||
load_data: load_data,
|
||||
pipeline_id: window.pipeline(),
|
||||
script_chan: window.main_thread_script_chan().clone(),
|
||||
|
|
|
@ -140,7 +140,7 @@ impl HTMLImageElement {
|
|||
// Return the image via a message to the script thread, which marks the element
|
||||
// as dirty and triggers a reflow.
|
||||
let image_response = message.to().unwrap();
|
||||
let runnable = ImageResponseHandlerRunnable::new(
|
||||
let runnable = box ImageResponseHandlerRunnable::new(
|
||||
trusted_node.clone(), image_response);
|
||||
let runnable = wrapper.wrap_runnable(runnable);
|
||||
let _ = script_chan.send(CommonScriptMsg::RunnableMsg(
|
||||
|
@ -179,7 +179,7 @@ impl HTMLImageElement {
|
|||
}
|
||||
}
|
||||
|
||||
let runnable = ImgParseErrorRunnable {
|
||||
let runnable = box ImgParseErrorRunnable {
|
||||
img: Trusted::new(self),
|
||||
src: src.into(),
|
||||
};
|
||||
|
|
|
@ -237,7 +237,7 @@ impl HTMLMediaElement {
|
|||
}
|
||||
}
|
||||
|
||||
let task = Task {
|
||||
let task = box Task {
|
||||
elem: Trusted::new(self),
|
||||
};
|
||||
let win = window_from_node(self);
|
||||
|
@ -261,7 +261,7 @@ impl HTMLMediaElement {
|
|||
}
|
||||
}
|
||||
|
||||
let task = Task {
|
||||
let task = box Task {
|
||||
elem: Trusted::new(self),
|
||||
};
|
||||
let win = window_from_node(self);
|
||||
|
@ -270,7 +270,7 @@ impl HTMLMediaElement {
|
|||
|
||||
fn queue_fire_simple_event(&self, type_: &'static str) {
|
||||
let win = window_from_node(self);
|
||||
let task = FireSimpleEventTask::new(self, type_);
|
||||
let task = box FireSimpleEventTask::new(self, type_);
|
||||
let _ = win.dom_manipulation_task_source().queue(task, win.r());
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ impl HTMLMediaElement {
|
|||
|
||||
fn queue_dedicated_media_source_failure_steps(&self) {
|
||||
let window = window_from_node(self);
|
||||
let _ = window.dom_manipulation_task_source().queue(DedicatedMediaSourceFailureTask::new(self), window.r());
|
||||
let _ = window.dom_manipulation_task_source().queue(box DedicatedMediaSourceFailureTask::new(self), window.r());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dedicated-media-source-failure-steps
|
||||
|
|
|
@ -161,7 +161,7 @@ impl Storage {
|
|||
let window = global_ref.as_window();
|
||||
let task_source = window.dom_manipulation_task_source();
|
||||
let trusted_storage = Trusted::new(self);
|
||||
task_source.queue(StorageEventRunnable::new(trusted_storage, key, old_value, new_value), window).unwrap();
|
||||
task_source.queue(box StorageEventRunnable::new(trusted_storage, key, old_value, new_value), window).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@ pub struct NetworkListener<Listener: PreInvoke + Send + 'static> {
|
|||
|
||||
impl<Listener: PreInvoke + Send + 'static> NetworkListener<Listener> {
|
||||
pub fn notify<A: Action<Listener> + Send + 'static>(&self, action: A) {
|
||||
let runnable = ListenerRunnable {
|
||||
let runnable = box ListenerRunnable {
|
||||
context: self.context.clone(),
|
||||
action: action,
|
||||
};
|
||||
let result = if let Some(ref wrapper) = self.wrapper {
|
||||
self.script_chan.send(CommonScriptMsg::RunnableMsg(NetworkEvent, wrapper.wrap_runnable(runnable)))
|
||||
} else {
|
||||
self.script_chan.send(CommonScriptMsg::RunnableMsg(NetworkEvent, box runnable))
|
||||
self.script_chan.send(CommonScriptMsg::RunnableMsg(NetworkEvent, runnable))
|
||||
};
|
||||
if let Err(err) = result {
|
||||
warn!("failed to deliver network data: {:?}", err);
|
||||
|
|
|
@ -174,10 +174,10 @@ pub struct RunnableWrapper {
|
|||
}
|
||||
|
||||
impl RunnableWrapper {
|
||||
pub fn wrap_runnable<T: Runnable + Send + 'static>(&self, runnable: T) -> Box<Runnable + Send> {
|
||||
pub fn wrap_runnable<T: Runnable + Send + 'static>(&self, runnable: Box<T>) -> Box<Runnable + Send> {
|
||||
box CancellableRunnable {
|
||||
cancelled: self.cancelled.clone(),
|
||||
inner: box runnable,
|
||||
inner: runnable,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1226,7 +1226,7 @@ impl ScriptThread {
|
|||
doc.mut_loader().inhibit_events();
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#the-end step 7
|
||||
let handler = DocumentProgressHandler::new(Trusted::new(doc));
|
||||
let handler = box DocumentProgressHandler::new(Trusted::new(doc));
|
||||
self.dom_manipulation_task_source.queue(handler, doc.window()).unwrap();
|
||||
|
||||
self.constellation_chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap();
|
||||
|
|
|
@ -16,7 +16,7 @@ use task_source::TaskSource;
|
|||
pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||
|
||||
impl TaskSource for DOMManipulationTaskSource {
|
||||
fn queue<T: Runnable + Send + 'static>(&self, msg: T, window: &Window) -> Result<(), ()> {
|
||||
fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()> {
|
||||
let msg = DOMManipulationTask(window.get_runnable_wrapper().wrap_runnable(msg));
|
||||
self.0.send(MainThreadScriptMsg::DOMManipulation(msg)).map_err(|_| ())
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ impl DOMManipulationTaskSource {
|
|||
cancelable: EventCancelable,
|
||||
window: &Window) {
|
||||
let target = Trusted::new(target);
|
||||
let runnable = EventRunnable {
|
||||
let runnable = box EventRunnable {
|
||||
target: target,
|
||||
name: name,
|
||||
bubbles: bubbles,
|
||||
|
@ -41,7 +41,7 @@ impl DOMManipulationTaskSource {
|
|||
|
||||
pub fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) {
|
||||
let target = Trusted::new(target);
|
||||
let runnable = SimpleEventRunnable {
|
||||
let runnable = box SimpleEventRunnable {
|
||||
target: target,
|
||||
name: name,
|
||||
};
|
||||
|
|
|
@ -13,5 +13,5 @@ use script_thread::Runnable;
|
|||
use std::result::Result;
|
||||
|
||||
pub trait TaskSource {
|
||||
fn queue<T: Runnable + Send + 'static>(&self, msg: T, window: &Window) -> Result<(), ()>;
|
||||
fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()>;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use task_source::TaskSource;
|
|||
pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>);
|
||||
|
||||
impl TaskSource for UserInteractionTaskSource {
|
||||
fn queue<T: Runnable + Send + 'static>(&self, msg: T, window: &Window) -> Result<(), ()> {
|
||||
fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()> {
|
||||
let msg = UserInteractionTask(window.get_runnable_wrapper().wrap_runnable(msg));
|
||||
self.0.send(MainThreadScriptMsg::UserInteraction(msg)).map_err(|_| ())
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ impl UserInteractionTaskSource {
|
|||
cancelable: EventCancelable,
|
||||
window: &Window) {
|
||||
let target = Trusted::new(target);
|
||||
let runnable = EventRunnable {
|
||||
let runnable = box EventRunnable {
|
||||
target: target,
|
||||
name: name,
|
||||
bubbles: bubbles,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue