Remove #[legacy_modes]

This commit is contained in:
Brian Anderson 2012-10-10 18:19:23 -07:00
parent 47d05c9908
commit f2022f86b7
33 changed files with 103 additions and 98 deletions

View file

@ -61,7 +61,7 @@ pub enum PingMsg {
pub type ContentTask = Chan<ControlMsg>; pub type ContentTask = Chan<ControlMsg>;
fn ContentTask<S: Compositor Send Copy>(layout_task: LayoutTask, fn ContentTask<S: Compositor Send Copy>(layout_task: LayoutTask,
+compositor: S, compositor: S,
resource_task: ResourceTask, resource_task: ResourceTask,
img_cache_task: ImageCacheTask) -> ContentTask { img_cache_task: ImageCacheTask) -> ContentTask {
do task().sched_mode(SingleThreaded).spawn_listener::<ControlMsg> |from_master| { do task().sched_mode(SingleThreaded).spawn_listener::<ControlMsg> |from_master| {
@ -143,14 +143,14 @@ impl Content {
} }
} }
fn handle_msg(+msg: Either<ControlMsg,Event>) -> bool { fn handle_msg(msg: Either<ControlMsg,Event>) -> bool {
match move msg { match move msg {
Left(move control_msg) => self.handle_control_msg(control_msg), Left(move control_msg) => self.handle_control_msg(control_msg),
Right(move event) => self.handle_event(event) Right(move event) => self.handle_event(event)
} }
} }
fn handle_control_msg(+control_msg: ControlMsg) -> bool { fn handle_control_msg(control_msg: ControlMsg) -> bool {
match move control_msg { match move control_msg {
ParseMsg(move url) => { ParseMsg(move url) => {
debug!("content: Received url `%s` to parse", url_to_str(copy url)); debug!("content: Received url `%s` to parse", url_to_str(copy url));

View file

@ -237,7 +237,7 @@ fn parser(input_port: comm::Port<ProgressMsg>, state : ParserState) -> CssLexer
}; };
} }
fn lex_css_from_bytes(+input_port: comm::Port<ProgressMsg>, result_chan : &Chan<Token>) { fn lex_css_from_bytes(input_port: comm::Port<ProgressMsg>, result_chan : &Chan<Token>) {
let lexer = parser(input_port, CssElement); let lexer = parser(input_port, CssElement);
loop { loop {
@ -252,7 +252,7 @@ fn lex_css_from_bytes(+input_port: comm::Port<ProgressMsg>, result_chan : &Chan<
} }
} }
fn spawn_css_lexer_from_string(+content : ~str) -> pipes::Port<Token> { fn spawn_css_lexer_from_string(content : ~str) -> pipes::Port<Token> {
let (result_chan, result_port) = pipes::stream(); let (result_chan, result_port) = pipes::stream();
do task::spawn { do task::spawn {
@ -267,7 +267,7 @@ fn spawn_css_lexer_from_string(+content : ~str) -> pipes::Port<Token> {
} }
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
pub fn spawn_css_lexer_task(+url: Url, resource_task: ResourceTask) -> pipes::Port<Token> { pub fn spawn_css_lexer_task(url: Url, resource_task: ResourceTask) -> pipes::Port<Token> {
let (result_chan, result_port) = pipes::stream(); let (result_chan, result_port) = pipes::stream();
do task::spawn || { do task::spawn || {

View file

@ -32,7 +32,7 @@ impl TokenReader : TokenReaderMethods {
} }
} }
fn unget(+tok : Token) { fn unget(tok : Token) {
assert is_none(&self.lookahead); assert is_none(&self.lookahead);
self.lookahead = Some(tok); self.lookahead = Some(tok);
} }
@ -204,7 +204,7 @@ impl TokenReader : ParserMethods {
} }
} }
pub fn build_stylesheet(+stream : pipes::Port<Token>) -> ~[~css::Rule] { pub fn build_stylesheet(stream : pipes::Port<Token>) -> ~[~css::Rule] {
let mut rule_list = ~[]; let mut rule_list = ~[];
let reader = {stream : stream, mut lookahead : None}; let reader = {stream : stream, mut lookahead : None};

View file

@ -40,7 +40,7 @@ struct StyleApplicator {
} }
// TODO: normalize this into a normal preorder tree traversal function // TODO: normalize this into a normal preorder tree traversal function
fn apply_style(layout_ctx: &LayoutContext, node: Node, +reflow: fn~()) { fn apply_style(layout_ctx: &LayoutContext, node: Node, reflow: fn~()) {
let applicator = StyleApplicator { let applicator = StyleApplicator {
node: node, node: node,
reflow: reflow reflow: reflow
@ -54,7 +54,7 @@ fn apply_style(layout_ctx: &LayoutContext, node: Node, +reflow: fn~()) {
/** A wrapper around a set of functions that can be applied as a /** A wrapper around a set of functions that can be applied as a
* top-down traversal of layout boxes. * top-down traversal of layout boxes.
*/ */
fn inheritance_wrapper(layout_ctx: &LayoutContext, node : Node, +reflow: fn~()) { fn inheritance_wrapper(layout_ctx: &LayoutContext, node : Node, reflow: fn~()) {
let applicator = StyleApplicator { let applicator = StyleApplicator {
node: node, node: node,
reflow: reflow reflow: reflow

View file

@ -225,7 +225,7 @@ mod test {
use dvec::DVec; use dvec::DVec;
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
fn new_node_from_attr(scope: NodeScope, +name: ~str, +val: ~str) -> Node { fn new_node_from_attr(scope: &NodeScope, name: ~str, val: ~str) -> Node {
let elmt = ElementData(~"div", ~HTMLDivElement); let elmt = ElementData(~"div", ~HTMLDivElement);
let attr = ~Attr(name, val); let attr = ~Attr(name, val);
elmt.attrs.push(attr); elmt.attrs.push(attr);
@ -235,7 +235,7 @@ mod test {
#[test] #[test]
fn test_match_pipe1() { fn test_match_pipe1() {
let scope = NodeScope(); let scope = NodeScope();
let node = new_node_from_attr(scope, ~"lang", ~"en-us"); let node = new_node_from_attr(&scope, ~"lang", ~"en-us");
let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]); let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]);
@ -245,7 +245,7 @@ mod test {
#[test] #[test]
fn test_match_pipe2() { fn test_match_pipe2() {
let scope = NodeScope(); let scope = NodeScope();
let node = new_node_from_attr(scope, ~"lang", ~"en"); let node = new_node_from_attr(&scope, ~"lang", ~"en");
let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]); let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]);
@ -255,7 +255,7 @@ mod test {
#[test] #[test]
fn test_not_match_pipe() { fn test_not_match_pipe() {
let scope = NodeScope(); let scope = NodeScope();
let node = new_node_from_attr(scope, ~"lang", ~"english"); let node = new_node_from_attr(&scope, ~"lang", ~"english");
let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]); let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]);
@ -265,7 +265,7 @@ mod test {
#[test] #[test]
fn test_match_includes() { fn test_match_includes() {
let scope = NodeScope(); let scope = NodeScope();
let node = new_node_from_attr(scope, ~"mad", ~"hatter cobler cooper"); let node = new_node_from_attr(&scope, ~"mad", ~"hatter cobler cooper");
let sel = Element(~"div", ~[Includes(~"mad", ~"hatter")]); let sel = Element(~"div", ~[Includes(~"mad", ~"hatter")]);
@ -275,7 +275,7 @@ mod test {
#[test] #[test]
fn test_match_exists() { fn test_match_exists() {
let scope = NodeScope(); let scope = NodeScope();
let node = new_node_from_attr(scope, ~"mad", ~"hatter cobler cooper"); let node = new_node_from_attr(&scope, ~"mad", ~"hatter cobler cooper");
let sel1 = Element(~"div", ~[Exists(~"mad")]); let sel1 = Element(~"div", ~[Exists(~"mad")]);
let sel2 = Element(~"div", ~[Exists(~"hatter")]); let sel2 = Element(~"div", ~[Exists(~"hatter")]);
@ -287,8 +287,8 @@ mod test {
#[test] #[test]
fn test_match_exact() { fn test_match_exact() {
let scope = NodeScope(); let scope = NodeScope();
let node1 = new_node_from_attr(scope, ~"mad", ~"hatter cobler cooper"); let node1 = new_node_from_attr(&scope, ~"mad", ~"hatter cobler cooper");
let node2 = new_node_from_attr(scope, ~"mad", ~"hatter"); let node2 = new_node_from_attr(&scope, ~"mad", ~"hatter");
let sel = Element(~"div", ~[Exact(~"mad", ~"hatter")]); let sel = Element(~"div", ~[Exact(~"mad", ~"hatter")]);
@ -300,12 +300,12 @@ mod test {
fn match_tree() { fn match_tree() {
let scope = NodeScope(); let scope = NodeScope();
let root = new_node_from_attr(scope, ~"class", ~"blue"); let root = new_node_from_attr(&scope, ~"class", ~"blue");
let child1 = new_node_from_attr(scope, ~"id", ~"green"); let child1 = new_node_from_attr(&scope, ~"id", ~"green");
let child2 = new_node_from_attr(scope, ~"flag", ~"black"); let child2 = new_node_from_attr(&scope, ~"flag", ~"black");
let gchild = new_node_from_attr(scope, ~"flag", ~"grey"); let gchild = new_node_from_attr(&scope, ~"flag", ~"grey");
let ggchild = new_node_from_attr(scope, ~"flag", ~"white"); let ggchild = new_node_from_attr(&scope, ~"flag", ~"white");
let gggchild = new_node_from_attr(scope, ~"flag", ~"purple"); let gggchild = new_node_from_attr(&scope, ~"flag", ~"purple");
scope.add_child(root, child1); scope.add_child(root, child1);
scope.add_child(root, child2); scope.add_child(root, child2);

View file

@ -24,10 +24,10 @@ enum CSSValue<T : Copy> {
} }
impl<T : Copy> ParseResult<T> { impl<T : Copy> ParseResult<T> {
pure fn extract<U>(f: fn(+v: CSSValue<T>) -> U) -> Option<U> { extract(&self, f) } pure fn extract<U>(f: fn(v: CSSValue<T>) -> U) -> Option<U> { extract(&self, f) }
} }
pure fn extract<T : Copy, U>(res: &ParseResult<T>, f: fn(+v: CSSValue<T>) -> U) -> Option<U> { pure fn extract<T : Copy, U>(res: &ParseResult<T>, f: fn(v: CSSValue<T>) -> U) -> Option<U> {
match *res { match *res {
Fail => None, Fail => None,
CSSInitial => Some(f(Initial)), CSSInitial => Some(f(Initial)),

View file

@ -18,7 +18,7 @@ enum DOMString {
type rust_box<T> = {rc: uint, td: *sys::TypeDesc, next: *(), prev: *(), payload: T}; type rust_box<T> = {rc: uint, td: *sys::TypeDesc, next: *(), prev: *(), payload: T};
unsafe fn squirrel_away<T>(+x: @T) -> *rust_box<T> { unsafe fn squirrel_away<T>(x: @T) -> *rust_box<T> {
let y: *rust_box<T> = cast::reinterpret_cast(&x); let y: *rust_box<T> = cast::reinterpret_cast(&x);
cast::forget(x); cast::forget(x);
y y
@ -26,7 +26,7 @@ unsafe fn squirrel_away<T>(+x: @T) -> *rust_box<T> {
type rust_unique<T> = {payload: T}; type rust_unique<T> = {payload: T};
unsafe fn squirrel_away_unique<T>(+x: ~T) -> *rust_box<T> { unsafe fn squirrel_away_unique<T>(x: ~T) -> *rust_box<T> {
let y: *rust_box<T> = cast::reinterpret_cast(&x); let y: *rust_box<T> = cast::reinterpret_cast(&x);
cast::forget(x); cast::forget(x);
y y
@ -94,8 +94,8 @@ extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *jsval, bp: *mut JSB
return 1; return 1;
} }
pub fn prototype_jsclass(+name: ~str) -> fn(+compartment: bare_compartment) -> JSClass { pub fn prototype_jsclass(name: ~str) -> fn(compartment: bare_compartment) -> JSClass {
|+compartment: bare_compartment| { |compartment: bare_compartment| {
{name: compartment.add_name(copy name), {name: compartment.add_name(copy name),
flags: 0, flags: 0,
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
@ -122,9 +122,9 @@ pub fn prototype_jsclass(+name: ~str) -> fn(+compartment: bare_compartment) -> J
} }
} }
pub fn instance_jsclass(+name: ~str, finalize: *u8) pub fn instance_jsclass(name: ~str, finalize: *u8)
-> fn(+compartment: bare_compartment) -> JSClass { -> fn(compartment: bare_compartment) -> JSClass {
|+compartment: bare_compartment| { |compartment: bare_compartment| {
{name: compartment.add_name(copy name), {name: compartment.add_name(copy name),
flags: JSCLASS_HAS_RESERVED_SLOTS(1), flags: JSCLASS_HAS_RESERVED_SLOTS(1),
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
@ -152,7 +152,7 @@ pub fn instance_jsclass(+name: ~str, finalize: *u8)
} }
// FIXME: A lot of string copies here // FIXME: A lot of string copies here
pub fn define_empty_prototype(+name: ~str, +proto: Option<~str>, compartment: &bare_compartment) pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: &bare_compartment)
-> js::rust::jsobj { -> js::rust::jsobj {
compartment.register_class(utils::prototype_jsclass(copy name)); compartment.register_class(utils::prototype_jsclass(copy name));

View file

@ -73,11 +73,12 @@ struct ScopeResource<T:Send,A> {
d : ScopeData<T,A>, d : ScopeData<T,A>,
drop unsafe { drop unsafe {
error!("dropp!");
for self.d.free_list.each |h| { free_handle(*h); } for self.d.free_list.each |h| { free_handle(*h); }
} }
} }
fn ScopeResource<T:Send,A>(+d : ScopeData<T,A>) -> ScopeResource<T,A> { fn ScopeResource<T:Send,A>(d : ScopeData<T,A>) -> ScopeResource<T,A> {
ScopeResource { d: d } ScopeResource { d: d }
} }
@ -101,7 +102,7 @@ impl<T:Send,A> Handle<T,A> {
fn set_read_ptr(t: *T) unsafe { (**self).read_ptr = t; } fn set_read_ptr(t: *T) unsafe { (**self).read_ptr = t; }
fn set_write_ptr(t: *mut T) unsafe { (**self).write_ptr = t; } fn set_write_ptr(t: *mut T) unsafe { (**self).write_ptr = t; }
fn set_read_aux(t: *A) unsafe { (**self).read_aux = t; } fn set_read_aux(t: *A) unsafe { (**self).read_aux = t; }
fn set_next_dirty(+h: Handle<T,A>) unsafe { (**self).next_dirty = h; } fn set_next_dirty(h: Handle<T,A>) unsafe { (**self).next_dirty = h; }
pure fn is_null() -> bool { (*self).is_null() } pure fn is_null() -> bool { (*self).is_null() }
fn is_not_null() -> bool { (*self).is_not_null() } fn is_not_null() -> bool { (*self).is_not_null() }
@ -222,6 +223,7 @@ impl<T:Copy Send,A> Scope<T,A> {
// FIXME: This could avoid a deep copy by taking ownership of `v` // FIXME: This could avoid a deep copy by taking ownership of `v`
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
fn handle(v: &T) -> Handle<T,A> unsafe { fn handle(v: &T) -> Handle<T,A> unsafe {
debug!("vv: %?", *v);
let d: *HandleData<T,A> = let d: *HandleData<T,A> =
cast::reinterpret_cast( cast::reinterpret_cast(
&libc::malloc(sys::size_of::<HandleData<T,A>>() as size_t)); &libc::malloc(sys::size_of::<HandleData<T,A>>() as size_t));
@ -231,6 +233,9 @@ impl<T:Copy Send,A> Scope<T,A> {
(*d).next_dirty = null_handle(); (*d).next_dirty = null_handle();
let h = _Handle(d); let h = _Handle(d);
push(&mut self.d.free_list, h); push(&mut self.d.free_list, h);
do self.read(&h) |v| {
debug!("vv: %?", *v);
}
return h; return h;
} }
} }

View file

@ -8,7 +8,7 @@ struct Document {
css_rules: ARC<Stylesheet>, css_rules: ARC<Stylesheet>,
} }
fn Document(+root: Node, +scope: NodeScope, +css_rules: Stylesheet) -> Document { fn Document(root: Node, scope: NodeScope, css_rules: Stylesheet) -> Document {
Document { Document {
root : root, root : root,
scope : scope, scope : scope,

View file

@ -20,7 +20,7 @@ impl ElementData {
} }
} }
fn set_attr(name: &str, +value: ~str) { fn set_attr(name: &str, value: ~str) {
let idx = do self.attrs.position |attr| { name == attr.name }; let idx = do self.attrs.position |attr| { name == attr.name };
match idx { match idx {
Some(idx) => self.attrs.set_elt(idx, ~Attr(name.to_str(), value)), Some(idx) => self.attrs.set_elt(idx, ~Attr(name.to_str(), value)),
@ -29,7 +29,7 @@ impl ElementData {
} }
} }
fn ElementData(+tag_name: ~str, +kind: ~ElementKind) -> ElementData { fn ElementData(tag_name: ~str, kind: ~ElementKind) -> ElementData {
ElementData { ElementData {
tag_name : tag_name, tag_name : tag_name,
kind : kind, kind : kind,
@ -42,7 +42,7 @@ struct Attr {
value: ~str, value: ~str,
} }
fn Attr(+name: ~str, +value: ~str) -> Attr { fn Attr(name: ~str, value: ~str) -> Attr {
Attr { Attr {
name : name, name : name,
value : value, value : value,

View file

@ -101,8 +101,8 @@ struct DoctypeData {
force_quirks: bool force_quirks: bool
} }
fn DoctypeData(+name: ~str, +public_id: Option<~str>, fn DoctypeData(name: ~str, public_id: Option<~str>,
+system_id: Option<~str>, force_quirks: bool) -> DoctypeData { system_id: Option<~str>, force_quirks: bool) -> DoctypeData {
DoctypeData { DoctypeData {
name : name, name : name,
public_id : public_id, public_id : public_id,
@ -146,7 +146,7 @@ trait NodeScopeExtensions {
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
impl NodeScope : NodeScopeExtensions { impl NodeScope : NodeScopeExtensions {
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}))
} }
} }
@ -168,7 +168,7 @@ impl NodeScope : tree::ReadMethods<Node> {
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
impl NodeScope : tree::WriteMethods<Node> { impl NodeScope : tree::WriteMethods<Node> {
fn add_child(+node: Node, +child: Node) { fn add_child(node: Node, child: Node) {
tree::add_child(&self, node, child) tree::add_child(&self, node, child)
} }

View file

@ -22,9 +22,9 @@ pub struct Engine<C:Compositor Send Copy> {
content_task: ContentTask content_task: ContentTask
} }
pub fn Engine<C:Compositor Send Copy>(+compositor: C, pub fn Engine<C:Compositor Send Copy>(compositor: C,
+resource_task: ResourceTask, resource_task: ResourceTask,
+image_cache_task: ImageCacheTask) -> Engine<C> { image_cache_task: ImageCacheTask) -> Engine<C> {
let render_task = RenderTask(compositor); let render_task = RenderTask(compositor);
let layout_task = LayoutTask(render_task, image_cache_task); let layout_task = LayoutTask(render_task, image_cache_task);
let content_task = ContentTask(layout_task, compositor, resource_task, image_cache_task); let content_task = ContentTask(layout_task, compositor, resource_task, image_cache_task);
@ -48,7 +48,7 @@ impl<C: Compositor Copy Send> Engine<C> {
} }
} }
fn handle_request(+request: Msg) -> bool { fn handle_request(request: Msg) -> bool {
match request { match request {
LoadURLMsg(url) => { LoadURLMsg(url) => {
// TODO: change copy to move once we have match move // TODO: change copy to move once we have match move

View file

@ -6,8 +6,8 @@ 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
*/ */
trait Compositor { trait Compositor {
fn begin_drawing(+next_dt: pipes::Chan<DrawTarget>); fn begin_drawing(next_dt: pipes::Chan<DrawTarget>);
fn draw(+next_dt: pipes::Chan<DrawTarget>, +draw_me: DrawTarget); fn draw(next_dt: pipes::Chan<DrawTarget>, +draw_me: DrawTarget);
fn add_event_listener(listener: comm::Chan<Event>); fn add_event_listener(listener: comm::Chan<Event>);
} }

View file

@ -57,7 +57,7 @@ pub fn SolidColor(bounds: Rect<au>, r: u8, g: u8, b: u8) -> DisplayItem {
} }
} }
pub fn Text(bounds: Rect<au>, +run: ~TextRun, offset: uint, length: uint) -> DisplayItem { pub fn Text(bounds: Rect<au>, run: ~TextRun, offset: uint, length: uint) -> DisplayItem {
DisplayItem { DisplayItem {
draw: |self, ctx| draw_Text(self, ctx), draw: |self, ctx| draw_Text(self, ctx),
bounds: bounds, bounds: bounds,
@ -66,7 +66,7 @@ pub fn Text(bounds: Rect<au>, +run: ~TextRun, offset: uint, length: uint) -> Dis
} }
// ARC should be cloned into ImageData, but Images are not sendable // ARC should be cloned into ImageData, but Images are not sendable
pub fn Image(bounds: Rect<au>, +image: ARC<~image::base::Image>) -> DisplayItem { pub fn Image(bounds: Rect<au>, image: ARC<~image::base::Image>) -> DisplayItem {
DisplayItem { DisplayItem {
draw: |self, ctx| draw_Image(self, ctx), draw: |self, ctx| draw_Image(self, ctx),
bounds: bounds, bounds: bounds,

View file

@ -15,7 +15,7 @@ impl au : Num {
pure fn to_int() -> int { *self as int } pure fn to_int() -> int { *self as int }
static pure fn from_int(+n: int) -> au { static pure fn from_int(n: int) -> au {
au((n & (i32::max_value as int)) as i32) au((n & (i32::max_value as int)) as i32)
} }
} }
@ -35,7 +35,7 @@ impl au : cmp::Eq {
pub pure fn min(x: au, y: au) -> au { if x < y { x } else { y } } pub pure fn min(x: au, y: au) -> au { if x < y { x } else { y } }
pub pure fn max(x: au, y: au) -> au { if x > y { x } else { y } } pub pure fn max(x: au, y: au) -> au { if x > y { x } else { y } }
pub fn box<A:Copy Num>(+x: A, +y: A, +w: A, +h: A) -> Rect<A> { pub fn box<A:Copy Num>(x: A, y: A, w: A, h: A) -> Rect<A> {
Rect(Point2D(x, y), Size2D(w, h)) Rect(Point2D(x, y), Size2D(w, h))
} }

View file

@ -37,10 +37,10 @@ pub enum Msg {
} }
impl Chan<Msg> : Compositor { impl Chan<Msg> : Compositor {
fn begin_drawing(+next_dt: pipes::Chan<DrawTarget>) { fn begin_drawing(next_dt: pipes::Chan<DrawTarget>) {
self.send(BeginDrawing(next_dt)) self.send(BeginDrawing(next_dt))
} }
fn draw(+next_dt: pipes::Chan<DrawTarget>, +draw_me: DrawTarget) { fn draw(next_dt: pipes::Chan<DrawTarget>, draw_me: DrawTarget) {
self.send(Draw(next_dt, draw_me)) self.send(Draw(next_dt, draw_me))
} }
fn add_event_listener(_listener: Chan<Event>) { fn add_event_listener(_listener: Chan<Event>) {
@ -69,8 +69,8 @@ pub fn PngCompositor(output: Chan<~[u8]>) -> PngCompositor {
} }
} }
fn do_draw(+sender: pipes::Chan<DrawTarget>, fn do_draw(sender: pipes::Chan<DrawTarget>,
+dt: DrawTarget, dt: DrawTarget,
output: Chan<~[u8]>, output: Chan<~[u8]>,
cairo_surface: &ImageSurface) { cairo_surface: &ImageSurface) {
let buffer = BytesWriter(); let buffer = BytesWriter();

View file

@ -41,7 +41,7 @@ struct RenderContext {
pub type RenderTask = comm::Chan<Msg>; pub type RenderTask = comm::Chan<Msg>;
pub fn RenderTask<C: Compositor Send>(+compositor: C) -> RenderTask { pub fn RenderTask<C: Compositor Send>(compositor: C) -> RenderTask {
do task::spawn_listener |po: comm::Port<Msg>| { do task::spawn_listener |po: comm::Port<Msg>| {
let (draw_target_ch, draw_target_po) = pipes::stream(); let (draw_target_ch, draw_target_po) = pipes::stream();
let mut draw_target_ch = draw_target_ch; let mut draw_target_ch = draw_target_ch;
@ -120,7 +120,7 @@ pub fn draw_solid_color(ctx: &RenderContext, bounds: &Rect<au>, r: u8, g: u8, b:
ctx.canvas.fill_rect(&bounds.to_azure_rect(), &ColorPattern(color)); ctx.canvas.fill_rect(&bounds.to_azure_rect(), &ColorPattern(color));
} }
pub fn draw_image(ctx: &RenderContext, bounds: Rect<au>, +image: ARC<~Image>) { pub fn draw_image(ctx: &RenderContext, bounds: Rect<au>, image: ARC<~Image>) {
let image = std::arc::get(&image); let image = std::arc::get(&image);
let size = Size2D(image.width as i32, image.height as i32); let size = Size2D(image.width as i32, image.height as i32);
let stride = image.width * 4; let stride = image.width * 4;

View file

@ -166,7 +166,7 @@ fn build_element_kind(tag: &str) -> ~ElementKind {
} }
pub fn parse_html(scope: NodeScope, pub fn parse_html(scope: NodeScope,
+url: Url, url: Url,
resource_task: ResourceTask, resource_task: ResourceTask,
image_cache_task: ImageCacheTask) -> HtmlParserResult unsafe { image_cache_task: ImageCacheTask) -> HtmlParserResult unsafe {
// Spawn a CSS parser to receive links to CSS style sheets. // Spawn a CSS parser to receive links to CSS style sheets.

View file

@ -100,7 +100,7 @@ impl InputState : InputStateUtil {
self.lookahead = Some(CoeChar(ch)); self.lookahead = Some(CoeChar(ch));
} }
fn parse_err(+err: ~str) -> ! { fn parse_err(err: ~str) -> ! {
fail err fail err
} }
@ -131,7 +131,7 @@ impl InputState : InputStateUtil {
return str::from_bytes(result); return str::from_bytes(result);
} }
fn expect_ident(+expected: ~str) { fn expect_ident(expected: ~str) {
let actual = self.parse_ident(); let actual = self.parse_ident();
if expected != actual { if expected != actual {
self.parse_err(#fmt("expected '%s' but found '%s'", expected, actual)); self.parse_err(#fmt("expected '%s' but found '%s'", expected, actual));

View file

@ -11,7 +11,7 @@ use stb_image = stb_image::image;
pub type Image = stb_image::Image; pub type Image = stb_image::Image;
pub fn Image(width: uint, height: uint, depth: uint, +data: ~[u8]) -> Image { pub fn Image(width: uint, height: uint, depth: uint, data: ~[u8]) -> Image {
stb_image::new_image(width, height, depth, data) stb_image::new_image(width, height, depth, data)
} }

View file

@ -19,7 +19,7 @@ pub struct ImageHolder {
} }
fn ImageHolder(+url : Url, image_cache_task: ImageCacheTask, +cb: fn~()) -> ImageHolder { fn ImageHolder(url : Url, image_cache_task: ImageCacheTask, cb: fn~()) -> ImageHolder {
debug!("ImageHolder() %?", url.to_str()); debug!("ImageHolder() %?", url.to_str());
let holder = ImageHolder { let holder = ImageHolder {
url : Some(copy url), url : Some(copy url),

View file

@ -270,7 +270,7 @@ impl FlowContext : FlowContextMethods {
} }
// Actual methods that do not require much flow-specific logic // Actual methods that do not require much flow-specific logic
pure fn foldl_boxes_for_node<B: Copy>(node: Node, +seed: B, blk: pure fn&(+a: B,@RenderBox) -> B) -> B { pure fn foldl_boxes_for_node<B: Copy>(node: Node, seed: B, blk: pure fn&(a: B,@RenderBox) -> B) -> B {
match self { match self {
RootFlow(*) => match self.root().box { RootFlow(*) => match self.root().box {
Some(box) if box.d().node == node => { blk(seed, box) }, Some(box) if box.d().node == node => { blk(seed, box) },

View file

@ -55,7 +55,7 @@ fn OSMain() -> OSMain {
} }
} }
fn mainloop(+mode: Mode, po: comm::Port<Msg>) { fn mainloop(mode: Mode, po: comm::Port<Msg>) {
let key_handlers: @DVec<pipes::Chan<()>> = @DVec(); let key_handlers: @DVec<pipes::Chan<()>> = @DVec();
let event_listeners: @DVec<comm::Chan<Event>> = @DVec(); let event_listeners: @DVec<comm::Chan<Event>> = @DVec();
@ -166,10 +166,10 @@ Implementation to allow the osmain channel to be used as a graphics
compositor for the renderer compositor for the renderer
*/ */
impl OSMain : Compositor { impl OSMain : Compositor {
fn begin_drawing(+next_dt: pipes::Chan<DrawTarget>) { fn begin_drawing(next_dt: pipes::Chan<DrawTarget>) {
self.send(BeginDrawing(next_dt)) self.send(BeginDrawing(next_dt))
} }
fn draw(+next_dt: pipes::Chan<DrawTarget>, +draw_me: DrawTarget) { fn draw(next_dt: pipes::Chan<DrawTarget>, draw_me: DrawTarget) {
self.send(Draw(next_dt, draw_me)) self.send(Draw(next_dt, draw_me))
} }
fn add_event_listener(listener: comm::Chan<Event>) { fn add_event_listener(listener: comm::Chan<Event>) {
@ -182,7 +182,7 @@ struct SurfaceSet {
mut back: Surface, mut back: Surface,
} }
fn lend_surface(surfaces: &SurfaceSet, +receiver: pipes::Chan<DrawTarget>) { fn lend_surface(surfaces: &SurfaceSet, receiver: pipes::Chan<DrawTarget>) {
// 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
@ -197,7 +197,7 @@ fn lend_surface(surfaces: &SurfaceSet, +receiver: pipes::Chan<DrawTarget>) {
assert surfaces.front.have; assert surfaces.front.have;
} }
fn return_surface(surfaces: &SurfaceSet, +draw_target: DrawTarget) { fn return_surface(surfaces: &SurfaceSet, draw_target: DrawTarget) {
#debug("osmain: returning surface %?", draw_target); #debug("osmain: returning surface %?", draw_target);
// We have room for a return // We have room for a return
assert surfaces.front.have; assert surfaces.front.have;
@ -227,7 +227,7 @@ fn Surface() -> 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: Send>(+f: fn~(+po: comm::Port<T>)) -> comm::Chan<T> { fn on_osmain<T: Send>(f: fn~(po: comm::Port<T>)) -> comm::Chan<T> {
task::task().sched_mode(task::PlatformThread).spawn_listener(f) task::task().sched_mode(task::PlatformThread).spawn_listener(f)
} }

View file

@ -8,7 +8,7 @@ use io::{file_reader, ReaderUtil};
const READ_SIZE: uint = 1024; const READ_SIZE: uint = 1024;
pub fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) { pub fn factory(url: Url, progress_chan: Chan<ProgressMsg>) {
assert url.scheme == ~"file"; assert url.scheme == ~"file";
do spawn { do spawn {

View file

@ -6,7 +6,7 @@ use resource_task::{ProgressMsg, Payload, Done};
use std::net::url::Url; use std::net::url::Url;
use http_client::{uv_http_request}; use http_client::{uv_http_request};
pub fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) { pub fn factory(url: Url, progress_chan: Chan<ProgressMsg>) {
assert url.scheme == ~"http"; assert url.scheme == ~"http";
do spawn { do spawn {

View file

@ -80,7 +80,7 @@ pub fn ImageCacheTask(resource_task: ResourceTask) -> ImageCacheTask {
ImageCacheTask_(resource_task, default_decoder_factory) ImageCacheTask_(resource_task, default_decoder_factory)
} }
pub fn ImageCacheTask_(resource_task: ResourceTask, +decoder_factory: DecoderFactory) -> ImageCacheTask { pub fn ImageCacheTask_(resource_task: ResourceTask, decoder_factory: DecoderFactory) -> ImageCacheTask {
// FIXME: Doing some dancing to avoid copying decoder_factory, our test // FIXME: Doing some dancing to avoid copying decoder_factory, our test
// version of which contains an uncopyable type which rust will currently // version of which contains an uncopyable type which rust will currently
// copy unsoundly // copy unsoundly
@ -200,18 +200,18 @@ impl ImageCache {
} }
} }
priv fn get_state(+url: Url) -> ImageState { priv fn get_state(url: Url) -> ImageState {
match self.state_map.find(url) { match self.state_map.find(url) {
Some(state) => state, Some(state) => state,
None => Init None => Init
} }
} }
priv fn set_state(+url: Url, state: ImageState) { priv fn set_state(url: Url, state: ImageState) {
self.state_map.insert(url, state); self.state_map.insert(url, state);
} }
priv fn prefetch(+url: Url) { priv fn prefetch(url: Url) {
match self.get_state(copy url) { match self.get_state(copy url) {
Init => { Init => {
let to_cache = self.from_client.chan(); let to_cache = self.from_client.chan();
@ -246,7 +246,7 @@ impl ImageCache {
} }
} }
priv fn store_prefetched_image_data(+url: Url, data: &Result<Cell<~[u8]>, ()>) { priv fn store_prefetched_image_data(url: Url, data: &Result<Cell<~[u8]>, ()>) {
match self.get_state(copy url) { match self.get_state(copy url) {
Prefetching(next_step) => { Prefetching(next_step) => {
match *data { match *data {
@ -275,7 +275,7 @@ impl ImageCache {
} }
} }
priv fn decode(+url: Url) { priv fn decode(url: Url) {
match self.get_state(copy url) { match self.get_state(copy url) {
Init => fail ~"decoding image before prefetch", Init => fail ~"decoding image before prefetch",
@ -321,7 +321,7 @@ impl ImageCache {
} }
} }
priv fn store_image(+url: Url, image: &Option<ARC<~Image>>) { priv fn store_image(url: Url, image: &Option<ARC<~Image>>) {
match self.get_state(copy url) { match self.get_state(copy url) {
Decoding => { Decoding => {
@ -348,7 +348,7 @@ impl ImageCache {
} }
priv fn purge_waiters(+url: Url, f: fn() -> ImageResponseMsg) { priv fn purge_waiters(url: Url, f: fn() -> ImageResponseMsg) {
match self.wait_map.find(copy url) { match self.wait_map.find(copy url) {
Some(@waiters) => { Some(@waiters) => {
for waiters.each |response| { for waiters.each |response| {
@ -361,7 +361,7 @@ impl ImageCache {
} }
priv fn get_image(+url: Url, response: Chan<ImageResponseMsg>) { priv fn get_image(url: Url, response: Chan<ImageResponseMsg>) {
match self.get_state(copy url) { match self.get_state(copy url) {
Init => fail ~"request for image before prefetch", Init => fail ~"request for image before prefetch",
@ -387,7 +387,7 @@ impl ImageCache {
} }
} }
priv fn wait_for_image(+url: Url, response: Chan<ImageResponseMsg>) { priv fn wait_for_image(url: Url, response: Chan<ImageResponseMsg>) {
match self.get_state(copy url) { match self.get_state(copy url) {
Init => fail ~"request for image before prefetch", Init => fail ~"request for image before prefetch",
@ -435,7 +435,7 @@ impl ImageCacheTask: ImageCacheTaskClient {
} }
fn load_image_data(+url: Url, resource_task: ResourceTask) -> Result<~[u8], ()> { fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<~[u8], ()> {
let response_port = Port(); let response_port = Port();
resource_task.send(resource_task::Load(url, response_port.chan())); resource_task.send(resource_task::Load(url, response_port.chan()));
@ -461,7 +461,7 @@ fn default_decoder_factory() -> ~fn(&[u8]) -> Option<Image> {
} }
#[cfg(test)] #[cfg(test)]
fn mock_resource_task(+on_load: ~fn(resource: Chan<resource_task::ProgressMsg>)) -> ResourceTask { fn mock_resource_task(on_load: ~fn(resource: Chan<resource_task::ProgressMsg>)) -> ResourceTask {
do spawn_listener |from_client, move on_load| { do spawn_listener |from_client, move on_load| {
// infer me // infer me

View file

@ -47,7 +47,7 @@ Creates a task to load a specific resource
The ResourceManager delegates loading to a different type of loader task for The ResourceManager delegates loading to a different type of loader task for
each URL scheme each URL scheme
*/ */
type LoaderTaskFactory = fn~(+url: Url, Chan<ProgressMsg>); type LoaderTaskFactory = fn~(url: Url, Chan<ProgressMsg>);
/// Create a ResourceTask with the default loaders /// Create a ResourceTask with the default loaders
fn ResourceTask() -> ResourceTask { fn ResourceTask() -> ResourceTask {
@ -58,7 +58,7 @@ fn ResourceTask() -> ResourceTask {
create_resource_task_with_loaders(loaders) create_resource_task_with_loaders(loaders)
} }
fn create_resource_task_with_loaders(+loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceTask { fn create_resource_task_with_loaders(loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceTask {
do spawn_listener |from_client| { do spawn_listener |from_client| {
// TODO: change copy to move once we can move into closures // TODO: change copy to move once we can move into closures
ResourceManager(from_client, copy loaders).start() ResourceManager(from_client, copy loaders).start()
@ -73,7 +73,7 @@ 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,
@ -95,7 +95,7 @@ impl ResourceManager {
} }
} }
fn load(+url: Url, progress_chan: Chan<ProgressMsg>) { fn load(url: Url, progress_chan: Chan<ProgressMsg>) {
match self.get_loader_factory(&url) { match self.get_loader_factory(&url) {
Some(loader_factory) => { Some(loader_factory) => {
@ -143,7 +143,7 @@ fn test_bad_scheme() {
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
fn should_delegate_to_scheme_loader() { fn should_delegate_to_scheme_loader() {
let payload = ~[1, 2, 3]; let payload = ~[1, 2, 3];
let loader_factory = fn~(+_url: Url, progress_chan: Chan<ProgressMsg>, copy payload) { let loader_factory = fn~(_url: Url, progress_chan: Chan<ProgressMsg>, copy payload) {
progress_chan.send(Payload(copy payload)); progress_chan.send(Payload(copy payload));
progress_chan.send(Done(Ok(()))); progress_chan.send(Done(Ok(())));
}; };

View file

@ -7,7 +7,7 @@
#[license = "MPL"]; #[license = "MPL"];
#[crate_type = "lib"]; #[crate_type = "lib"];
#[legacy_modes]; //#[legacy_modes];
extern mod std; extern mod std;
extern mod azure; extern mod azure;

View file

@ -66,7 +66,7 @@ fn run_pipeline_screen(urls: &[~str]) {
osmain.send(osmain::Exit); osmain.send(osmain::Exit);
} }
fn run_pipeline_png(+url: ~str, outfile: &str) { fn run_pipeline_png(url: ~str, outfile: &str) {
// Use a PNG encoder as the graphics compositor // Use a PNG encoder as the graphics compositor
use gfx::png_compositor; use gfx::png_compositor;
use png_compositor::PngCompositor; use png_compositor::PngCompositor;

View file

@ -70,7 +70,7 @@ pub impl Font : FontMethods {
// TODO: font should compute its own metrics using native_font. // TODO: font should compute its own metrics using native_font.
// TODO: who should own fontbuf? // TODO: who should own fontbuf?
fn Font(lib: @FontCache, fontbuf: @~[u8], +native_font: NativeFont, +metrics: FontMetrics) -> Font { fn Font(lib: @FontCache, fontbuf: @~[u8], native_font: NativeFont, metrics: FontMetrics) -> Font {
Font { Font {
lib: lib, lib: lib,
fontbuf : fontbuf, fontbuf : fontbuf,

View file

@ -126,7 +126,7 @@ impl TextRun {
} }
} }
fn TextRun(font: &Font, +text: ~str) -> TextRun { fn TextRun(font: &Font, text: ~str) -> TextRun {
let glyph_store = GlyphStore(text.len()); let glyph_store = GlyphStore(text.len());
let run = TextRun { let run = TextRun {
text: text, text: text,
@ -160,7 +160,7 @@ fn test_calc_min_break_width() {
#[test] #[test]
#[ignore] #[ignore]
fn test_iter_indivisible_pieces() { fn test_iter_indivisible_pieces() {
fn test_pieces(+text: ~str, +res: ~[~str]) { fn test_pieces(text: ~str, res: ~[~str]) {
let flib = FontCache(); let flib = FontCache();
let font = flib.get_test_font(); let font = flib.get_test_font();
let run = TextRun(font, copy text); let run = TextRun(font, copy text);

View file

@ -41,7 +41,7 @@ pub fn empty<T>() -> Tree<T> {
mut next_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) {
ops.with_tree_fields(&child, |child_tf| { ops.with_tree_fields(&child, |child_tf| {
match child_tf.parent { match child_tf.parent {

View file

@ -15,7 +15,7 @@ Create a URL object from a string. Does various helpful browsery things like
*/ */
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
fn make_url(+str_url: ~str, +current_url: Option<Url>) -> Url { fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
let mut schm = url::get_scheme(str_url); let mut schm = url::get_scheme(str_url);
let str_url = if result::is_err(&schm) { let str_url = if result::is_err(&schm) {
if current_url.is_none() { if current_url.is_none() {