Fixed all strings in the old format

This commit is contained in:
Margaret Meyerhofer 2012-07-17 17:00:48 -07:00
parent c25cb50d9d
commit 6148309ce1
36 changed files with 238 additions and 238 deletions

@ -1 +1 @@
Subproject commit 29aafdbc3c5aa7567ee457276f65cb72638ad5c5
Subproject commit 065a91cf8855489a71b06157d19c1e61888af5b7

@ -1 +1 @@
Subproject commit 3adac7fed761eb238df17300b6bba96e06aa3fe9
Subproject commit a090f22aed9143abba074f65b9518a83f4c8d830

@ -1 +1 @@
Subproject commit 37e72fca69a5b9051f81b3d2be6d30efc4939c7e
Subproject commit 899def413d8aab57af49f1ae4204531fb69bfb62

@ -1 +1 @@
Subproject commit f31dd12655523ee96b72da24c8195a76d988b50f
Subproject commit ad076e2738332ac8464856f6a470eaf1e25f03ca

@ -1 +1 @@
Subproject commit fc51299da10833faa6fe322ced5e998139015c76
Subproject commit 678688c3b624761ece89afe45e650158f7ecbc8d

@ -1 +1 @@
Subproject commit 2339847a9b992af83412d31c0b24111a115e26da
Subproject commit 598bd4d5826792ea5420e5ca7267678c17338b71

@ -1 +1 @@
Subproject commit ce58ddadbc61b3c79033db13b3e63ac2946c7588
Subproject commit 0f3d130e46b1314f1c98b99ce91f443805a9efa6

@ -1 +1 @@
Subproject commit 30f1c06c32979da20f6dc82119b4037deba08229
Subproject commit 795ac08b121f343d8dac06a2add917aad0972ac0

View file

@ -15,21 +15,21 @@ enum NodeData = {
enum NodeKind {
Element(ElementData),
Text(str)
Text(~str)
}
class ElementData {
let tag_name: str;
let tag_name: ~str;
let kind: ~ElementKind;
let attrs: dvec<~Attr>;
new(-tag_name: str, -kind: ~ElementKind) {
new(-tag_name: ~str, -kind: ~ElementKind) {
self.tag_name = tag_name;
self.kind = kind;
self.attrs = dvec();
}
fn get_attr(attr_name: str) -> option<str> {
fn get_attr(attr_name: ~str) -> option<~str> {
let mut i = 0u;
while i < self.attrs.len() {
if attr_name == self.attrs[i].name {
@ -43,10 +43,10 @@ class ElementData {
}
class Attr {
let name: str;
let value: str;
let name: ~str;
let value: ~str;
new(-name: str, -value: str) {
new(-name: ~str, -value: ~str) {
self.name = name;
self.value = value;
}

View file

@ -229,7 +229,7 @@ impl WriterMethods<T:copy send,A> for Scope<T,A> {
#[warn(no_non_implicitly_copyable_typarams)]
mod test {
type animal = {name: str, species: species};
type animal = {name: ~str, species: species};
enum species {
chicken(~chicken),
bull(~bull)
@ -244,8 +244,8 @@ mod test {
#[test]
fn handles_get_freed() {
let s: animal_scope = Scope();
s.handle({name:"henrietta", species:chicken(~{mut eggs_per_day:22u})});
s.handle({name:"ferdinand", species:bull(~{mut horns:3u})});
s.handle({name:~"henrietta", species:chicken(~{mut eggs_per_day:22u})});
s.handle({name:~"ferdinand", species:bull(~{mut horns:3u})});
}
fn mutate(a: animal) {
@ -266,10 +266,10 @@ mod test {
fn interspersed_execution() {
let s: animal_scope = Scope();
let henrietta =
s.handle({name:"henrietta",
s.handle({name:~"henrietta",
species:chicken(~{mut eggs_per_day:0u})});
let ferdinand =
s.handle({name:"ferdinand",
s.handle({name:~"ferdinand",
species:bull(~{mut horns:0u})});
let iter1 = 3u;

View file

@ -14,14 +14,14 @@ enum StyleDeclaration{
}
enum Attr{
Exists(str),
Exact(str, str),
Includes(str, str),
StartsWith(str, str)
Exists(~str),
Exact(~str, ~str),
Includes(~str, ~str),
StartsWith(~str, ~str)
}
enum Selector{
Element(str, ~[Attr]),
Element(~str, ~[Attr]),
Child(~Selector, ~Selector),
Descendant(~Selector, ~Selector),
Sibling(~Selector, ~Selector)

View file

@ -41,7 +41,7 @@ fn Renderer<S: Sink send copy>(sink: S) -> chan<Msg> {
let draw_target = draw_target_ch.recv();
#debug("renderer: rendering");
do util::time::time("rendering") {
do util::time::time(~"rendering") {
clear(draw_target);
draw_display_list(draw_target, display_list);
#debug("renderer: returning surface");
@ -79,7 +79,7 @@ fn draw_display_list(draw_target: AzDrawTargetRef, display_list: dl::display_lis
draw_text(draw_target, item, text_run);
}
dl::padding(*) {
fail "should never see padding";
fail ~"should never see padding";
}
}
}

View file

@ -94,9 +94,9 @@ impl BoxTreeWriteMethods of tree::WriteMethods<@Box> for BTree {
impl layout_methods_priv for @Box {
#[doc="Dumps the box tree, for debugging, with indentation."]
fn dump_indent(indent: uint) {
let mut s = "";
let mut s = ~"";
for uint::range(0u, indent) |_i| {
s += " ";
s += ~" ";
}
s += #fmt("%?", self.kind);
@ -137,9 +137,9 @@ impl layout_methods for @Box {
impl PrivateNodeMethods for Node {
#[doc="Dumps the node tree, for debugging, with indentation."]
fn dump_indent(indent: uint) {
let mut s = "";
let mut s = ~"";
for uint::range(0u, indent) |_i| {
s += " ";
s += ~" ";
}
s += #fmt("%?", self.read(|n| copy n.kind ));
@ -201,10 +201,10 @@ mod test {
~HTMLImageElement({mut size: size})
}
let n0 = s.new_node(Element(ElementData("img", mk_img(Size2D(au(10),au(10))))));
let n1 = s.new_node(Element(ElementData("img", mk_img(Size2D(au(10),au(10))))));
let n2 = s.new_node(Element(ElementData("img", mk_img(Size2D(au(10),au(20))))));
let n3 = s.new_node(Element(ElementData("div", ~HTMLDivElement)));
let n0 = s.new_node(Element(ElementData(~"img", mk_img(Size2D(au(10),au(10))))));
let n1 = s.new_node(Element(ElementData(~"img", mk_img(Size2D(au(10),au(10))))));
let n2 = s.new_node(Element(ElementData(~"img", mk_img(Size2D(au(10),au(20))))));
let n3 = s.new_node(Element(ElementData(~"div", ~HTMLDivElement)));
tree::add_child(s, n3, n0);
tree::add_child(s, n3, n1);

View file

@ -118,7 +118,7 @@ fn should_convert_text_boxes_to_solid_color_background_items() {
#[ignore(reason = "crashy")];
let s = Scope();
let n = s.new_node(Text("firecracker"));
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
let subbox = alt check b.kind { TextBox(subbox) { subbox } };
b.reflow_text(px_to_au(800), subbox);
@ -136,7 +136,7 @@ fn should_convert_text_boxes_to_text_items() {
#[ignore(reason = "crashy")];
let s = Scope();
let n = s.new_node(Text("firecracker"));
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
let subbox = alt check b.kind { TextBox(subbox) { subbox } };
b.reflow_text(px_to_au(800), subbox);
@ -153,7 +153,7 @@ fn should_calculate_the_bounds_of_the_text_box_background_color() {
#[ignore];
let s = Scope();
let n = s.new_node(Text("firecracker"));
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
let subbox = alt check b.kind { TextBox(subbox) { subbox } };
b.reflow_text(px_to_au(800), subbox);
@ -172,7 +172,7 @@ fn should_calculate_the_bounds_of_the_text_items() {
#[ignore];
let s = Scope();
let n = s.new_node(Text("firecracker"));
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
let subbox = alt check b.kind { TextBox(subbox) { subbox } };
b.reflow_text(px_to_au(800), subbox);

View file

@ -40,7 +40,7 @@ fn Layout(renderer: Renderer) -> Layout {
#debug("layout: received layout request for:");
node.dump();
do util::time::time("layout") {
do util::time::time(~"layout") {
node.initialize_style_for_subtree();
node.recompute_style_for_subtree(arc(copy styles));

View file

@ -26,7 +26,7 @@ impl ApplyStyleBoxMethods for @Box {
alt element.kind {
~HTMLImageElement(*) {
alt element.get_attr("src") {
alt element.get_attr(~"src") {
some(url) {
// FIXME: Some sort of BASE HREF support!
// FIXME: Parse URLs!

View file

@ -29,7 +29,7 @@ fn attrs_match(attr: Attr, elmt: ElementData) -> bool {
Includes(name, val) {
// Comply with css spec, if the specified attribute is empty
// it cannot match.
if val == "" { ret false; }
if val == ~"" { ret false; }
alt elmt.get_attr(name) {
some(value) { ret value.split_char(' ').contains(val); }
@ -41,11 +41,11 @@ 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(~" ") { ret false; }
// We match on either the exact value or value-foo
if value.len() == val.len() { ret true; }
else { ret value.starts_with(val + "-"); }
else { ret value.starts_with(val + ~"-"); }
}
none {
ret false;
@ -66,7 +66,7 @@ impl priv_matching_methods for Node {
Element(tag, attrs) {
alt self.read(|n| copy *n.kind) {
base::Element(elmt) {
if !(tag == "*" || tag == elmt.tag_name) {
if !(tag == ~"*" || tag == elmt.tag_name) {
ret false;
}
@ -207,8 +207,8 @@ mod test {
import io::println;
#[warn(no_non_implicitly_copyable_typarams)]
fn new_node_from_attr(scope: NodeScope, -name: str, -val: str) -> Node {
let elmt = ElementData("div", ~HTMLDivElement);
fn new_node_from_attr(scope: NodeScope, -name: ~str, -val: ~str) -> Node {
let elmt = ElementData(~"div", ~HTMLDivElement);
let attr = ~Attr(name, val);
elmt.attrs.push(attr);
ret scope.new_node(base::Element(elmt));
@ -217,9 +217,9 @@ mod test {
#[test]
fn test_match_pipe1() {
let scope = NodeScope();
let node = new_node_from_attr(scope, "lang", "en-us");
let node = new_node_from_attr(scope, ~"lang", ~"en-us");
let sel = Element("*", ~[StartsWith("lang", "en")]);
let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]);
assert node.matches_selector(~sel);
}
@ -227,9 +227,9 @@ mod test {
#[test]
fn test_match_pipe2() {
let scope = NodeScope();
let node = new_node_from_attr(scope, "lang", "en");
let node = new_node_from_attr(scope, ~"lang", ~"en");
let sel = Element("*", ~[StartsWith("lang", "en")]);
let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]);
assert node.matches_selector(~sel);
}
@ -237,9 +237,9 @@ mod test {
#[test]
fn test_not_match_pipe() {
let scope = NodeScope();
let node = new_node_from_attr(scope, "lang", "english");
let node = new_node_from_attr(scope, ~"lang", ~"english");
let sel = Element("*", ~[StartsWith("lang", "en")]);
let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]);
assert !node.matches_selector(~sel);
}
@ -247,9 +247,9 @@ mod test {
#[test]
fn test_match_includes() {
let scope = NodeScope();
let node = new_node_from_attr(scope, "mad", "hatter cobler cooper");
let node = new_node_from_attr(scope, ~"mad", ~"hatter cobler cooper");
let sel = Element("div", ~[Includes("mad", "hatter")]);
let sel = Element(~"div", ~[Includes(~"mad", ~"hatter")]);
assert node.matches_selector(~sel);
}
@ -257,10 +257,10 @@ mod test {
#[test]
fn test_match_exists() {
let scope = NodeScope();
let node = new_node_from_attr(scope, "mad", "hatter cobler cooper");
let node = new_node_from_attr(scope, ~"mad", ~"hatter cobler cooper");
let sel1 = Element("div", ~[Exists("mad")]);
let sel2 = Element("div", ~[Exists("hatter")]);
let sel1 = Element(~"div", ~[Exists(~"mad")]);
let sel2 = Element(~"div", ~[Exists(~"hatter")]);
assert node.matches_selector(~sel1);
assert !node.matches_selector(~sel2);
@ -269,10 +269,10 @@ mod test {
#[test]
fn test_match_exact() {
let scope = NodeScope();
let node1 = new_node_from_attr(scope, "mad", "hatter cobler cooper");
let node2 = new_node_from_attr(scope, "mad", "hatter");
let node1 = new_node_from_attr(scope, ~"mad", ~"hatter cobler cooper");
let node2 = new_node_from_attr(scope, ~"mad", ~"hatter");
let sel = Element("div", ~[Exact("mad", "hatter")]);
let sel = Element(~"div", ~[Exact(~"mad", ~"hatter")]);
assert !node1.matches_selector(~copy sel);
assert node2.matches_selector(~sel);
@ -282,12 +282,12 @@ mod test {
fn match_tree() {
let scope = NodeScope();
let root = new_node_from_attr(scope, "class", "blue");
let child1 = new_node_from_attr(scope, "id", "green");
let child2 = new_node_from_attr(scope, "flag", "black");
let gchild = new_node_from_attr(scope, "flag", "grey");
let ggchild = new_node_from_attr(scope, "flag", "white");
let gggchild = new_node_from_attr(scope, "flag", "purple");
let root = new_node_from_attr(scope, ~"class", ~"blue");
let child1 = new_node_from_attr(scope, ~"id", ~"green");
let child2 = new_node_from_attr(scope, ~"flag", ~"black");
let gchild = new_node_from_attr(scope, ~"flag", ~"grey");
let ggchild = new_node_from_attr(scope, ~"flag", ~"white");
let gggchild = new_node_from_attr(scope, ~"flag", ~"purple");
scope.add_child(root, child1);
scope.add_child(root, child2);
@ -295,8 +295,8 @@ mod test {
scope.add_child(gchild, ggchild);
scope.add_child(ggchild, gggchild);
let sel1 = Descendant(~Element("*", ~[Exact("class", "blue")]),
~Element("*", ~[]));
let sel1 = Descendant(~Element(~"*", ~[Exact(~"class", ~"blue")]),
~Element(~"*", ~[]));
assert !root.matches_selector(~copy sel1);
assert child1.matches_selector(~copy sel1);
@ -305,9 +305,9 @@ mod test {
assert ggchild.matches_selector(~copy sel1);
assert gggchild.matches_selector(~sel1);
let sel2 = Descendant(~Child(~Element("*", ~[Exact("class", "blue")]),
~Element("*", ~[])),
~Element("div", ~[Exists("flag")]));
let sel2 = Descendant(~Child(~Element(~"*", ~[Exact(~"class", ~"blue")]),
~Element(~"*", ~[])),
~Element(~"div", ~[Exists(~"flag")]));
assert !root.matches_selector(~copy sel2);
assert !child1.matches_selector(~copy sel2);
@ -316,7 +316,7 @@ mod test {
assert ggchild.matches_selector(~copy sel2);
assert gggchild.matches_selector(~sel2);
let sel3 = Sibling(~Element("*", ~[]), ~Element("*", ~[]));
let sel3 = Sibling(~Element(~"*", ~[]), ~Element(~"*", ~[]));
assert !root.matches_selector(~copy sel3);
assert child1.matches_selector(~copy sel3);
@ -325,9 +325,9 @@ mod test {
assert !ggchild.matches_selector(~copy sel3);
assert !gggchild.matches_selector(~sel3);
let sel4 = Descendant(~Child(~Element("*", ~[Exists("class")]),
~Element("*", ~[])),
~Element("*", ~[]));
let sel4 = Descendant(~Child(~Element(~"*", ~[Exists(~"class")]),
~Element(~"*", ~[])),
~Element(~"*", ~[]));
assert !root.matches_selector(~copy sel4);
assert !child1.matches_selector(~copy sel4);

View file

@ -68,7 +68,7 @@ impl style_methods for Node {
"]
fn get_computed_style() -> computed_style {
if !self.has_aux() {
fail "get_computed_style() called on a node without a style!";
fail ~"get_computed_style() called on a node without a style!";
}
ret copy *self.aux(|x| copy x).computed_style;
}

View file

@ -7,10 +7,10 @@ import servo_text::font_library::FontLibrary;
import base::{Box, TextBox};
class text_box {
let text: str;
let text: ~str;
let mut run: option<TextRun>;
new(-text: str) {
new(-text: ~str) {
self.text = text;
self.run = none;
}
@ -21,7 +21,7 @@ impl text_layout_methods for @Box {
fn reflow_text(_available_width: au, subbox: @text_box) {
alt self.kind {
TextBox(*) { /* ok */ }
_ { fail "expected text box in reflow_text!" }
_ { fail ~"expected text box in reflow_text!" }
};
// FIXME: The font library should not be initialized here
@ -44,7 +44,7 @@ fn should_calculate_the_size_of_the_text_box() {
import gfx::geometry::px_to_au;
let s = Scope();
let n = s.new_node(Text("firecracker"));
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
let subbox = alt check b.kind { TextBox(subbox) { subbox } };

View file

@ -13,7 +13,7 @@ iface channel {
}
iface io_service {
fn new_uri(spec: str) -> uri;
fn new_uri(spec: ~str) -> uri;
fn new_channel(uri: uri) -> channel;
}

View file

@ -1,13 +1,13 @@
export uri, build_uri;
type uri = {
spec: str,
scheme: str,
host: option<str>,
spec: ~str,
scheme: ~str,
host: option<~str>,
port: option<uint>,
path: str
path: ~str
};
fn build_uri(_spec: str) -> uri {
fn build_uri(_spec: ~str) -> uri {
fail
}

View file

@ -6,23 +6,23 @@ from command line arguments.
"];
type Opts = {
urls: ~[str],
urls: ~[~str],
render_mode: RenderMode
};
enum RenderMode {
Screen,
Png(str)
Png(~str)
}
#[warn(no_non_implicitly_copyable_typarams)]
fn from_cmdline_args(args: ~[str]) -> Opts {
fn from_cmdline_args(args: ~[~str]) -> Opts {
import std::getopts;
let args = args.tail();
let opts = ~[
getopts::optopt("o")
getopts::optopt(~"o")
];
let match = alt getopts::getopts(args, opts) {
@ -31,12 +31,12 @@ fn from_cmdline_args(args: ~[str]) -> Opts {
};
let urls = if match.free.is_empty() {
fail "servo asks that you provide 1 or more URLs"
fail ~"servo asks that you provide 1 or more URLs"
} else {
copy match.free
};
let render_mode = alt getopts::opt_maybe_str(match, "o") {
let render_mode = alt getopts::opt_maybe_str(match, ~"o") {
some(output_file) { Png(copy output_file) }
none { Screen }
};

View file

@ -35,7 +35,7 @@ fn parse_element(reader : TokenReader) -> option<~style::Selector> {
let elmt_name = alt reader.get() {
Element(tag) { copy tag }
Eof { ret none; }
_ { fail "Expected an element" }
_ { fail ~"Expected an element" }
};
let mut attr_list = ~[];
@ -50,10 +50,10 @@ fn parse_element(reader : TokenReader) -> option<~style::Selector> {
break;
}
Eof { ret none; }
Element(_) { fail "Unexpected second element without "
+ "relation to first element"; }
EndDescription { fail "Unexpected '}'"; }
Description(_, _) { fail "Unexpected description"; }
Element(_) { fail ~"Unexpected second element without "
+ ~"relation to first element"; }
EndDescription { fail ~"Unexpected '}'"; }
Description(_, _) { fail ~"Unexpected description"; }
}
}
@ -141,28 +141,28 @@ fn parse_rule(reader : TokenReader) -> option<~style::Rule> {
EndDescription { break; }
Description(prop, val) {
alt prop {
"font-size" {
~"font-size" {
// TODO, support more ways to declare a font size than # pt
assert val.ends_with("pt");
assert val.ends_with(~"pt");
let num = val.substr(0u, val.len() - 2u);
alt uint::from_str(num) {
some(n) { push(desc_list, FontSize(n)); }
none { fail "Nonnumber provided as font size"; }
none { fail ~"Nonnumber provided as font size"; }
}
}
"display" {
~"display" {
alt val {
"inline" { push(desc_list, Display(DisInline)); }
"block" { push(desc_list, Display(DisBlock)); }
"none" { push(desc_list, Display(DisNone)); }
~"inline" { push(desc_list, Display(DisInline)); }
~"block" { push(desc_list, Display(DisBlock)); }
~"none" { push(desc_list, Display(DisNone)); }
_ { #debug["Recieved unknown display value '%s'", val]; }
}
}
"color" {
~"color" {
push(desc_list, TextColor(parse_color(val)));
}
"background-color" {
~"background-color" {
push(desc_list, BackgroundColor(parse_color(val)));
}
_ { #debug["Recieved unknown style property '%s'", val]; }

View file

@ -25,9 +25,9 @@ enum Token {
Child,
Sibling,
Comma,
Element(str),
Element(~str),
Attr(style::Attr),
Description(str, str),
Description(~str, ~str),
Eof
}
@ -74,10 +74,10 @@ impl css_methods for CssLexer {
if c == '.' as u8 || c == '#' as u8 {
self.parser_state = CssAttribute;
self.input_state.unget(c);
ret Element("*");
ret Element(~"*");
} else if c == '*' as u8 {
self.parser_state = CssAttribute;
ret Element("*");
ret Element(~"*");
}
self.input_state.unget(c);
@ -99,21 +99,21 @@ impl css_methods for CssLexer {
alt self.input_state.get() {
CoeChar(c) { ch = c }
CoeEof { fail "File ended before description of style" }
CoeEof { fail ~"File ended before description of style" }
}
ret 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 { ret Attr(style::Includes(~"class", self.input_state.parse_ident())); }
'#' as u8 { ret Attr(style::Includes(~"id", self.input_state.parse_ident())); }
'[' as u8 {
let attr_name = self.input_state.parse_ident();
alt self.input_state.get() {
CoeChar(c) { ch = c; }
CoeEof { fail "File ended before description finished"; }
CoeEof { fail ~"File ended before description finished"; }
}
if ch == ']' as u8 {
@ -152,7 +152,7 @@ impl css_methods for CssLexer {
alt self.input_state.get() {
CoeChar(c) { ch = c }
CoeEof { fail "Reached end of file in CSS description" }
CoeEof { fail ~"Reached end of file in CSS description" }
}
}
@ -164,7 +164,7 @@ impl css_methods for CssLexer {
self.input_state.eat_whitespace();
} else if ch == ':' as u8 {
if desc_name.len() == 0u {
fail "Expected descriptor name";
fail ~"Expected descriptor name";
} else {
break;
}
@ -174,7 +174,7 @@ impl css_methods for CssLexer {
alt self.input_state.get() {
CoeChar(c) { ch = c }
CoeEof { fail "Reached end of file in CSS description" }
CoeEof { fail ~"Reached end of file in CSS description" }
}
}
@ -185,21 +185,21 @@ impl css_methods for CssLexer {
loop {
alt self.input_state.get() {
CoeChar(c) { ch = c }
CoeEof { fail "Reached end of file in CSS description" }
CoeEof { fail ~"Reached end of file in CSS description" }
}
if ch.is_whitespace() {
self.input_state.eat_whitespace();
} else if ch == '}' as u8 {
if desc_val.len() == 0u {
fail "Expected descriptor value";
fail ~"Expected descriptor value";
} else {
self.input_state.unget('}' as u8);
break;
}
} else if ch == ';' as u8 {
if desc_val.len() == 0u {
fail "Expected descriptor value";
fail ~"Expected descriptor value";
} else {
break;
}
@ -223,7 +223,7 @@ fn spawn_css_lexer_task(-filename: ~str) -> port<Token> {
let result_chan = chan(result_port);
task::spawn(|| {
assert (copy filename).ends_with(".css");
assert (copy filename).ends_with(~".css");
let file_try = io::read_whole_file(filename);
// Check if the given css file existed, if it does, parse it,

View file

@ -19,14 +19,14 @@ enum css_message {
}
#[warn(no_non_implicitly_copyable_typarams)]
fn link_up_attribute(scope: NodeScope, node: Node, -key: str, -value: str) {
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 {
Element(element) {
element.attrs.push(~Attr(copy key, copy value));
alt *element.kind {
HTMLImageElement(img) if key == "width" {
HTMLImageElement(img) if key == ~"width" {
alt int::from_str(value) {
none {
// Drop on the floor.
@ -34,7 +34,7 @@ fn link_up_attribute(scope: NodeScope, node: Node, -key: str, -value: str) {
some(s) { img.size.width = geometry::px_to_au(s); }
}
}
HTMLImageElement(img) if key == "height" {
HTMLImageElement(img) if key == ~"height" {
alt int::from_str(value) {
none {
// Drop on the floor.
@ -51,22 +51,22 @@ fn link_up_attribute(scope: NodeScope, node: Node, -key: str, -value: str) {
}
Text(*) {
fail "attempt to link up an attribute to a text node"
fail ~"attempt to link up an attribute to a text node"
}
}
})
}
fn build_element_kind(tag_name: str) -> ~ElementKind {
fn build_element_kind(tag_name: ~str) -> ~ElementKind {
alt tag_name {
"div" { ~HTMLDivElement }
"img" {
~"div" { ~HTMLDivElement }
~"img" {
~HTMLImageElement({
mut size: Size2D(geometry::px_to_au(100),
geometry::px_to_au(100))
})
}
"head" { ~HTMLHeadElement }
~"head" { ~HTMLHeadElement }
_ { ~UnknownElement }
}
}
@ -117,7 +117,7 @@ fn css_link_listener(to_parent : chan<Stylesheet>, from_parent : port<css_messag
#[warn(no_non_implicitly_copyable_typarams)]
fn build_dom(scope: NodeScope, stream: port<Token>) -> (Node, port<Stylesheet>) {
// The current reference node.
let mut cur_node = scope.new_node(Element(ElementData("html", ~HTMLDivElement)));
let mut cur_node = scope.new_node(Element(ElementData(~"html", ~HTMLDivElement)));
// We will spawn a separate task to parse any css that is
// encountered, each link to a stylesheet is sent to the waiting
// task. After the html sheet has been fully read, the spawned
@ -153,10 +153,10 @@ fn build_dom(scope: NodeScope, stream: port<Token>) -> (Node, port<Stylesheet>)
//TODO: check for things other than the link tag
scope.read(cur_node, |n| {
alt *n.kind {
Element(elmt) if elmt.tag_name == "link" {
alt elmt.get_attr("rel") {
some(r) if r == "stylesheet" {
alt elmt.get_attr("href") {
Element(elmt) if elmt.tag_name == ~"link" {
alt elmt.get_attr(~"rel") {
some(r) if r == ~"stylesheet" {
alt elmt.get_attr(~"href") {
some(filename) {
#debug["Linking to a css sheet named: %s", filename];
style_chan.send(file(copy filename));

View file

@ -6,12 +6,12 @@ import vec::push;
import lexer_util::*;
enum Token {
StartOpeningTag(str),
StartOpeningTag(~str),
EndOpeningTag,
EndTag(str),
EndTag(~str),
SelfCloseTag,
Text(str),
Attr(str, str),
Text(~str),
Attr(~str, ~str),
Doctype,
Eof
}
@ -47,14 +47,14 @@ impl html_methods for HtmlLexer {
if ch == ('<' as u8) {
alt self.input_state.get() {
CoeChar(c) { ch = c; }
CoeEof { self.input_state.parse_err("eof after '<'") }
CoeEof { self.input_state.parse_err(~"eof after '<'") }
}
if ch == ('!' as u8) {
self.input_state.eat_whitespace();
self.input_state.expect_ident("DOCTYPE");
self.input_state.expect_ident(~"DOCTYPE");
self.input_state.eat_whitespace();
self.input_state.expect_ident("html");
self.input_state.expect_ident(~"html");
self.input_state.eat_whitespace();
self.input_state.expect('>' as u8);
ret Doctype;
@ -169,7 +169,7 @@ fn spawn_html_lexer_task(-filename: ~str) -> port<Token> {
task::spawn(|| {
let filename = copy html_file;
assert (copy filename).ends_with(".html");
assert (copy filename).ends_with(~".html");
let file_data = io::read_whole_file(filename).get();
let reader = io::bytes_reader(file_data);

View file

@ -45,7 +45,7 @@ impl util_methods for InputState {
self.lookahead = some(CoeChar(ch));
}
fn parse_err(err: str) -> ! {
fn parse_err(err: ~str) -> ! {
fail err
}
@ -62,7 +62,7 @@ impl util_methods for InputState {
}
}
fn parse_ident() -> str {
fn parse_ident() -> ~str {
let mut result: ~[u8] = ~[];
loop {
alt self.get() {
@ -70,21 +70,21 @@ impl util_methods for InputState {
if (c.is_alpha()) {
push(result, c);
} else if result.len() == 0u {
self.parse_err("expected ident");
self.parse_err(~"expected ident");
} else {
self.unget(c);
break;
}
}
CoeEof {
self.parse_err("expected ident");
self.parse_err(~"expected ident");
}
}
}
ret str::from_bytes(result);
}
fn expect_ident(expected: str) {
fn expect_ident(expected: ~str) {
let actual = self.parse_ident();
if expected != actual {
self.parse_err(#fmt("expected '%s' but found '%s'", expected, actual));

View file

@ -43,7 +43,7 @@ fn mainloop(po: port<Msg>) {
let surfaces = @surface_set();
let window = glut::create_window("Servo");
let window = glut::create_window(~"Servo");
glut::reshape_window(window, 800, 600);
let context = layers::rendergl::init_render_context();
@ -109,7 +109,7 @@ fn mainloop(po: port<Msg>) {
#debug("osmain: drawing to screen");
do util::time::time("compositing") {
do util::time::time(~"compositing") {
layers::rendergl::render_scene(context, *scene);
}

View file

@ -5,7 +5,7 @@ import osmain::{OSMain, AddKeyHandler};
import opts::{Opts, Screen, Png};
import engine::{Engine, LoadURLMsg};
fn main(args: ~[str]) {
fn main(args: ~[~str]) {
run(opts::from_cmdline_args(args))
}
@ -18,14 +18,14 @@ fn run(opts: Opts) {
Png(outfile) {
assert opts.urls.is_not_empty();
if opts.urls.len() > 1u {
fail "servo asks that you stick to a single URL in PNG output mode"
fail ~"servo asks that you stick to a single URL in PNG output mode"
}
run_pipeline_png(opts.urls.head(), outfile)
}
}
}
fn run_pipeline_screen(urls: ~[str]) {
fn run_pipeline_screen(urls: ~[~str]) {
// The platform event handler thread
let osmain = OSMain();
@ -55,7 +55,7 @@ fn run_pipeline_screen(urls: ~[str]) {
osmain.send(osmain::Exit);
}
fn run_pipeline_png(-url: str, outfile: str) {
fn run_pipeline_png(-url: ~str, outfile: ~str) {
// Use a PNG encoder as the graphics sink
import gfx::pngsink;

View file

@ -116,7 +116,7 @@ class Font {
let status_str = unsafe { from_c_str(status_cstr) };
#error("cairo_scaled_font_glyph_extents status: %s", status_str);
fail "failed to get glyph extents from cairo"
fail ~"failed to get glyph extents from cairo"
}
}
}
@ -162,7 +162,7 @@ fn get_cairo_font(buf: &~[u8]) -> (*cairo_scaled_font_t, fn@()) {
// FIXME: Need negative tests
if cfont.is_null() {
dtor();
fail "unable to create cairo scaled font";
fail ~"unable to create cairo scaled font";
}
dtor = fn@(move dtor) { cairo_scaled_font_destroy(cfont); dtor() };
@ -199,7 +199,7 @@ fn get_cairo_face(buf: &~[u8]) -> (*cairo_font_face_t, fn@()) {
if FT_New_Memory_Face(library, cbuf, (*buf).len() as FT_Long,
0 as FT_Long, addr_of(face)).failed() {
dtor();
fail "unable to create FreeType face";
fail ~"unable to create FreeType face";
}
});
dtor = fn@(move dtor) { FT_Done_Face(face).for_sure(); dtor() };
@ -208,7 +208,7 @@ fn get_cairo_face(buf: &~[u8]) -> (*cairo_font_face_t, fn@()) {
if cface.is_null() {
// FIXME: Need tests for failure case
dtor();
fail "unable to create cairo font face";
fail ~"unable to create cairo font face";
}
dtor = fn@(move dtor) { cairo_font_face_destroy(cface); dtor() };
@ -247,7 +247,7 @@ fn get_cairo_face(buf: &~[u8]) -> (*cairo_font_face_t, fn@()) {
dtor = fn@(move dtor) { CGDataProviderRelease(fontprov); dtor() };
let cgfont = CGFontCreateWithDataProvider(fontprov);
if cgfont.is_null() { fail "could not create quartz font" }
if cgfont.is_null() { fail ~"could not create quartz font" }
dtor = fn@(move dtor) { CGFontRelease(cgfont); dtor() };
let cface = cairo_quartz_font_face_create_for_cgfont(cgfont);

View file

@ -28,7 +28,7 @@ class FreeTypeNativeFont/& {
drop {
assert self.face.is_not_null();
if !FT_Done_Face(self.face).succeeded() {
fail "FT_Done_Face failed";
fail ~"FT_Done_Face failed";
}
}
@ -73,7 +73,7 @@ fn create(lib: FT_Library, buf: &~[u8]) -> result<FreeTypeNativeFont, ()> {
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" }
if !res.succeeded() { fail ~"unable to set font char size" }
ok(FreeTypeNativeFont(face))
} else {
err(())

View file

@ -35,7 +35,7 @@ import harfbuzz::bindgen::{hb_blob_create, hb_blob_destroy,
Calculate the layout metrics associated with a some given text
when rendered in a specific font.
"]
fn shape_text(font: &Font, text: str) -> ~[Glyph] unsafe {
fn shape_text(font: &Font, text: ~str) -> ~[Glyph] unsafe {
#debug("shaping text '%s'", text);
let face_blob = vec::as_buf(*(*font).buf(), |buf| {
@ -146,7 +146,7 @@ fn should_get_glyph_indexes() {
#[ignore(reason = "random failures")];
let font = font::create_test_font();
let glyphs = shape_text(font, "firecracker");
let glyphs = shape_text(font, ~"firecracker");
let idxs = glyphs.map(|glyph| glyph.index);
assert idxs == ~[32u, 8u, 13u, 14u, 10u, 13u, 201u, 10u, 37u, 14u, 13u];
}
@ -156,7 +156,7 @@ fn should_get_glyph_h_advance() {
#[ignore(reason = "random failures")];
let font = font::create_test_font();
let glyphs = shape_text(font, "firecracker");
let glyphs = shape_text(font, ~"firecracker");
let actual = glyphs.map(|g| g.pos.advance.x);
let expected = (~[6, 4, 7, 9, 8, 7, 10, 8, 9, 9, 7]).map(|a| px_to_au(a));
assert expected == actual;

View file

@ -11,7 +11,7 @@ import shaper::shape_text;
class TextRun {
let glyphs: ~[Glyph];
new(font: Font, text: str) {
new(font: Font, text: ~str) {
self.glyphs = shape_text(&font, text);
}
@ -34,7 +34,7 @@ fn should_calculate_the_total_size() {
let flib = FontLibrary();
let font = flib.get_test_font();
let run = TextRun(*font, "firecracker");
let run = TextRun(*font, ~"firecracker");
let expected = Size2D(px_to_au(84), px_to_au(20));
assert run.size() == expected;
}

View file

@ -41,7 +41,7 @@ fn hsla(h : float, s : float, l : float, a : float) -> Color {
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; }
_ { fail "unexpected hue value"; }
_ { fail ~"unexpected hue value"; }
}
}
@ -57,7 +57,7 @@ fn hsl(h : float, s : float, l : float) -> Color {
}
impl methods for Color {
fn print() -> str {
fn print() -> ~str {
#fmt["rgba(%u,%u,%u,%f)", self.red as uint, self.green as uint,
self.blue as uint, self.alpha]
}
@ -68,37 +68,37 @@ mod parsing {
// TODO, fail by ignoring the rule instead of setting the
// color to black
fn fail_unrecognized(col : str) -> Color {
fn fail_unrecognized(col : ~str) -> Color {
#warn["Unrecognized color %s", col];
ret black();
}
#[doc="Match an exact color keyword."]
fn parse_by_name(color : str) -> Color {
fn parse_by_name(color : ~str) -> Color {
alt color.to_lower() {
"black" { black() }
"silver" { silver() }
"gray" { gray() }
"grey" { gray() }
"white" { white() }
"maroon" { maroon() }
"red" { red() }
"purple" { purple() }
"fuchsia" { fuchsia() }
"green" { green() }
"lime" { lime() }
"olive" { olive() }
"yellow" { yellow() }
"navy" { navy() }
"blue" { blue() }
"teal" { teal() }
"aqua" { aqua() }
~"black" { black() }
~"silver" { silver() }
~"gray" { gray() }
~"grey" { gray() }
~"white" { white() }
~"maroon" { maroon() }
~"red" { red() }
~"purple" { purple() }
~"fuchsia" { fuchsia() }
~"green" { green() }
~"lime" { lime() }
~"olive" { olive() }
~"yellow" { yellow() }
~"navy" { navy() }
~"blue" { blue() }
~"teal" { teal() }
~"aqua" { aqua() }
_ { fail_unrecognized(color) }
}
}
#[doc="Parses a color specification in the form rgb(foo,bar,baz)"]
fn parse_rgb(color : str) -> Color {
fn parse_rgb(color : ~str) -> Color {
// Shave off the rgb( and the )
let only_colors = color.substr(4u, color.len() - 5u);
@ -114,7 +114,7 @@ mod parsing {
}
#[doc="Parses a color specification in the form rgba(foo,bar,baz,qux)"]
fn parse_rgba(color : str) -> Color {
fn parse_rgba(color : ~str) -> Color {
// Shave off the rgba( and the )
let only_vals = color.substr(5u, color.len() - 6u);
@ -130,7 +130,7 @@ mod parsing {
}
#[doc="Parses a color specification in the form hsl(foo,bar,baz)"]
fn parse_hsl(color : str) -> Color {
fn parse_hsl(color : ~str) -> Color {
// Shave off the hsl( and the )
let only_vals = color.substr(4u, color.len() - 5u);
@ -146,7 +146,7 @@ mod parsing {
}
#[doc="Parses a color specification in the form hsla(foo,bar,baz,qux)"]
fn parse_hsla(color : str) -> Color {
fn parse_hsla(color : ~str) -> Color {
// Shave off the hsla( and the )
let only_vals = color.substr(5u, color.len() - 6u);
@ -163,12 +163,12 @@ mod parsing {
// Currently colors are supported in rgb(a,b,c) form and also by
// keywords for several common colors.
// TODO: extend this
fn parse_color(color : str) -> Color {
fn parse_color(color : ~str) -> Color {
alt 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) }
c if c.starts_with("hsla(") { parse_hsla(c) }
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) }
c if c.starts_with(~"hsla(") { parse_hsla(c) }
c { parse_by_name(c) }
}
}
@ -181,54 +181,54 @@ mod test {
#[test]
fn test_parse_by_name() {
assert red().eq(parse_color("red"));
assert lime().eq(parse_color("Lime"));
assert blue().eq(parse_color("BLUE"));
assert green().eq(parse_color("GreEN"));
assert white().eq(parse_color("white"));
assert black().eq(parse_color("Black"));
assert gray().eq(parse_color("Gray"));
assert silver().eq(parse_color("SiLvEr"));
assert maroon().eq(parse_color("maroon"));
assert purple().eq(parse_color("PURPLE"));
assert fuchsia().eq(parse_color("FUCHSIA"));
assert olive().eq(parse_color("oLiVe"));
assert yellow().eq(parse_color("yellow"));
assert navy().eq(parse_color("NAVY"));
assert teal().eq(parse_color("Teal"));
assert aqua().eq(parse_color("Aqua"));
assert red().eq(parse_color(~"red"));
assert lime().eq(parse_color(~"Lime"));
assert blue().eq(parse_color(~"BLUE"));
assert green().eq(parse_color(~"GreEN"));
assert white().eq(parse_color(~"white"));
assert black().eq(parse_color(~"Black"));
assert gray().eq(parse_color(~"Gray"));
assert silver().eq(parse_color(~"SiLvEr"));
assert maroon().eq(parse_color(~"maroon"));
assert purple().eq(parse_color(~"PURPLE"));
assert fuchsia().eq(parse_color(~"FUCHSIA"));
assert olive().eq(parse_color(~"oLiVe"));
assert yellow().eq(parse_color(~"yellow"));
assert navy().eq(parse_color(~"NAVY"));
assert teal().eq(parse_color(~"Teal"));
assert aqua().eq(parse_color(~"Aqua"));
}
#[test]
fn test_parsing_rgb() {
assert red().eq(parse_color("rgb(255,0,0)"));
assert red().eq(parse_color("rgba(255,0,0,1.0)"));
assert red().eq(parse_color("rgba(255,0,0,1)"));
assert lime().eq(parse_color("rgba(0,255,0,1.00)"));
assert rgb(1u8,2u8,3u8).eq(parse_color("rgb(1,2,03)"));
assert rgba(15u8,250u8,3u8,0.5).eq(parse_color("rgba(15,250,3,.5)"));
assert rgba(15u8,250u8,3u8,0.5).eq(parse_color("rgba(15,250,3,0.5)"));
assert red().eq(parse_color(~"rgb(255,0,0)"));
assert red().eq(parse_color(~"rgba(255,0,0,1.0)"));
assert red().eq(parse_color(~"rgba(255,0,0,1)"));
assert lime().eq(parse_color(~"rgba(0,255,0,1.00)"));
assert rgb(1u8,2u8,3u8).eq(parse_color(~"rgb(1,2,03)"));
assert rgba(15u8,250u8,3u8,0.5).eq(parse_color(~"rgba(15,250,3,.5)"));
assert rgba(15u8,250u8,3u8,0.5).eq(parse_color(~"rgba(15,250,3,0.5)"));
}
#[test]
fn test_parsing_hsl() {
assert red().eq(parse_color("hsl(0,1,.5)"));
assert lime().eq(parse_color("hsl(120.0,1.0,.5)"));
assert blue().eq(parse_color("hsl(240.0,1.0,.5)"));
assert green().eq(parse_color("hsl(120.0,1.0,.25)"));
assert white().eq(parse_color("hsl(1.0,1.,1.0)"));
assert white().eq(parse_color("hsl(129.0,0.3,1.0)"));
assert black().eq(parse_color("hsl(231.2,0.75,0.0)"));
assert black().eq(parse_color("hsl(11.2,0.0,0.0)"));
assert gray().eq(parse_color("hsl(0.0,0.0,0.5)"));
assert maroon().eq(parse_color("hsl(0.0,1.0,0.25)"));
assert purple().eq(parse_color("hsl(300.0,1.0,0.25)"));
assert fuchsia().eq(parse_color("hsl(300,1.0,0.5)"));
assert olive().eq(parse_color("hsl(60.,1.0,0.25)"));
assert yellow().eq(parse_color("hsl(60.,1.0,0.5)"));
assert navy().eq(parse_color("hsl(240.0,1.0,.25)"));
assert teal().eq(parse_color("hsl(180.0,1.0,.25)"));
assert aqua().eq(parse_color("hsl(180.0,1.0,.5)"));
assert red().eq(parse_color(~"hsl(0,1,.5)"));
assert lime().eq(parse_color(~"hsl(120.0,1.0,.5)"));
assert blue().eq(parse_color(~"hsl(240.0,1.0,.5)"));
assert green().eq(parse_color(~"hsl(120.0,1.0,.25)"));
assert white().eq(parse_color(~"hsl(1.0,1.,1.0)"));
assert white().eq(parse_color(~"hsl(129.0,0.3,1.0)"));
assert black().eq(parse_color(~"hsl(231.2,0.75,0.0)"));
assert black().eq(parse_color(~"hsl(11.2,0.0,0.0)"));
assert gray().eq(parse_color(~"hsl(0.0,0.0,0.5)"));
assert maroon().eq(parse_color(~"hsl(0.0,1.0,0.25)"));
assert purple().eq(parse_color(~"hsl(300.0,1.0,0.25)"));
assert fuchsia().eq(parse_color(~"hsl(300,1.0,0.5)"));
assert olive().eq(parse_color(~"hsl(60.,1.0,0.25)"));
assert yellow().eq(parse_color(~"hsl(60.,1.0,0.5)"));
assert navy().eq(parse_color(~"hsl(240.0,1.0,.25)"));
assert teal().eq(parse_color(~"hsl(180.0,1.0,.25)"));
assert aqua().eq(parse_color(~"hsl(180.0,1.0,.5)"));
}
}

View file

@ -1,7 +1,7 @@
// Timing functions.
import std::time::precise_time_ns;
fn time(msg: str, callback: fn()) {
fn time(msg: ~str, callback: fn()) {
let start_time = precise_time_ns();
callback();
let end_time = precise_time_ns();

View file

@ -43,7 +43,7 @@ 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 {
some(_) { fail "Already has a parent"; }
some(_) { fail ~"Already has a parent"; }
none { child_tf.parent = some(parent); }
}