Language changes.

This commit is contained in:
Josh Matthews 2013-02-24 20:56:11 -05:00
parent 1c3db7cf44
commit ce514f2785
38 changed files with 186 additions and 162 deletions

@ -1 +1 @@
Subproject commit a782efc4f16fed52f1f82af5869bfb5285bbc3f4 Subproject commit b26d434ad126c1ee35ca63c02ff3d9a243e3a00a

@ -1 +1 @@
Subproject commit 29e5fa637965d7ce2c1b9b1347d8fe6054a71243 Subproject commit ebfb866ff36203de9f76a852be986ac5df895483

@ -1 +1 @@
Subproject commit 7fd0efc2e7dbfdc6e7db79537ac13b2c752a2284 Subproject commit 5a9e5a84a2b4061fc7f72b5d50e47272da910ae9

@ -1 +1 @@
Subproject commit 90612c9e26dc024429212b79e50d99a19c3476c1 Subproject commit 2de7e3f2c404d3691212cac40a73986f4e65743c

@ -1 +1 @@
Subproject commit 474721fb86731c37f8c56a8dee28f96f22fe30b9 Subproject commit 677c6cec147ffb33abf8e8a25aa589dd03a8665f

View file

@ -22,7 +22,7 @@ The interface used to by the renderer to aquire draw targets for
each rendered frame and submit them to be drawn to the display each rendered frame and submit them to be drawn to the display
*/ */
pub trait Compositor { pub trait Compositor {
fn begin_drawing(next_dt: pipes::Chan<LayerBufferSet>); fn begin_drawing(next_dt: comm::Chan<LayerBufferSet>);
fn draw(next_dt: pipes::Chan<LayerBufferSet>, +draw_me: LayerBufferSet); fn draw(next_dt: comm::Chan<LayerBufferSet>, +draw_me: LayerBufferSet);
} }

View file

@ -188,7 +188,10 @@ pub impl FontContext {
let result_handle = self.handle.create_font_from_identifier(copy *identifier, let result_handle = self.handle.create_font_from_identifier(copy *identifier,
copy desc.style); copy desc.style);
result::chain(result_handle, |handle| { result::chain(result_handle, |handle| {
Ok(Font::new_from_adopted_handle(&self, handle, &desc.style, self.backend)) Ok(Font::new_from_adopted_handle(&self,
handle,
&desc.style,
self.backend))
}) })
} }
}; };

View file

