mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
auto merge of #2489 : zwarich/servo/render-chan-newtype, r=jdm
Also, derive Clone rather than implementing it manually.
This commit is contained in:
commit
606cadbe4c
3 changed files with 10 additions and 21 deletions
|
@ -73,34 +73,23 @@ pub fn BufferRequest(screen_rect: Rect<uint>, page_rect: Rect<f32>) -> BufferReq
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(#2005, pcwalton): This should be a newtype struct.
|
#[deriving(Clone)]
|
||||||
pub struct RenderChan {
|
pub struct RenderChan(Sender<Msg>);
|
||||||
pub chan: Sender<Msg>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Clone for RenderChan {
|
|
||||||
fn clone(&self) -> RenderChan {
|
|
||||||
RenderChan {
|
|
||||||
chan: self.chan.clone(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RenderChan {
|
impl RenderChan {
|
||||||
pub fn new() -> (Receiver<Msg>, RenderChan) {
|
pub fn new() -> (Receiver<Msg>, RenderChan) {
|
||||||
let (chan, port) = channel();
|
let (chan, port) = channel();
|
||||||
let render_chan = RenderChan {
|
(port, RenderChan(chan))
|
||||||
chan: chan,
|
|
||||||
};
|
|
||||||
(port, render_chan)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send(&self, msg: Msg) {
|
pub fn send(&self, msg: Msg) {
|
||||||
assert!(self.send_opt(msg).is_ok(), "RenderChan.send: render port closed")
|
let &RenderChan(ref chan) = self;
|
||||||
|
assert!(chan.send_opt(msg).is_ok(), "RenderChan.send: render port closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_opt(&self, msg: Msg) -> Result<(), Msg> {
|
pub fn send_opt(&self, msg: Msg) -> Result<(), Msg> {
|
||||||
self.chan.send_opt(msg)
|
let &RenderChan(ref chan) = self;
|
||||||
|
chan.send_opt(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,7 +397,7 @@ impl Constellation {
|
||||||
fn force_pipeline_exit(old_pipeline: &Rc<Pipeline>) {
|
fn force_pipeline_exit(old_pipeline: &Rc<Pipeline>) {
|
||||||
let ScriptChan(ref old_script) = old_pipeline.script_chan;
|
let ScriptChan(ref old_script) = old_pipeline.script_chan;
|
||||||
old_script.send_opt(ExitPipelineMsg(old_pipeline.id));
|
old_script.send_opt(ExitPipelineMsg(old_pipeline.id));
|
||||||
old_pipeline.render_chan.chan.send_opt(render_task::ExitMsg(None));
|
old_pipeline.render_chan.send_opt(render_task::ExitMsg(None));
|
||||||
let LayoutChan(ref old_layout) = old_pipeline.layout_chan;
|
let LayoutChan(ref old_layout) = old_pipeline.layout_chan;
|
||||||
old_layout.send_opt(layout_interface::ExitNowMsg);
|
old_layout.send_opt(layout_interface::ExitNowMsg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,12 +197,12 @@ impl Pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn grant_paint_permission(&self) {
|
pub fn grant_paint_permission(&self) {
|
||||||
self.render_chan.chan.send_opt(PaintPermissionGranted);
|
self.render_chan.send_opt(PaintPermissionGranted);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn revoke_paint_permission(&self) {
|
pub fn revoke_paint_permission(&self) {
|
||||||
debug!("pipeline revoking render channel paint permission");
|
debug!("pipeline revoking render channel paint permission");
|
||||||
self.render_chan.chan.send_opt(PaintPermissionRevoked);
|
self.render_chan.send_opt(PaintPermissionRevoked);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exit(&self) {
|
pub fn exit(&self) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue