diff --git a/servo/src/servo/content.rs b/servo/src/servo/content.rs index a0c14283ddc8..a6d8dfd0b7fb 100644 --- a/servo/src/servo/content.rs +++ b/servo/src/servo/content.rs @@ -43,8 +43,6 @@ import std::net::url::url; import url_to_str = std::net::url::to_str; import util::url::make_url; -type Content = chan; - enum ControlMsg { ParseMsg(url), ExecuteMsg(url), @@ -114,14 +112,14 @@ class Content { } fn handle_msg(msg: either) -> bool { - alt msg { + match msg { left(control_msg) => self.handle_control_msg(control_msg), right(event) => self.handle_event(event) } } fn handle_control_msg(control_msg: ControlMsg) -> bool { - alt control_msg { + match control_msg { ParseMsg(url) => { #debug["content: Received url `%s` to parse", url_to_str(url)]; @@ -161,7 +159,7 @@ class Content { ExecuteMsg(url) => { #debug["content: Received url `%s` to execute", url_to_str(url)]; - alt read_whole_file(url.path) { + match read_whole_file(url.path) { err(msg) => { println(#fmt["Error opening %s: %s", url_to_str(url), msg]); } @@ -202,10 +200,10 @@ class Content { } fn handle_event(event: Event) -> bool { - alt event { + match event { ResizeEvent(new_width, new_height) => { #debug("content got resize event: %d, %d", new_width, new_height); - alt copy self.document { + match copy self.document { none => { // Nothing to do. } diff --git a/servo/src/servo/dom/bindings/node.rs b/servo/src/servo/dom/bindings/node.rs index 33d4d06117b4..ba305ef90e1a 100644 --- a/servo/src/servo/dom/bindings/node.rs +++ b/servo/src/servo/dom/bindings/node.rs @@ -93,7 +93,7 @@ unsafe fn unwrap(obj: *JSObject) -> *rust_box { extern fn getFirstChild(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval) -> JSBool { unsafe { (*unwrap(obj)).payload.read(|nd| { - alt nd.tree.first_child { + match nd.tree.first_child { some(n) => { let obj = create(cx, n).ptr; *rval = RUST_OBJECT_TO_JSVAL(obj); @@ -110,7 +110,7 @@ extern fn getFirstChild(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut js extern fn getNextSibling(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval) -> JSBool { unsafe { (*unwrap(obj)).payload.read(|nd| { - alt nd.tree.next_sibling { + match nd.tree.next_sibling { some(n) => { let obj = create(cx, n).ptr; *rval = RUST_OBJECT_TO_JSVAL(obj); @@ -127,7 +127,7 @@ extern fn getNextSibling(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut j extern fn getTagName(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval) -> JSBool { unsafe { (*unwrap(obj)).payload.read(|nd| { - alt nd.kind { + match nd.kind { ~Element(ed) => { let s = str(copy ed.tag_name); *rval = domstring_to_jsval(cx, s); diff --git a/servo/src/servo/dom/bindings/utils.rs b/servo/src/servo/dom/bindings/utils.rs index f9978dd7c2e5..eeeac86b8ee8 100644 --- a/servo/src/servo/dom/bindings/utils.rs +++ b/servo/src/servo/dom/bindings/utils.rs @@ -54,7 +54,7 @@ fn jsval_to_str(cx: *JSContext, v: jsval) -> result<~str, ()> { } unsafe fn domstring_to_jsval(cx: *JSContext, str: DOMString) -> jsval { - alt str { + match str { null_string => { JSVAL_NULL } diff --git a/servo/src/servo/dom/rcu.rs b/servo/src/servo/dom/rcu.rs index 8d5587fe3747..64c9071a7a39 100644 --- a/servo/src/servo/dom/rcu.rs +++ b/servo/src/servo/dom/rcu.rs @@ -249,14 +249,14 @@ mod test { } fn mutate(a: animal) { - alt a.species { + match a.species { chicken(c) => c.eggs_per_day += 1u, bull(c) => c.horns += 1u } } fn read_characteristic(a: animal) -> uint { - alt a.species { + match a.species { chicken(c) => c.eggs_per_day, bull(c) => c.horns } diff --git a/servo/src/servo/engine.rs b/servo/src/servo/engine.rs index f7861af49ece..31500e47994d 100644 --- a/servo/src/servo/engine.rs +++ b/servo/src/servo/engine.rs @@ -41,9 +41,9 @@ class Engine { } fn handle_request(request: Msg) -> bool { - alt request { + match request { LoadURLMsg(url) => { - // TODO: change copy to move once we have alt move + // TODO: change copy to move once we have match move let url = copy url; if url.path.ends_with(".js") { self.content.send(ExecuteMsg(url)) diff --git a/servo/src/servo/gfx/pngsink.rs b/servo/src/servo/gfx/pngsink.rs index 04b9e6654995..a3139c736821 100644 --- a/servo/src/servo/gfx/pngsink.rs +++ b/servo/src/servo/gfx/pngsink.rs @@ -58,7 +58,7 @@ fn PngSink(output: chan<~[u8]>) -> PngSink { assert draw_target.is_not_null(); loop { - alt po.recv() { + match po.recv() { BeginDrawing(sender) => { #debug("pngsink: begin_drawing"); sender.send(draw_target); diff --git a/servo/src/servo/gfx/renderer.rs b/servo/src/servo/gfx/renderer.rs index 061544dfe91e..f8c72e31e3df 100644 --- a/servo/src/servo/gfx/renderer.rs +++ b/servo/src/servo/gfx/renderer.rs @@ -46,7 +46,7 @@ fn Renderer(sink: S) -> comm::chan { sink.begin_drawing(draw_target_ch); loop { - alt po.recv() { + match po.recv() { RenderMsg(display_list) => { #debug("renderer: got render request"); let draw_target = draw_target_po.recv(); @@ -87,7 +87,7 @@ fn draw_display_list(draw_target: AzDrawTargetRef, display_list: dl::display_lis for display_list.each |item| { #debug["drawing %?", item]; - alt item.item_type { + match item.item_type { dl::display_item_solid_color(r, g, b) => draw_solid_color(draw_target, item, r, g, b), dl::display_item_image(image) => draw_image(draw_target, item, *image), dl::display_item_text(text_run) => draw_text(draw_target, item, text_run), @@ -132,7 +132,7 @@ fn draw_image(draw_target: AzDrawTargetRef, item: dl::display_item, image: arc<~ let data = do vec::from_fn(image.width * image.height * 4) |i| { let color = i % 4; let pixel = i / 4; - alt color { + match color { 0 => image.data[pixel * 3 + 2], 1 => image.data[pixel * 3 + 1], 2 => image.data[pixel * 3 + 0], diff --git a/servo/src/servo/gfx/surface.rs b/servo/src/servo/gfx/surface.rs index a155f405c5fe..79dff0f4fe38 100644 --- a/servo/src/servo/gfx/surface.rs +++ b/servo/src/servo/gfx/surface.rs @@ -14,7 +14,7 @@ type image_surface = { impl format for format { fn bpp() -> uint { - alt self { + match self { fo_rgba_8888 => 32u } } diff --git a/servo/src/servo/layout/base.rs b/servo/src/servo/layout/base.rs index d99887dc5b97..943fcd8f8ebe 100644 --- a/servo/src/servo/layout/base.rs +++ b/servo/src/servo/layout/base.rs @@ -48,7 +48,7 @@ class Appearance { let mut image = none; // Do a dance where we swap the ImageHolder out before we can - // get the image out of it because we can't alt over it + // get the image out of it because we can't match against it // because holder.get_image() is not pure. if (self.background_image).is_some() { let mut temp = none; @@ -179,7 +179,7 @@ impl layout_methods_priv for @Box { impl layout_methods for @Box { #[doc="The main reflow routine."] fn reflow(available_width: au) { - alt self.kind { + match self.kind { BlockBox => self.reflow_block(available_width), InlineBox => self.reflow_inline(available_width), IntrinsicBox(size) => self.reflow_intrinsic(*size), diff --git a/servo/src/servo/layout/box_builder.rs b/servo/src/servo/layout/box_builder.rs index 938273bbc634..55f621df1784 100644 --- a/servo/src/servo/layout/box_builder.rs +++ b/servo/src/servo/layout/box_builder.rs @@ -54,10 +54,10 @@ impl methods for ctxt { } // Add the child's box to the current enclosing box or the current anonymous box. - alt kid.get_specified_style().display_type { + match kid.get_specified_style().display_type { some(DisBlock) => BTree.add_child(self.parent_box, kid_box), some(DisInline) => { - let anon_box = alt self.anon_box { + let anon_box = match self.anon_box { none => { // // The anonymous box inherits the attributes of its parents for now, so @@ -101,7 +101,7 @@ impl methods for ctxt { } // Add the child's box to the current enclosing box. - alt kid.get_specified_style().display_type { + match kid.get_specified_style().display_type { some(DisBlock) => { // TODO #warn("TODO: non-inline display found inside inline box"); @@ -124,7 +124,7 @@ impl methods for ctxt { #debug("parent node:"); self.parent_node.dump(); - alt self.parent_node.get_specified_style().display_type { + match self.parent_node.get_specified_style().display_type { some(DisBlock) => self.construct_boxes_for_block_children(), some(DisInline) => self.construct_boxes_for_inline_children(), some(DisNone) => { /* Nothing to do. */ } @@ -141,7 +141,7 @@ impl methods for ctxt { anonymous box to the block. "] fn finish_anonymous_box_if_necessary() { - alt copy self.anon_box { + match copy self.anon_box { none => { /* Nothing to do. */ } some(b) => BTree.add_child(self.parent_box, b) } @@ -159,10 +159,10 @@ impl box_builder_priv of box_builder_priv for Node { size. "] fn determine_box_kind() -> BoxKind { - alt self.read(|n| copy n.kind) { + match self.read(|n| copy n.kind) { ~Text(string) => TextBox(@text_box(copy string)), ~Element(element) => { - alt *element.kind { + match *element.kind { HTMLDivElement => BlockBox, HTMLImageElement({size}) => IntrinsicBox(@size), UnknownElement => InlineBox @@ -181,7 +181,7 @@ impl box_builder_methods of box_builder_methods for Node { fn construct_boxes() -> @Box { let box_kind = self.determine_box_kind(); let my_box = @Box(self, box_kind); - alt box_kind { + match box_kind { BlockBox | InlineBox => { let cx = create_context(self, my_box); cx.construct_boxes_for_children(); diff --git a/servo/src/servo/layout/display_list_builder.rs b/servo/src/servo/layout/display_list_builder.rs index 4760c268e2bb..2a1fa1244669 100644 --- a/servo/src/servo/layout/display_list_builder.rs +++ b/servo/src/servo/layout/display_list_builder.rs @@ -72,7 +72,7 @@ fn box_to_display_items(list: dl::display_list, box: @Box, origin: Point2D) let bounds = Rect(origin, copy box.bounds.size); let col = box.appearance.background_color; - alt box.kind { + match box.kind { TextBox(subbox) => { let run = copy subbox.run; assert run.is_some(); @@ -119,13 +119,13 @@ fn should_convert_text_boxes_to_solid_color_background_items() { let n = s.new_node(Text(~"firecracker")); let b = n.construct_boxes(); - let subbox = alt check b.kind { TextBox(subbox) => subbox }; + let subbox = match check b.kind { TextBox(subbox) => subbox }; b.reflow_text(px_to_au(800), subbox); let list = dvec(); box_to_display_items(list, b, Point2D(px_to_au(0), px_to_au(0))); - alt list[0].item_type { + match list[0].item_type { dl::display_item_solid_color(*) => { } _ => { fail } } @@ -140,13 +140,13 @@ fn should_convert_text_boxes_to_text_items() { let n = s.new_node(Text(~"firecracker")); let b = n.construct_boxes(); - let subbox = alt check b.kind { TextBox(subbox) => { subbox } }; + let subbox = match check b.kind { TextBox(subbox) => { subbox } }; b.reflow_text(px_to_au(800), subbox); let list = dvec(); box_to_display_items(list, b, Point2D(px_to_au(0), px_to_au(0))); - alt list[1].item_type { + match list[1].item_type { dl::display_item_text(_) => { } _ => { fail } } @@ -160,7 +160,7 @@ fn should_calculate_the_bounds_of_the_text_box_background_color() { let n = s.new_node(Text(~"firecracker")); let b = n.construct_boxes(); - let subbox = alt check b.kind { TextBox(subbox) => { subbox } }; + let subbox = match check b.kind { TextBox(subbox) => { subbox } }; b.reflow_text(px_to_au(800), subbox); let list = dvec(); @@ -182,7 +182,7 @@ fn should_calculate_the_bounds_of_the_text_items() { let n = s.new_node(Text(~"firecracker")); let b = n.construct_boxes(); - let subbox = alt check b.kind { TextBox(subbox) => { subbox } }; + let subbox = match check b.kind { TextBox(subbox) => { subbox } }; b.reflow_text(px_to_au(800), subbox); let list = dvec(); diff --git a/servo/src/servo/layout/layout_task.rs b/servo/src/servo/layout/layout_task.rs index 54284a07c916..5ceabecc3c68 100644 --- a/servo/src/servo/layout/layout_task.rs +++ b/servo/src/servo/layout/layout_task.rs @@ -29,7 +29,7 @@ enum Msg { fn Layout(renderer: Renderer) -> Layout { do spawn_listener::|request| { loop { - alt request.recv() { + match request.recv() { PingMsg(ping_channel) => ping_channel.send(content::PongMsg), ExitMsg => { #debug("layout: ExitMsg received"); diff --git a/servo/src/servo/layout/style/apply.rs b/servo/src/servo/layout/style/apply.rs index 155abf5bcd04..7acf79c769b5 100644 --- a/servo/src/servo/layout/style/apply.rs +++ b/servo/src/servo/layout/style/apply.rs @@ -33,16 +33,16 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box { fn apply_style() { // Right now, we only handle images. do self.node.read |node| { - alt node.kind { + match node.kind { ~Element(element) => { let style = self.node.get_specified_style(); - self.appearance.background_color = alt style.background_color { + self.appearance.background_color = match style.background_color { some(col) => col, none => node.kind.default_color() }; - alt element.kind { + match element.kind { ~HTMLImageElement(*) => { let url = element.get_attr(~"src"); diff --git a/servo/src/servo/layout/style/matching.rs b/servo/src/servo/layout/style/matching.rs index e487d639c3ae..5a5e73c43342 100644 --- a/servo/src/servo/layout/style/matching.rs +++ b/servo/src/servo/layout/style/matching.rs @@ -13,15 +13,15 @@ export matching_methods; #[doc="Check if a CSS attribute matches the attribute of an HTML element."] fn attrs_match(attr: Attr, elmt: ElementData) -> bool { - alt attr { + match attr { Exists(name) => { - alt elmt.get_attr(name) { + match elmt.get_attr(name) { some(_) => true, none => false } } Exact(name, val) => { - alt elmt.get_attr(name) { + match elmt.get_attr(name) { some(value) => value == val, none => false } @@ -31,13 +31,13 @@ fn attrs_match(attr: Attr, elmt: ElementData) -> bool { // it cannot match. if val == ~"" { return false; } - alt elmt.get_attr(name) { + match elmt.get_attr(name) { some(value) => value.split_char(' ').contains(val), none => false } } StartsWith(name, val) => { - alt elmt.get_attr(name) { + match elmt.get_attr(name) { some(value) => { //check that there is only one attribute value and it //starts with the perscribed value @@ -66,10 +66,10 @@ impl priv_matching_methods of priv_matching_methods for Node { information, describes the given HTML element. "] fn matches_element(sel: ~Selector) -> bool { - alt *sel { + match *sel { Child(_, _) | Descendant(_, _) | Sibling(_, _) => { return false; } Element(tag, attrs) => { - alt self.read(|n| copy *n.kind) { + match self.read(|n| copy *n.kind) { base::Element(elmt) => { if !(tag == ~"*" || tag == elmt.tag_name) { return false; @@ -94,10 +94,10 @@ impl priv_matching_methods of priv_matching_methods for Node { #[doc = "Checks if a generic CSS selector matches a given HTML element"] fn matches_selector(sel : ~Selector) -> bool { - alt *sel { + match *sel { Element(str, atts) => { return self.matches_element(sel); } Child(sel1, sel2) => { - return alt self.read(|n| n.tree.parent) { + return match self.read(|n| n.tree.parent) { some(parent) => self.matches_element(sel2) && parent.matches_selector(sel1), none => false } @@ -107,7 +107,7 @@ impl priv_matching_methods of priv_matching_methods for Node { //loop over all ancestors to check if they are the person //we should be descended from. - let mut cur_parent = alt self.read(|n| n.tree.parent) { + let mut cur_parent = match self.read(|n| n.tree.parent) { some(parent) => parent, none => return false }; @@ -115,7 +115,7 @@ impl priv_matching_methods of priv_matching_methods for Node { loop { if cur_parent.matches_selector(sel1) { return true; } - cur_parent = alt cur_parent.read(|n| n.tree.parent) { + cur_parent = match cur_parent.read(|n| n.tree.parent) { some(parent) => parent, none => return false }; @@ -125,13 +125,13 @@ impl priv_matching_methods of priv_matching_methods for Node { if !self.matches_element(sel2) { return false; } // Loop over this node's previous siblings to see if they match. - alt self.read(|n| n.tree.prev_sibling) { + match self.read(|n| n.tree.prev_sibling) { some(sib) => { let mut cur_sib = sib; loop { if cur_sib.matches_selector(sel1) { return true; } - cur_sib = alt cur_sib.read(|n| n.tree.prev_sibling) { + cur_sib = match cur_sib.read(|n| n.tree.prev_sibling) { some(sib) => sib, none => { break; } }; @@ -141,13 +141,13 @@ impl priv_matching_methods of priv_matching_methods for Node { } // check the rest of the siblings - alt self.read(|n| n.tree.next_sibling) { + match self.read(|n| n.tree.next_sibling) { some(sib) => { let mut cur_sib = sib; loop { if cur_sib.matches_selector(sel1) { return true; } - cur_sib = alt cur_sib.read(|n| n.tree.next_sibling) { + cur_sib = match cur_sib.read(|n| n.tree.next_sibling) { some(sib) => sib, none => { break; } }; @@ -170,7 +170,7 @@ impl priv_style_methods of priv_style_methods for Node { #[doc="Update the computed style of an HTML element with a style specified by CSS."] fn update_style(decl : StyleDeclaration) { self.aux(|layout| { - alt decl { + match decl { BackgroundColor(col) => layout.specified_style.background_color = some(col), Display(dis) => layout.specified_style.display_type = some(dis), FontSize(size) => layout.specified_style.font_size = some(size), diff --git a/servo/src/servo/layout/style/style.rs b/servo/src/servo/layout/style/style.rs index 6a3ea4b8fb2e..39b917cf3aaf 100644 --- a/servo/src/servo/layout/style/style.rs +++ b/servo/src/servo/layout/style/style.rs @@ -29,7 +29,7 @@ trait default_style_methods { #[doc="Default stylesfor various attributes in case they don't get initialized from css selectors"] impl default_style_methods of default_style_methods for NodeKind { fn default_color() -> Color { - alt self { + match self { Text(*) => { white() } Element(*) => { let r = rand::rng(); @@ -39,10 +39,10 @@ impl default_style_methods of default_style_methods for NodeKind { } fn default_display_type() -> DisplayType { - alt self { + match self { Text(*) => { DisInline } Element(element) => { - alt *element.kind { + match *element.kind { HTMLDivElement => DisBlock, HTMLHeadElement => DisNone, HTMLImageElement(*) => DisInline, diff --git a/servo/src/servo/layout/text.rs b/servo/src/servo/layout/text.rs index 035a2ebabdc2..df5e0c64ac5f 100644 --- a/servo/src/servo/layout/text.rs +++ b/servo/src/servo/layout/text.rs @@ -23,7 +23,7 @@ trait text_layout_methods { #[doc="The main reflow routine for text layout."] impl text_layout_methods of text_layout_methods for @Box { fn reflow_text(_available_width: au, subbox: @text_box) { - alt self.kind { + match self.kind { TextBox(*) => { /* ok */ } _ => { fail ~"expected text box in reflow_text!" } }; @@ -51,7 +51,7 @@ fn should_calculate_the_size_of_the_text_box() { let n = s.new_node(Text(~"firecracker")); let b = n.construct_boxes(); - let subbox = alt check b.kind { TextBox(subbox) => { subbox } }; + let subbox = match check b.kind { TextBox(subbox) => { subbox } }; b.reflow_text(px_to_au(800), subbox); let expected = Size2D(px_to_au(84), px_to_au(20)); assert b.bounds.size == expected; diff --git a/servo/src/servo/opts.rs b/servo/src/servo/opts.rs index 88f0898163a2..3a5f4973257a 100644 --- a/servo/src/servo/opts.rs +++ b/servo/src/servo/opts.rs @@ -25,7 +25,7 @@ fn from_cmdline_args(args: ~[~str]) -> Opts { getopts::optopt(~"o") ]; - let opt_match = alt getopts::getopts(args, opts) { + let opt_match = match getopts::getopts(args, opts) { result::ok(m) => { copy m } result::err(f) => { fail getopts::fail_str(f) } }; @@ -36,7 +36,7 @@ fn from_cmdline_args(args: ~[~str]) -> Opts { copy opt_match.free }; - let render_mode = alt getopts::opt_maybe_str(opt_match, ~"o") { + let render_mode = match getopts::opt_maybe_str(opt_match, ~"o") { some(output_file) => { Png(copy output_file) } none => { Screen } }; diff --git a/servo/src/servo/parser/css_builder.rs b/servo/src/servo/parser/css_builder.rs index 814fa7c1350c..e3096793dbf8 100644 --- a/servo/src/servo/parser/css_builder.rs +++ b/servo/src/servo/parser/css_builder.rs @@ -26,7 +26,7 @@ trait util_methods { impl util_methods of util_methods for TokenReader { fn get() -> Token { - alt copy self.lookahead { + match copy self.lookahead { some(tok) => { self.lookahead = none; copy tok } none => { self.stream.recv() } } @@ -48,7 +48,7 @@ trait parser_methods { impl parser_methods of parser_methods for TokenReader { fn parse_element() -> option<~style::Selector> { // Get the current element type - let elmt_name = alt self.get() { + let elmt_name = match self.get() { Element(tag) => { copy tag } Eof => { return none; } _ => { fail ~"Expected an element" } @@ -59,7 +59,7 @@ impl parser_methods of parser_methods for TokenReader { // Get the attributes associated with that element loop { let tok = self.get(); - alt tok { + match tok { Attr(attr) => { push(attr_list, copy attr); } StartDescription | Descendant | Child | Sibling | Comma => { self.unget(tok); @@ -81,7 +81,7 @@ impl parser_methods of parser_methods for TokenReader { loop { let mut cur_sel; - alt self.parse_element() { + match self.parse_element() { some(elmt) => { cur_sel = copy elmt; } none => { return none; } // we hit an eof in the middle of a rule } @@ -90,9 +90,9 @@ impl parser_methods of parser_methods for TokenReader { let tok = self.get(); let built_sel <- cur_sel; - alt tok { + match tok { Descendant => { - alt self.parse_element() { + match self.parse_element() { some(elmt) => { let new_sel = copy elmt; cur_sel <- ~style::Descendant(built_sel, new_sel) @@ -101,7 +101,7 @@ impl parser_methods of parser_methods for TokenReader { } } Child => { - alt self.parse_element() { + match self.parse_element() { some(elmt) => { let new_sel = copy elmt; cur_sel <- ~style::Child(built_sel, new_sel) @@ -110,7 +110,7 @@ impl parser_methods of parser_methods for TokenReader { } } Sibling => { - alt self.parse_element() { + match self.parse_element() { some(elmt) => { let new_sel = copy elmt; cur_sel <- ~style::Sibling(built_sel, new_sel) @@ -138,7 +138,7 @@ impl parser_methods of parser_methods for TokenReader { // check if we should break out of the nesting loop as well // TODO: fix this when rust gets labelled loops let tok = self.get(); - alt tok { + match tok { StartDescription => { break; } Comma => { } _ => { self.unget(tok); } @@ -154,10 +154,10 @@ impl parser_methods of parser_methods for TokenReader { // Get the description to be applied to the selector loop { let tok = self.get(); - alt tok { + match tok { EndDescription => { break; } Description(prop, val) => { - let desc = alt prop { + let desc = match prop { // TODO: have color parsing return an option instead of a real value ~"background-color" => parse_color(val).map(|res| BackgroundColor(res)), ~"color" => parse_color(val).map(|res| TextColor(res)), @@ -180,8 +180,8 @@ impl parser_methods of parser_methods for TokenReader { } fn parse_rule() -> option<~style::Rule> { - // TODO: get rid of copies once alt move works - let sel_list = alt self.parse_selector() { + // TODO: get rid of copies once match move works + let sel_list = match self.parse_selector() { some(list) => { copy list } none => { return none; } }; @@ -189,7 +189,7 @@ impl parser_methods of parser_methods for TokenReader { #debug("sel_list: %?", sel_list); // Get the description to be applied to the selector - let desc_list = alt self.parse_description() { + let desc_list = match self.parse_description() { some(list) => { copy list } none => { return none; } }; @@ -205,7 +205,7 @@ fn build_stylesheet(+stream : pipes::port) -> ~[~style::Rule] { let reader = {stream : stream, mut lookahead : none}; loop { - alt reader.parse_rule() { + match reader.parse_rule() { some(rule) => { push(rule_list, copy rule); } none => { break; } } diff --git a/servo/src/servo/parser/css_lexer.rs b/servo/src/servo/parser/css_lexer.rs index a2a2b15be51f..56b78a5629f6 100644 --- a/servo/src/servo/parser/css_lexer.rs +++ b/servo/src/servo/parser/css_lexer.rs @@ -49,12 +49,12 @@ trait css_methods { impl css_methods of css_methods for CssLexer { fn parse_css() -> Token { let mut ch: u8; - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => ch = c, CoeEof => { return Eof; } } - let token = alt self.parser_state { + let token = match self.parser_state { CssDescription => self.parse_css_description(ch), CssAttribute => self.parse_css_attribute(ch), CssElement => self.parse_css_element(ch), @@ -68,7 +68,7 @@ impl css_methods of css_methods for CssLexer { fn parse_css_relation(c : u8) -> Token { self.parser_state = CssElement; - let token = alt c { + let token = match c { '{' as u8 => { self.parser_state = CssDescription; StartDescription } '>' as u8 => { Child } '+' as u8 => { Sibling } @@ -112,7 +112,7 @@ impl css_methods of css_methods for CssLexer { self.parser_state = CssRelation; self.input_state.eat_whitespace(); - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { ch = c } CoeEof => { fail ~"File ended before description of style" } } @@ -120,13 +120,13 @@ impl css_methods of css_methods for CssLexer { return self.parse_css_relation(ch); } - alt ch { + match ch { '.' as u8 => return Attr(style::Includes(~"class", self.input_state.parse_ident())), '#' as u8 => return Attr(style::Includes(~"id", self.input_state.parse_ident())), '[' as u8 => { let attr_name = self.input_state.parse_ident(); - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { ch = c; } CoeEof => { fail ~"File ended before description finished"; } } @@ -165,7 +165,7 @@ impl css_methods of css_methods for CssLexer { } else if ch.is_whitespace() { self.input_state.eat_whitespace(); - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { ch = c } CoeEof => { fail ~"Reached end of file in CSS description" } } @@ -187,7 +187,7 @@ impl css_methods of css_methods for CssLexer { push(desc_name, ch); } - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { ch = c } CoeEof => { fail ~"Reached end of file in CSS description" } } @@ -198,7 +198,7 @@ impl css_methods of css_methods for CssLexer { // Get the value of the descriptor loop { - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { ch = c } CoeEof => { fail ~"Reached end of file in CSS description" } } diff --git a/servo/src/servo/parser/html_builder.rs b/servo/src/servo/parser/html_builder.rs index d033987d5559..caf302b81676 100644 --- a/servo/src/servo/parser/html_builder.rs +++ b/servo/src/servo/parser/html_builder.rs @@ -32,12 +32,12 @@ enum js_message { fn link_up_attribute(scope: NodeScope, node: Node, -key: ~str, -value: ~str) { // TODO: Implement atoms so that we don't always perform string comparisons. scope.read(node, |node_contents| { - alt *node_contents.kind { + match *node_contents.kind { Element(element) => { element.attrs.push(~Attr(copy key, copy value)); - alt *element.kind { + match *element.kind { HTMLImageElement(img) if key == ~"width" => { - alt int::from_str(value) { + match int::from_str(value) { none => { // Drop on the floor. } @@ -45,7 +45,7 @@ fn link_up_attribute(scope: NodeScope, node: Node, -key: ~str, -value: ~str) { } } HTMLImageElement(img) if key == ~"height" => { - alt int::from_str(value) { + match int::from_str(value) { none => { // Drop on the floor. } @@ -69,7 +69,7 @@ fn link_up_attribute(scope: NodeScope, node: Node, -key: ~str, -value: ~str) { } fn build_element_kind(tag_name: ~str) -> ~ElementKind { - alt tag_name { + match tag_name { ~"div" => ~HTMLDivElement, ~"img" => { ~HTMLImageElement({ mut size: Size2D(geometry::px_to_au(100), @@ -101,11 +101,11 @@ fn css_link_listener(to_parent : comm::chan, from_parent : comm::por let mut result_vec = ~[]; loop { - alt from_parent.recv() { + match from_parent.recv() { File(url) => { let result_port = comm::port(); let result_chan = comm::chan(result_port); - // TODO: change copy to move once we have alt move + // TODO: change copy to move once we have match move let url = copy url; task::spawn(|| { // TODO: change copy to move once we can move into closures @@ -132,11 +132,11 @@ fn js_script_listener(to_parent : comm::chan<~[~[u8]]>, from_parent : comm::port let mut result_vec = ~[]; loop { - alt from_parent.recv() { + match from_parent.recv() { js_file(url) => { let result_port = comm::port(); let result_chan = comm::chan(result_port); - // TODO: change copy to move once we have alt move + // TODO: change copy to move once we have match move let url = copy url; do task::spawn || { let input_port = port(); @@ -145,7 +145,7 @@ fn js_script_listener(to_parent : comm::chan<~[~[u8]]>, from_parent : comm::port let mut buf = ~[]; loop { - alt input_port.recv() { + match input_port.recv() { Payload(data) => { buf += data; } @@ -195,7 +195,7 @@ fn build_dom(scope: NodeScope, stream: comm::port, url: url, loop { let token = stream.recv(); - alt token { + match token { parser::Eof => { break; } parser::StartOpeningTag(tag_name) => { #debug["starting tag %s", tag_name]; @@ -216,11 +216,11 @@ fn build_dom(scope: NodeScope, stream: comm::port, url: url, parser::SelfCloseTag => { //TODO: check for things other than the link tag scope.read(cur_node, |n| { - alt *n.kind { + match *n.kind { Element(elmt) if elmt.tag_name == ~"link" => { - alt elmt.get_attr(~"rel") { + match elmt.get_attr(~"rel") { some(r) if r == ~"stylesheet" => { - alt elmt.get_attr(~"href") { + match elmt.get_attr(~"href") { some(filename) => { #debug["Linking to a css sheet named: %s", filename]; // FIXME: Need to base the new url on the current url @@ -241,9 +241,9 @@ fn build_dom(scope: NodeScope, stream: comm::port, url: url, parser::EndTag(tag_name) => { // TODO: Assert that the closing tag has the right name. scope.read(cur_node, |n| { - alt *n.kind { + match *n.kind { Element(elmt) if elmt.tag_name == ~"script" => { - alt elmt.get_attr(~"src") { + match elmt.get_attr(~"src") { some(filename) => { #debug["Linking to a js script named: %s", filename]; let new_url = make_url(filename, some(copy url)); diff --git a/servo/src/servo/parser/html_lexer.rs b/servo/src/servo/parser/html_lexer.rs index 9eef05e4cc19..c83c1dc5e413 100644 --- a/servo/src/servo/parser/html_lexer.rs +++ b/servo/src/servo/parser/html_lexer.rs @@ -38,11 +38,11 @@ trait html_methods { impl html_methods of html_methods for HtmlLexer { fn parse_html() -> Token { let mut ch: u8; - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { ch = c; } CoeEof => { return Eof; } } - let token = alt self.parser_state { + let token = match self.parser_state { NormalHtml => { self.parse_in_normal_state(ch) } TagHtml => { self.parse_in_tag_state(ch) } }; @@ -54,7 +54,7 @@ impl html_methods of html_methods for HtmlLexer { fn parse_in_normal_state(c: u8) -> Token { let mut ch = c; if ch == ('<' as u8) { - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { ch = c; } CoeEof => { self.input_state.parse_err(~"eof after '<'") } } @@ -88,7 +88,7 @@ impl html_methods of html_methods for HtmlLexer { // Make a text node. let mut s: ~[u8] = ~[ch]; loop { - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { if c == ('<' as u8) { self.input_state.unget(c); @@ -110,7 +110,7 @@ impl html_methods of html_methods for HtmlLexer { } if ch == ('/' as u8) { - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { if c == ('>' as u8) { self.parser_state = NormalHtml; @@ -132,7 +132,7 @@ impl html_methods of html_methods for HtmlLexer { // Parse an attribute. let mut attribute_name = ~[ch]; loop { - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { if c == ('=' as u8) { break; } push(attribute_name, c); @@ -148,7 +148,7 @@ impl html_methods of html_methods for HtmlLexer { self.input_state.expect('"' as u8); let mut attribute_value = ~[]; loop { - alt self.input_state.get() { + match self.input_state.get() { CoeChar(c) => { if c == ('"' as u8) { break; } push(attribute_value, c); diff --git a/servo/src/servo/parser/lexer_util.rs b/servo/src/servo/parser/lexer_util.rs index ce8cbab0854d..62880a550687 100644 --- a/servo/src/servo/parser/lexer_util.rs +++ b/servo/src/servo/parser/lexer_util.rs @@ -46,7 +46,7 @@ trait util_methods { impl util_methods of util_methods for InputState { fn get() -> CharOrEof { - alt copy self.lookahead { + match copy self.lookahead { some(coe) => { let rv = coe; self.lookahead = none; @@ -67,9 +67,9 @@ impl util_methods of util_methods for InputState { return CoeEof; } - alt self.input_port.recv() { + match self.input_port.recv() { Payload(data) => { - // TODO: change copy to move once we have alt move + // TODO: change copy to move once we have match move self.buffer = copy data; return CoeChar(vec::shift(self.buffer)); } @@ -90,7 +90,7 @@ impl util_methods of util_methods for InputState { } fn expect(ch: u8) { - alt self.get() { + match self.get() { CoeChar(c) => { if c != ch { self.parse_err(#fmt("expected '%c'", ch as char)); } } CoeEof => { self.parse_err(#fmt("expected '%c' at eof", ch as char)); } } @@ -99,7 +99,7 @@ impl util_methods of util_methods for InputState { fn parse_ident() -> ~str { let mut result: ~[u8] = ~[]; loop { - alt self.get() { + match self.get() { CoeChar(c) => { if (c.is_alpha()) { push(result, c); } else if result.len() == 0u { self.parse_err(~"expected ident"); } @@ -125,7 +125,7 @@ impl util_methods of util_methods for InputState { fn eat_whitespace() { loop { - alt self.get() { + match self.get() { CoeChar(c) => { if !c.is_whitespace() { self.unget(c); diff --git a/servo/src/servo/parser/parser_util.rs b/servo/src/servo/parser/parser_util.rs index 2cfc2e328b55..e68132beb6bc 100644 --- a/servo/src/servo/parser/parser_util.rs +++ b/servo/src/servo/parser/parser_util.rs @@ -10,7 +10,7 @@ export parse_size; export parse_display_type; fn parse_unit(str : ~str) -> option { - alt str { + match str { s if s.ends_with(~"%") => from_str(str.substr(0, str.len() - 1)).map(|f| Percent(f)), s if s.ends_with(~"in") => from_str(str.substr(0, str.len() - 2)).map(|f| In(f)), s if s.ends_with(~"cm") => from_str(str.substr(0, str.len() - 2)).map(|f| Cm(f)), @@ -28,7 +28,7 @@ fn parse_font_size(str : ~str) -> option { // The default pixel size, not sure if this is accurate. let default = 16.0; - alt str { + match str { ~"xx-small" => some(Px(0.6*default)), ~"x-small" => some(Px(0.75*default)), ~"small" => some(Px(8.0/9.0*default)), @@ -45,7 +45,7 @@ fn parse_font_size(str : ~str) -> option { // For width / height, and anything else with the same attribute values fn parse_size(str : ~str) -> option { - alt str { + match str { ~"auto" => some(Auto), ~"inherit" => some(Em(1.0)), _ => parse_unit(str), @@ -53,7 +53,7 @@ fn parse_size(str : ~str) -> option { } fn parse_display_type(str : ~str) -> option { - alt str { + match str { ~"inline" => some(DisInline), ~"block" => some(DisBlock), ~"none" => some(DisNone), diff --git a/servo/src/servo/platform/osmain.rs b/servo/src/servo/platform/osmain.rs index 7e2c472b5b56..a03a631c90a1 100644 --- a/servo/src/servo/platform/osmain.rs +++ b/servo/src/servo/platform/osmain.rs @@ -70,7 +70,7 @@ fn mainloop(po: port) { // Handle messages #debug("osmain: peeking"); while po.peek() { - alt po.recv() { + match po.recv() { AddKeyHandler(key_ch) => key_handlers.push(#move(key_ch)), AddEventListener(event_listener) => event_listeners.push(event_listener), BeginDrawing(sender) => lend_surface(*surfaces, sender), @@ -224,7 +224,7 @@ fn destroy_surface(+surface: surface) { #[doc = "A function for spawning into the platform's main thread"] fn on_osmain(+f: fn~(comm::port)) -> comm::chan { - task::task().sched_mode(task::osmain).spawn_listener(f) + task::task().sched_mode(task::platform_thread).spawn_listener(f) } // #[cfg(target_os = "linux")] diff --git a/servo/src/servo/resource/file_loader.rs b/servo/src/servo/resource/file_loader.rs index 3e400bfa70c3..16632a29de68 100644 --- a/servo/src/servo/resource/file_loader.rs +++ b/servo/src/servo/resource/file_loader.rs @@ -13,7 +13,7 @@ fn factory(url: url, progress_chan: chan) { assert url.scheme == ~"file"; do spawn { - alt file_reader(url.path) { + match file_reader(url.path) { ok(reader) => { while !reader.eof() { let data = reader.read_bytes(READ_SIZE); diff --git a/servo/src/servo/resource/http_loader.rs b/servo/src/servo/resource/http_loader.rs index 0dc1c6124478..69da5c9d3a24 100644 --- a/servo/src/servo/resource/http_loader.rs +++ b/servo/src/servo/resource/http_loader.rs @@ -18,7 +18,7 @@ fn factory(url: url, progress_chan: chan) { let errored = @mut false; do request.begin |event| { let url = copy url; - alt event { + match event { http_client::Status(*) => { } http_client::Payload(data) => { #debug("http_loader: got data from %?", url); diff --git a/servo/src/servo/resource/resource_task.rs b/servo/src/servo/resource/resource_task.rs index 17e617086d01..b8748987c3b8 100644 --- a/servo/src/servo/resource/resource_task.rs +++ b/servo/src/servo/resource/resource_task.rs @@ -67,7 +67,7 @@ class ResourceManager { fn start() { loop { - alt self.from_client.recv() { + match self.from_client.recv() { Load(url, progress_chan) => { self.load(url, progress_chan) } @@ -80,7 +80,7 @@ class ResourceManager { fn load(url: url, progress_chan: chan) { - alt self.get_loader_factory(url) { + match self.get_loader_factory(url) { some(loader_factory) => { #debug("resource_task: loading url: %s", url::to_str(url)); loader_factory(url, progress_chan); @@ -115,7 +115,7 @@ fn test_bad_scheme() { let resource_task = ResourceTask(); let progress = port(); resource_task.send(Load(url::from_str(~"bogus://whatever").get(), progress.chan())); - alt check progress.recv() { + match check progress.recv() { Done(result) => { assert result.is_err() } } resource_task.send(Exit); diff --git a/servo/src/servo/servo.rs b/servo/src/servo/servo.rs index 9b13c9ffc21a..acda36e728eb 100644 --- a/servo/src/servo/servo.rs +++ b/servo/src/servo/servo.rs @@ -16,7 +16,7 @@ fn main(args: ~[~str]) { #[allow(non_implicitly_copyable_typarams)] fn run(opts: Opts) { - alt opts.render_mode { + match opts.render_mode { Screen => run_pipeline_screen(opts.urls), Png(outfile) => { assert opts.urls.is_not_empty(); @@ -47,7 +47,7 @@ fn run_pipeline_screen(urls: ~[~str]) { engine_chan.send(LoadURLMsg(url)); #debug["master: Waiting for keypress"]; - alt keypress_from_osmain.try_recv() { + match keypress_from_osmain.try_recv() { some(*) => { } none => { #error("keypress stream closed unexpectedly") } }; @@ -76,7 +76,7 @@ fn run_pipeline_png(-url: ~str, outfile: ~str) { let engine_chan = engine.start(); engine_chan.send(LoadURLMsg(make_url(url, none))); - alt buffered_file_writer(outfile) { + match buffered_file_writer(outfile) { ok(writer) => writer.write(pngdata_from_sink.recv()), err(e) => fail e } diff --git a/servo/src/servo/text/font.rs b/servo/src/servo/text/font.rs index b21eb9fce4cb..9bdd99987ff5 100644 --- a/servo/src/servo/text/font.rs +++ b/servo/src/servo/text/font.rs @@ -101,7 +101,7 @@ class Font { self.cairo_font, unsafe { vec_to_ptr(glyphs) }, 1 as c_int, addr_of(extents)); - alt cairo_scaled_font_status(self.cairo_font) { + match cairo_scaled_font_status(self.cairo_font) { status if status == CAIRO_STATUS_SUCCESS => { #debug("x_advance: %?", extents.x_advance); diff --git a/servo/src/servo/text/shaper.rs b/servo/src/servo/text/shaper.rs index 35ad014eba39..40aa552785a7 100644 --- a/servo/src/servo/text/shaper.rs +++ b/servo/src/servo/text/shaper.rs @@ -111,7 +111,7 @@ extern fn glyph_func(_font: *hb_font_t, let font: *Font = reinterpret_cast(font_data); assert font.is_not_null(); - return alt (*font).glyph_idx(unicode as char) { + return match (*font).glyph_idx(unicode as char) { some(g) => { *glyph = g as hb_codepoint_t; true diff --git a/servo/src/servo/util/color.rs b/servo/src/servo/util/color.rs index 29edea33e6c1..7190152b05a7 100644 --- a/servo/src/servo/util/color.rs +++ b/servo/src/servo/util/color.rs @@ -36,7 +36,7 @@ fn hsla(h : float, s : float, l : float, a : float) -> Color { fn hue_to_rgb(m1 : float, m2 : float, h : float) -> float { let h = if h < 0.0 { h + 1.0 } else if h > 1.0 { h - 1.0 } else { h }; - alt h { + match h { 0.0 to 1.0/6.0 => m1 + (m2 - m1)*h*6.0, 1.0/6.0 to 1.0/2.0 => m2, 1.0/2.0 to 2.0/3.0 => m1 + (m2 - m1)*(4.0 - 6.0*h), @@ -73,7 +73,7 @@ mod parsing { #[doc="Match an exact color keyword."] fn parse_by_name(color : ~str) -> option { - let col = alt color.to_lower() { + let col = match color.to_lower() { ~"black" => black(), ~"silver" => silver(), ~"gray" => gray(), @@ -106,7 +106,7 @@ mod parsing { let cols = only_colors.split_char(','); if cols.len() != 3u { return fail_unrecognized(color); } - alt (u8::from_str(cols[0]), u8::from_str(cols[1]), + match (u8::from_str(cols[0]), u8::from_str(cols[1]), u8::from_str(cols[2])) { (some(r), some(g), some(b)) => { some(rgb(r, g, b)) } _ => { fail_unrecognized(color) } @@ -122,7 +122,7 @@ mod parsing { let cols = only_vals.split_char(','); if cols.len() != 4u { return fail_unrecognized(color); } - alt (u8::from_str(cols[0]), u8::from_str(cols[1]), + match (u8::from_str(cols[0]), u8::from_str(cols[1]), u8::from_str(cols[2]), float::from_str(cols[3])) { (some(r), some(g), some(b), some(a)) => { some(rgba(r, g, b, a)) } _ => { fail_unrecognized(color) } @@ -138,7 +138,7 @@ mod parsing { let vals = only_vals.split_char(','); if vals.len() != 3u { return fail_unrecognized(color); } - alt (float::from_str(vals[0]), float::from_str(vals[1]), + match (float::from_str(vals[0]), float::from_str(vals[1]), float::from_str(vals[2])) { (some(h), some(s), some(l)) => { some(hsl(h, s, l)) } _ => { fail_unrecognized(color) } @@ -153,7 +153,7 @@ mod parsing { let vals = only_vals.split_char(','); if vals.len() != 4u { return fail_unrecognized(color); } - alt (float::from_str(vals[0]), float::from_str(vals[1]), + match (float::from_str(vals[0]), float::from_str(vals[1]), float::from_str(vals[2]), float::from_str(vals[3])) { (some(h), some(s), some(l), some(a)) => { some(hsla(h, s, l, a)) } _ => { fail_unrecognized(color) } @@ -164,7 +164,7 @@ mod parsing { // keywords for several common colors. // TODO: extend this fn parse_color(color : ~str) -> option { - alt color { + match color { c if c.starts_with(~"rgb(") => parse_rgb(c), c if c.starts_with(~"rgba(") => parse_rgba(c), c if c.starts_with(~"hsl(") => parse_hsl(c), diff --git a/servo/src/servo/util/tree.rs b/servo/src/servo/util/tree.rs index c970c61f6eeb..bb77d63f58a8 100644 --- a/servo/src/servo/util/tree.rs +++ b/servo/src/servo/util/tree.rs @@ -21,7 +21,7 @@ trait WriteMethods { fn each_child>(ops: O, node: T, f: fn(T) -> bool) { let mut p = ops.with_tree_fields(node, |f| f.first_child); loop { - alt copy p { + match copy p { none => { return; } some(c) => { if !f(c) { return; } @@ -42,7 +42,7 @@ fn empty() -> Tree { fn add_child>(ops: O, parent: T, child: T) { ops.with_tree_fields(child, |child_tf| { - alt child_tf.parent { + match child_tf.parent { some(_) => { fail ~"Already has a parent"; } none => { child_tf.parent = some(parent); } } @@ -51,7 +51,7 @@ fn add_child>(ops: O, parent: T, child: T) { assert child_tf.next_sibling == none; ops.with_tree_fields(parent, |parent_tf| { - alt copy parent_tf.last_child { + match copy parent_tf.last_child { none => { parent_tf.first_child = some(child); }