@ -4,8 +4,9 @@ extern mod fontconfig;
use fc = fontconfig; use fc = fontconfig;
use ft = freetype; use ft = freetype;
use gfx_font::FontHandle; use gfx_font::{FontHandle, FontHandleMethods};
use gfx_font_list::{FontEntry, FontFamily, FontFamilyMap}; use gfx_font_list::{FontEntry, FontFamily, FontFamilyMap};
use gfx_font_context::FontContextHandleMethods;
use freetype_impl::font_context::FreeTypeFontContextHandle; use freetype_impl::font_context::FreeTypeFontContextHandle;
use freetype_impl::font::FreeTypeFontHandle; use freetype_impl::font::FreeTypeFontHandle;
use self::fontconfig::fontconfig::{FcConfig, FcFontSet, FcChar8, use self::fontconfig::fontconfig::{FcConfig, FcFontSet, FcChar8,
@ -90,7 +91,7 @@ pub impl FontconfigFontListHandle {
if FcPatternGetString(*font, FC_FILE, 0, &file) == FcResultMatch { if FcPatternGetString(*font, FC_FILE, 0, &file) == FcResultMatch {
str::raw::from_c_str(file as *libc::c_char) str::raw::from_c_str(file as *libc::c_char)
} else { } else {
fail; fail!();
} }
}; };
let index = do str::as_c_str("index") |FC_INDEX| { let index = do str::as_c_str("index") |FC_INDEX| {
@ -98,7 +99,7 @@ pub impl FontconfigFontListHandle {
if FcPatternGetInteger(*font, FC_INDEX, 0, &index) == FcResultMatch { if FcPatternGetInteger(*font, FC_INDEX, 0, &index) == FcResultMatch {
index index
} else { } else {
fail; fail!();
} }
}; };

View file

@ -36,7 +36,7 @@ pub impl FreeTypeFontContextHandle {
static pub fn new() -> FreeTypeFontContextHandle { static pub fn new() -> FreeTypeFontContextHandle {
let ctx: FT_Library = ptr::null(); let ctx: FT_Library = ptr::null();
let result = FT_Init_FreeType(ptr::to_unsafe_ptr(&ctx)); let result = FT_Init_FreeType(ptr::to_unsafe_ptr(&ctx));
if !result.succeeded() { fail; } if !result.succeeded() { fail!(); }
FreeTypeFontContextHandle { FreeTypeFontContextHandle {
ctx: @FreeTypeLibraryHandle { ctx: ctx }, ctx: @FreeTypeLibraryHandle { ctx: ctx },

View file

@ -6,7 +6,7 @@ use util::time;
use azure::AzFloat; use azure::AzFloat;
use azure::azure_hl::{B8G8R8A8, DrawTarget}; use azure::azure_hl::{B8G8R8A8, DrawTarget};
use core::libc::c_int; use core::libc::c_int;
use core::pipes::Chan; use core::comm::Chan;
use geom::matrix2d::Matrix2D; use geom::matrix2d::Matrix2D;
use geom::point::Point2D; use geom::point::Point2D;
use geom::rect::Rect; use geom::rect::Rect;
@ -111,7 +111,7 @@ pub fn render_layers(layer_ref: *RenderLayer,
//} //}
// Create a port and channel pair to receive the new buffer. // Create a port and channel pair to receive the new buffer.
let (new_buffer_port, new_buffer_chan) = pipes::stream(); let (new_buffer_port, new_buffer_chan) = comm::stream();
// Send the buffer to the child. // Send the buffer to the child.
f(layer_ref, buffer, new_buffer_chan); f(layer_ref, buffer, new_buffer_chan);

View file

@ -12,7 +12,7 @@ use util::time::time;
use core::libc::size_t; use core::libc::size_t;
use core::libc::types::common::c99::uint16_t; use core::libc::types::common::c99::uint16_t;
use core::pipes::{Chan, Port, SharedChan}; use core::comm::{Chan, Port, SharedChan};
use core::task::SingleThreaded; use core::task::SingleThreaded;
use std::arc::ARC; use std::arc::ARC;
use std::arc; use std::arc;
@ -21,7 +21,7 @@ use std::task_pool::TaskPool;
pub enum Msg { pub enum Msg {
RenderMsg(RenderLayer), RenderMsg(RenderLayer),
ExitMsg(pipes::Chan<()>) ExitMsg(comm::Chan<()>)
} }
pub type RenderTask = SharedChan<Msg>; pub type RenderTask = SharedChan<Msg>;
@ -30,7 +30,7 @@ pub fn RenderTask<C:Compositor + Owned>(compositor: C, opts: Opts) -> RenderTask
let compositor_cell = Cell(compositor); let compositor_cell = Cell(compositor);
let opts_cell = Cell(opts); let opts_cell = Cell(opts);
let render_task = do spawn_listener |po: Port<Msg>| { let render_task = do spawn_listener |po: Port<Msg>| {
let (layer_buffer_set_port, layer_buffer_channel) = pipes::stream(); let (layer_buffer_set_port, layer_buffer_channel) = comm::stream();
let compositor = compositor_cell.take(); let compositor = compositor_cell.take();
compositor.begin_drawing(layer_buffer_channel); compositor.begin_drawing(layer_buffer_channel);
@ -38,10 +38,10 @@ pub fn RenderTask<C:Compositor + Owned>(compositor: C, opts: Opts) -> RenderTask
// FIXME: Annoying three-cell dance here. We need one-shot closures. // FIXME: Annoying three-cell dance here. We need one-shot closures.
let opts = opts_cell.with_ref(|o| copy *o); let opts = opts_cell.with_ref(|o| copy *o);
let n_threads = opts.n_render_threads; let n_threads = opts.n_render_threads;
let new_opts_cell: Cell<Opts> = Cell(opts); let new_opts_cell = Cell(opts);
let thread_pool = do TaskPool::new(n_threads, Some(SingleThreaded)) { let thread_pool = do TaskPool::new(n_threads, Some(SingleThreaded)) {
let opts_cell: Cell<Opts> = Cell(new_opts_cell.with_ref(|o| copy *o)); let opts_cell = Cell(new_opts_cell.with_ref(|o| copy *o));
let f: ~fn(uint) -> ThreadRenderContext = |thread_index| { let f: ~fn(uint) -> ThreadRenderContext = |thread_index| {
ThreadRenderContext { ThreadRenderContext {
thread_index: thread_index, thread_index: thread_index,
@ -73,12 +73,12 @@ priv struct ThreadRenderContext {
priv struct Renderer<C> { priv struct Renderer<C> {
port: Port<Msg>, port: Port<Msg>,
compositor: C, compositor: C,
layer_buffer_set_port: Cell<pipes::Port<LayerBufferSet>>, layer_buffer_set_port: Cell<comm::Port<LayerBufferSet>>,
thread_pool: TaskPool<ThreadRenderContext>, thread_pool: TaskPool<ThreadRenderContext>,
opts: Opts, opts: Opts,
} }
impl<C: Compositor Owned> Renderer<C> { impl<C: Compositor + Owned> Renderer<C> {
fn start() { fn start() {
debug!("renderer: beginning rendering loop"); debug!("renderer: beginning rendering loop");
@ -103,7 +103,7 @@ impl<C: Compositor Owned> Renderer<C> {
} }
let layer_buffer_set = layer_buffer_set_port.recv(); let layer_buffer_set = layer_buffer_set_port.recv();
let (new_layer_buffer_set_port, layer_buffer_set_channel) = pipes::stream(); let (new_layer_buffer_set_port, layer_buffer_set_channel) = comm::stream();
self.layer_buffer_set_port.put_back(new_layer_buffer_set_port); self.layer_buffer_set_port.put_back(new_layer_buffer_set_port);
let layer_buffer_set_cell = Cell(layer_buffer_set); let layer_buffer_set_cell = Cell(layer_buffer_set);

View file

@ -1,4 +1,4 @@
use pipes::Chan; use comm::Chan;
use task::spawn; use task::spawn;
use resource::resource_task::{ProgressMsg, Payload, Done, LoaderTask}; use resource::resource_task::{ProgressMsg, Payload, Done, LoaderTask};
use std::net::url::Url; use std::net::url::Url;

View file

@ -1,4 +1,4 @@
use pipes::{Chan, SharedChan}; use comm::{Chan, SharedChan};
use task::spawn; use task::spawn;
use resource::resource_task::{ProgressMsg, Payload, Done, LoaderTask}; use resource::resource_task::{ProgressMsg, Payload, Done, LoaderTask};
use std::cell::Cell; use std::cell::Cell;

View file

@ -4,7 +4,7 @@ use resource::resource_task::ResourceTask;
use util::url::{make_url, UrlMap, url_map}; use util::url::{make_url, UrlMap, url_map};
use clone_arc = std::arc::clone; use clone_arc = std::arc::clone;
use core::pipes::{Chan, Port, SharedChan, stream}; use core::comm::{Chan, Port, SharedChan, stream};
use core::task::spawn; use core::task::spawn;
use resource::util::spawn_listener; use resource::util::spawn_listener;
use core::to_str::ToStr; use core::to_str::ToStr;

View file

@ -6,7 +6,7 @@ multiple times and thus triggering reflows multiple times.
use clone_arc = std::arc::clone; use clone_arc = std::arc::clone;
use std::net::url::Url; use std::net::url::Url;
use pipes::{Port, Chan, stream}; use comm::{Port, Chan, stream};
use resource::image_cache_task::{ImageCacheTask, ImageResponseMsg, Prefetch, Decode, GetImage}; use resource::image_cache_task::{ImageCacheTask, ImageResponseMsg, Prefetch, Decode, GetImage};
use resource::image_cache_task::{ WaitForImage, ImageReady, ImageNotReady, ImageFailed}; use resource::image_cache_task::{ WaitForImage, ImageReady, ImageNotReady, ImageFailed};
use util::url::{UrlMap, url_map}; use util::url::{UrlMap, url_map};
@ -73,14 +73,14 @@ pub impl LocalImageCache {
ImageReady(ref image) => { ImageReady(ref image) => {
// FIXME: appease borrowck // FIXME: appease borrowck
unsafe { unsafe {
let (port, chan) = pipes::stream(); let (port, chan) = comm::stream();
chan.send(ImageReady(clone_arc(image))); chan.send(ImageReady(clone_arc(image)));
return port; return port;
} }
} }
ImageNotReady => { ImageNotReady => {
if last_round == self.round_number { if last_round == self.round_number {
let (port, chan) = pipes::stream(); let (port, chan) = comm::stream();
chan.send(ImageNotReady); chan.send(ImageNotReady);
return port; return port;
} else { } else {
@ -89,13 +89,13 @@ pub impl LocalImageCache {
} }
} }
ImageFailed => { ImageFailed => {
let (port, chan) = pipes::stream(); let (port, chan) = comm::stream();
chan.send(ImageFailed); chan.send(ImageFailed);
return port; return port;
} }
} }
let (response_port, response_chan) = pipes::stream(); let (response_port, response_chan) = comm::stream();
self.image_cache_task.send(GetImage(copy *url, response_chan)); self.image_cache_task.send(GetImage(copy *url, response_chan));
let response = response_port.recv(); let response = response_port.recv();
@ -111,7 +111,7 @@ pub impl LocalImageCache {
let on_image_available = self.on_image_available.get()(); let on_image_available = self.on_image_available.get()();
let url = copy *url; let url = copy *url;
do task::spawn { do task::spawn {
let (response_port, response_chan) = pipes::stream(); let (response_port, response_chan) = comm::stream();
image_cache_task.send(WaitForImage(copy url, response_chan)); image_cache_task.send(WaitForImage(copy url, response_chan));
on_image_available(response_port.recv()); on_image_available(response_port.recv());
} }
@ -127,7 +127,7 @@ pub impl LocalImageCache {
}; };
state.last_response = response_copy; state.last_response = response_copy;
let (port, chan) = pipes::stream(); let (port, chan) = comm::stream();
chan.send(response); chan.send(response);
return port; return port;
} }

View file

@ -4,7 +4,7 @@ A task that takes a URL and streams back the binary data
*/ */
use pipes::{Chan, Port, SharedChan}; use comm::{Chan, Port, SharedChan};
use resource::util::spawn_listener; use resource::util::spawn_listener;
use std::cell::Cell; use std::cell::Cell;
use std::net::url; use std::net::url;
@ -69,8 +69,8 @@ pub struct ResourceManager {
pub fn ResourceManager(from_client: Port<ControlMsg>, pub fn ResourceManager(from_client: Port<ControlMsg>,
loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceManager { loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceManager {
ResourceManager { ResourceManager {
from_client: from_client, from_client : from_client,
loaders: loaders, loaders : loaders,
} }
} }

View file

@ -1,10 +1,9 @@
use core::pipes::{Chan, Port}; use core::comm::{Chan, Port};
use core::pipes;
pub fn spawn_listener<A: Owned>(f: ~fn(Port<A>)) -> Chan<A> { pub fn spawn_listener<A: Owned>(f: ~fn(Port<A>)) -> Chan<A> {
let (setup_po, setup_ch) = pipes::stream(); let (setup_po, setup_ch) = comm::stream();
do task::spawn { do task::spawn {
let (po, ch) = pipes::stream(); let (po, ch) = comm::stream();
setup_ch.send(ch); setup_ch.send(ch);
f(po); f(po);
} }

View file

@ -1,6 +1,6 @@
use core::cmp::*; use core::cmp::*;
pub trait Cache<K: Copy Eq, V: Copy> { pub trait Cache<K: Copy + Eq, V: Copy> {
static fn new(size: uint) -> Self; static fn new(size: uint) -> Self;
fn insert(key: &K, value: V); fn insert(key: &K, value: V);
fn find(key: &K) -> Option<V>; fn find(key: &K) -> Option<V>;
@ -12,7 +12,7 @@ pub struct MonoCache<K, V> {
mut entry: Option<(K,V)>, mut entry: Option<(K,V)>,
} }
pub impl<K: Copy Eq, V: Copy> Cache<K,V> for MonoCache<K,V> { pub impl<K: Copy + Eq, V: Copy> Cache<K,V> for MonoCache<K,V> {
static fn new(_size: uint) -> MonoCache<K,V> { static fn new(_size: uint) -> MonoCache<K,V> {
MonoCache { entry: None } MonoCache { entry: None }
} }

View file

@ -1,11 +1,11 @@
use core::cmp::{Ord, Eq}; use core::cmp::{Ord, Eq};
pub trait BinarySearchMethods<T: Ord Eq> { pub trait BinarySearchMethods<T: Ord + Eq> {
pure fn binary_search(&self, key: &T) -> Option<&self/T>; pure fn binary_search(&self, key: &T) -> Option<&self/T>;
pure fn binary_search_index(&self, key: &T) -> Option<uint>; pure fn binary_search_index(&self, key: &T) -> Option<uint>;
} }
pub impl<T: Ord Eq> BinarySearchMethods<T> for &[T] { pub impl<T: Ord + Eq> BinarySearchMethods<T> for &[T] {
pure fn binary_search(&self, key: &T) -> Option<&self/T> { pure fn binary_search(&self, key: &T) -> Option<&self/T> {
match self.binary_search_index(key) { match self.binary_search_index(key) {
None => None, None => None,
@ -38,7 +38,7 @@ pub impl<T: Ord Eq> BinarySearchMethods<T> for &[T] {
} }
} }
fn test_find_all_elems<T: Eq Ord>(arr: &[T]) { fn test_find_all_elems<T: Eq + Ord>(arr: &[T]) {
let mut i = 0; let mut i = 0;
while i < arr.len() { while i < arr.len() {
assert test_match(&arr[i], arr.binary_search(&arr[i])); assert test_match(&arr[i], arr.binary_search(&arr[i]));
@ -46,7 +46,7 @@ fn test_find_all_elems<T: Eq Ord>(arr: &[T]) {
} }
} }
fn test_miss_all_elems<T: Eq Ord>(arr: &[T], misses: &[T]) { fn test_miss_all_elems<T: Eq + Ord>(arr: &[T], misses: &[T]) {
let mut i = 0; let mut i = 0;
while i < misses.len() { while i < misses.len() {
let res = arr.binary_search(&misses[i]); let res = arr.binary_search(&misses[i]);

View file

@ -13,7 +13,8 @@ use layout::layout_task::{AddStylesheet, BuildData, BuildMsg, Damage, LayoutTask
use layout::layout_task::{MatchSelectorsDamage, NoDamage, ReflowDamage}; use layout::layout_task::{MatchSelectorsDamage, NoDamage, ReflowDamage};
use util::task::spawn_listener; use util::task::spawn_listener;
use core::pipes::{Port, Chan, SharedChan, select2}; use core::comm::{Port, Chan, SharedChan};
use core::pipes::select2i;
use core::either; use core::either;
use core::task::{SingleThreaded, spawn, task}; use core::task::{SingleThreaded, spawn, task};
use core::io::{println, read_whole_file}; use core::io::{println, read_whole_file};
@ -57,7 +58,7 @@ pub fn ContentTask(layout_task: LayoutTask,
resource_task: ResourceTask, resource_task: ResourceTask,
img_cache_task: ImageCacheTask) img_cache_task: ImageCacheTask)
-> ContentTask { -> ContentTask {
let (control_port, control_chan) = pipes::stream(); let (control_port, control_chan) = comm::stream();
let control_chan = SharedChan(control_chan); let control_chan = SharedChan(control_chan);
let control_chan_copy = control_chan.clone(); let control_chan_copy = control_chan.clone();
@ -81,13 +82,13 @@ pub fn ContentTask(layout_task: LayoutTask,
pub struct Content { pub struct Content {
layout_task: LayoutTask, layout_task: LayoutTask,
mut layout_join_port: Option<pipes::Port<()>>, mut layout_join_port: Option<comm::Port<()>>,
image_cache_task: ImageCacheTask, image_cache_task: ImageCacheTask,
control_port: pipes::Port<ControlMsg>, control_port: comm::Port<ControlMsg>,
control_chan: pipes::SharedChan<ControlMsg>, control_chan: comm::SharedChan<ControlMsg>,
event_port: pipes::Port<Event>, event_port: comm::Port<Event>,
event_chan: pipes::SharedChan<Event>, event_chan: comm::SharedChan<Event>,
scope: NodeScope, scope: NodeScope,
jsrt: jsrt, jsrt: jsrt,
@ -107,12 +108,12 @@ pub struct Content {
} }
pub fn Content(layout_task: LayoutTask, pub fn Content(layout_task: LayoutTask,
control_port: pipes::Port<ControlMsg>, control_port: comm::Port<ControlMsg>,
control_chan: pipes::SharedChan<ControlMsg>, control_chan: comm::SharedChan<ControlMsg>,
resource_task: ResourceTask, resource_task: ResourceTask,
img_cache_task: ImageCacheTask, img_cache_task: ImageCacheTask,
event_port: pipes::Port<Event>, event_port: comm::Port<Event>,
event_chan: pipes::SharedChan<Event>) event_chan: comm::SharedChan<Event>)
-> @Content { -> @Content {
let jsrt = jsrt(); let jsrt = jsrt();
let cx = jsrt.cx(); let cx = jsrt.cx();
@ -169,7 +170,7 @@ impl Content {
} }
fn handle_msg() -> bool { fn handle_msg() -> bool {
match pipes::select2i(&self.control_port, &self.event_port) { match select2i(&self.control_port, &self.event_port) {
either::Left(*) => self.handle_control_msg(self.control_port.recv()), either::Left(*) => self.handle_control_msg(self.control_port.recv()),
either::Right(*) => self.handle_event(self.event_port.recv()) either::Right(*) => self.handle_event(self.event_port.recv())
} }
@ -306,7 +307,7 @@ impl Content {
self.join_layout(); self.join_layout();
// Layout will let us know when it's done // Layout will let us know when it's done
let (join_port, join_chan) = pipes::stream(); let (join_port, join_chan) = comm::stream();
self.layout_join_port = Some(join_port); self.layout_join_port = Some(join_port);
// Send new document and relevant styles to layout // Send new document and relevant styles to layout
@ -333,7 +334,7 @@ impl Content {
self.relayout(self.document.get(), &(copy self.doc_url).get()); self.relayout(self.document.get(), &(copy self.doc_url).get());
self.join_layout(); self.join_layout();
let (response_port, response_chan) = pipes::stream(); let (response_port, response_chan) = comm::stream();
self.layout_task.send(layout_task::QueryMsg(query, response_chan)); self.layout_task.send(layout_task::QueryMsg(query, response_chan));
return response_port.recv() return response_port.recv()
} }

View file

@ -1,7 +1,8 @@
use js::rust::{Compartment, jsobj}; use js::rust::{Compartment, jsobj};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED,
JSVAL_NULL, JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS}; JSVAL_NULL, JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp}; use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp,
JSPropertySpec, JSPropertyOpWrapper, JSStrictPropertyOpWrapper};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError, use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN, JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_DefineProperties}; JS_DefineFunctions, JS_DefineProperty, JS_DefineProperties};
@ -95,16 +96,18 @@ pub fn init(compartment: @mut Compartment, doc: @Document) {
let obj = utils::define_empty_prototype(~"Document", None, compartment); let obj = utils::define_empty_prototype(~"Document", None, compartment);
let attrs = @~[ let attrs = @~[
{name: compartment.add_name(~"documentElement"), JSPropertySpec {
name: compartment.add_name(~"documentElement"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: getDocumentElement, info: null()}, getter: JSPropertyOpWrapper {op: getDocumentElement, info: null()},
setter: {op: null(), info: null()}}, setter: JSStrictPropertyOpWrapper {op: null(), info: null()}},
{name: null(), JSPropertySpec {
name: null(),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: null(), info: null()}, getter: JSPropertyOpWrapper {op: null(), info: null()},
setter: {op: null(), info: null()}}]; setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
vec::push(&mut compartment.global_props, attrs); vec::push(&mut compartment.global_props, attrs);
vec::as_imm_buf(*attrs, |specs, _len| { vec::as_imm_buf(*attrs, |specs, _len| {
assert JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs) == 1; assert JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs) == 1;

View file

@ -1,7 +1,8 @@
use js::rust::{Compartment, jsobj}; use js::rust::{Compartment, jsobj};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL, use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS}; JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec}; use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec,
JSPropertyOpWrapper, JSStrictPropertyOpWrapper};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError, use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN, JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty}; JS_DefineFunctions, JS_DefineProperty};
@ -32,16 +33,18 @@ extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
pub fn init(compartment: @mut Compartment) { pub fn init(compartment: @mut Compartment) {
let obj = utils::define_empty_prototype(~"Element", Some(~"Node"), compartment); let obj = utils::define_empty_prototype(~"Element", Some(~"Node"), compartment);
let attrs = @~[ let attrs = @~[
{name: compartment.add_name(~"tagName"), JSPropertySpec {
name: compartment.add_name(~"tagName"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: getTagName, info: null()}, getter: JSPropertyOpWrapper {op: getTagName, info: null()},
setter: {op: null(), info: null()}}, setter: JSStrictPropertyOpWrapper {op: null(), info: null()}},
{name: null(), JSPropertySpec {
name: null(),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: null(), info: null()}, getter: JSPropertyOpWrapper {op: null(), info: null()},
setter: {op: null(), info: null()}}]; setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
vec::push(&mut compartment.global_props, attrs); vec::push(&mut compartment.global_props, attrs);
vec::as_imm_buf(*attrs, |specs, _len| { vec::as_imm_buf(*attrs, |specs, _len| {
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs); JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
@ -57,16 +60,16 @@ pub fn init(compartment: @mut Compartment) {
let obj = utils::define_empty_prototype(~"HTMLImageElement", Some(~"HTMLElement"), compartment); let obj = utils::define_empty_prototype(~"HTMLImageElement", Some(~"HTMLElement"), compartment);
let attrs = @~[ let attrs = @~[
{name: compartment.add_name(~"width"), JSPropertySpec {name: compartment.add_name(~"width"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: HTMLImageElement_getWidth, info: null()}, getter: JSPropertyOpWrapper {op: HTMLImageElement_getWidth, info: null()},
setter: {op: HTMLImageElement_setWidth, info: null()}}, setter: JSStrictPropertyOpWrapper {op: HTMLImageElement_setWidth, info: null()}},
{name: null(), JSPropertySpec {name: null(),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: null(), info: null()}, getter: JSPropertyOpWrapper {op: null(), info: null()},
setter: {op: null(), info: null()}}]; setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
vec::push(&mut compartment.global_props, attrs); vec::push(&mut compartment.global_props, attrs);
vec::as_imm_buf(*attrs, |specs, _len| { vec::as_imm_buf(*attrs, |specs, _len| {
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs); JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);

View file

@ -1,7 +1,8 @@
use js::rust::{Compartment, jsobj}; use js::rust::{Compartment, jsobj};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL, use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS}; JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec}; use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec,
JSPropertyOpWrapper, JSStrictPropertyOpWrapper};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError, use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN, JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate}; JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate};
@ -22,29 +23,33 @@ pub fn init(compartment: @mut Compartment) {
let obj = utils::define_empty_prototype(~"Node", None, compartment); let obj = utils::define_empty_prototype(~"Node", None, compartment);
let attrs = @~[ let attrs = @~[
{name: compartment.add_name(~"firstChild"), JSPropertySpec {
name: compartment.add_name(~"firstChild"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: getFirstChild, info: null()}, getter: JSPropertyOpWrapper {op: getFirstChild, info: null()},
setter: {op: null(), info: null()}}, setter: JSStrictPropertyOpWrapper {op: null(), info: null()}},
{name: compartment.add_name(~"nextSibling"), JSPropertySpec {
name: compartment.add_name(~"nextSibling"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: getNextSibling, info: null()}, getter: JSPropertyOpWrapper {op: getNextSibling, info: null()},
setter: {op: null(), info: null()}}, setter: JSStrictPropertyOpWrapper {op: null(), info: null()}},
{name: compartment.add_name(~"nodeType"), JSPropertySpec {
name: compartment.add_name(~"nodeType"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: getNodeType, info: null()}, getter: JSPropertyOpWrapper {op: getNodeType, info: null()},
setter: {op: null(), info: null()}}, setter: JSStrictPropertyOpWrapper {op: null(), info: null()}},
{name: null(), JSPropertySpec {
name: null(),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: null(), info: null()}, getter: JSPropertyOpWrapper {op: null(), info: null()},
setter: {op: null(), info: null()}}]; setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}];
vec::push(&mut compartment.global_props, attrs); vec::push(&mut compartment.global_props, attrs);
vec::as_imm_buf(*attrs, |specs, _len| { vec::as_imm_buf(*attrs, |specs, _len| {
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs); JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);

View file

@ -63,11 +63,11 @@ use core::libc::types::os::arch::c95::size_t;
use ptr::Ptr; use ptr::Ptr;
use vec::push; use vec::push;
type ScopeData<T,A> = { struct ScopeData<T,A> {
mut layout_active: bool, mut layout_active: bool,
mut free_list: ~[Handle<T,A>], mut free_list: ~[Handle<T,A>],
mut first_dirty: Handle<T,A> mut first_dirty: Handle<T,A>
}; }
struct ScopeResource<T,A> { struct ScopeResource<T,A> {
d : ScopeData<T,A>, d : ScopeData<T,A>,
@ -149,7 +149,7 @@ impl<T:Owned,A> cmp::Eq for Handle<T,A> {
} }
// Private methods // Private methods
impl<T: Copy Owned,A> Scope<T,A> { impl<T: Copy + Owned,A> Scope<T,A> {
fn clone(v: *T) -> *T { fn clone(v: *T) -> *T {
unsafe { unsafe {
let n: *mut T = let n: *mut T =
@ -190,13 +190,16 @@ fn null_handle<T:Owned,A>() -> Handle<T,A> {
} }
pub fn Scope<T:Owned,A>() -> Scope<T,A> { pub fn Scope<T:Owned,A>() -> Scope<T,A> {
@ScopeResource({mut layout_active: false, @ScopeResource(
mut free_list: ~[], ScopeData {
mut first_dirty: null_handle()}) mut layout_active: false,
mut free_list: ~[],
mut first_dirty: null_handle()
})
} }
// Writer methods // Writer methods
impl<T:Copy Owned,A> Scope<T,A> { impl<T:Copy + Owned,A> Scope<T,A> {
fn is_reader_forked() -> bool { fn is_reader_forked() -> bool {
self.d.layout_active self.d.layout_active
} }

View file

@ -1,5 +1,5 @@
pub enum Event { pub enum Event {
ResizeEvent(uint, uint, pipes::Chan<()>), ResizeEvent(uint, uint, comm::Chan<()>),
ReflowEvent ReflowEvent
} }

View file

@ -17,10 +17,10 @@ use std::arc::ARC;
use util::tree; use util::tree;
use super::cow; use super::cow;
pub enum NodeData = { pub struct NodeData {
tree: tree::Tree<Node>, tree: tree::Tree<Node>,
kind: ~NodeKind, kind: ~NodeKind,
}; }
/* The tree holding Nodes (read-only) */ /* The tree holding Nodes (read-only) */
pub enum NodeTree { NodeTree } pub enum NodeTree { NodeTree }
@ -124,14 +124,14 @@ pub fn define_bindings(compartment: @mut Compartment, doc: @Document, win: @Wind
/** The COW rd_aux data is a (weak) pointer to the layout data, /** The COW rd_aux data is a (weak) pointer to the layout data,
defined by this `LayoutData` enum. It contains the CSS style object defined by this `LayoutData` struct. It contains the CSS style object
as well as the primary `RenderBox`. as well as the primary `RenderBox`.
Note that there may be multiple boxes per DOM node. */ Note that there may be multiple boxes per DOM node. */
enum LayoutData = { pub struct LayoutData {
mut style: Option<CompleteSelectResults>, mut style: Option<CompleteSelectResults>,
mut flow: Option<@FlowContext> mut flow: Option<@FlowContext>
}; }
pub type Node = cow::Handle<NodeData, LayoutData>; pub type Node = cow::Handle<NodeData, LayoutData>;
@ -148,7 +148,7 @@ pub trait NodeScopeExtensions {
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
impl NodeScopeExtensions for NodeScope { impl NodeScopeExtensions for NodeScope {
fn new_node(k: NodeKind) -> Node { fn new_node(k: NodeKind) -> Node {
self.handle(&NodeData({tree: tree::empty(), kind: ~k})) self.handle(&NodeData {tree: tree::empty(), kind: ~k})
} }
} }

View file

@ -1,4 +1,4 @@
use core::pipes::{Port, Chan}; use core::comm::{Port, Chan};
use content::content_task::{ControlMsg, Timer, ExitMsg}; use content::content_task::{ControlMsg, Timer, ExitMsg};
use js::jsapi::JSVal; use js::jsapi::JSVal;
use dvec::DVec; use dvec::DVec;
@ -69,7 +69,7 @@ impl Window {
} }
} }
pub fn Window(content_chan: pipes::SharedChan<ControlMsg>) -> Window { pub fn Window(content_chan: comm::SharedChan<ControlMsg>) -> Window {
Window { Window {
timer_chan: do spawn_listener |timer_port: Port<TimerControlMsg>| { timer_chan: do spawn_listener |timer_port: Port<TimerControlMsg>| {

View file

@ -8,7 +8,7 @@ use resource::resource_task::ResourceTask;
use resource::resource_task; use resource::resource_task;
use util::task::spawn_listener; use util::task::spawn_listener;
use core::pipes::{Port, Chan}; use core::comm::{Port, Chan};
use gfx::compositor::Compositor; use gfx::compositor::Compositor;
use gfx::opts::Opts; use gfx::opts::Opts;
use gfx::render_task::RenderTask; use gfx::render_task::RenderTask;
@ -35,8 +35,8 @@ pub struct Engine<C> {
pub fn Engine<C:Compositor + Owned + Clone>(compositor: C, pub fn Engine<C:Compositor + Owned + Clone>(compositor: C,
opts: &Opts, opts: &Opts,
dom_event_port: pipes::Port<Event>, dom_event_port: comm::Port<Event>,
dom_event_chan: pipes::SharedChan<Event>, dom_event_chan: comm::SharedChan<Event>,
resource_task: ResourceTask, resource_task: ResourceTask,
image_cache_task: ImageCacheTask) image_cache_task: ImageCacheTask)
-> EngineTask { -> EngineTask {
@ -87,7 +87,7 @@ impl<C:Compositor + Owned + Clone> Engine<C> {
self.content_task.send(content_task::ExitMsg); self.content_task.send(content_task::ExitMsg);
self.layout_task.send(layout_task::ExitMsg); self.layout_task.send(layout_task::ExitMsg);
let (response_port, response_chan) = pipes::stream(); let (response_port, response_chan) = comm::stream();
self.render_task.send(render_task::ExitMsg(response_chan)); self.render_task.send(render_task::ExitMsg(response_chan));
response_port.recv(); response_port.recv();

View file

@ -4,7 +4,7 @@ Some little helpers for hooking up the HTML parser with the CSS parser
use resource::resource_task::{ResourceTask, ProgressMsg, Load, Payload, Done}; use resource::resource_task::{ResourceTask, ProgressMsg, Load, Payload, Done};
use core::pipes::{Port, Chan}; use core::comm::{Port, Chan};
use core::pipes; use core::pipes;
use core::str; use core::str;
use newcss::stylesheet::Stylesheet; use newcss::stylesheet::Stylesheet;
@ -22,10 +22,10 @@ pub enum StylesheetProvenance {
pub fn spawn_css_parser(provenance: StylesheetProvenance, pub fn spawn_css_parser(provenance: StylesheetProvenance,
resource_task: ResourceTask) resource_task: ResourceTask)
-> Port<Stylesheet> { -> Port<Stylesheet> {
let (result_port, result_chan) = pipes::stream(); let (result_port, result_chan) = comm::stream();
let provenance_cell = Cell(provenance); let provenance_cell = Cell(provenance);
do task::spawn |copy resource_task| { do task::spawn {
let url = do provenance_cell.with_ref |p| { let url = do provenance_cell.with_ref |p| {
match *p { match *p {
UrlProvenance(copy the_url) => the_url, UrlProvenance(copy the_url) => the_url,
@ -44,7 +44,7 @@ pub fn spawn_css_parser(provenance: StylesheetProvenance,
fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) -> DataStream { fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) -> DataStream {
match provenance { match provenance {
UrlProvenance(url) => { UrlProvenance(url) => {
let (input_port, input_chan) = pipes::stream(); let (input_port, input_chan) = comm::stream();
resource_task.send(Load(url, input_chan)); resource_task.send(Load(url, input_chan));
resource_port_to_data_stream(input_port) resource_port_to_data_stream(input_port)
} }

View file

@ -11,7 +11,7 @@ use resource::image_cache_task;
use resource::resource_task::{Done, Load, Payload, ResourceTask}; use resource::resource_task::{Done, Load, Payload, ResourceTask};
use util::task::{spawn_listener, spawn_conversation}; use util::task::{spawn_listener, spawn_conversation};
use core::pipes::{Chan, Port, SharedChan}; use core::comm::{Chan, Port, SharedChan};
use html::cssparse::{InlineProvenance, StylesheetProvenance, UrlProvenance, spawn_css_parser}; use html::cssparse::{InlineProvenance, StylesheetProvenance, UrlProvenance, spawn_css_parser};
use hubbub::hubbub::Attribute; use hubbub::hubbub::Attribute;
use hubbub::hubbub; use hubbub::hubbub;
@ -84,10 +84,10 @@ fn js_script_listener(to_parent: Chan<~[~[u8]]>,
loop { loop {
match from_parent.recv() { match from_parent.recv() {
JSTaskNewFile(url) => { JSTaskNewFile(url) => {
let (result_port, result_chan) = pipes::stream(); let (result_port, result_chan) = comm::stream();
let resource_task = resource_task.clone(); let resource_task = resource_task.clone();
do task::spawn { do task::spawn {
let (input_port, input_chan) = pipes::stream(); let (input_port, input_chan) = comm::stream();
// TODO: change copy to move once we can move into closures // TODO: change copy to move once we can move into closures
resource_task.send(Load(copy url, input_chan)); resource_task.send(Load(copy url, input_chan));
@ -379,7 +379,7 @@ pub fn parse_html(scope: NodeScope,
}); });
debug!("set tree handler"); debug!("set tree handler");
let (input_port, input_chan) = pipes::stream(); let (input_port, input_chan) = comm::stream();
resource_task.send(Load(copy *url, input_chan)); resource_task.send(Load(copy *url, input_chan));
debug!("loaded page"); debug!("loaded page");
loop { loop {

View file

@ -17,10 +17,10 @@ impl LayoutAuxMethods for Node {
fn initialize_layout_data() -> Option<@LayoutData> { fn initialize_layout_data() -> Option<@LayoutData> {
match self.has_aux() { match self.has_aux() {
false => { false => {
let data = @LayoutData({ let data = @LayoutData {
mut style : None, mut style : None,
mut flow : None mut flow : None
}); };
self.set_aux(data); Some(data) self.set_aux(data); Some(data)
}, },
true => None true => None

View file

@ -322,11 +322,16 @@ priv impl TextRunScanner {
} /* /fn flush_clump_to_list */ } /* /fn flush_clump_to_list */
} }
struct PendingLine {
mut range: Range,
mut width: Au
}
struct LineboxScanner { struct LineboxScanner {
flow: @FlowContext, flow: @FlowContext,
new_boxes: DVec<@RenderBox>, new_boxes: DVec<@RenderBox>,
work_list: @mut DList<@RenderBox>, work_list: @mut DList<@RenderBox>,
pending_line: {mut range: Range, mut width: Au}, pending_line: PendingLine,
line_spans: DVec<Range>, line_spans: DVec<Range>,
} }
@ -337,7 +342,7 @@ fn LineboxScanner(inline: @FlowContext) -> LineboxScanner {
flow: inline, flow: inline,
new_boxes: DVec(), new_boxes: DVec(),
work_list: DList(), work_list: DList(),
pending_line: {mut range: Range::empty(), mut width: Au(0)}, pending_line: PendingLine {mut range: Range::empty(), mut width: Au(0)},
line_spans: DVec() line_spans: DVec()
} }
} }

View file

@ -18,7 +18,7 @@ use resource::local_image_cache::LocalImageCache;
use util::task::spawn_listener; use util::task::spawn_listener;
use util::time::time; use util::time::time;
use core::pipes::{Chan, Port, SharedChan}; use core::comm::{Chan, Port, SharedChan};
use core::dvec::DVec; use core::dvec::DVec;
use core::mutable::Mut; use core::mutable::Mut;
use core::task::*; use core::task::*;
@ -79,9 +79,9 @@ impl Damage {
pub struct BuildData { pub struct BuildData {
node: Node, node: Node,
url: Url, url: Url,
dom_event_chan: pipes::SharedChan<Event>, dom_event_chan: comm::SharedChan<Event>,
window_size: Size2D<uint>, window_size: Size2D<uint>,
content_join_chan: pipes::Chan<()>, content_join_chan: comm::Chan<()>,
damage: Damage, damage: Damage,
} }
@ -295,7 +295,7 @@ impl Layout {
// to the content task, and ultimately cause the image to be // to the content task, and ultimately cause the image to be
// re-requested. We probably don't need to go all the way back to // re-requested. We probably don't need to go all the way back to
// the content task for this. // the content task for this.
fn make_on_image_available_cb(dom_event_chan: pipes::SharedChan<Event>) -> @fn() -> ~fn(ImageResponseMsg) { fn make_on_image_available_cb(dom_event_chan: comm::SharedChan<Event>) -> @fn() -> ~fn(ImageResponseMsg) {
// This has a crazy signature because the image cache needs to // This has a crazy signature because the image cache needs to
// make multiple copies of the callback, and the dom event // make multiple copies of the callback, and the dom event
// channel is not a copyable type, so this is actually a // channel is not a copyable type, so this is actually a

View file

@ -4,7 +4,7 @@ use platform::resize_rate_limiter::ResizeRateLimiter;
use azure::azure_hl::{BackendType, B8G8R8A8, DataSourceSurface, DrawTarget, SourceSurfaceMethods}; use azure::azure_hl::{BackendType, B8G8R8A8, DataSourceSurface, DrawTarget, SourceSurfaceMethods};
use core::dvec::DVec; use core::dvec::DVec;
use core::pipes::{Chan, SharedChan, Port}; use core::comm::{Chan, SharedChan, Port};
use core::task::TaskBuilder; use core::task::TaskBuilder;
use core::util; use core::util;
use geom::matrix::{Matrix4, identity}; use geom::matrix::{Matrix4, identity};
@ -46,13 +46,13 @@ enum Window {
} }
pub enum Msg { pub enum Msg {
BeginDrawing(pipes::Chan<LayerBufferSet>), BeginDrawing(comm::Chan<LayerBufferSet>),
Draw(pipes::Chan<LayerBufferSet>, LayerBufferSet), Draw(comm::Chan<LayerBufferSet>, LayerBufferSet),
AddKeyHandler(pipes::Chan<()>), AddKeyHandler(comm::Chan<()>),
Exit Exit
} }
pub fn OSMain(dom_event_chan: pipes::SharedChan<Event>, opts: Opts) -> OSMain { pub fn OSMain(dom_event_chan: comm::SharedChan<Event>, opts: Opts) -> OSMain {
let dom_event_chan = Cell(dom_event_chan); let dom_event_chan = Cell(dom_event_chan);
OSMain { OSMain {
chan: SharedChan(on_osmain::<Msg>(|po| { chan: SharedChan(on_osmain::<Msg>(|po| {
@ -276,10 +276,10 @@ Implementation to allow the osmain channel to be used as a graphics
compositor for the renderer compositor for the renderer
*/ */
impl Compositor for OSMain { impl Compositor for OSMain {
fn begin_drawing(next_dt: pipes::Chan<LayerBufferSet>) { fn begin_drawing(next_dt: comm::Chan<LayerBufferSet>) {
self.chan.send(BeginDrawing(next_dt)) self.chan.send(BeginDrawing(next_dt))
} }
fn draw(next_dt: pipes::Chan<LayerBufferSet>, draw_me: LayerBufferSet) { fn draw(next_dt: comm::Chan<LayerBufferSet>, draw_me: LayerBufferSet) {
self.chan.send(Draw(next_dt, draw_me)) self.chan.send(Draw(next_dt, draw_me))
} }
} }
@ -289,7 +289,7 @@ struct SurfaceSet {
mut back: Surface, mut back: Surface,
} }
fn lend_surface(surfaces: &SurfaceSet, receiver: pipes::Chan<LayerBufferSet>) { fn lend_surface(surfaces: &SurfaceSet, receiver: comm::Chan<LayerBufferSet>) {
// We are in a position to lend out the surface? // We are in a position to lend out the surface?
assert surfaces.front.have; assert surfaces.front.have;
// Ok then take it // Ok then take it
@ -349,9 +349,9 @@ fn Surface(backend: BackendType) -> Surface {
/// A function for spawning into the platform's main thread /// A function for spawning into the platform's main thread
fn on_osmain<T: Owned>(f: fn~(po: Port<T>)) -> Chan<T> { fn on_osmain<T: Owned>(f: fn~(po: Port<T>)) -> Chan<T> {
let (setup_po, setup_ch) = pipes::stream(); let (setup_po, setup_ch) = comm::stream();
do task::task().sched_mode(task::PlatformThread).spawn { do task::task().sched_mode(task::PlatformThread).spawn {
let (po, ch) = pipes::stream(); let (po, ch) = comm::stream();
setup_ch.send(ch); setup_ch.send(ch);
f(po); f(po);
} }

View file

@ -9,14 +9,14 @@ use dom::event::{Event, ResizeEvent};
pub struct ResizeRateLimiter { pub struct ResizeRateLimiter {
/// The channel we send resize events on /// The channel we send resize events on
/* priv */ dom_event_chan: pipes::SharedChan<Event>, /* priv */ dom_event_chan: comm::SharedChan<Event>,
/// The port we are waiting on for a response to the last resize event /// The port we are waiting on for a response to the last resize event
/* priv */ mut last_response_port: Option<pipes::Port<()>>, /* priv */ mut last_response_port: Option<comm::Port<()>>,
/// The next window resize event we should fire /// The next window resize event we should fire
/* priv */ mut next_resize_event: Option<(uint, uint)> /* priv */ mut next_resize_event: Option<(uint, uint)>
} }
pub fn ResizeRateLimiter(dom_event_chan: pipes::SharedChan<Event>) -> ResizeRateLimiter { pub fn ResizeRateLimiter(dom_event_chan: comm::SharedChan<Event>) -> ResizeRateLimiter {
ResizeRateLimiter { ResizeRateLimiter {
dom_event_chan: dom_event_chan, dom_event_chan: dom_event_chan,
last_response_port: None, last_response_port: None,
@ -59,7 +59,7 @@ impl ResizeRateLimiter {
} }
priv fn send_event(width: uint, height: uint) { priv fn send_event(width: uint, height: uint) {
let (port, chan) = pipes::stream(); let (port, chan) = comm::stream();
self.dom_event_chan.send(ResizeEvent(width, height, chan)); self.dom_event_chan.send(ResizeEvent(width, height, chan));
self.last_response_port = Some(port); self.last_response_port = Some(port);
} }

View file

@ -97,7 +97,7 @@ use engine::{Engine, ExitMsg, LoadURLMsg}; // FIXME: "ExitMsg" is pollution.
use platform::osmain::{AddKeyHandler, OSMain}; use platform::osmain::{AddKeyHandler, OSMain};
use core::option::swap_unwrap; use core::option::swap_unwrap;
use core::pipes::{Port, Chan}; use core::comm::{Port, Chan};
pub use gfx::opts::{Opts, Png, Screen}; // FIXME: Do we really want "Screen" and "Png" visible? pub use gfx::opts::{Opts, Png, Screen}; // FIXME: Do we really want "Screen" and "Png" visible?
pub use gfx::resource; pub use gfx::resource;
@ -126,14 +126,14 @@ fn run(opts: &Opts) {
} }
fn run_pipeline_screen(opts: &Opts) { fn run_pipeline_screen(opts: &Opts) {
let (dom_event_port, dom_event_chan) = pipes::stream(); let (dom_event_port, dom_event_chan) = comm::stream();
let dom_event_chan = pipes::SharedChan(dom_event_chan); let dom_event_chan = comm::SharedChan(dom_event_chan);
// The platform event handler thread // The platform event handler thread
let osmain = OSMain(dom_event_chan.clone(), copy *opts); let osmain = OSMain(dom_event_chan.clone(), copy *opts);
// Send each file to render then wait for keypress // Send each file to render then wait for keypress
let (keypress_from_osmain, keypress_to_engine) = pipes::stream(); let (keypress_from_osmain, keypress_to_engine) = comm::stream();
osmain.chan.send(AddKeyHandler(keypress_to_engine)); osmain.chan.send(AddKeyHandler(keypress_to_engine));
// Create a servo instance // Create a servo instance
@ -160,7 +160,7 @@ fn run_pipeline_screen(opts: &Opts) {
// Shut everything down // Shut everything down
debug!("master: Shut down"); debug!("master: Shut down");
let (exit_response_from_engine, exit_chan) = pipes::stream(); let (exit_response_from_engine, exit_chan) = comm::stream();
engine_task.send(engine::ExitMsg(exit_chan)); engine_task.send(engine::ExitMsg(exit_chan));
exit_response_from_engine.recv(); exit_response_from_engine.recv();
@ -181,8 +181,8 @@ fn run_pipeline_png(url: ~str, outfile: &str) {
use resource::image_cache_task::SyncImageCacheTask; use resource::image_cache_task::SyncImageCacheTask;
listen(|pngdata_from_compositor| { listen(|pngdata_from_compositor| {
let (dom_event_port, dom_event_chan) = pipes::stream(); let (dom_event_port, dom_event_chan) = comm::stream();
let dom_event_chan = pipes::SharedChan(dom_event_chan); let dom_event_chan = comm::SharedChan(dom_event_chan);
let compositor = PngCompositor(pngdata_from_compositor); let compositor = PngCompositor(pngdata_from_compositor);
let resource_task = ResourceTask(); let resource_task = ResourceTask();
@ -201,7 +201,7 @@ fn run_pipeline_png(url: ~str, outfile: &str) {
Err(e) => fail!(e) Err(e) => fail!(e)
} }
let (exit_chan, exit_response_from_engine) = pipes::stream(); let (exit_chan, exit_response_from_engine) = comm::stream();
engine_task.send(engine::ExitMsg(exit_chan)); engine_task.send(engine::ExitMsg(exit_chan));
exit_response_from_engine.recv(); exit_response_from_engine.recv();
compositor.send(png_compositor::Exit); compositor.send(png_compositor::Exit);

View file

@ -1,12 +1,11 @@
use core::pipes::{Chan, Port}; use core::comm::{Chan, Port};
use core::pipes;
use core::task; use core::task;
use std::cell::Cell; use std::cell::Cell;
pub fn spawn_listener<A: Owned>(f: fn~(Port<A>)) -> Chan<A> { pub fn spawn_listener<A: Owned>(f: fn~(Port<A>)) -> Chan<A> {
let (setup_po, setup_ch) = pipes::stream(); let (setup_po, setup_ch) = comm::stream();
do task::spawn { do task::spawn {
let (po, ch) = pipes::stream(); let (po, ch) = comm::stream();
setup_ch.send(ch); setup_ch.send(ch);
f(po); f(po);
} }
@ -14,7 +13,7 @@ pub fn spawn_listener<A: Owned>(f: fn~(Port<A>)) -> Chan<A> {
} }
pub fn spawn_conversation<A: Owned, B: Owned>(f: fn~(Port<A>, Chan<B>)) -> (Port<B>, Chan<A>) { pub fn spawn_conversation<A: Owned, B: Owned>(f: fn~(Port<A>, Chan<B>)) -> (Port<B>, Chan<A>) {
let (from_child, to_parent) = pipes::stream(); let (from_child, to_parent) = comm::stream();
let to_parent = Cell(to_parent); let to_parent = Cell(to_parent);
let to_child = do spawn_listener |from_parent| { let to_child = do spawn_listener |from_parent| {
f(from_parent, to_parent.take()) f(from_parent, to_parent.take())

View file

@ -4,13 +4,13 @@ use core::vec;
// //
// TODO: Use traits. // TODO: Use traits.
pub type Tree<T> = { pub struct Tree<T> {
mut parent: Option<T>, mut parent: Option<T>,
mut first_child: Option<T>, mut first_child: Option<T>,
mut last_child: Option<T>, mut last_child: Option<T>,
mut prev_sibling: Option<T>, mut prev_sibling: Option<T>,
mut next_sibling: Option<T> mut next_sibling: Option<T>
}; }
pub trait ReadMethods<T> { pub trait ReadMethods<T> {
fn with_tree_fields<R>(&T, f: fn(&Tree<T>) -> R) -> R; fn with_tree_fields<R>(&T, f: fn(&Tree<T>) -> R) -> R;
@ -59,11 +59,13 @@ pub fn parent<T:Copy,O:ReadMethods<T>>(ops: &O, node: &T) -> Option<T> {
} }
pub fn empty<T>() -> Tree<T> { pub fn empty<T>() -> Tree<T> {
{mut parent: None, Tree {
mut first_child: None, mut parent: None,
mut last_child: None, mut first_child: None,
mut prev_sibling: None, mut last_child: None,
mut next_sibling: None} mut prev_sibling: None,
mut next_sibling: None
}
} }
pub fn add_child<T:Copy,O:WriteMethods<T>>(ops: &O, parent: T, child: T) { pub fn add_child<T:Copy,O:WriteMethods<T>>(ops: &O, parent: T, child: T) {