diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/main/constellation.rs | 31 | ||||
-rw-r--r-- | src/components/main/macros.rs | 80 | ||||
-rw-r--r-- | src/components/main/pipeline.rs | 17 | ||||
-rwxr-xr-x | src/components/main/servo.rc | 2 | ||||
-rw-r--r-- | src/components/msg/compositor_msg.rs | 1 |
5 files changed, 35 insertions, 96 deletions
diff --git a/src/components/main/constellation.rs b/src/components/main/constellation.rs index 0461982f0c0..a18b56cbd50 100644 --- a/src/components/main/constellation.rs +++ b/src/components/main/constellation.rs @@ -72,12 +72,14 @@ impl NavigationContext { self.current.get() } - pub fn navigate(&mut self, id: uint) { - self.next.clear(); + /// Navigates to a new id, returning all id's evicted from next + pub fn navigate(&mut self, id: uint) -> ~[uint] { + let evicted = replace(&mut self.next, ~[]); do self.current.mutate_default(id) |cur_id| { self.previous.push(cur_id); id } + evicted } } @@ -91,25 +93,29 @@ impl Constellation { let opts = Cell::new(copy *opts); - let (constellation_port, constellation_chan) = comm::stream(); - let (constellation_port, constellation_chan) = (Cell::new(constellation_port), - ConstellationChan::new(constellation_chan)); + let (constellation_port, constellation_chan) = special_stream!(ConstellationChan); + let constellation_port = Cell::new(constellation_port); let compositor_chan = Cell::new(compositor_chan); let constellation_chan_clone = Cell::new(constellation_chan.clone()); + + let resource_task = Cell::new(resource_task); + let image_cache_task = Cell::new(image_cache_task); + let profiler_chan = Cell::new(profiler_chan); + do task::spawn { let mut constellation = Constellation { chan: constellation_chan_clone.take(), request_port: constellation_port.take(), compositor_chan: compositor_chan.take(), - resource_task: resource_task.clone(), - image_cache_task: image_cache_task.clone(), + resource_task: resource_task.take(), + image_cache_task: image_cache_task.take(), pipelines: HashMap::new(), navigation_context: NavigationContext::new(), next_id: 0, current_token_bearer: None, next_token_bearer: None, - profiler_chan: profiler_chan.clone(), + profiler_chan: profiler_chan.take(), opts: opts.take(), }; constellation.run(); @@ -234,7 +240,14 @@ impl Constellation { self.next_token_bearer = None; // Don't navigate on Navigate type, because that is handled by forward/back match pipeline.navigation_type.get() { - constellation_msg::Load => self.navigation_context.navigate(id), + constellation_msg::Load => { + let evicted = self.navigation_context.navigate(id); + /* FIXME(tkuehn): the following code causes a segfault + for evicted.iter().advance |id| { + self.pipelines.get(id).exit(); + } + */ + } _ => {} } } diff --git a/src/components/main/macros.rs b/src/components/main/macros.rs index 169e0a0a201..ed7ec2d2f15 100644 --- a/src/components/main/macros.rs +++ b/src/components/main/macros.rs @@ -2,79 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #[macro_escape]; -{ - macro_rules! move_ref( - { $x:expr } => { unsafe { let y <- *ptr::to_unsafe_ptr(*$x); y } } - ) - - macro_rules! move_val( - { $x:expr } => { unsafe { let y <- *ptr::to_unsafe_ptr(*$x); y } } - ) - - // select! - macro_rules! select_if( - +macro_rules! special_stream( + ($Chan:ident) => ( { - $index:expr, - $count:expr - } => { - fail - }; - - { - $index:expr, - $count:expr, - $port:path => [ - $(type_this $message:path$(($(x $x: ident),+))dont_type_this* - -> $next:ident => { $e:expr }),+ - ] - $(, $ports:path => [ - $(type_this $messages:path$(($(x $xs: ident),+))dont_type_this* - -> $nexts:ident => { $es:expr }),+ - ] )* - } => { - if $index == $count { - match pipes::try_recv($port) { - $(Some($message($($(ref $x,)+)* ref next)) => { - // FIXME (#2329) we really want move out of enum here. - let $next = move_ref!(next); - $e - })+ - _ => fail - } - } else { - select_if!( - $index, - $count + 1 - $(, $ports => [ - $(type_this $messages$(($(x $xs),+))dont_type_this* - -> $nexts => { $es }),+ - ])* - ) - } - }; - ) - - macro_rules! select( - { - $( $port:path => { - $($message:path$(($($x: ident),+))dont_type_this* - -> $next:ident $e:expr),+ - } )+ - } => { - let index = pipes::selecti([$(($port).header()),+]/_); - select_if!(index, 0 $(, $port => [ - $(type_this $message$(($(x $x),+))dont_type_this* -> $next => { $e }),+ - ])+) + let (port, chan) = comm::stream::(); + (port, $Chan::new(chan)) } - ) - - macro_rules! closure_stream( - ($Msg:ty, $Chan:ident) => ( - { - let (port, chan) = comm::stream::<$Msg>(); - (Cell(port), $Chan::new(chan)) - } - ); - ) -} + ); +) diff --git a/src/components/main/pipeline.rs b/src/components/main/pipeline.rs index e2a56c80e21..f5b6cf9c664 100644 --- a/src/components/main/pipeline.rs +++ b/src/components/main/pipeline.rs @@ -18,15 +18,6 @@ use servo_net::resource_task::ResourceTask; use servo_util::time::ProfilerChan; use std::comm; -macro_rules! special_stream( - ($Chan:ident) => ( - { - let (port, chan) = comm::stream::(); - (port, $Chan::new(chan)) - } - ); -) - /// A uniquely-identifiable pipeline of stript task, layout task, and render task. pub struct Pipeline { id: uint, @@ -64,16 +55,16 @@ impl Pipeline { render_chan.clone(), image_cache_task.clone(), copy opts, - profiler_chan.clone()); + profiler_chan); ScriptTask::create(id, - compositor_chan.clone(), + compositor_chan, layout_chan.clone(), script_port, script_chan.clone(), constellation_chan, - resource_task.clone(), - image_cache_task.clone()); + resource_task, + image_cache_task); Pipeline::new(id, script_chan, diff --git a/src/components/main/servo.rc b/src/components/main/servo.rc index 7804bebbc2e..3ee37198619 100755 --- a/src/components/main/servo.rc +++ b/src/components/main/servo.rc @@ -53,6 +53,8 @@ use std::os; #[path="compositing/mod.rs"] pub mod compositing; +pub mod macros; + pub mod css { priv mod select_handler; priv mod node_util; diff --git a/src/components/msg/compositor_msg.rs b/src/components/msg/compositor_msg.rs index d53a97a9378..666a40d4b9b 100644 --- a/src/components/msg/compositor_msg.rs +++ b/src/components/msg/compositor_msg.rs @@ -70,6 +70,7 @@ pub struct CompositorToken { impl CompositorToken { pub fn new() -> CompositorToken { CompositorToken { + // Of course, this doesn't guarantee that renderers will invalidate their tokens construction_restrictor: NonCopyable::new(), } } |