Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed syntax by changing alt to match

  • Loading branch information...
commit 7e8d0949d092bb6c5fe162861261efae2e5fdc28 1 parent 0b796c4
@mmeyerho mmeyerho authored
Showing with 145 additions and 147 deletions.
  1. +1 −1  src/rust-geom
  2. +1 −1  src/rust-glut
  3. +1 −1  src/rust-http-client
  4. +1 −1  src/rust-layers
  5. +5 −7 src/servo/content.rs
  6. +3 −3 src/servo/dom/bindings/node.rs
  7. +1 −1  src/servo/dom/bindings/utils.rs
  8. +2 −2 src/servo/dom/rcu.rs
  9. +2 −2 src/servo/engine.rs
  10. +1 −1  src/servo/gfx/pngsink.rs
  11. +3 −3 src/servo/gfx/renderer.rs
  12. +1 −1  src/servo/gfx/surface.rs
  13. +2 −2 src/servo/layout/base.rs
  14. +8 −8 src/servo/layout/box_builder.rs
  15. +7 −7 src/servo/layout/display_list_builder.rs
  16. +1 −1  src/servo/layout/layout_task.rs
  17. +3 −3 src/servo/layout/style/apply.rs
  18. +16 −16 src/servo/layout/style/matching.rs
  19. +3 −3 src/servo/layout/style/style.rs
  20. +2 −2 src/servo/layout/text.rs
  21. +2 −2 src/servo/opts.rs
  22. +15 −15 src/servo/parser/css_builder.rs
  23. +9 −9 src/servo/parser/css_lexer.rs
  24. +16 −16 src/servo/parser/html_builder.rs
  25. +7 −7 src/servo/parser/html_lexer.rs
  26. +6 −6 src/servo/parser/lexer_util.rs
  27. +4 −4 src/servo/parser/parser_util.rs
  28. +2 −2 src/servo/platform/osmain.rs
  29. +1 −1  src/servo/resource/file_loader.rs
  30. +1 −1  src/servo/resource/http_loader.rs
  31. +3 −3 src/servo/resource/resource_task.rs
  32. +3 −3 src/servo/servo.rs
  33. +1 −1  src/servo/text/font.rs
  34. +1 −1  src/servo/text/shaper.rs
  35. +7 −7 src/servo/util/color.rs
  36. +3 −3 src/servo/util/tree.rs
2  src/rust-geom
@@ -1 +1 @@
-Subproject commit 15129163057f8f4d4a1a5b34864bbea0b2ef42fb
+Subproject commit 27bde1d49759768eb7c8e0ac328c3286e0f0cdde
2  src/rust-glut
@@ -1 +1 @@
-Subproject commit 377d4a6eecef416c9fc082914c265c2ece765909
+Subproject commit 02886d609541f7bfa6190ec67993a9ad312ea913
2  src/rust-http-client
@@ -1 +1 @@
-Subproject commit b63c020bacba761619d7da85cf112c4fae75b6d5
+Subproject commit a21334a5f021730eee2953586146400af970da46
2  src/rust-layers
@@ -1 +1 @@
-Subproject commit f071d5e2772973580df979a643deaf9745f5a7f7
+Subproject commit 01e236701b76e9da304f34c8f1ddeb1d7b3cb4d1
View
12 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<ControlMsg>;
-
enum ControlMsg {
ParseMsg(url),
ExecuteMsg(url),
@@ -114,14 +112,14 @@ class Content<S:Sink send copy> {
}
fn handle_msg(msg: either<ControlMsg,Event>) -> 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<S:Sink send copy> {
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<S:Sink send copy> {
}
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.
}
View
6 src/servo/dom/bindings/node.rs
@@ -93,7 +93,7 @@ unsafe fn unwrap(obj: *JSObject) -> *rust_box<Node> {
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);
View
2  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
}
View
4 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
}
View
4 src/servo/engine.rs
@@ -41,9 +41,9 @@ class Engine<S:Sink send copy> {
}
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))
View
2  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);
View
6 src/servo/gfx/renderer.rs
@@ -46,7 +46,7 @@ fn Renderer<S: Sink send copy>(sink: S) -> comm::chan<Msg> {
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],
View
2  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
}
}
View
4 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),
View
16 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();
View
14 src/servo/layout/display_list_builder.rs
@@ -72,7 +72,7 @@ fn box_to_display_items(list: dl::display_list, box: @Box, origin: Point2D<au>)
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();
View
2  src/servo/layout/layout_task.rs
@@ -29,7 +29,7 @@ enum Msg {
fn Layout(renderer: Renderer) -> Layout {
do spawn_listener::<Msg>|request| {
loop {
- alt request.recv() {
+ match request.recv() {
PingMsg(ping_channel) => ping_channel.send(content::PongMsg),
ExitMsg => {
#debug("layout: ExitMsg received");
View
6 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");
View
32 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),
View
6 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,
View
4 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;
View
4 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 }
};
View
30 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<Token>) -> ~[~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; }
}
View
18 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" }
}
View
32 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<Stylesheet>, 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<Token>, 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<Token>, 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<Token>, 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));
View
14 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);
View
12 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);
View
8 src/servo/parser/parser_util.rs
@@ -10,7 +10,7 @@ export parse_size;
export parse_display_type;
fn parse_unit(str : ~str) -> option<Unit> {
- 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<Unit> {
// 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<Unit> {
// For width / height, and anything else with the same attribute values
fn parse_size(str : ~str) -> option<Unit> {
- 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<Unit> {
}
fn parse_display_type(str : ~str) -> option<DisplayType> {
- alt str {
+ match str {
~"inline" => some(DisInline),
~"block" => some(DisBlock),
~"none" => some(DisNone),
View
4 src/servo/platform/osmain.rs
@@ -70,7 +70,7 @@ fn mainloop(po: port<Msg>) {
// 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<T: send>(+f: fn~(comm::port<T>)) -> comm::chan<T> {
- task::task().sched_mode(task::osmain).spawn_listener(f)
+ task::task().sched_mode(task::platform_thread).spawn_listener(f)
}
// #[cfg(target_os = "linux")]
View
2  src/servo/resource/file_loader.rs
@@ -13,7 +13,7 @@ fn factory(url: url, progress_chan: chan<ProgressMsg>) {
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);
View
2  src/servo/resource/http_loader.rs
@@ -18,7 +18,7 @@ fn factory(url: url, progress_chan: chan<ProgressMsg>) {
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);
View
6 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<ProgressMsg>) {
- 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);
View
6 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
}
View
2  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);
View
2  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
View
14 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<Color> {
- 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<Color> {
- 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),
View
6 src/servo/util/tree.rs
@@ -21,7 +21,7 @@ trait WriteMethods<T> {
fn each_child<T:copy,O:ReadMethods<T>>(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<T>() -> Tree<T> {
fn add_child<T:copy,O:WriteMethods<T>>(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<T:copy,O:WriteMethods<T>>(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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.