aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTuncer Ayaz <tuncer.ayaz@gmail.com>2012-08-05 14:42:50 +0200
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2012-08-05 14:42:50 +0200
commitcb855210979971f6f22a0ae187ea0b54d783a08c (patch)
treef78be5373b27676db425940a93edd7a1efe05f37
parent1a713b81bbc370b0d81701e4641063c486cfb7fb (diff)
downloadservo-cb855210979971f6f22a0ae187ea0b54d783a08c.tar.gz
servo-cb855210979971f6f22a0ae187ea0b54d783a08c.zip
Adapt to rust changes
-rw-r--r--src/servo/content.rs12
-rw-r--r--src/servo/dom/base.rs2
-rw-r--r--src/servo/dom/bindings/document.rs10
-rw-r--r--src/servo/dom/bindings/node.rs8
-rw-r--r--src/servo/dom/bindings/utils.rs4
-rw-r--r--src/servo/dom/rcu.rs4
-rw-r--r--src/servo/engine.rs4
-rw-r--r--src/servo/gfx/pngsink.rs2
-rw-r--r--src/servo/layout/base.rs6
-rw-r--r--src/servo/layout/box_builder.rs10
-rw-r--r--src/servo/layout/display_list_builder.rs4
-rw-r--r--src/servo/layout/style/matching.rs56
-rw-r--r--src/servo/layout/style/style.rs2
-rw-r--r--src/servo/layout/traverse.rs6
-rw-r--r--src/servo/parser/css_builder.rs30
-rw-r--r--src/servo/parser/css_lexer.rs50
-rw-r--r--src/servo/parser/html_builder.rs2
-rw-r--r--src/servo/parser/html_lexer.rs42
-rw-r--r--src/servo/parser/lexer_util.rs22
-rw-r--r--src/servo/resource/resource_task.rs6
-rw-r--r--src/servo/text/font.rs22
-rw-r--r--src/servo/text/font_library.rs4
-rw-r--r--src/servo/text/native_font/ft_native_font.rs26
-rw-r--r--src/servo/text/native_font/quartz_native_font.rs2
-rw-r--r--src/servo/text/shaper.rs20
-rw-r--r--src/servo/text/text_run.rs2
-rw-r--r--src/servo/util/color.rs32
-rw-r--r--src/servo/util/tree.rs6
28 files changed, 198 insertions, 198 deletions
diff --git a/src/servo/content.rs b/src/servo/content.rs
index 0a677233f6c..5a2eee9fb55 100644
--- a/src/servo/content.rs
+++ b/src/servo/content.rs
@@ -115,10 +115,10 @@ class Content<S:Sink send copy> {
fn handle_msg(msg: either<ControlMsg,Event>) -> bool {
alt msg {
left(control_msg) {
- ret self.handle_control_msg(control_msg);
+ return self.handle_control_msg(control_msg);
}
right(event) {
- ret self.handle_event(event);
+ return self.handle_event(event);
}
}
}
@@ -157,7 +157,7 @@ class Content<S:Sink send copy> {
});
}
- ret true;
+ return true;
}
ExecuteMsg(url) {
@@ -177,12 +177,12 @@ class Content<S:Sink send copy> {
});
}
}
- ret true;
+ return true;
}
ExitMsg {
self.layout.send(layout_task::ExitMsg);
- ret false;
+ return false;
}
}
}
@@ -215,7 +215,7 @@ class Content<S:Sink send copy> {
self.relayout(*document);
}
}
- ret true;
+ return true;
}
}
}
diff --git a/src/servo/dom/base.rs b/src/servo/dom/base.rs
index 36fe1f8501a..f20129f6a1e 100644
--- a/src/servo/dom/base.rs
+++ b/src/servo/dom/base.rs
@@ -41,7 +41,7 @@ class ElementData {
let mut i = 0u;
while i < self.attrs.len() {
if attr_name == self.attrs[i].name {
- ret some(copy self.attrs[i].value);
+ return some(copy self.attrs[i].value);
}
i += 1u;
}
diff --git a/src/servo/dom/bindings/document.rs b/src/servo/dom/bindings/document.rs
index 8c96fb1a074..469406a54ae 100644
--- a/src/servo/dom/bindings/document.rs
+++ b/src/servo/dom/bindings/document.rs
@@ -27,7 +27,7 @@ enum Element = int;
str::as_c_str("Not enough arguments", |s| {
JS_ReportError(cx, s);
});
- ret 0;
+ return 0;
}
let id;
unsafe {
@@ -40,13 +40,13 @@ enum Element = int;
let elem = (*doc).getElementById(s);
}
//XXX wrap result
- ret 1;
+ return 1;
}
err(_) {
str::as_c_str("???", |s| {
JS_ReportError(cx, s);
});
- ret 0;
+ return 0;
}
}
}*/
@@ -56,13 +56,13 @@ enum Element = int;
let uri = (*unwrap(JS_THIS_OBJECT(cx, vp))).payload.getDocumentURI();
JS_SET_RVAL(cx, vp, domstring_to_jsval(cx, uri));
}
- ret 1;
+ return 1;
}*/
extern fn getDocumentElement(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval) -> JSBool unsafe {
let node = (*unwrap(obj)).payload.root;
*rval = RUST_OBJECT_TO_JSVAL(node::create(cx, node).ptr);
- ret 1;
+ return 1;
}
unsafe fn unwrap(obj: *JSObject) -> *rust_box<Document> {
diff --git a/src/servo/dom/bindings/node.rs b/src/servo/dom/bindings/node.rs
index 7c5d705b329..ce3609ea69c 100644
--- a/src/servo/dom/bindings/node.rs
+++ b/src/servo/dom/bindings/node.rs
@@ -82,7 +82,7 @@ fn create(cx: *JSContext, node: Node) -> jsobj unsafe {
JS_SetReservedSlot(obj.ptr, 0, RUST_PRIVATE_TO_JSVAL(raw_ptr));
}
- ret obj;
+ return obj;
}
unsafe fn unwrap(obj: *JSObject) -> *rust_box<Node> {
@@ -104,7 +104,7 @@ extern fn getFirstChild(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut js
}
});
}
- ret 1;
+ return 1;
}
extern fn getNextSibling(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval) -> JSBool {
@@ -121,7 +121,7 @@ extern fn getNextSibling(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut j
}
});
}
- ret 1;
+ return 1;
}
extern fn getTagName(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval) -> JSBool {
@@ -139,5 +139,5 @@ extern fn getTagName(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval
}
});
}
- ret 1;
+ return 1;
}
diff --git a/src/servo/dom/bindings/utils.rs b/src/servo/dom/bindings/utils.rs
index 00b49f90ee0..a481f60a60d 100644
--- a/src/servo/dom/bindings/utils.rs
+++ b/src/servo/dom/bindings/utils.rs
@@ -37,13 +37,13 @@ fn jsval_to_str(cx: *JSContext, v: jsval) -> result<~str, ()> {
} else {
jsstr = JS_ValueToString(cx, v);
if jsstr.is_null() {
- ret err(());
+ return err(());
}
}
let len = 0;
let chars = JS_GetStringCharsZAndLength(cx, jsstr, ptr::addr_of(len));
- ret if chars.is_null() {
+ return if chars.is_null() {
err(())
} else {
unsafe {
diff --git a/src/servo/dom/rcu.rs b/src/servo/dom/rcu.rs
index 84609a1d8b4..0a11127f4d7 100644
--- a/src/servo/dom/rcu.rs
+++ b/src/servo/dom/rcu.rs
@@ -138,7 +138,7 @@ impl ScopePrivate<T: copy send,A> for Scope<T,A> {
// take glue be tolerant of this.
*n = unsafe{*v};
- ret unsafe::reinterpret_cast(n);
+ return unsafe::reinterpret_cast(n);
}
}
@@ -221,7 +221,7 @@ impl WriterMethods<T:copy send,A> for Scope<T,A> {
(*d).next_dirty = null_handle();
let h = _Handle(d);
push(self.d.free_list, h);
- ret h;
+ return h;
}
}
diff --git a/src/servo/engine.rs b/src/servo/engine.rs
index abb86ecacda..2bf4c1ccb0f 100644
--- a/src/servo/engine.rs
+++ b/src/servo/engine.rs
@@ -48,7 +48,7 @@ class Engine<S:Sink send copy> {
} else {
self.content.send(ParseMsg(url))
}
- ret true;
+ return true;
}
ExitMsg(sender) {
@@ -63,7 +63,7 @@ class Engine<S:Sink send copy> {
self.resource_task.send(resource_task::Exit);
sender.send(());
- ret false;
+ return false;
}
}
}
diff --git a/src/servo/gfx/pngsink.rs b/src/servo/gfx/pngsink.rs
index c717fbb4f09..1dfbc7daf95 100644
--- a/src/servo/gfx/pngsink.rs
+++ b/src/servo/gfx/pngsink.rs
@@ -99,7 +99,7 @@ fn do_draw(sender: pipes::chan<AzDrawTargetRef>,
let data = vec_from_buf(data, len);
data_ch.send(data);
- ret CAIRO_STATUS_SUCCESS;
+ return CAIRO_STATUS_SUCCESS;
}
let closure = addr_of(data_ch);
diff --git a/src/servo/layout/base.rs b/src/servo/layout/base.rs
index e3127b2ab38..795ab8f2622 100644
--- a/src/servo/layout/base.rs
+++ b/src/servo/layout/base.rs
@@ -58,7 +58,7 @@ class Appearance {
self.background_image = some(holder);
}
- ret image;
+ return image;
}
}
@@ -115,7 +115,7 @@ class ImageHolder {
let im_arc = option::unwrap(temp);
self.image = some(clone(&im_arc));
- ret ~im_arc;
+ return ~im_arc;
}
}
@@ -265,7 +265,7 @@ mod test {
push(r, copy root.bounds);
- ret r;
+ return r;
}
#[test]
diff --git a/src/servo/layout/box_builder.rs b/src/servo/layout/box_builder.rs
index f8ea00caed3..1df99eeb449 100644
--- a/src/servo/layout/box_builder.rs
+++ b/src/servo/layout/box_builder.rs
@@ -30,10 +30,10 @@ enum ctxt = {
};
fn create_context(parent_node: Node, parent_box: @Box) -> ctxt {
- ret ctxt({
- parent_node: parent_node,
- parent_box: parent_box,
- mut anon_box: none
+ return ctxt({
+ parent_node: parent_node,
+ parent_box: parent_box,
+ mut anon_box: none
});
}
@@ -194,7 +194,7 @@ impl box_builder_methods of box_builder_methods for Node {
// Nothing to do.
}
}
- ret my_box;
+ return my_box;
}
}
diff --git a/src/servo/layout/display_list_builder.rs b/src/servo/layout/display_list_builder.rs
index 913da09a583..b301ed317a5 100644
--- a/src/servo/layout/display_list_builder.rs
+++ b/src/servo/layout/display_list_builder.rs
@@ -27,7 +27,7 @@ Builds a display list for a box and all its children
fn build_display_list(box : @Box) -> dl::display_list {
let list = dvec();
build_display_list_from_origin(list, box, Point2D(au(0), au(0)));
- ret list;
+ return list;
}
#[doc="
@@ -84,7 +84,7 @@ fn box_to_display_items(list: dl::display_list, box: @Box, origin: Point2D<au>)
item_type: dl::display_item_text(run.get()),
bounds: bounds
}));
- ret;
+ return;
}
_ {
// Fall through
diff --git a/src/servo/layout/style/matching.rs b/src/servo/layout/style/matching.rs
index 6c2b96c3e14..91dcb0920f4 100644
--- a/src/servo/layout/style/matching.rs
+++ b/src/servo/layout/style/matching.rs
@@ -16,24 +16,24 @@ fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
alt attr {
Exists(name) {
alt elmt.get_attr(name) {
- some(_) { ret true; }
- none { ret false; }
+ some(_) { return true; }
+ none { return false; }
}
}
Exact(name, val) {
alt elmt.get_attr(name) {
- some(value) { ret value == val; }
- none { ret false; }
+ some(value) { return value == val; }
+ none { return false; }
}
}
Includes(name, val) {
// Comply with css spec, if the specified attribute is empty
// it cannot match.
- if val == ~"" { ret false; }
+ if val == ~"" { return false; }
alt elmt.get_attr(name) {
- some(value) { ret value.split_char(' ').contains(val); }
- none { ret false; }
+ some(value) { return value.split_char(' ').contains(val); }
+ none { return false; }
}
}
StartsWith(name, val) {
@@ -41,14 +41,14 @@ fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
some(value) {
//check that there is only one attribute value and it
//starts with the perscribed value
- if !value.starts_with(val) || value.contains(~" ") { ret false; }
+ if !value.starts_with(val) || value.contains(~" ") { return false; }
// We match on either the exact value or value-foo
- if value.len() == val.len() { ret true; }
- else { ret value.starts_with(val + ~"-"); }
+ if value.len() == val.len() { return true; }
+ else { return value.starts_with(val + ~"-"); }
}
none {
- ret false;
+ return false;
}
}
}
@@ -67,74 +67,74 @@ impl priv_matching_methods of priv_matching_methods for Node {
"]
fn matches_element(sel: ~Selector) -> bool {
alt *sel {
- Child(_, _) | Descendant(_, _) | Sibling(_, _) { ret false; }
+ Child(_, _) | Descendant(_, _) | Sibling(_, _) { return false; }
Element(tag, attrs) {
alt self.read(|n| copy *n.kind) {
base::Element(elmt) {
if !(tag == ~"*" || tag == elmt.tag_name) {
- ret false;
+ return false;
}
let mut i = 0u;
while i < attrs.len() {
- if !attrs_match(attrs[i], elmt) { ret false; }
+ if !attrs_match(attrs[i], elmt) { return false; }
i += 1u;
}
- ret true;
+ return true;
}
Text(str) { /*fall through, currently unsupported*/ }
}
}
}
- ret false; //If we got this far it was because something was
+ return false; //If we got this far it was because something was
//unsupported.
}
#[doc = "Checks if a generic CSS selector matches a given HTML element"]
fn matches_selector(sel : ~Selector) -> bool {
alt *sel {
- Element(str, atts) { ret self.matches_element(sel); }
+ Element(str, atts) { return self.matches_element(sel); }
Child(sel1, sel2) {
alt self.read(|n| n.tree.parent) {
some(parent) {
- ret self.matches_element(sel2) &&
+ return self.matches_element(sel2) &&
parent.matches_selector(sel1);
}
- none { ret false; }
+ none { return false; }
}
}
Descendant(sel1, sel2) {
if !self.matches_element(sel2) {
- ret false;
+ return false;
}
//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) {
some(parent) { parent }
- none { ret false; }
+ none { return false; }
};
loop {
- if cur_parent.matches_selector(sel1) { ret true; }
+ if cur_parent.matches_selector(sel1) { return true; }
cur_parent = alt cur_parent.read(|n| n.tree.parent) {
some(parent) { parent }
- none { ret false; }
+ none { return false; }
};
}
}
Sibling(sel1, sel2) {
- if !self.matches_element(sel2) { ret false; }
+ 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) {
some(sib) {
let mut cur_sib = sib;
loop {
- if cur_sib.matches_selector(sel1) { ret true; }
+ if cur_sib.matches_selector(sel1) { return true; }
cur_sib = alt cur_sib.read(|n| n.tree.prev_sibling) {
some(sib) { sib }
@@ -150,7 +150,7 @@ impl priv_matching_methods of priv_matching_methods for Node {
some(sib) {
let mut cur_sib = sib;
loop {
- if cur_sib.matches_selector(sel1) { ret true; }
+ if cur_sib.matches_selector(sel1) { return true; }
cur_sib = alt cur_sib.read(|n| n.tree.next_sibling) {
some(sib) { sib }
@@ -161,7 +161,7 @@ impl priv_matching_methods of priv_matching_methods for Node {
none { }
}
- ret false;
+ return false;
}
}
}
@@ -227,7 +227,7 @@ mod test {
let elmt = ElementData(~"div", ~HTMLDivElement);
let attr = ~Attr(name, val);
elmt.attrs.push(attr);
- ret scope.new_node(base::Element(elmt));
+ return scope.new_node(base::Element(elmt));
}
#[test]
diff --git a/src/servo/layout/style/style.rs b/src/servo/layout/style/style.rs
index 49071d7ee11..b962913e8a0 100644
--- a/src/servo/layout/style/style.rs
+++ b/src/servo/layout/style/style.rs
@@ -131,7 +131,7 @@ impl style_methods of style_methods for Node {
if !self.has_aux() {
fail ~"get_computed_style() called on a node without a style!";
}
- ret copy *self.aux(|x| copy x).specified_style;
+ return copy *self.aux(|x| copy x).specified_style;
}
#[doc="
diff --git a/src/servo/layout/traverse.rs b/src/servo/layout/traverse.rs
index 85b5695f16e..e137e257ae1 100644
--- a/src/servo/layout/traverse.rs
+++ b/src/servo/layout/traverse.rs
@@ -22,13 +22,13 @@ type shared_box<T> = {
#[doc="Transform and @ into its underlying representation. The reference count stays constant."]
fn unwrap_box(-b : @Box) -> *shared_box<Box> unsafe {
let new_box : *shared_box<Box> = unsafe::transmute(b);
- ret new_box;
+ return new_box;
}
#[doc="Transform an underlying representation back to an @. The reference count stays constant."]
fn rewrap_box(-b : *shared_box<Box>) -> @Box unsafe {
let new_box : @Box = unsafe::transmute(b);
- ret new_box;
+ return new_box;
}
#[doc="
@@ -89,7 +89,7 @@ fn traverse_helper(-root : @Box, -top_down : fn~(@Box), -bottom_up : fn~(@Box))
#[doc="A noneffectful function to be used if only one pass is required."]
fn nop(box : @Box) {
- ret;
+ return;
}
#[doc="
diff --git a/src/servo/parser/css_builder.rs b/src/servo/parser/css_builder.rs
index c1be1e65d16..94b2b0abbbb 100644
--- a/src/servo/parser/css_builder.rs
+++ b/src/servo/parser/css_builder.rs
@@ -50,7 +50,7 @@ impl parser_methods of parser_methods for TokenReader {
// Get the current element type
let elmt_name = alt self.get() {
Element(tag) { copy tag }
- Eof { ret none; }
+ Eof { return none; }
_ { fail ~"Expected an element" }
};
@@ -65,13 +65,13 @@ impl parser_methods of parser_methods for TokenReader {
self.unget(tok);
break;
}
- Eof { ret none; }
+ Eof { return none; }
Element(_) { fail ~"Unexpected second element without relation to first element"; }
EndDescription { fail ~"Unexpected '}'"; }
Description(_, _) { fail ~"Unexpected description"; }
}
}
- ret some(~style::Element(elmt_name, attr_list));
+ return some(~style::Element(elmt_name, attr_list));
}
fn parse_selector() -> option<~[~Selector]> {
@@ -83,7 +83,7 @@ impl parser_methods of parser_methods for TokenReader {
alt self.parse_element() {
some(elmt) { cur_sel = copy elmt; }
- none { ret none; } // we hit an eof in the middle of a rule
+ none { return none; } // we hit an eof in the middle of a rule
}
loop {
@@ -97,7 +97,7 @@ impl parser_methods of parser_methods for TokenReader {
let new_sel = copy elmt;
cur_sel <- ~style::Descendant(built_sel, new_sel)
}
- none { ret none; }
+ none { return none; }
}
}
Child {
@@ -106,7 +106,7 @@ impl parser_methods of parser_methods for TokenReader {
let new_sel = copy elmt;
cur_sel <- ~style::Child(built_sel, new_sel)
}
- none { ret none; }
+ none { return none; }
}
}
Sibling {
@@ -115,7 +115,7 @@ impl parser_methods of parser_methods for TokenReader {
let new_sel = copy elmt;
cur_sel <- ~style::Sibling(built_sel, new_sel)
}
- none { ret none; }
+ none { return none; }
}
}
StartDescription {
@@ -131,7 +131,7 @@ impl parser_methods of parser_methods for TokenReader {
Attr(_) | EndDescription | Element(_) | Description(_, _) {
fail #fmt["Unexpected token %? in elements", tok];
}
- Eof { ret none; }
+ Eof { return none; }
}
}
@@ -145,7 +145,7 @@ impl parser_methods of parser_methods for TokenReader {
}
}
- ret some(sel_list);
+ return some(sel_list);
}
fn parse_description() -> option<~[StyleDeclaration]> {
@@ -169,20 +169,20 @@ impl parser_methods of parser_methods for TokenReader {
};
desc.map(|res| push(desc_list, res));
}
- Eof { ret none; }
+ Eof { return none; }
StartDescription | Descendant | Child | Sibling | Comma | Element(_) | Attr(_) {
fail #fmt["Unexpected token %? in description", tok];
}
}
}
- ret some(desc_list);
+ return some(desc_list);
}
fn parse_rule() -> option<~style::Rule> {
let sel_list = alt self.parse_selector() {
some(list){ copy list }
- none { ret none; }
+ none { return none; }
};
#debug("sel_list: %?", sel_list);
@@ -190,12 +190,12 @@ impl parser_methods of parser_methods for TokenReader {
// Get the description to be applied to the selector
let desc_list = alt self.parse_description() {
some(list) { copy list }
- none { ret none; }
+ none { return none; }
};
#debug("desc_list: %?", desc_list);
- ret some(~(sel_list, desc_list));
+ return some(~(sel_list, desc_list));
}
}
@@ -210,5 +210,5 @@ fn build_stylesheet(+stream : pipes::port<Token>) -> ~[~style::Rule] {
}
}
- ret rule_list;
+ return rule_list;
}
diff --git a/src/servo/parser/css_lexer.rs b/src/servo/parser/css_lexer.rs
index b6bdcb2a615..145df96afcf 100644
--- a/src/servo/parser/css_lexer.rs
+++ b/src/servo/parser/css_lexer.rs
@@ -51,7 +51,7 @@ impl css_methods of css_methods for CssLexer {
let mut ch: u8;
alt self.input_state.get() {
CoeChar(c) { ch = c; }
- CoeEof { ret Eof; }
+ CoeEof { return Eof; }
}
let token = alt self.parser_state {
@@ -62,7 +62,7 @@ impl css_methods of css_methods for CssLexer {
};
#debug["token=%?", token];
- ret token;
+ return token;
}
fn parse_css_relation(c : u8) -> Token {
@@ -78,7 +78,7 @@ impl css_methods of css_methods for CssLexer {
self.input_state.eat_whitespace();
- ret token;
+ return token;
}
fn parse_css_element(c : u8) -> Token {
@@ -89,10 +89,10 @@ impl css_methods of css_methods for CssLexer {
if c == '.' as u8 || c == '#' as u8 {
self.parser_state = CssAttribute;
self.input_state.unget(c);
- ret Element(~"*");
+ return Element(~"*");
} else if c == '*' as u8 {
self.parser_state = CssAttribute;
- ret Element(~"*");
+ return Element(~"*");
}
self.input_state.unget(c);
@@ -100,7 +100,7 @@ impl css_methods of css_methods for CssLexer {
self.parser_state = CssAttribute;
- ret Element(element);
+ return Element(element);
}
fn parse_css_attribute(c : u8) -> Token {
@@ -117,12 +117,12 @@ impl css_methods of css_methods for CssLexer {
CoeEof { fail ~"File ended before description of style" }
}
- ret self.parse_css_relation(ch);
+ return self.parse_css_relation(ch);
}
alt ch {
- '.' as u8 { ret Attr(style::Includes(~"class", self.input_state.parse_ident())); }
- '#' as u8 { ret Attr(style::Includes(~"id", self.input_state.parse_ident())); }
+ '.' 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();
@@ -132,21 +132,21 @@ impl css_methods of css_methods for CssLexer {
}
if ch == ']' as u8 {
- ret Attr(style::Exists(attr_name));
+ return Attr(style::Exists(attr_name));
} else if ch == '=' as u8 {
let attr_val = self.input_state.parse_ident();
self.input_state.expect(']' as u8);
- ret Attr(style::Exact(attr_name, attr_val));
+ return Attr(style::Exact(attr_name, attr_val));
} else if ch == '~' as u8 {
self.input_state.expect('=' as u8);
let attr_val = self.input_state.parse_ident();
self.input_state.expect(']' as u8);
- ret Attr(style::Includes(attr_name, attr_val));
+ return Attr(style::Includes(attr_name, attr_val));
} else if ch == '|' as u8 {
self.input_state.expect('=' as u8);
let attr_val = self.input_state.parse_ident();
self.input_state.expect(']' as u8);
- ret Attr(style::StartsWith(attr_name, attr_val));
+ return Attr(style::StartsWith(attr_name, attr_val));
}
fail #fmt("Unexpected symbol %c in attribute", ch as char);
@@ -161,7 +161,7 @@ impl css_methods of css_methods for CssLexer {
if ch == '}' as u8 {
self.parser_state = CssElement;
self.input_state.eat_whitespace();
- ret EndDescription;
+ return EndDescription;
} else if ch.is_whitespace() {
self.input_state.eat_whitespace();
@@ -223,19 +223,19 @@ impl css_methods of css_methods for CssLexer {
}
}
- ret Description(from_bytes(desc_name), from_bytes(desc_val));
+ return Description(from_bytes(desc_name), from_bytes(desc_val));
}
}
fn parser(input_port: comm::port<ProgressMsg>, state : ParserState) -> CssLexer {
- ret {
- input_state: {
- mut lookahead: none,
- mut buffer: ~[],
- input_port: input_port,
- mut eof: false
- },
- mut parser_state: state
+ return {
+ input_state: {
+ mut lookahead: none,
+ mut buffer: ~[],
+ input_port: input_port,
+ mut eof: false
+ },
+ mut parser_state: state
};
}
@@ -266,7 +266,7 @@ fn spawn_css_lexer_from_string(-content : ~str) -> pipes::port<Token> {
lex_css_from_bytes(input_port, result_chan);
}
- ret result_port;
+ return result_port;
}
#[warn(no_non_implicitly_copyable_typarams)]
@@ -281,5 +281,5 @@ fn spawn_css_lexer_task(-url: url, resource_task: ResourceTask) -> pipes::port<T
lex_css_from_bytes(input_port, result_chan);
});
- ret result_port;
+ return result_port;
}
diff --git a/src/servo/parser/html_builder.rs b/src/servo/parser/html_builder.rs
index 850a0eb0993..a409db9360f 100644
--- a/src/servo/parser/html_builder.rs
+++ b/src/servo/parser/html_builder.rs
@@ -268,5 +268,5 @@ fn build_dom(scope: NodeScope, stream: comm::port<Token>, url: url,
style_chan.send(Exit);
js_chan.send(js_exit);
- ret (cur_node, style_port, js_port);
+ return (cur_node, style_port, js_port);
}
diff --git a/src/servo/parser/html_lexer.rs b/src/servo/parser/html_lexer.rs
index 911ca60e828..3d9bafa7c33 100644
--- a/src/servo/parser/html_lexer.rs
+++ b/src/servo/parser/html_lexer.rs
@@ -40,7 +40,7 @@ impl html_methods of html_methods for HtmlLexer {
let mut ch: u8;
alt self.input_state.get() {
CoeChar(c) { ch = c; }
- CoeEof { ret Eof; }
+ CoeEof { return Eof; }
}
let token = alt self.parser_state {
NormalHtml { self.parse_in_normal_state(ch) }
@@ -48,7 +48,7 @@ impl html_methods of html_methods for HtmlLexer {
};
#debug["token=%?", token];
- ret token;
+ return token;
}
fn parse_in_normal_state(c: u8) -> Token {
@@ -66,13 +66,13 @@ impl html_methods of html_methods for HtmlLexer {
self.input_state.expect_ident(~"html");
self.input_state.eat_whitespace();
self.input_state.expect('>' as u8);
- ret Doctype;
+ return Doctype;
}
if ch == ('/' as u8) {
let ident = self.input_state.parse_ident();
self.input_state.expect('>' as u8);
- ret EndTag(ident);
+ return EndTag(ident);
}
self.input_state.unget(ch);
@@ -82,7 +82,7 @@ impl html_methods of html_methods for HtmlLexer {
self.input_state.eat_whitespace();
self.parser_state = TagHtml;
- ret StartOpeningTag(ident);
+ return StartOpeningTag(ident);
}
// Make a text node.
@@ -92,11 +92,11 @@ impl html_methods of html_methods for HtmlLexer {
CoeChar(c) {
if c == ('<' as u8) {
self.input_state.unget(c);
- ret Text(from_bytes(s));
+ return Text(from_bytes(s));
}
push(s, c);
}
- CoeEof { ret Text(from_bytes(s)); }
+ CoeEof { return Text(from_bytes(s)); }
}
}
}
@@ -106,7 +106,7 @@ impl html_methods of html_methods for HtmlLexer {
if ch == ('>' as u8) {
self.parser_state = NormalHtml;
- ret EndOpeningTag;
+ return EndOpeningTag;
}
if ch == ('/' as u8) {
@@ -114,7 +114,7 @@ impl html_methods of html_methods for HtmlLexer {
CoeChar(c) {
if c == ('>' as u8) {
self.parser_state = NormalHtml;
- ret SelfCloseTag;
+ return SelfCloseTag;
} else {
#warn["/ not followed by > in a tag"];
}
@@ -139,7 +139,7 @@ impl html_methods of html_methods for HtmlLexer {
}
CoeEof {
let name = from_bytes(attribute_name);
- ret Attr(copy name, name);
+ return Attr(copy name, name);
}
}
}
@@ -154,7 +154,7 @@ impl html_methods of html_methods for HtmlLexer {
push(attribute_value, c);
}
CoeEof {
- ret Attr(from_bytes(attribute_name), from_bytes(attribute_value));
+ return Attr(from_bytes(attribute_name), from_bytes(attribute_value));
}
}
}
@@ -162,19 +162,19 @@ impl html_methods of html_methods for HtmlLexer {
// Eat whitespacpe.
self.input_state.eat_whitespace();
- ret Attr(from_bytes(attribute_name), from_bytes(attribute_value));
+ return Attr(from_bytes(attribute_name), from_bytes(attribute_value));
}
}
fn lexer(+input_port: port<resource_task::ProgressMsg>, state : ParseState) -> HtmlLexer {
- ret {
- input_state: {
- mut lookahead: none,
- mut buffer: ~[],
- input_port: input_port,
- mut eof: false
- },
- mut parser_state: state
+ return {
+ input_state: {
+ mut lookahead: none,
+ mut buffer: ~[],
+ input_port: input_port,
+ mut eof: false
+ },
+ mut parser_state: state
};
}
@@ -197,5 +197,5 @@ fn spawn_html_lexer_task(-url: url, resource_task: ResourceTask) -> port<Token>
}
});
- ret html_port;
+ return html_port;
}
diff --git a/src/servo/parser/lexer_util.rs b/src/servo/parser/lexer_util.rs
index dcd0f0140ea..1f63e246f5d 100644
--- a/src/servo/parser/lexer_util.rs
+++ b/src/servo/parser/lexer_util.rs
@@ -25,12 +25,12 @@ trait u8_methods {
impl u8_methods of u8_methods for u8 {
fn is_whitespace() -> bool {
- ret self == ' ' as u8 || self == '\n' as u8 || self == '\t' as u8;
+ return self == ' ' as u8 || self == '\n' as u8 || self == '\t' as u8;
}
fn is_alpha() -> bool {
- ret (self >= ('A' as u8) && self <= ('Z' as u8)) ||
- (self >= ('a' as u8) && self <= ('z' as u8));
+ return (self >= ('A' as u8) && self <= ('Z' as u8)) ||
+ (self >= ('a' as u8) && self <= ('z' as u8));
}
}
@@ -50,7 +50,7 @@ impl util_methods of util_methods for InputState {
some(coe) {
let rv = coe;
self.lookahead = none;
- ret rv;
+ return rv;
}
none {
/* fall through */
@@ -60,21 +60,21 @@ impl util_methods of util_methods for InputState {
// FIXME: Lots of copies here
if self.buffer.len() > 0 {
- ret CoeChar(vec::shift(self.buffer));
+ return CoeChar(vec::shift(self.buffer));
}
if self.eof {
- ret CoeEof;
+ return CoeEof;
}
alt self.input_port.recv() {
Payload(data) {
self.buffer = data;
- ret CoeChar(vec::shift(self.buffer));
+ return CoeChar(vec::shift(self.buffer));
}
Done(*) {
self.eof = true;
- ret CoeEof;
+ return CoeEof;
}
}
}
@@ -112,7 +112,7 @@ impl util_methods of util_methods for InputState {
}
}
}
- ret str::from_bytes(result);
+ return str::from_bytes(result);
}
fn expect_ident(expected: ~str) {
@@ -128,11 +128,11 @@ impl util_methods of util_methods for InputState {
CoeChar(c) {
if !c.is_whitespace() {
self.unget(c);
- ret;
+ return;
}
}
CoeEof {
- ret;
+ return;
}
}
}
diff --git a/src/servo/resource/resource_task.rs b/src/servo/resource/resource_task.rs
index b9cb8ae0dc8..849a7f1dc77 100644
--- a/src/servo/resource/resource_task.rs
+++ b/src/servo/resource/resource_task.rs
@@ -95,10 +95,10 @@ class ResourceManager {
for self.loaders.each |scheme_loader| {
let (scheme, loader_factory) = scheme_loader;
if scheme == url.scheme {
- ret some(loader_factory);
+ return some(loader_factory);
}
}
- ret none;
+ return none;
}
}
@@ -133,4 +133,4 @@ fn should_delegate_to_scheme_loader() {
assert progress.recv() == Payload(payload);
assert progress.recv() == Done(ok(()));
resource_task.send(Exit);
-} \ No newline at end of file
+}
diff --git a/src/servo/text/font.rs b/src/servo/text/font.rs
index e0304041c93..bd638b9539f 100644
--- a/src/servo/text/font.rs
+++ b/src/servo/text/font.rs
@@ -62,18 +62,18 @@ class Font {
)
});
- ret if status == CAIRO_STATUS_SUCCESS {
+ return if status == CAIRO_STATUS_SUCCESS {
- // This might not be true, but at least we'll know if it isn't
- assert num_glyphs == 1 as c_int;
+ // This might not be true, but at least we'll know if it isn't
+ assert num_glyphs == 1 as c_int;
- let glyph_index = unsafe { *glyphs }.index as GlyphIndex;
- #debug("glyph index is %?", glyph_index);
- cairo_glyph_free(glyphs);
- some(glyph_index)
+ let glyph_index = unsafe { *glyphs }.index as GlyphIndex;
+ #debug("glyph index is %?", glyph_index);
+ cairo_glyph_free(glyphs);
+ some(glyph_index)
} else {
- #error("cairo did not give me a glyph for %u", codepoint as uint);
- none
+ #error("cairo did not give me a glyph for %u", codepoint as uint);
+ none
}
}
@@ -107,7 +107,7 @@ class Font {
#debug("x_advance: %?", extents.x_advance);
#debug("y_advance: %?", extents.y_advance);
- ret extents.x_advance as int;
+ return extents.x_advance as int;
}
status {
import str::unsafe::from_c_str;
@@ -266,7 +266,7 @@ fn create_test_font() -> @Font {
import font_library::FontLibrary;
let flib = FontLibrary();
- ret flib.get_test_font();
+ return flib.get_test_font();
}
fn test_font_bin() -> ~[u8] { #include_bin("JosefinSans-SemiBold.ttf") }
diff --git a/src/servo/text/font_library.rs b/src/servo/text/font_library.rs
index c4dabdfdf1f..a67024fd0f7 100644
--- a/src/servo/text/font_library.rs
+++ b/src/servo/text/font_library.rs
@@ -9,7 +9,7 @@ class FontLibrary {
fn get_font() -> @Font {
let f = Font(font::test_font_bin());
- ret @f;
+ return @f;
}
fn get_test_font() -> @Font {
@@ -21,4 +21,4 @@ class FontLibrary {
fn should_get_fonts() {
let lib = FontLibrary();
lib.get_font();
-} \ No newline at end of file
+}
diff --git a/src/servo/text/native_font/ft_native_font.rs b/src/servo/text/native_font/ft_native_font.rs
index a39f84e4313..e51721f7961 100644
--- a/src/servo/text/native_font/ft_native_font.rs
+++ b/src/servo/text/native_font/ft_native_font.rs
@@ -35,7 +35,7 @@ class FreeTypeNativeFont/& {
fn glyph_index(codepoint: char) -> option<GlyphIndex> {
assert self.face.is_not_null();
let idx = FT_Get_Char_Index(self.face, codepoint as FT_ULong);
- ret if idx != 0 as FT_UInt {
+ return if idx != 0 as FT_UInt {
some(idx as GlyphIndex)
} else {
#warn("Invalid codepoint: %?", codepoint);
@@ -56,11 +56,11 @@ class FreeTypeNativeFont/& {
#debug("h_advance for %? is %?", glyph, advance);
// FIXME: Dividing by 64 converts to pixels, which
// is not the unit we should be using
- ret some((advance / 64) as int);
+ return some((advance / 64) as int);
}
} else {
#warn("Unable to load glyph %?. reason: %?", glyph, res);
- ret none;
+ return none;
}
}
}
@@ -68,16 +68,16 @@ class FreeTypeNativeFont/& {
fn create(lib: FT_Library, buf: &~[u8]) -> result<FreeTypeNativeFont, ()> {
assert lib.is_not_null();
let face: FT_Face = null();
- ret vec_as_buf(*buf, |cbuf, len| {
- if FT_New_Memory_Face(lib, cbuf, (*buf).len() as FT_Long,
- 0 as FT_Long, addr_of(face)).succeeded() {
- // FIXME: These values are placeholders
- let res = FT_Set_Char_Size(face, 0, 20*64, 0, 72);
- if !res.succeeded() { fail ~"unable to set font char size" }
- ok(FreeTypeNativeFont(face))
- } else {
- err(())
- }
+ return vec_as_buf(*buf, |cbuf, len| {
+ if FT_New_Memory_Face(lib, cbuf, (*buf).len() as FT_Long,
+ 0 as FT_Long, addr_of(face)).succeeded() {
+ // FIXME: These values are placeholders
+ let res = FT_Set_Char_Size(face, 0, 20*64, 0, 72);
+ if !res.succeeded() { fail ~"unable to set font char size" }
+ ok(FreeTypeNativeFont(face))
+ } else {
+ err(())
+ }
})
}
diff --git a/src/servo/text/native_font/quartz_native_font.rs b/src/servo/text/native_font/quartz_native_font.rs
index a4adf5eb6bb..12a229a18d1 100644
--- a/src/servo/text/native_font/quartz_native_font.rs
+++ b/src/servo/text/native_font/quartz_native_font.rs
@@ -62,7 +62,7 @@ fn create(buf: ~[u8]) -> result<QuartzNativeFont, ()> {
// FIXME: Error handling
assert cgfont.is_not_null();
- ret ok(QuartzNativeFont(fontprov, cgfont));
+ return ok(QuartzNativeFont(fontprov, cgfont));
}
fn with_test_native_font(f: fn@(nf: &NativeFont)) {
diff --git a/src/servo/text/shaper.rs b/src/servo/text/shaper.rs
index 72277b4e9e2..ce4a67e7d7d 100644
--- a/src/servo/text/shaper.rs
+++ b/src/servo/text/shaper.rs
@@ -98,7 +98,7 @@ fn shape_text(font: &Font, text: ~str) -> ~[Glyph] unsafe {
hb_face_destroy(hbface);
hb_blob_destroy(face_blob);
- ret glyphs;
+ return glyphs;
}
extern fn glyph_func(_font: *hb_font_t,
@@ -111,14 +111,14 @@ extern fn glyph_func(_font: *hb_font_t,
let font: *Font = reinterpret_cast(font_data);
assert font.is_not_null();
- ret alt (*font).glyph_idx(unicode as char) {
- some(g) {
- *glyph = g as hb_codepoint_t;
- true
- }
- none {
- false
- }
+ return alt (*font).glyph_idx(unicode as char) {
+ some(g) {
+ *glyph = g as hb_codepoint_t;
+ true
+ }
+ none {
+ false
+ }
} as hb_bool_t;
}
@@ -131,7 +131,7 @@ extern fn glyph_h_advance_func(_font: *hb_font_t,
let h_advance = (*font).glyph_h_advance(glyph as uint);
#debug("h_advance for codepoint %? is %?", glyph, h_advance);
- ret h_advance as hb_position_t;
+ return h_advance as hb_position_t;
}
fn hb_glyph_pos_to_servo_glyph_pos(hb_pos: &hb_glyph_position_t) -> GlyphPos {
diff --git a/src/servo/text/text_run.rs b/src/servo/text/text_run.rs
index 4189954de79..082defa5d6b 100644
--- a/src/servo/text/text_run.rs
+++ b/src/servo/text/text_run.rs
@@ -24,7 +24,7 @@ class TextRun {
Point2D(cur.x.add(glyph.pos.offset.x).add(glyph.pos.advance.x),
cur.y.add(glyph.pos.offset.y).add(glyph.pos.advance.y))
});
- ret Size2D(pen_end.x, pen_end.y);
+ return Size2D(pen_end.x, pen_end.y);
}
}
diff --git a/src/servo/util/color.rs b/src/servo/util/color.rs
index 738de6f672c..0d4244d566c 100644
--- a/src/servo/util/color.rs
+++ b/src/servo/util/color.rs
@@ -13,8 +13,8 @@ enum Color = {red : u8, green : u8, blue : u8, alpha : float};
impl Color of eq for Color {
pure fn eq(&&other: Color) -> bool {
- ret self.red == other.red && self.green == other.green && self.blue == other.blue &&
- self.alpha == other.alpha;
+ return self.red == other.red && self.green == other.green && self.blue == other.blue &&
+ self.alpha == other.alpha;
}
}
@@ -23,7 +23,7 @@ fn rgba(r : u8, g : u8, b : u8, a : float) -> Color {
}
fn rgb(r : u8, g : u8, b : u8) -> Color {
- ret rgba(r, g, b, 1.0);
+ return rgba(r, g, b, 1.0);
}
fn hsla(h : float, s : float, l : float, a : float) -> Color {
@@ -37,10 +37,10 @@ fn hsla(h : float, s : float, l : float, a : float) -> Color {
let h = if h < 0.0 { h + 1.0 } else if h > 1.0 { h - 1.0 } else { h };
alt h {
- 0.0 to 1.0/6.0 { ret m1 + (m2 - m1)*h*6.0; }
- 1.0/6.0 to 1.0/2.0 { ret m2; }
- 1.0/2.0 to 2.0/3.0 { ret m1 + (m2 - m1)*(4.0 - 6.0*h); }
- 2.0/3.0 to 1.0 { ret m1; }
+ 0.0 to 1.0/6.0 { return m1 + (m2 - m1)*h*6.0; }
+ 1.0/6.0 to 1.0/2.0 { return m2; }
+ 1.0/2.0 to 2.0/3.0 { return m1 + (m2 - m1)*(4.0 - 6.0*h); }
+ 2.0/3.0 to 1.0 { return m1; }
_ { fail ~"unexpected hue value"; }
}
}
@@ -49,11 +49,11 @@ fn hsla(h : float, s : float, l : float, a : float) -> Color {
let g = round(255.0*hue_to_rgb(m1, m2, h) as c_double);
let b = round(255.0*hue_to_rgb(m1, m2, h - 1.0/3.0) as c_double);
- ret rgba(r as u8, g as u8, b as u8, a);
+ return rgba(r as u8, g as u8, b as u8, a);
}
fn hsl(h : float, s : float, l : float) -> Color {
- ret hsla(h, s, l, 1.0);
+ return hsla(h, s, l, 1.0);
}
impl methods for Color {
@@ -68,7 +68,7 @@ mod parsing {
fn fail_unrecognized(col : ~str) -> option<Color> {
#warn["Unrecognized color %s", col];
- ret none;
+ return none;
}
#[doc="Match an exact color keyword."]
@@ -91,10 +91,10 @@ mod parsing {
~"blue" { blue() }
~"teal" { teal() }
~"aqua" { aqua() }
- _ { ret fail_unrecognized(color) }
+ _ { return fail_unrecognized(color) }
};
- ret some(col);
+ return some(col);
}
#[doc="Parses a color specification in the form rgb(foo,bar,baz)"]
@@ -104,7 +104,7 @@ mod parsing {
// split up r, g, and b
let cols = only_colors.split_char(',');
- if cols.len() != 3u { ret fail_unrecognized(color); }
+ if cols.len() != 3u { return fail_unrecognized(color); }
alt (u8::from_str(cols[0]), u8::from_str(cols[1]),
u8::from_str(cols[2])) {
@@ -120,7 +120,7 @@ mod parsing {
// split up r, g, and b
let cols = only_vals.split_char(',');
- if cols.len() != 4u { ret fail_unrecognized(color); }
+ if cols.len() != 4u { return fail_unrecognized(color); }
alt (u8::from_str(cols[0]), u8::from_str(cols[1]),
u8::from_str(cols[2]), float::from_str(cols[3])) {
@@ -136,7 +136,7 @@ mod parsing {
// split up h, s, and l
let vals = only_vals.split_char(',');
- if vals.len() != 3u { ret fail_unrecognized(color); }
+ if vals.len() != 3u { return fail_unrecognized(color); }
alt (float::from_str(vals[0]), float::from_str(vals[1]),
float::from_str(vals[2])) {
@@ -151,7 +151,7 @@ mod parsing {
let only_vals = color.substr(5u, color.len() - 6u);
let vals = only_vals.split_char(',');
- if vals.len() != 4u { ret fail_unrecognized(color); }
+ if vals.len() != 4u { return fail_unrecognized(color); }
alt (float::from_str(vals[0]), float::from_str(vals[1]),
float::from_str(vals[2]), float::from_str(vals[3])) {
diff --git a/src/servo/util/tree.rs b/src/servo/util/tree.rs
index f12c298b889..49d3f32b7f3 100644
--- a/src/servo/util/tree.rs
+++ b/src/servo/util/tree.rs
@@ -22,9 +22,9 @@ 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 {
- none { ret; }
+ none { return; }
some(c) {
- if !f(c) { ret; }
+ if !f(c) { return; }
p = ops.with_tree_fields(c, |f| f.next_sibling);
}
}
@@ -109,7 +109,7 @@ mod test {
add_child(dtree, p, c);
}
- ret {p: p, children: children};
+ return {p: p, children: children};
}
#[test]