diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2012-10-04 11:02:53 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2012-10-04 15:28:10 -0700 |
commit | 994c47d22b0a3603978d4b6dcb8ffed72e65ac9a (patch) | |
tree | 6939083c1dd3a6cf070a92214573c95cdd1f1833 | |
parent | e105f3b5571f0cbfae3fc6a96938d4d039bb660d (diff) | |
download | servo-994c47d22b0a3603978d4b6dcb8ffed72e65ac9a.tar.gz servo-994c47d22b0a3603978d4b6dcb8ffed72e65ac9a.zip |
Update for language changes; remove pipe protocols.
67 files changed, 428 insertions, 722 deletions
diff --git a/Makefile.in b/Makefile.in index 1542a62d1e4..6a3731d8825 100644 --- a/Makefile.in +++ b/Makefile.in @@ -145,7 +145,7 @@ all: servo package # Servo binaries servo: $(DEPS_servo) - $(CFG_RUSTC) $(RFLAGS_servo) -o $@ $< --bin + $(RUSTC) $(RFLAGS_servo) -o $@ $< --bin # Darwin app packaging diff --git a/mk/check.mk b/mk/check.mk index 5ee706d38db..82acf9fa052 100644 --- a/mk/check.mk +++ b/mk/check.mk @@ -18,13 +18,13 @@ $(eval $(call DEF_SUBMODULE_TEST_RULES,$(submodule)))) # Testing targets servo-test: $(DEPS_servo) - $(CFG_RUSTC) $(RFLAGS_servo) --test -o $@ $< + $(RUSTC) $(RFLAGS_servo) --test -o $@ $< reftest: $(S)src/reftest/reftest.rs servo - $(CFG_RUSTC) $(RFLAGS_servo) -o $@ $< -L . + $(RUSTC) $(RFLAGS_servo) -o $@ $< -L . contenttest: $(S)src/contenttest/contenttest.rs servo - $(CFG_RUSTC) $(RFLAGS_servo) -o $@ $< -L . + $(RUSTC) $(RFLAGS_servo) -o $@ $< -L . .PHONY: check $(DEPS_CHECK) diff --git a/src/rust-azure b/src/rust-azure -Subproject 0b520a6caf17b05d25db0026431873ae3f86a45 +Subproject c201bc1f2c6cb38d7a81647516f3f55892c8d89 diff --git a/src/rust-cocoa b/src/rust-cocoa -Subproject 5019635e3f44851c08716bd44b70229b2d625aa +Subproject 7dff0d5d6dc40e53989f0db94df74be79bda91c diff --git a/src/rust-core-foundation b/src/rust-core-foundation -Subproject 22a7aa74798117d9dcfb4640290b35b0950f063 +Subproject 9733c605bd11dbd2ebbcd45e4629c157bb8cc01 diff --git a/src/rust-geom b/src/rust-geom -Subproject 5dea272fc5f6a9b3812a845d003724d1bcdaf0b +Subproject e56e41dc94e8f8083d484866fcc22d44b7eb2ef diff --git a/src/rust-glut b/src/rust-glut -Subproject a038f14ebb1219fb7ff9808dde98597ed864548 +Subproject 2886e54d6230050ee7a25e590faad969f95a7d1 diff --git a/src/rust-harfbuzz b/src/rust-harfbuzz -Subproject fa1de008eb31d9401dbc3d6232d6fa4e87d54da +Subproject f1670147011cee03a94c751d6d77a30c2330ee4 diff --git a/src/rust-http-client b/src/rust-http-client -Subproject 28857cda6e86d4da58cb0e25206b7def6bd8753 +Subproject 8cab62f8095e7c99b858da256f4f7042d57d971 diff --git a/src/rust-hubbub b/src/rust-hubbub -Subproject b1184364a73b2269b29897466d984aeb5d6e464 +Subproject 546e797384821679fe45f8fe549fc8735ba2461 diff --git a/src/rust-layers b/src/rust-layers -Subproject 9223fe2a99ec5c76dc98a98ca99a10ff3513a84 +Subproject 4d916307330d5b7e5818c87d3aebda175477b9a diff --git a/src/rust-mozjs b/src/rust-mozjs -Subproject a4ef0a56c990d979fa34fed93293c305a03f67c +Subproject 21de9b86992e4a1d60ef82a8611c1fe08aa8164 diff --git a/src/rust-opengles b/src/rust-opengles -Subproject 5a32c07acfc06c24bef948a1ddc60eed09a3792 +Subproject 74a86cbf8616b34b4fce4891fad21a181a25354 diff --git a/src/rust-stb-image b/src/rust-stb-image -Subproject 60b6a4ec1d2bd63b24383fe31865552d7eedada +Subproject 5907c48bf0e77562735b8a2fab286a6e5c33a20 diff --git a/src/servo/content/content_task.rs b/src/servo/content/content_task.rs index d55e1f082e1..1e0bd248a16 100644 --- a/src/servo/content/content_task.rs +++ b/src/servo/content/content_task.rs @@ -18,12 +18,11 @@ use dom::node::{Node, NodeScope, define_bindings}; use dom::event::{Event, ResizeEvent, ReflowEvent}; use dom::window::Window; use gfx::compositor::Compositor; -use html::lexer::spawn_html_lexer_task; use layout::layout_task; use layout_task::{LayoutTask, BuildMsg}; use resource::image_cache_task::ImageCacheTask; -use css::styles::Stylesheet; +use css::values::Stylesheet; use jsrt = js::rust::rt; use js::rust::{cx, methods}; @@ -48,18 +47,18 @@ use js::jsapi::{JSContext, jsval}; use js::jsapi::bindgen::{JS_CallFunctionValue, JS_GetContextPrivate}; use ptr::null; -enum ControlMsg { +pub enum ControlMsg { ParseMsg(Url), ExecuteMsg(Url), Timer(~dom::window::TimerData), ExitMsg } -enum PingMsg { +pub enum PingMsg { PongMsg } -type ContentTask = Chan<ControlMsg>; +pub type ContentTask = Chan<ControlMsg>; fn ContentTask<S: Compositor Send Copy>(layout_task: LayoutTask, +compositor: S, @@ -179,11 +178,11 @@ impl Content { self.window = Some(@window); self.doc_url = Some(copy url); - let compartment = option::expect(self.compartment, ~"TODO error checking"); + let compartment = option::expect(&self.compartment, ~"TODO error checking"); compartment.define_functions(debug_fns); define_bindings(*compartment, - option::get(self.document), - option::get(self.window)); + option::get(&self.document), + option::get(&self.window)); for vec::each(js_scripts) |bytes| { self.cx.evaluate_script(compartment.global_obj, *bytes, ~"???", 1u); @@ -193,17 +192,17 @@ impl Content { } Timer(timerData) => { - let compartment = option::expect(self.compartment, ~"TODO error checking"); + let compartment = option::expect(&self.compartment, ~"TODO error checking"); let thisValue = if timerData.args.len() > 0 { RUST_JSVAL_TO_OBJECT(unsafe { timerData.args.shift() }) } else { compartment.global_obj.ptr }; - let _rval = JSVAL_NULL; + let rval = JSVAL_NULL; //TODO: support extra args. requires passing a *jsval argv JS_CallFunctionValue(self.cx.ptr, thisValue, timerData.funval, - 0, null(), ptr::addr_of(_rval)); - self.relayout(*option::get(self.document), &option::get(self.doc_url)); + 0, null(), ptr::to_unsafe_ptr(&rval)); + self.relayout(*option::get(&self.document), &option::get(&self.doc_url)); return true; } @@ -216,7 +215,7 @@ impl Content { println(fmt!("Error opening %s: %s", url_to_str(copy url), msg)); } Ok(bytes) => { - let compartment = option::expect(self.compartment, ~"TODO error checking"); + let compartment = option::expect(&self.compartment, ~"TODO error checking"); compartment.define_functions(debug_fns); self.cx.evaluate_script(compartment.global_obj, bytes, url.path, 1u); } diff --git a/src/servo/css/lexer.rs b/src/servo/css/lexer.rs index dfe467ec04b..7c949e745c6 100644 --- a/src/servo/css/lexer.rs +++ b/src/servo/css/lexer.rs @@ -23,7 +23,7 @@ type CssLexer = { mut parser_state: ParserState }; -enum Token { +pub enum Token { StartDescription, EndDescription, Descendant, @@ -80,7 +80,7 @@ impl CssLexer : CssLexerMethods { } fn parse_css_element(c : u8) -> Token { - assert is_none(self.input_state.lookahead); + assert is_none(&self.input_state.lookahead); /* Check for special attributes with an implied element, or a wildcard which is not a alphabet character.*/ @@ -182,7 +182,7 @@ impl CssLexer : CssLexerMethods { break; } } else { - push(desc_name, ch); + push(&mut desc_name, ch); } match self.input_state.get() { @@ -217,7 +217,7 @@ impl CssLexer : CssLexerMethods { break; } } else { - push(desc_val, ch); + push(&mut desc_val, ch); } } @@ -267,7 +267,7 @@ fn spawn_css_lexer_from_string(-content : ~str) -> pipes::Port<Token> { } #[allow(non_implicitly_copyable_typarams)] -fn spawn_css_lexer_task(-url: Url, resource_task: ResourceTask) -> pipes::Port<Token> { +pub fn spawn_css_lexer_task(-url: Url, resource_task: ResourceTask) -> pipes::Port<Token> { let (result_chan, result_port) = pipes::stream(); do task::spawn || { diff --git a/src/servo/css/parser.rs b/src/servo/css/parser.rs index b1cad6a7ed8..7643dca9249 100644 --- a/src/servo/css/parser.rs +++ b/src/servo/css/parser.rs @@ -8,7 +8,7 @@ Constructs a list of css style rules from a token stream use css::values::*; // Disambiguate parsed Selector, Rule values from tokens use css = css::values; -use tok = lexer; +use mod tok = lexer; use lexer::Token; use comm::recv; use option::{map, is_none}; @@ -33,7 +33,7 @@ impl TokenReader : TokenReaderMethods { } fn unget(-tok : Token) { - assert is_none(self.lookahead); + assert is_none(&self.lookahead); self.lookahead = Some(tok); } } @@ -60,7 +60,7 @@ impl TokenReader : ParserMethods { loop { let token = self.get(); match token { - tok::Attr(attr) => { push(attr_list, copy attr); } + tok::Attr(attr) => { push(&mut attr_list, copy attr); } tok::StartDescription | tok::Descendant | tok::Child | tok::Sibling | tok::Comma => { self.unget(token); break; @@ -119,12 +119,12 @@ impl TokenReader : ParserMethods { } } tok::StartDescription => { - push(sel_list, built_sel); + push(&mut sel_list, built_sel); self.unget(tok::StartDescription); break; } tok::Comma => { - push(sel_list, built_sel); + push(&mut sel_list, built_sel); self.unget(tok::Comma); break; } @@ -159,8 +159,8 @@ impl TokenReader : ParserMethods { tok::Description(prop, val) => { let desc : Option<StyleDeclaration> = match prop { // TODO: have color parsing return a ParseResult instead of a real value - ~"background-color" => parse_color(val).map(|res| BackgroundColor(Specified(BgColor(res)))), - ~"color" => parse_color(val).map(|res| Color(Specified(TextColor(res)))), + ~"background-color" => parse_color(val).map(|res| BackgroundColor(Specified(BgColor(*res)))), + ~"color" => parse_color(val).map(|res| Color(Specified(TextColor(*res)))), ~"display" => parse_display_type(val).extract(|res| Display(res)), ~"font-size" => parse_font_size(val).extract(|res| FontSize(res)), ~"height" => parse_box_sizing(val).extract(|res| Height(res)), @@ -168,7 +168,7 @@ impl TokenReader : ParserMethods { _ => { #debug["Recieved unknown style property '%s'", val]; None } }; match desc { - Some(d) => push(desc_list, d), + Some(d) => push(&mut desc_list, d), None => { #debug["Couldn't parse value '%s' for property '%s'", val, prop] } } } @@ -204,13 +204,13 @@ impl TokenReader : ParserMethods { } } -fn build_stylesheet(+stream : pipes::Port<Token>) -> ~[~css::Rule] { +pub fn build_stylesheet(+stream : pipes::Port<Token>) -> ~[~css::Rule] { let mut rule_list = ~[]; let reader = {stream : stream, mut lookahead : None}; loop { match reader.parse_rule() { - Some(rule) => { push(rule_list, copy rule); } + Some(rule) => { push(&mut rule_list, copy rule); } None => { break; } } } diff --git a/src/servo/css/parser_util.rs b/src/servo/css/parser_util.rs index 0c680ec9137..fd6f476acb7 100644 --- a/src/servo/css/parser_util.rs +++ b/src/servo/css/parser_util.rs @@ -18,14 +18,14 @@ fn parse_length(str : ~str) -> Option<Length> { const PX_PER_PT: float = 1.0 / 0.75; match str { - s if s.ends_with(~"in") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * 72.0 * f)), - s if s.ends_with(~"cm") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(f / 2.54 * 72.0 * 1.0/0.75)), - s if s.ends_with(~"mm") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(f * 0.1 / 2.54 * 72.0 * 1.0/0.75)), - s if s.ends_with(~"pt") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * f)), - s if s.ends_with(~"pc") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * 12.0 * f)), - s if s.ends_with(~"px") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(f)), - s if s.ends_with(~"em") => from_str(str.substr(0, str.len() - 2)).map(|f| Em(f)), - s if s.ends_with(~"ex") => from_str(str.substr(0, str.len() - 2)).map(|f| Em(0.5*f)), + s if s.ends_with(~"in") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * 72.0 * *f)), + s if s.ends_with(~"cm") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(*f / 2.54 * 72.0 * 1.0/0.75)), + s if s.ends_with(~"mm") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(*f * 0.1 / 2.54 * 72.0 * 1.0/0.75)), + s if s.ends_with(~"pt") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * *f)), + s if s.ends_with(~"pc") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(1.0/0.75 * 12.0 * *f)), + s if s.ends_with(~"px") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(*f)), + s if s.ends_with(~"em") => from_str(str.substr(0, str.len() - 2)).map(|f| Em(*f)), + s if s.ends_with(~"ex") => from_str(str.substr(0, str.len() - 2)).map(|f| Em(0.5 * *f)), _ => None, } } diff --git a/src/servo/css/resolve/apply.rs b/src/servo/css/resolve/apply.rs index 5f741b59955..0a3f198cf92 100644 --- a/src/servo/css/resolve/apply.rs +++ b/src/servo/css/resolve/apply.rs @@ -3,9 +3,10 @@ */ use au = gfx::geometry; +use css::styles::SpecifiedStyle; use dom::node::{Node, NodeTree}; use dom::element::*; -use layout::box::{RenderBox, SpecifiedStyle, RenderBoxTree}; +use layout::box::{RenderBox, RenderBoxTree}; use layout::context::LayoutContext; use layout::traverse_parallel::top_down_traversal; use image::ImageHolder; @@ -126,4 +127,4 @@ impl StyleApplicator { #[cfg(test)] mod test { /* TODO: rewrite once cascade and resolve written. */ -}
\ No newline at end of file +} diff --git a/src/servo/css/resolve/matching.rs b/src/servo/css/resolve/matching.rs index dcf9a9346c5..d1d058cf0c2 100644 --- a/src/servo/css/resolve/matching.rs +++ b/src/servo/css/resolve/matching.rs @@ -31,7 +31,7 @@ fn attrs_match(attr: Attr, elmt: ElementData) -> bool { if val == ~"" { return false; } match elmt.get_attr(name) { - Some(value) => value.split_char(' ').contains(val), + Some(value) => value.split_char(' ').contains(&val), None => false } } diff --git a/src/servo/css/values.rs b/src/servo/css/values.rs index 4f2bf80cfef..89044910348 100644 --- a/src/servo/css/values.rs +++ b/src/servo/css/values.rs @@ -168,21 +168,21 @@ enum StyleDeclaration { Width(CSSValue<BoxSizing>) } -enum Attr{ +pub enum Attr { Exists(~str), Exact(~str, ~str), Includes(~str, ~str), StartsWith(~str, ~str) } -enum Selector{ +pub enum Selector { Element(~str, ~[Attr]), Child(~Selector, ~Selector), Descendant(~Selector, ~Selector), Sibling(~Selector, ~Selector) } -type Rule = (~[~Selector], ~[StyleDeclaration]); +pub type Rule = (~[~Selector], ~[StyleDeclaration]); type Stylesheet = ~[~Rule]; diff --git a/src/servo/dom/bindings/document.rs b/src/servo/dom/bindings/document.rs index 036ad799a43..cf63afafc3a 100644 --- a/src/servo/dom/bindings/document.rs +++ b/src/servo/dom/bindings/document.rs @@ -88,7 +88,7 @@ extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) { } } -fn init(compartment: bare_compartment, doc: @Document) { +pub fn init(compartment: bare_compartment, doc: @Document) { let obj = utils::define_empty_prototype(~"Document", None, compartment); let attrs = @~[ @@ -97,7 +97,7 @@ fn init(compartment: bare_compartment, doc: @Document) { flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, getter: {op: getDocumentElement, info: null()}, setter: {op: null(), info: null()}}]; - vec::push(compartment.global_props, attrs); + vec::push(&mut compartment.global_props, attrs); vec::as_imm_buf(*attrs, |specs, _len| { assert JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs) == 1; }); diff --git a/src/servo/dom/bindings/element.rs b/src/servo/dom/bindings/element.rs index e58d9bc9701..024ede2533c 100644 --- a/src/servo/dom/bindings/element.rs +++ b/src/servo/dom/bindings/element.rs @@ -30,7 +30,7 @@ extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) { } } -fn init(compartment: bare_compartment) { +pub fn init(compartment: bare_compartment) { let obj = utils::define_empty_prototype(~"Element", Some(~"Node"), compartment); let attrs = @~[ {name: compartment.add_name(~"tagName"), @@ -38,7 +38,7 @@ fn init(compartment: bare_compartment) { flags: (JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS) as u8, getter: {op: getTagName, info: null()}, setter: {op: null(), info: null()}}]; - vec::push(compartment.global_props, attrs); + vec::push(&mut compartment.global_props, attrs); vec::as_imm_buf(*attrs, |specs, _len| { JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs); }); @@ -58,7 +58,7 @@ fn init(compartment: bare_compartment) { flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, getter: {op: HTMLImageElement_getWidth, info: null()}, setter: {op: HTMLImageElement_setWidth, info: null()}}]; - vec::push(compartment.global_props, attrs); + vec::push(&mut compartment.global_props, attrs); vec::as_imm_buf(*attrs, |specs, _len| { JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs); }); @@ -147,7 +147,7 @@ extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut jsval) return 1; } -fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe { +pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe { let proto = scope.write(node, |nd| { match nd.kind { ~Element(ed) => { diff --git a/src/servo/dom/bindings/node.rs b/src/servo/dom/bindings/node.rs index 0158ac2a3f8..9f3a0eb86b9 100644 --- a/src/servo/dom/bindings/node.rs +++ b/src/servo/dom/bindings/node.rs @@ -14,7 +14,7 @@ use utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval, use libc::c_uint; use ptr::null; -fn init(compartment: bare_compartment) { +pub fn init(compartment: bare_compartment) { let obj = utils::define_empty_prototype(~"Node", None, compartment); let attrs = @~[ @@ -35,13 +35,13 @@ fn init(compartment: bare_compartment) { flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, getter: {op: getNodeType, info: null()}, setter: {op: null(), info: null()}}]; - vec::push(compartment.global_props, attrs); + vec::push(&mut compartment.global_props, attrs); vec::as_imm_buf(*attrs, |specs, _len| { JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs); }); } -fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe { +pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe { do scope.write(node) |nd| { match nd.kind { ~Element(*) => { diff --git a/src/servo/dom/bindings/utils.rs b/src/servo/dom/bindings/utils.rs index 0ccb7386cd3..43566c83b3e 100644 --- a/src/servo/dom/bindings/utils.rs +++ b/src/servo/dom/bindings/utils.rs @@ -45,7 +45,7 @@ fn jsval_to_str(cx: *JSContext, v: jsval) -> Result<~str, ()> { } let len = 0; - let chars = JS_GetStringCharsZAndLength(cx, jsstr, ptr::addr_of(len)); + let chars = JS_GetStringCharsZAndLength(cx, jsstr, ptr::to_unsafe_ptr(&len)); return if chars.is_null() { Err(()) } else { @@ -70,7 +70,7 @@ unsafe fn domstring_to_jsval(cx: *JSContext, str: DOMString) -> jsval { } } -fn get_compartment(cx: *JSContext) -> *bare_compartment { +pub fn get_compartment(cx: *JSContext) -> *bare_compartment { unsafe { let privptr: *libc::c_void = JS_GetContextPrivate(cx); let compartment: *bare_compartment = cast::reinterpret_cast(&privptr); @@ -94,7 +94,7 @@ extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *jsval, bp: *mut JSB return 1; } -fn prototype_jsclass(name: ~str) -> fn(+bare_compartment) -> JSClass { +pub fn prototype_jsclass(name: ~str) -> fn(+compartment: bare_compartment) -> JSClass { |+compartment: bare_compartment, copy name| { {name: compartment.add_name(name), flags: 0, @@ -122,8 +122,8 @@ fn prototype_jsclass(name: ~str) -> fn(+bare_compartment) -> JSClass { } } -fn instance_jsclass(name: ~str, finalize: *u8) - -> fn(+bare_compartment) -> JSClass { +pub fn instance_jsclass(name: ~str, finalize: *u8) + -> fn(+compartment: bare_compartment) -> JSClass { |+compartment: bare_compartment, copy name| { {name: compartment.add_name(name), flags: JSCLASS_HAS_RESERVED_SLOTS(1), @@ -151,7 +151,7 @@ fn instance_jsclass(name: ~str, finalize: *u8) } } -fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: bare_compartment) +pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: bare_compartment) -> js::rust::jsobj { compartment.register_class(utils::prototype_jsclass(name)); diff --git a/src/servo/dom/bindings/window.rs b/src/servo/dom/bindings/window.rs index 6effce5dd60..128f8126b92 100644 --- a/src/servo/dom/bindings/window.rs +++ b/src/servo/dom/bindings/window.rs @@ -64,7 +64,7 @@ extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) { } } -fn init(compartment: bare_compartment, win: @Window) { +pub fn init(compartment: bare_compartment, win: @Window) { let proto = utils::define_empty_prototype(~"Window", None, compartment); compartment.register_class(utils::instance_jsclass(~"WindowInstance", finalize)); diff --git a/src/servo/dom/node.rs b/src/servo/dom/node.rs index 0569213a611..99468ede6fa 100644 --- a/src/servo/dom/node.rs +++ b/src/servo/dom/node.rs @@ -87,7 +87,7 @@ impl Node : DebugMethods { } } -enum NodeKind { +pub enum NodeKind { Doctype(DoctypeData), Comment(~str), Element(ElementData), diff --git a/src/servo/dom/rcu.rs b/src/servo/dom/rcu.rs index 17abd6bf099..5b4aef7b234 100644 --- a/src/servo/dom/rcu.rs +++ b/src/servo/dom/rcu.rs @@ -53,11 +53,6 @@ use core::libc::types::os::arch::c95::size_t; use ptr::Ptr; use vec::push; -export Handle; -export ReaderMethods; -export WriterMethods; -export Scope; - type ScopeData<T:Send,A> = { mut layout_active: bool, mut free_list: ~[Handle<T,A>], @@ -76,13 +71,13 @@ fn ScopeResource<T:Send,A>(d : ScopeData<T,A>) -> ScopeResource<T,A> { ScopeResource { d: d } } -type Scope<T:Send,A> = @ScopeResource<T,A>; +pub type Scope<T:Send,A> = @ScopeResource<T,A>; type HandleData<T:Send,A> = {mut read_ptr: *T, mut write_ptr: *mut T, mut read_aux: *A, mut next_dirty: Handle<T,A>}; -enum Handle<T:Send,A> { +pub enum Handle<T:Send,A> { _Handle(*HandleData<T,A>) } @@ -118,7 +113,7 @@ impl<T:Send,A> Handle<T,A> { **Warning:** the reader is responsible for keeping this data live! ")] fn set_aux(p: @A) unsafe { - (**self).read_aux = ptr::addr_of(*p); + (**self).read_aux = ptr::to_unsafe_ptr(&*p); } #[doc(str = "access the auxiliary data associated with this handle.")] @@ -159,7 +154,7 @@ fn null_handle<T:Send,A>() -> Handle<T,A> { _Handle(ptr::null()) } -fn Scope<T:Send,A>() -> Scope<T,A> { +pub fn Scope<T:Send,A>() -> Scope<T,A> { @ScopeResource({mut layout_active: false, mut free_list: ~[], mut first_dirty: null_handle()}) @@ -219,12 +214,12 @@ impl<T:Copy Send,A> Scope<T,A> { let d: *HandleData<T,A> = cast::reinterpret_cast( &libc::malloc(sys::size_of::<HandleData<T,A>>() as size_t)); - (*d).read_ptr = self.clone(ptr::addr_of(v)); + (*d).read_ptr = self.clone(ptr::to_unsafe_ptr(&v)); (*d).write_ptr = cast::reinterpret_cast(&(*d).read_ptr); (*d).read_aux = ptr::null(); (*d).next_dirty = null_handle(); let h = _Handle(d); - push(self.d.free_list, h); + push(&mut self.d.free_list, h); return h; } } diff --git a/src/servo/dom/window.rs b/src/servo/dom/window.rs index 6bc74913ad8..4f3fd09e68f 100644 --- a/src/servo/dom/window.rs +++ b/src/servo/dom/window.rs @@ -20,12 +20,12 @@ struct Window { // Holder for the various JS values associated with setTimeout // (ie. function value to invoke and all arguments to pass // to the function when calling it) -struct TimerData { +pub struct TimerData { funval: jsval, args: DVec<jsval>, } -fn TimerData(argc: libc::c_uint, argv: *jsval) -> TimerData unsafe { +pub fn TimerData(argc: libc::c_uint, argv: *jsval) -> TimerData unsafe { let data = TimerData { funval : *argv, args : DVec(), diff --git a/src/servo/engine.rs b/src/servo/engine.rs index bcba7bbbfb3..ace4fdd900b 100644 --- a/src/servo/engine.rs +++ b/src/servo/engine.rs @@ -1,112 +1,87 @@ -export EngineTask, EngineTask_, EngineProto; - use gfx::compositor::Compositor; -use gfx::render_task; -use render_task::RenderTask; -use pipes::{spawn_service, select}; +use mod gfx::render_task; +use gfx::render_task::{Renderer, RenderTask}; +use task::spawn_listener; use layout::layout_task; use layout_task::LayoutTask; -use content::content_task; -use content_task::{ContentTask}; +use mod content::content_task; +use content::content_task::{ContentTask, ExecuteMsg, ParseMsg, ExitMsg}; use resource::resource_task; -use resource::resource_task::{ResourceTask}; +use resource::resource_task::ResourceTask; use std::net::url::Url; use resource::image_cache_task; -use image_cache_task::{ImageCacheTask, ImageCacheTaskClient}; - +use image_cache_task::{ImageCacheTask, image_cache_task, ImageCacheTaskClient}; use pipes::{Port, Chan}; -fn macros() { - include!("macros.rs"); -} - -type EngineTask = EngineProto::client::Running; - -fn EngineTask<C: Compositor Send Copy>(+compositor: C) -> EngineTask { - let resource_task = ResourceTask(); - let image_cache_task = ImageCacheTask(resource_task); - EngineTask_(compositor, resource_task, image_cache_task) -} - -fn EngineTask_<C: Compositor Send Copy>( - +compositor: C, - resource_task: ResourceTask, - image_cache_task: ImageCacheTask -) -> EngineTask { - do spawn_service(EngineProto::init) |request, move compositor| { - - let render_task = RenderTask(compositor); - let layout_task = LayoutTask(render_task, image_cache_task); - let content_task = ContentTask(layout_task, compositor, resource_task, image_cache_task); - - Engine { - compositor: compositor, - render_task: render_task, - resource_task: resource_task, - image_cache_task: image_cache_task, - layout_task: layout_task, - content_task: content_task, - }.run(request); - } -} - - -struct Engine<C:Compositor> { +pub struct Engine<C:Compositor Send Copy> { compositor: C, - render_task: RenderTask, + render_task: Renderer, resource_task: ResourceTask, image_cache_task: ImageCacheTask, layout_task: LayoutTask, - content_task: ContentTask, + content_task: ContentTask } -impl<C: Compositor> Engine<C> { - fn run(+request: EngineProto::server::Running) { - use EngineProto::*; - let mut request = request; - - loop { - select!( - request => { - LoadURL(url) -> next { - // TODO: change copy to move once we have match move - let url = move_ref!(url); - if url.path.ends_with(".js") { - self.content_task.send(content_task::ExecuteMsg(url)) - } else { - self.content_task.send(content_task::ParseMsg(url)) - } - request = next; - }, - - Exit -> channel { - self.content_task.send(content_task::ExitMsg); - self.layout_task.send(layout_task::ExitMsg); - - let (response_chan, response_port) = pipes::stream(); - self.render_task.send(render_task::ExitMsg(response_chan)); - response_port.recv(); - - self.image_cache_task.exit(); - self.resource_task.send(resource_task::Exit); - - server::Exited(channel); - break - } - } - ) - } +pub fn Engine<C:Compositor Send Copy>(compositor: C, + resource_task: ResourceTask, + image_cache_task: ImageCacheTask) -> Engine<C> { + let render_task = RenderTask(compositor); + let layout_task = LayoutTask(render_task, image_cache_task); + let content_task = ContentTask(layout_task, compositor, resource_task, image_cache_task); + + Engine { + compositor: compositor, + render_task: render_task, + resource_task: resource_task, + image_cache_task: image_cache_task, + layout_task: layout_task, + content_task: content_task } } -proto! EngineProto( - Running:send { - LoadURL(Url) -> Running, - Exit -> Exiting +impl<C: Compositor Copy Send> Engine<C> { + fn start() -> comm::Chan<Msg> { + do spawn_listener::<Msg> |request| { + while self.handle_request(request.recv()) { + // Go on... + } + } } - Exiting:recv { - Exited -> ! + fn handle_request(request: Msg) -> bool { + match request { + LoadURLMsg(url) => { + // TODO: change copy to move once we have match move + let url = copy url; + if url.path.ends_with(".js") { + self.content_task.send(ExecuteMsg(url)) + } else { + self.content_task.send(ParseMsg(url)) + } + return true; + } + + ExitMsg(sender) => { + self.content_task.send(content_task::ExitMsg); + self.layout_task.send(layout_task::ExitMsg); + + let (response_chan, response_port) = pipes::stream(); + + self.render_task.send(render_task::ExitMsg(response_chan)); + response_port.recv(); + + self.image_cache_task.exit(); + self.resource_task.send(resource_task::Exit); + + sender.send(()); + return false; + } + } } -) +} + +pub enum Msg { + LoadURLMsg(Url), + ExitMsg(Chan<()>) +} diff --git a/src/servo/gfx/display_list.rs b/src/servo/gfx/display_list.rs index 916fc1d58d9..7a3d14f8743 100644 --- a/src/servo/gfx/display_list.rs +++ b/src/servo/gfx/display_list.rs @@ -29,7 +29,7 @@ A run of glyphs in a single font. This is distinguished from any similar structure used by layout in that this must be sendable, whereas the text shaping data structures may end up unsendable. */ -struct GlyphRun { +pub struct GlyphRun { glyphs: ~[Glyph] } @@ -54,7 +54,7 @@ fn draw_Image(self: &DisplayItem, ctx: &RenderContext) { } } -fn SolidColor(bounds: Rect<au>, r: u8, g: u8, b: u8) -> DisplayItem { +pub fn SolidColor(bounds: Rect<au>, r: u8, g: u8, b: u8) -> DisplayItem { DisplayItem { // TODO: this seems wrong. draw: |self, ctx| draw_SolidColor(self, ctx), @@ -63,7 +63,7 @@ fn SolidColor(bounds: Rect<au>, r: u8, g: u8, b: u8) -> DisplayItem { } } -fn Glyphs(bounds: Rect<au>, run: GlyphRun) -> DisplayItem { +pub fn Glyphs(bounds: Rect<au>, run: GlyphRun) -> DisplayItem { DisplayItem { draw: |self, ctx| draw_Glyphs(self, ctx), bounds: bounds, @@ -72,7 +72,7 @@ fn Glyphs(bounds: Rect<au>, run: GlyphRun) -> DisplayItem { } // ARC should be cloned into ImageData, but Images are not sendable -fn Image(bounds: Rect<au>, image: ARC<~image::base::Image>) -> DisplayItem { +pub fn Image(bounds: Rect<au>, image: ARC<~image::base::Image>) -> DisplayItem { DisplayItem { // TODO: this seems wrong. draw: |self, ctx| draw_Image(self, ctx), @@ -81,7 +81,7 @@ fn Image(bounds: Rect<au>, image: ARC<~image::base::Image>) -> DisplayItem { } } -type DisplayList = DVec<~DisplayItem>; +pub type DisplayList = DVec<~DisplayItem>; trait DisplayListMethods { fn draw(ctx: &RenderContext); diff --git a/src/servo/gfx/geometry.rs b/src/servo/gfx/geometry.rs index b498c236574..63b4389c63b 100644 --- a/src/servo/gfx/geometry.rs +++ b/src/servo/gfx/geometry.rs @@ -3,19 +3,19 @@ use geom::rect::Rect; use geom::size::Size2D; use num::{Num, from_int}; -enum au = i32; +pub enum au = i32; impl au : Num { - pure fn add(&&other: au) -> au { au(*self + *other) } - pure fn sub(&&other: au) -> au { au(*self - *other) } - pure fn mul(&&other: au) -> au { au(*self * *other) } - pure fn div(&&other: au) -> au { au(*self / *other) } - pure fn modulo(&&other: au) -> au { au(*self % *other) } + pure fn add(other: &au) -> au { au(*self + **other) } + pure fn sub(other: &au) -> au { au(*self - **other) } + pure fn mul(other: &au) -> au { au(*self * **other) } + pure fn div(other: &au) -> au { au(*self / **other) } + pure fn modulo(other: &au) -> au { au(*self % **other) } pure fn neg() -> au { au(-*self) } pure fn to_int() -> int { *self as int } - static pure fn from_int(n: int) -> au { + static pure fn from_int(+n: int) -> au { au((n & (i32::max_value as int)) as i32) } } @@ -32,31 +32,31 @@ impl au : cmp::Eq { pure fn ne(other: &au) -> bool { *self != **other } } -pure fn min(x: au, y: au) -> au { if x < y { x } else { y } } -pure fn max(x: au, y: au) -> au { if x > y { x } else { y } } +pub pure fn min(x: au, y: au) -> au { if x < y { x } else { y } } +pub pure fn max(x: au, y: au) -> au { if x > y { x } else { y } } -fn box<A:Copy Num>(x: A, y: A, w: A, h: A) -> Rect<A> { +pub fn box<A:Copy Num>(x: A, y: A, w: A, h: A) -> Rect<A> { Rect(Point2D(x, y), Size2D(w, h)) } -fn zero_rect() -> Rect<au> { +pub fn zero_rect() -> Rect<au> { let z = au(0); Rect(Point2D(z, z), Size2D(z, z)) } -fn zero_point() -> Point2D<au> { +pub fn zero_point() -> Point2D<au> { Point2D(au(0), au(0)) } -fn zero_size() -> Size2D<au> { +pub fn zero_size() -> Size2D<au> { Size2D(au(0), au(0)) } -pure fn from_px(i: int) -> au { +pub pure fn from_px(i: int) -> au { from_int(i * 60) } -pure fn to_px(au: au) -> int { +pub pure fn to_px(au: au) -> int { (*au / 60) as int } diff --git a/src/servo/gfx/render_task.rs b/src/servo/gfx/render_task.rs index b1214a6c70a..2a4383c9e39 100644 --- a/src/servo/gfx/render_task.rs +++ b/src/servo/gfx/render_task.rs @@ -1,20 +1,21 @@ +use mod azure::azure_hl; use au = geometry; use au::au; use platform::osmain; use comm::*; use image::base::Image; use dl = display_list; -use azure::*; -use azure::bindgen::*; use libc::size_t; use text::font::Font; use display_list::GlyphRun; use geom::size::Size2D; use geom::rect::Rect; use geom::point::Point2D; +use azure::{AzDrawOptions, AzFloat, AzGlyph, AzGlyphBuffer}; +use azure::bindgen::AzDrawTargetFillGlyphs; use azure_hl::{AsAzureRect, B8G8R8A8, Color, ColorPattern, DrawOptions, DrawSurfaceOptions}; use azure_hl::{DrawTarget, Linear}; -use ptr::addr_of; +use ptr::to_unsafe_ptr; use std::arc::ARC; use azure::cairo::{cairo_font_face_t, cairo_scaled_font_t}; use std::cell::Cell; @@ -23,7 +24,7 @@ use servo_text::font_cache::FontCache; use pipes::{Port, Chan}; -type Renderer = comm::Chan<Msg>; +pub type Renderer = comm::Chan<Msg>; pub enum Msg { RenderMsg(dl::DisplayList), @@ -35,9 +36,9 @@ struct RenderContext { font_cache: @FontCache, } -type RenderTask = comm::Chan<Msg>; +pub type RenderTask = comm::Chan<Msg>; -fn RenderTask<C: Compositor Send>(+compositor: C) -> RenderTask { +pub fn RenderTask<C: Compositor Send>(+compositor: C) -> RenderTask { do task::spawn_listener |po: comm::Port<Msg>| { let (draw_target_ch, draw_target_po) = pipes::stream(); let mut draw_target_ch = draw_target_ch; @@ -133,7 +134,7 @@ pub fn draw_image(ctx: &RenderContext, bounds: Rect<au>, image: ARC<~Image>) { } pub fn draw_glyphs(ctx: &RenderContext, bounds: Rect<au>, text_run: &GlyphRun) { - use ptr::{addr_of, null}; + use ptr::{null}; use vec::raw::to_ptr; use libc::types::common::c99::{uint16_t, uint32_t}; use geom::point::Point2D; @@ -155,7 +156,7 @@ pub fn draw_glyphs(ctx: &RenderContext, bounds: Rect<au>, text_run: &GlyphRun) { }; let cfont = get_cairo_font(font); - let azfont = AzCreateScaledFontWithCairo(addr_of(nfont), 1f as AzFloat, cfont); + let azfont = AzCreateScaledFontWithCairo(to_unsafe_ptr(&nfont), 1f as AzFloat, cfont); assert azfont.is_not_null(); cairo_scaled_font_destroy(cfont); @@ -165,7 +166,7 @@ pub fn draw_glyphs(ctx: &RenderContext, bounds: Rect<au>, text_run: &GlyphRun) { b: 0f as AzFloat, a: 1f as AzFloat }; - let pattern = AzCreateColorPattern(addr_of(color)); + let pattern = AzCreateColorPattern(to_unsafe_ptr(&color)); assert pattern.is_not_null(); let options: AzDrawOptions = { @@ -173,17 +174,17 @@ pub fn draw_glyphs(ctx: &RenderContext, bounds: Rect<au>, text_run: &GlyphRun) { fields: 0 as uint16_t }; - let mut origin = Point2D(bounds.origin.x, bounds.origin.y.add(bounds.size.height)); + let mut origin = Point2D(bounds.origin.x, bounds.origin.y.add(&bounds.size.height)); let azglyphs = text_run.glyphs.map(|glyph| { let azglyph: AzGlyph = { mIndex: glyph.index as uint32_t, mPosition: { - x: au::to_px(origin.x.add(glyph.pos.offset.x)) as AzFloat, - y: au::to_px(origin.y.add(glyph.pos.offset.y)) as AzFloat + x: au::to_px(origin.x.add(&glyph.pos.offset.x)) as AzFloat, + y: au::to_px(origin.y.add(&glyph.pos.offset.y)) as AzFloat } }; - origin = Point2D(origin.x.add(glyph.pos.advance.x), - origin.y.add(glyph.pos.advance.y)); + origin = Point2D(origin.x.add(&glyph.pos.advance.x), + origin.y.add(&glyph.pos.advance.y)); azglyph }); @@ -193,8 +194,8 @@ pub fn draw_glyphs(ctx: &RenderContext, bounds: Rect<au>, text_run: &GlyphRun) { }}; // TODO: this call needs to move into azure_hl.rs - AzDrawTargetFillGlyphs(ctx.canvas.azure_draw_target, azfont, addr_of(glyphbuf), - pattern, addr_of(options), null()); + AzDrawTargetFillGlyphs(ctx.canvas.azure_draw_target, azfont, to_unsafe_ptr(&glyphbuf), + pattern, to_unsafe_ptr(&options), null()); AzReleaseColorPattern(pattern); AzReleaseScaledFont(azfont); @@ -246,14 +247,13 @@ fn get_cairo_font(font: &Font) -> *cairo_scaled_font_t { x0: 0 as c_double, y0: 0 as c_double }; - cairo_matrix_init_identity(addr_of(idmatrix)); + cairo_matrix_init_identity(to_unsafe_ptr(&idmatrix)); let fontmatrix = idmatrix; - cairo_matrix_scale(addr_of(fontmatrix), - 20f as c_double, 20f as c_double); + cairo_matrix_scale(to_unsafe_ptr(&fontmatrix), 20f as c_double, 20f as c_double); let options = cairo_font_options_create(); - let cfont = cairo_scaled_font_create(face, addr_of(fontmatrix), - addr_of(idmatrix), options); + let cfont = cairo_scaled_font_create(face, to_unsafe_ptr(&fontmatrix), + to_unsafe_ptr(&idmatrix), options); cairo_font_options_destroy(options); cairo_font_face_destroy(face); diff --git a/src/servo/gfx/surface.rs b/src/servo/gfx/surface.rs index 030522adbe8..be1b5438ce3 100644 --- a/src/servo/gfx/surface.rs +++ b/src/servo/gfx/surface.rs @@ -1,6 +1,6 @@ use geom::size::Size2D; -enum format { +pub enum format { fo_rgba_8888 // TODO: RGB 565, others? } @@ -16,7 +16,7 @@ impl format: cmp::Eq { } } -type image_surface = { +pub type image_surface = { size: Size2D<int>, format: format, buffer: ~[u8] @@ -30,7 +30,7 @@ impl format { } } -fn image_surface(size: Size2D<int>, format: format) -> image_surface { +pub fn image_surface(size: Size2D<int>, format: format) -> image_surface { { size: copy size, format: format, diff --git a/src/servo/html/hubbub_html_parser.rs b/src/servo/html/hubbub_html_parser.rs index 0d7cef4716c..91efd5306d6 100644 --- a/src/servo/html/hubbub_html_parser.rs +++ b/src/servo/html/hubbub_html_parser.rs @@ -65,7 +65,7 @@ fn css_link_listener(to_parent : comm::Chan<Stylesheet>, from_parent : comm::Por result_chan.send(css_rules); }); - vec::push(result_vec, result_port); + vec::push(&mut result_vec, result_port); } CSSTaskExit => { break; @@ -110,7 +110,7 @@ fn js_script_listener(to_parent : comm::Chan<~[~[u8]]>, from_parent : comm::Port } } } - vec::push(result_vec, result_port); + vec::push(&mut result_vec, result_port); } JSTaskExit => { break; @@ -165,10 +165,10 @@ fn build_element_kind(tag: &str) -> ~ElementKind { else { ~UnknownElement } } -fn parse_html(scope: NodeScope, - url: Url, - resource_task: ResourceTask, - image_cache_task: ImageCacheTask) -> HtmlParserResult unsafe { +pub fn parse_html(scope: NodeScope, + url: Url, + resource_task: ResourceTask, + image_cache_task: ImageCacheTask) -> HtmlParserResult unsafe { // Spawn a CSS parser to receive links to CSS style sheets. let (css_port, css_chan): (comm::Port<Stylesheet>, comm::Chan<CSSMessage>) = do task::spawn_conversation |css_port: comm::Port<CSSMessage>, @@ -237,7 +237,7 @@ fn parse_html(scope: NodeScope, }, ~HTMLImageElement(d) => { do elem.get_attr(~"src").iter |img_url_str| { - let img_url = make_url(copy img_url_str, Some(copy *url)); + let img_url = make_url(copy *img_url_str, Some(copy *url)); d.image = Some(copy img_url); // inform the image cache to load this, but don't store a handle. // TODO (Issue #84): don't prefetch if we are within a <noscript> tag. diff --git a/src/servo/html/lexer.rs b/src/servo/html/lexer.rs deleted file mode 100644 index f5d1a210543..00000000000 --- a/src/servo/html/lexer.rs +++ /dev/null @@ -1,246 +0,0 @@ -use comm::{Port, Chan}; -use option::is_none; -use str::from_bytes; -use vec::push; -use lexer_util::*; -use resource::resource_task; -use resource_task::{ResourceTask, ProgressMsg, Load}; -use std::net::url::Url; - -enum Token { - StartOpeningTag(~str), - EndOpeningTag, - EndTag(~str), - SelfCloseTag, - Text(~str), - Attr(~str, ~str), - Doctype, - Eof -} - -enum ParseState { - NormalHtml, - TagHtml, -} - -type HtmlLexer = { - input_state: InputState, - mut parser_state: ParseState -}; - -trait HtmlLexerMethods { - fn parse_html() -> Token; - fn parse_in_normal_state(c: u8) -> Token; - fn parse_in_tag_state(c: u8) -> Token; - fn eat_until_end_of_comment(); -} - -impl HtmlLexer : HtmlLexerMethods { - fn parse_html() -> Token { - let mut ch: u8; - match self.input_state.get() { - CoeChar(c) => { ch = c; } - CoeEof => { return Eof; } - } - let token = match self.parser_state { - NormalHtml => { self.parse_in_normal_state(ch) } - TagHtml => { self.parse_in_tag_state(ch) } - }; - - #debug["token=%?", token]; - return token; - } - - fn parse_in_normal_state(c: u8) -> Token { - let mut ch = c; - - if ch == ('<' as u8) { - match self.input_state.get() { - CoeChar(c) => { ch = c; } - CoeEof => { self.input_state.parse_err(~"eof after '<'") } - } - - if ch == ('!' as u8) { - let ch = self.input_state.get(); - // FIXME: This comment parsing is very hacky - if ch == CoeChar('-' as u8) { - self.eat_until_end_of_comment(); - return match self.input_state.get() { - CoeChar(c) => self.parse_in_normal_state(c), - CoeEof => self.input_state.parse_err(~"FIXME") - } - } else if ch == CoeChar('D' as u8) { - self.input_state.expect_ident(~"OCTYPE"); - self.input_state.eat_whitespace(); - self.input_state.expect_ident(~"html"); - self.input_state.eat_whitespace(); - self.input_state.expect('>' as u8); - return Doctype; - } else { - self.input_state.eat_whitespace(); - self.input_state.expect_ident(~"DOCTYPE"); - self.input_state.eat_whitespace(); - self.input_state.expect_ident(~"html"); - self.input_state.eat_whitespace(); - self.input_state.expect('>' as u8); - return Doctype; - } - } - - if ch == ('/' as u8) { - let ident = self.input_state.parse_ident(); - self.input_state.expect('>' as u8); - return EndTag(ident); - } - - self.input_state.unget(ch); - - self.input_state.eat_whitespace(); - let ident = self.input_state.parse_ident(); - self.input_state.eat_whitespace(); - - self.parser_state = TagHtml; - return StartOpeningTag(ident); - } - - // Make a text node. - let mut s: ~[u8] = ~[ch]; - loop { - match self.input_state.get() { - CoeChar(c) => { - if c == ('<' as u8) { - self.input_state.unget(c); - return Text(from_bytes(s)); - } - push(s, c); - } - CoeEof => { return Text(from_bytes(s)); } - } - } - } - - fn eat_until_end_of_comment() { - let mut state = None; - - loop { - match self.input_state.get() { - CoeChar(c) => { - match c { - '-' as u8 if state == None => { - state = Some(~"-") - } - '-' as u8 if state == Some(~"-") => { - state = Some(~"--") - } - '>' as u8 if state == Some(~"--") => { - return - } - _ => { - state = None - } - } - } - CoeEof => return - } - } - } - - fn parse_in_tag_state(c: u8) -> Token { - let mut ch = c; - - if ch == ('>' as u8) { - self.parser_state = NormalHtml; - return EndOpeningTag; - } - - if ch == ('/' as u8) { - match self.input_state.get() { - CoeChar(c) => { - if c == ('>' as u8) { - self.parser_state = NormalHtml; - return SelfCloseTag; - } else { - #warn["/ not followed by > in a tag"]; - } - } - CoeEof => { - #warn["/ not followed by > at end of file"]; - } - } - } - - if !ch.is_alpha() { - fail #fmt("expected alphabetical in tag but found %c", ch as char); - } - - // Parse an attribute. - let mut attribute_name = ~[ch]; - loop { - match self.input_state.get() { - CoeChar(c) => { - if c == ('=' as u8) { break; } - push(attribute_name, c); - } - CoeEof => { - let name = from_bytes(attribute_name); - return Attr(copy name, name); - } - } - } - - // Parse the attribute value. - self.input_state.expect('"' as u8); - let mut attribute_value = ~[]; - loop { - match self.input_state.get() { - CoeChar(c) => { - if c == ('"' as u8) { break; } - push(attribute_value, c); - } - CoeEof => { - return Attr(from_bytes(attribute_name), from_bytes(attribute_value)); - } - } - } - - // Eat whitespacpe. - self.input_state.eat_whitespace(); - - return Attr(from_bytes(attribute_name), from_bytes(attribute_value)); - } -} - -fn lexer(+input_port: Port<resource_task::ProgressMsg>, state : ParseState) -> HtmlLexer { - return { - input_state: { - mut lookahead: None, - mut buffer: ~[], - input_port: input_port, - mut eof: false - }, - mut parser_state: state - }; -} - -#[allow(non_implicitly_copyable_typarams)] -fn spawn_html_lexer_task(-url: Url, resource_task: ResourceTask) -> Port<Token> { - let html_port = Port(); - let html_chan = Chan(html_port); - - task::spawn(|| { - let input_port = Port(); - // TODO: change copy to move once we can move into closures - resource_task.send(Load(copy url, input_port.chan())); - - let lexer = lexer(input_port, NormalHtml); - - loop { - let token = lexer.parse_html(); - let should_break = match token { Eof => true, _ => false }; - html_chan.send(token); - if should_break { break; } - } - }); - - return html_port; -} diff --git a/src/servo/html/lexer_util.rs b/src/servo/html/lexer_util.rs index 0e54d0836fd..8aa040656a8 100644 --- a/src/servo/html/lexer_util.rs +++ b/src/servo/html/lexer_util.rs @@ -73,7 +73,7 @@ impl InputState : InputStateUtil { // FIXME: Lots of copies here if self.buffer.len() > 0 { - return CoeChar(vec::shift(self.buffer)); + return CoeChar(vec::shift(&mut self.buffer)); } if self.eof { @@ -84,7 +84,7 @@ impl InputState : InputStateUtil { Payload(data) => { // TODO: change copy to move once we have match move self.buffer = copy data; - return CoeChar(vec::shift(self.buffer)); + return CoeChar(vec::shift(&mut self.buffer)); } Done(*) => { self.eof = true; @@ -94,7 +94,7 @@ impl InputState : InputStateUtil { } fn unget(ch: u8) { - assert is_none(self.lookahead); + assert is_none(&self.lookahead); self.lookahead = Some(CoeChar(ch)); } @@ -114,7 +114,7 @@ impl InputState : InputStateUtil { loop { match self.get() { CoeChar(c) => { - if (c.is_alpha()) { push(result, c); } + if (c.is_alpha()) { push(&mut result, c); } else if result.len() == 0u { self.parse_err(~"expected ident"); } else { self.unget(c); diff --git a/src/servo/image/base.rs b/src/servo/image/base.rs index 6302c035475..ecfc08c6d4e 100644 --- a/src/servo/image/base.rs +++ b/src/servo/image/base.rs @@ -9,9 +9,9 @@ use stb_image = stb_image::image; // FIXME: Images must not be copied every frame. Instead we should atomically // reference count them. -type Image = stb_image::Image; +pub type Image = stb_image::Image; -fn Image(width: uint, height: uint, depth: uint, +data: ~[u8]) -> Image { +pub fn Image(width: uint, height: uint, depth: uint, +data: ~[u8]) -> Image { stb_image::new_image(width, height, depth, data) } @@ -21,7 +21,7 @@ fn test_image_bin() -> ~[u8] { return vec::from_fn(4962, |i| TEST_IMAGE[i]); } -fn load_from_memory(buffer: &[u8]) -> Option<Image> { +pub fn load_from_memory(buffer: &[u8]) -> Option<Image> { do stb_image::load_from_memory(buffer).map |image| { assert image.depth == 4; diff --git a/src/servo/image/holder.rs b/src/servo/image/holder.rs index 55531cc16dc..4e688f6600c 100644 --- a/src/servo/image/holder.rs +++ b/src/servo/image/holder.rs @@ -1,7 +1,7 @@ use std::net::url::Url; use std::arc::{ARC, clone, get}; use resource::image_cache_task::ImageCacheTask; -use resource::image_cache_task; +use mod resource::image_cache_task; use geom::size::Size2D; /** A struct to store image data. The image will be loaded once, the @@ -117,4 +117,4 @@ impl ImageHolder { return None; } } -}
\ No newline at end of file +} diff --git a/src/servo/layout/block.rs b/src/servo/layout/block.rs index fdbd911b4e4..8a097466e73 100644 --- a/src/servo/layout/block.rs +++ b/src/servo/layout/block.rs @@ -22,7 +22,7 @@ fn BlockFlowData() -> BlockFlowData { trait BlockLayout { pure fn starts_block_flow() -> bool; - pure fn with_block_box(fn(&&@RenderBox) -> ()) -> (); + pure fn with_block_box(fn(box: &@RenderBox) -> ()) -> (); fn bubble_widths_block(ctx: &LayoutContext); fn assign_widths_block(ctx: &LayoutContext); @@ -43,7 +43,7 @@ impl FlowContext : BlockLayout { /* Get the current flow's corresponding block box, if it exists, and do something with it. This works on both BlockFlow and RootFlow, since they are mostly the same. */ - pure fn with_block_box(cb:fn(&&@RenderBox) -> ()) -> () { + pure fn with_block_box(cb: fn(box: &@RenderBox) -> ()) -> () { match self { BlockFlow(*) => { let mut box = self.block().box; @@ -83,8 +83,8 @@ impl FlowContext : BlockLayout { /* if not an anonymous block context, add in block box's widths. these widths will not include child elements, just padding etc. */ do self.with_block_box |box| { - min_width = min_width.add(box.get_min_width()); - pref_width = pref_width.add(box.get_pref_width()); + min_width = min_width.add(&box.get_min_width()); + pref_width = pref_width.add(&box.get_pref_width()); } self.d().min_width = min_width; @@ -110,7 +110,7 @@ impl FlowContext : BlockLayout { do self.with_block_box |box| { box.d().position.size.width = remaining_width; let (left_used, right_used) = box.get_used_width(); - remaining_width = remaining_width.sub(left_used.add(right_used)); + remaining_width = remaining_width.sub(&left_used.add(&right_used)); } for FlowTree.each_child(@self) |child_ctx| { @@ -127,7 +127,7 @@ impl FlowContext : BlockLayout { for FlowTree.each_child(@self) |child_ctx| { child_ctx.d().position.origin.y = cur_y; - cur_y = cur_y.add(child_ctx.d().position.size.height); + cur_y = cur_y.add(&child_ctx.d().position.size.height); } self.d().position.size.height = cur_y; diff --git a/src/servo/layout/box.rs b/src/servo/layout/box.rs index af805b0766f..b5245769f1e 100644 --- a/src/servo/layout/box.rs +++ b/src/servo/layout/box.rs @@ -90,7 +90,7 @@ enum RenderBoxType { RenderBox_Text } -enum RenderBox { +pub enum RenderBox { GenericBox(RenderBoxData), ImageBox(RenderBoxData, ImageHolder), TextBox(RenderBoxData, TextBoxData) @@ -142,7 +142,7 @@ impl RenderBox { // TODO: If image isn't available, consult 'width'. ImageBox(_,i) => au::from_px(i.get_size().get_default(Size2D(0,0)).width), TextBox(_,d) => d.runs.foldl(au(0), |sum, run| { - au::max(sum, run.min_break_width()) + au::max(*sum, run.min_break_width()) }) } } @@ -160,7 +160,7 @@ impl RenderBox { // how to compute its own min and pref widths, and should // probably cache them. TextBox(_,d) => d.runs.foldl(au(0), |sum, run| { - au::max(sum, run.size().width) + au::max(*sum, run.size().width) }) } } @@ -261,7 +261,7 @@ impl RenderBox { bounds.size.height = runs[i].size().height; let glyph_run = make_glyph_run(&runs[i]); list.push(~dl::Glyphs(bounds, glyph_run)); - bounds.origin.y = bounds.origin.y.add(bounds.size.height); + bounds.origin.y = bounds.origin.y.add(&bounds.size.height); } return; @@ -301,10 +301,10 @@ trait ImageBoxMethods { * nested CSS boxes that are nested in an otherwise inline flow * context. */ -enum RenderBoxTree { RenderBoxTree } +pub enum RenderBoxTree { RenderBoxTree } impl RenderBoxTree : tree::ReadMethods<@RenderBox> { - fn each_child(node: @RenderBox, f: fn(&&@RenderBox) -> bool) { + fn each_child(node: @RenderBox, f: fn(&&box: @RenderBox) -> bool) { tree::each_child(self, node, f) } @@ -350,7 +350,7 @@ impl RenderBox : BoxedDebugMethods { @ImageBox(*) => ~"ImageBox", @TextBox(_,d) => { let mut s = d.runs.foldl(~"TextBox(runs=", |s, run| { - fmt!("%s \"%s\"", s, run.text) + fmt!("%s \"%s\"", *s, run.text) }); s += ~")"; s } @@ -385,10 +385,10 @@ mod test { fn flat_bounds(root: @RenderBox) -> ~[Rect<au>] { let mut r = ~[]; for tree::each_child(RenderBoxTree, root) |c| { - push_all(r, flat_bounds(c)); + push_all(&mut r, flat_bounds(c)); } - push(r, copy root.d().position); + push(&mut r, copy root.d().position); return r; } diff --git a/src/servo/layout/display_list_builder.rs b/src/servo/layout/display_list_builder.rs index 026eea5c4a3..53c355d2637 100644 --- a/src/servo/layout/display_list_builder.rs +++ b/src/servo/layout/display_list_builder.rs @@ -26,7 +26,7 @@ use vec::push; Right now, the builder isn't used for much, but it establishes the pattern we'll need once we support DL-based hit testing &c. */ -struct DisplayListBuilder { +pub struct DisplayListBuilder { ctx: &LayoutContext, } @@ -146,4 +146,4 @@ fn should_calculate_the_bounds_of_the_text_items() { do list.borrow |l| { assert l[1].bounds == expected; } } -*/
\ No newline at end of file +*/ diff --git a/src/servo/layout/flow.rs b/src/servo/layout/flow.rs index 992428b628c..abab04c44e5 100644 --- a/src/servo/layout/flow.rs +++ b/src/servo/layout/flow.rs @@ -181,8 +181,8 @@ impl FlowContext { _ => seed }, InlineFlow(*) => do self.inline().boxes.foldl(seed) |acc, box| { - if box.d().node == node { blk(acc, box) } - else { acc } + if box.d().node == node { blk(*acc, *box) } + else { *acc } }, _ => fail fmt!("Don't know how to iterate node's RenderBoxes for %?", self) } @@ -213,12 +213,12 @@ impl FlowContext { enum FlowTree { FlowTree } impl FlowTree : tree::ReadMethods<@FlowContext> { - fn each_child(ctx: @FlowContext, f: fn(&&@FlowContext) -> bool) { + fn each_child(ctx: @FlowContext, f: fn(&&box: @FlowContext) -> bool) { tree::each_child(self, ctx, f) } - fn with_tree_fields<R>(&&b: @FlowContext, f: fn(tree::Tree<@FlowContext>) -> R) -> R { - f(b.d().tree) + fn with_tree_fields<R>(&&box: @FlowContext, f: fn(tree::Tree<@FlowContext>) -> R) -> R { + f(box.d().tree) } } @@ -228,8 +228,8 @@ impl FlowTree : tree::WriteMethods<@FlowContext> { tree::add_child(self, parent, child) } - fn with_tree_fields<R>(&&b: @FlowContext, f: fn(tree::Tree<@FlowContext>) -> R) -> R { - f(b.d().tree) + fn with_tree_fields<R>(&&box: @FlowContext, f: fn(tree::Tree<@FlowContext>) -> R) -> R { + f(box.d().tree) } } @@ -259,7 +259,7 @@ impl FlowContext : BoxedDebugMethods { let repr = match *self { InlineFlow(*) => { let mut s = self.inline().boxes.foldl(~"InlineFlow(children=", |s, box| { - fmt!("%s %?", s, box.d().id) + fmt!("%s %?", *s, box.d().id) }); s += ~")"; s }, diff --git a/src/servo/layout/inline.rs b/src/servo/layout/inline.rs index 3418c866a2a..678ee2f3903 100644 --- a/src/servo/layout/inline.rs +++ b/src/servo/layout/inline.rs @@ -133,7 +133,7 @@ impl FlowContext : InlineLayout { }; box.d().position.origin = Point2D(au(0), cur_y); - cur_y = cur_y.add(au::max(line_height, box.d().position.size.height)); + cur_y = cur_y.add(&au::max(line_height, box.d().position.size.height)); } // for boxes.each |box| self.d().position.size.height = cur_y; diff --git a/src/servo/layout/layout_task.rs b/src/servo/layout/layout_task.rs index 749236cc198..d9ba3b6e7a9 100644 --- a/src/servo/layout/layout_task.rs +++ b/src/servo/layout/layout_task.rs @@ -30,28 +30,28 @@ use layout::traverse::*; use comm::*; use task::*; -type LayoutTask = Chan<Msg>; +pub type LayoutTask = comm::Chan<Msg>; -enum LayoutQuery { +pub enum LayoutQuery { ContentBox(Node) } -type LayoutQueryResponse = Result<LayoutQueryResponse_, ()>; +pub type LayoutQueryResponse = Result<LayoutQueryResponse_, ()>; enum LayoutQueryResponse_ { ContentSize(Size2D<int>) } -enum Msg { - BuildMsg(Node, ARC<Stylesheet>, Url, Chan<Event>), - PingMsg(Chan<content_task::PingMsg>), - QueryMsg(LayoutQuery, Chan<LayoutQueryResponse>), +pub enum Msg { + BuildMsg(Node, ARC<Stylesheet>, Url, comm::Chan<Event>), + PingMsg(comm::Chan<content_task::PingMsg>), + QueryMsg(LayoutQuery, comm::Chan<LayoutQueryResponse>), ExitMsg } fn LayoutTask(render_task: RenderTask, img_cache_task: ImageCacheTask) -> LayoutTask { - do spawn_listener::<Msg>|from_content| { + do spawn_listener::<Msg> |from_content| { Layout(render_task, img_cache_task, from_content).start(); } } diff --git a/src/servo/layout/traverse_parallel.rs b/src/servo/layout/traverse_parallel.rs index faad6a04b43..57b4bde29c2 100644 --- a/src/servo/layout/traverse_parallel.rs +++ b/src/servo/layout/traverse_parallel.rs @@ -56,7 +56,8 @@ finish, and then applies the second function to the current box. applied to that node's children */ -fn traverse_helper<T : Copy Send>(-root : @RenderBox, returned : T, -top_down : fn~(+T, @RenderBox) -> T, +fn traverse_helper<T : Copy Send>(-root : @RenderBox, returned : T, + -top_down : fn~(+val: T, @RenderBox) -> T, -bottom_up : fn~(@RenderBox)) { let returned = top_down(returned, root); @@ -110,7 +111,7 @@ fn nop(_box : @RenderBox) { A wrapper to change a function that only acts on a box to one that threasds a unit through to match travserse_helper */ -fn unit_wrapper(-fun : fn~(@RenderBox)) -> fn~(+(), @RenderBox) { +fn unit_wrapper(-fun : fn~(@RenderBox)) -> fn~(+val: (), @RenderBox) { fn~(+_u : (), box : @RenderBox) { fun(box); } } @@ -146,7 +147,7 @@ fn bottom_up_traversal(+root : @RenderBox, -bottom_up : fn~(@RenderBox)) { children in parallel, and then the parent. */ fn extended_full_traversal<T : Copy Send>(+root : @RenderBox, first_val : T, - -top_down : fn~(+T, @RenderBox) -> T, + -top_down : fn~(+val: T, @RenderBox) -> T, -bottom_up : fn~(@RenderBox)) { traverse_helper(root, first_val, top_down, bottom_up); } @@ -157,6 +158,6 @@ fn extended_full_traversal<T : Copy Send>(+root : @RenderBox, first_val : T, function is passed to each child when they are recursed upon. */ fn extended_top_down_traversal<T : Copy Send>(+root : @RenderBox, first_val : T, - -top_down : fn~(+T, @RenderBox) -> T) { + -top_down : fn~(+val: T, @RenderBox) -> T) { traverse_helper(root, first_val, top_down, nop); } diff --git a/src/servo/macros.rs b/src/servo/macros.rs index 4d32bb5e336..247226f344d 100644 --- a/src/servo/macros.rs +++ b/src/servo/macros.rs @@ -64,5 +64,4 @@ ])+) } ) - } diff --git a/src/servo/opts.rs b/src/servo/opts.rs index 3e85543d339..412b1afe6e1 100644 --- a/src/servo/opts.rs +++ b/src/servo/opts.rs @@ -1,18 +1,18 @@ //! Configuration options for a single run of the servo application. Created //! from command line arguments. -type Opts = { +pub type Opts = { urls: ~[~str], render_mode: RenderMode }; -enum RenderMode { +pub enum RenderMode { Screen, Png(~str) } #[allow(non_implicitly_copyable_typarams)] -fn from_cmdline_args(args: ~[~str]) -> Opts { +pub fn from_cmdline_args(args: ~[~str]) -> Opts { use std::getopts; let args = args.tail(); diff --git a/src/servo/platform/osmain.rs b/src/servo/platform/osmain.rs index 8b744a66961..3a2214ef9a2 100644 --- a/src/servo/platform/osmain.rs +++ b/src/servo/platform/osmain.rs @@ -1,13 +1,10 @@ export OSMain; export Msg, BeginDrawing, Draw, AddKeyHandler, Exit; -use azure::*; +use mod azure::azure_hl; use azure::azure_hl::DrawTarget; -use azure::bindgen::*; use azure::cairo; -use azure::cairo::bindgen::*; use azure::cairo_hl::ImageSurface; -use comm::*; use dvec::DVec; use azure::cairo::cairo_surface_t; use gfx::compositor::Compositor; @@ -23,6 +20,7 @@ use pipes::Chan; type OSMain = comm::Chan<Msg>; +// FIXME: Move me over to opts.rs. enum Mode { GlutMode, ShareMode @@ -33,7 +31,7 @@ enum Window { ShareWindow(ShareGlContext) } -enum Msg { +pub enum Msg { BeginDrawing(pipes::Chan<DrawTarget>), Draw(pipes::Chan<DrawTarget>, DrawTarget), AddKeyHandler(pipes::Chan<()>), @@ -57,7 +55,7 @@ fn OSMain() -> OSMain { } } -fn mainloop(+mode: Mode, po: Port<Msg>) { +fn mainloop(+mode: Mode, po: comm::Port<Msg>) { let key_handlers: @DVec<pipes::Chan<()>> = @DVec(); let event_listeners: @DVec<comm::Chan<Event>> = @DVec(); @@ -101,7 +99,7 @@ fn mainloop(+mode: Mode, po: Port<Msg>) { #debug("osmain: peeking"); while po.peek() { match po.recv() { - AddKeyHandler(key_ch) => key_handlers.push(#moov(key_ch)), + AddKeyHandler(move key_ch) => key_handlers.push(move key_ch), AddEventListener(event_listener) => event_listeners.push(event_listener), BeginDrawing(sender) => lend_surface(*surfaces, sender), Draw(sender, dt) => { @@ -229,13 +227,13 @@ fn 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> { +fn on_osmain<T: Send>(+f: fn~(+po: comm::Port<T>)) -> comm::Chan<T> { task::task().sched_mode(task::PlatformThread).spawn_listener(f) } // #[cfg(target_os = "linux")] mod platform { - fn runmain(f: fn()) { + pub fn runmain(f: fn()) { f() } } diff --git a/src/servo/resource/file_loader.rs b/src/servo/resource/file_loader.rs index 37e6ee477ec..50bd8b1c23f 100644 --- a/src/servo/resource/file_loader.rs +++ b/src/servo/resource/file_loader.rs @@ -8,7 +8,7 @@ use io::{file_reader, ReaderUtil}; const READ_SIZE: uint = 1024; -fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) { +pub fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) { assert url.scheme == ~"file"; do spawn { diff --git a/src/servo/resource/http_loader.rs b/src/servo/resource/http_loader.rs index 472bca1cd37..bf66c7e3ee6 100644 --- a/src/servo/resource/http_loader.rs +++ b/src/servo/resource/http_loader.rs @@ -6,7 +6,7 @@ use resource_task::{ProgressMsg, Payload, Done}; use std::net::url::Url; use http_client::{uv_http_request}; -fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) { +pub fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) { assert url.scheme == ~"http"; do spawn { diff --git a/src/servo/resource/image_cache_task.rs b/src/servo/resource/image_cache_task.rs index 953a089917e..b50a14d1864 100644 --- a/src/servo/resource/image_cache_task.rs +++ b/src/servo/resource/image_cache_task.rs @@ -1,9 +1,3 @@ -export Msg, Prefetch, Decode, GetImage, WaitForImage, Exit; -export ImageResponseMsg, ImageReady, ImageNotReady, ImageFailed; -export ImageCacheTask; -export ImageCacheTaskClient; -export SyncImageCacheTask; - use image::base::{Image, load_from_memory, test_image_bin}; use std::net::url::Url; use util::url::{make_url, UrlMap, url_map}; @@ -78,15 +72,15 @@ impl ImageResponseMsg: cmp::Eq { } } -type ImageCacheTask = Chan<Msg>; +pub type ImageCacheTask = Chan<Msg>; type DecoderFactory = ~fn() -> ~fn(~[u8]) -> Option<Image>; -fn ImageCacheTask(resource_task: ResourceTask) -> ImageCacheTask { +pub fn ImageCacheTask(resource_task: ResourceTask) -> ImageCacheTask { ImageCacheTask_(resource_task, default_decoder_factory) } -fn ImageCacheTask_(resource_task: ResourceTask, +decoder_factory: DecoderFactory) -> ImageCacheTask { +pub fn ImageCacheTask_(resource_task: ResourceTask, +decoder_factory: DecoderFactory) -> ImageCacheTask { // FIXME: Doing some dancing to avoid copying decoder_factory, our test // version of which contains an uncopyable type which rust will currently // copy unsoundly @@ -406,7 +400,7 @@ impl ImageCache { // We don't have this image yet match self.wait_map.find(copy url) { Some(waiters) => { - vec::push(*waiters, response); + vec::push(&mut *waiters, response); } None => { self.wait_map.insert(url, @mut ~[response]); diff --git a/src/servo/resource/resource_task.rs b/src/servo/resource/resource_task.rs index 65c45b0d025..d3d212d22d4 100644 --- a/src/servo/resource/resource_task.rs +++ b/src/servo/resource/resource_task.rs @@ -4,23 +4,19 @@ A task that takes a URL and streams back the binary data */ -export ControlMsg, Load, Exit; -export ProgressMsg, Payload, Done; -export ResourceTask, ResourceManager, LoaderTaskFactory; - use comm::{Chan, Port}; use task::{spawn, spawn_listener}; use std::net::url; use std::net::url::{Url, to_str}; -enum ControlMsg { +pub enum ControlMsg { /// Request the data associated with a particular URL Load(Url, Chan<ProgressMsg>), Exit } /// Messages sent in response to a `Load` message -enum ProgressMsg { +pub enum ProgressMsg { /// Binary data - there may be multiple of these Payload(~[u8]), /// Indicates loading is complete, either successfully or not @@ -69,15 +65,15 @@ fn create_resource_task_with_loaders(+loaders: ~[(~str, LoaderTaskFactory)]) -> } } -struct ResourceManager { +pub struct ResourceManager { from_client: Port<ControlMsg>, /// Per-scheme resource loaders loaders: ~[(~str, LoaderTaskFactory)], } -fn ResourceManager(from_client: Port<ControlMsg>, - loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceManager { +pub fn ResourceManager(from_client: Port<ControlMsg>, + loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceManager { ResourceManager { from_client : from_client, loaders : loaders, diff --git a/src/servo/servo.rc b/src/servo/servo.rc index 2a6f77ff202..a890f6ad190 100755 --- a/src/servo/servo.rc +++ b/src/servo/servo.rc @@ -21,123 +21,116 @@ extern mod http_client; extern mod hubbub; extern mod sharegl; -mod engine; - -mod dom { - mod bindings { - mod document; - mod element; - mod utils; - mod node; - mod window; +pub mod engine; + +pub mod dom { + pub mod bindings { + pub mod document; + pub mod element; + pub mod utils; + pub mod node; + pub mod window; } - mod document; - mod element; - mod event; - mod node; - mod rcu; - mod window; + pub mod document; + pub mod element; + pub mod event; + pub mod node; + pub mod rcu; + pub mod window; } #[allow(non_implicitly_copyable_typarams)] -mod content { - mod content_task; +pub mod content { + pub mod content_task; } -mod css { - mod lexer; - mod parser; - mod parser_util; +pub mod css { + pub mod lexer; + pub mod parser; + pub mod parser_util; - mod values; - mod styles; - mod resolve { - mod apply; - mod matching; + pub mod values; + pub mod styles; + pub mod resolve { + pub mod apply; + pub mod matching; } } -mod layout { - mod block; - mod box; - mod box_builder; - mod context; - mod debug; - mod display_list_builder; - mod flow; - mod layout_task; - mod inline; - mod root; - mod text; - mod traverse; - mod traverse_parallel; +pub mod layout { + pub mod block; + pub mod box; + pub mod box_builder; + pub mod context; + pub mod debug; + pub mod display_list_builder; + pub mod flow; + pub mod layout_task; + pub mod inline; + pub mod root; + pub mod text; + pub mod traverse; + pub mod traverse_parallel; } -mod gfx { - mod geometry; - mod surface; - mod render_task; - mod compositor; - mod png_compositor; - mod display_list; +pub mod gfx { + pub mod geometry; + pub mod surface; + pub mod render_task; + pub mod compositor; + pub mod png_compositor; + pub mod display_list; } -mod image { - mod base; - mod holder; - mod encode { - mod tga; +pub mod image { + pub mod base; + pub mod holder; + pub mod encode { + pub mod tga; } } -mod html { - mod lexer; - mod lexer_util; - mod hubbub_html_parser; +pub mod html { + pub mod lexer_util; + pub mod hubbub_html_parser; } -mod platform { - mod base; - mod osmain; +pub mod platform { + pub mod base; + pub mod osmain; } -mod text { - export glyph; - export text_run; - export font; - export font_cache; - export shaper; - - mod font; - mod font_cache; - mod glyph; - mod native_font { +pub mod text { + pub mod font; + pub mod font_cache; + pub mod glyph; + pub mod native_font { #[cfg(target_os = "macos")] - mod quartz_native_font; + pub mod quartz_native_font; #[cfg(target_os = "linux")] - mod ft_native_font; + pub mod ft_native_font; } - mod shaper; - mod text_run; - mod util; + pub mod shaper; + pub mod text_run; + pub mod util; } -mod resource { - mod resource_task; - mod file_loader; - mod http_loader; - mod image_cache_task; +pub mod resource { + pub mod resource_task; + pub mod file_loader; + pub mod http_loader; + pub mod image_cache_task; } -mod util { - mod color; - mod time; - mod tree; - mod url; - mod vec; +pub mod util { + pub mod tree; + pub mod color; + pub mod time; + pub mod url; + pub mod vec; } -mod opts; +pub mod opts; use servo_util = util; use servo_text = text; diff --git a/src/servo/servo.rs b/src/servo/servo.rs index b8e1b4e98a1..d5024c93d71 100644 --- a/src/servo/servo.rs +++ b/src/servo/servo.rs @@ -3,7 +3,9 @@ use option::swap_unwrap; use platform::osmain; use osmain::{OSMain, AddKeyHandler}; use opts::{Opts, Screen, Png}; -use engine::{EngineTask, EngineProto}; +use engine::{Engine, ExitMsg, LoadURLMsg}; +use resource::image_cache_task::ImageCacheTask; +use resource::resource_task::ResourceTask; use url_to_str = std::net::url::to_str; use util::url::make_url; @@ -37,15 +39,16 @@ fn run_pipeline_screen(urls: ~[~str]) { let (keypress_to_engine, keypress_from_osmain) = pipes::stream(); osmain.send(AddKeyHandler(keypress_to_engine)); - // Create a serve instance - let mut engine_task = Some(EngineTask(osmain)); + // Create a servo instance + let resource_task = ResourceTask(); + let image_cache_task = ImageCacheTask(resource_task); + let engine = Engine(osmain, resource_task, image_cache_task); + let engine_chan = engine.start(); for urls.each |filename| { let url = make_url(*filename, None); - #debug["master: Sending url `%s`", url_to_str(copy url)]; - engine_task = - Some(EngineProto::client::LoadURL(swap_unwrap(&mut engine_task), - url)); + #debug["master: Sending url `%s`", url_to_str(url)]; + engine_chan.send(LoadURLMsg(url)); #debug["master: Waiting for keypress"]; match keypress_from_osmain.try_recv() { @@ -56,39 +59,39 @@ fn run_pipeline_screen(urls: ~[~str]) { // Shut everything down #debug["master: Shut down"]; - let engine_task = EngineProto::client::Exit(option::unwrap(engine_task)); - pipes::recv(engine_task); + let (exit_chan, exit_response_from_engine) = pipes::stream(); + engine_chan.send(engine::ExitMsg(exit_chan)); + exit_response_from_engine.recv(); osmain.send(osmain::Exit); } fn run_pipeline_png(-url: ~str, outfile: ~str) { - // Use a PNG encoder as the graphics compositor use gfx::png_compositor; use png_compositor::PngCompositor; use io::{Writer, buffered_file_writer}; use resource::resource_task::ResourceTask; use resource::image_cache_task::SyncImageCacheTask; - use engine::EngineTask_; listen(|pngdata_from_compositor| { let compositor = PngCompositor(pngdata_from_compositor); let resource_task = ResourceTask(); - // For the PNG pipeline we are using a synchronous image cache - // so that all requests will be fullfilled before the first - // render + // For the PNG pipeline we are using a synchronous image task so that all images will be + // fulfilled before the first paint. let image_cache_task = SyncImageCacheTask(resource_task); - let engine_task = EngineTask_(compositor, resource_task, image_cache_task); - let engine_task = EngineProto::client::LoadURL(engine_task, make_url(url, None)); + let engine_task = Engine(compositor, resource_task, image_cache_task); + let engine_chan = engine_task.start(); + engine_chan.send(LoadURLMsg(make_url(url, None))); match buffered_file_writer(&Path(outfile)) { Ok(writer) => writer.write(pngdata_from_compositor.recv()), Err(e) => fail e } - let engine_task = EngineProto::client::Exit(engine_task); - pipes::recv(engine_task); + let (exit_chan, exit_response_from_engine) = pipes::stream(); + engine_chan.send(engine::ExitMsg(exit_chan)); + exit_response_from_engine.recv(); compositor.send(png_compositor::Exit); }) } diff --git a/src/servo/text/font_cache.rs b/src/servo/text/font_cache.rs index c6d1b82b164..24d1ded682b 100644 --- a/src/servo/text/font_cache.rs +++ b/src/servo/text/font_cache.rs @@ -50,15 +50,15 @@ fn create_font(lib: @FontCache, native_lib: &native::NativeFontCache) -> Result< } #[cfg(target_os = "linux")] -mod native { +pub mod native { use ptr::{null, addr_of}; use azure::freetype; use freetype::{FT_Library, FT_Error}; use freetype::bindgen::{FT_Init_FreeType, FT_Done_FreeType}; - type NativeFontCache = FT_Library; + pub type NativeFontCache = FT_Library; - fn create_native_lib() -> NativeFontCache { + pub fn create_native_lib() -> NativeFontCache { let lib: FT_Library = null(); let res = FT_Init_FreeType(addr_of(lib)); // FIXME: error handling @@ -66,22 +66,22 @@ mod native { return lib; } - fn destroy_native_lib(native_lib: &NativeFontCache) { + pub fn destroy_native_lib(native_lib: &NativeFontCache) { assert native_lib.is_not_null(); FT_Done_FreeType(*native_lib); } } #[cfg(target_os = "macos")] -mod native { - type NativeFontCache = (); +pub mod native { + pub type NativeFontCache = (); - fn create_native_lib() -> NativeFontCache { () } - fn destroy_native_lib(_native_lib: &NativeFontCache) { } + pub fn create_native_lib() -> NativeFontCache { () } + pub fn destroy_native_lib(_native_lib: &NativeFontCache) { } } #[test] -fn should_get_fonts() { +pub fn should_get_fonts() { let lib = FontCache(); lib.get_font(); } diff --git a/src/servo/text/glyph.rs b/src/servo/text/glyph.rs index 2b54c366324..ee9703db2c2 100644 --- a/src/servo/text/glyph.rs +++ b/src/servo/text/glyph.rs @@ -107,7 +107,7 @@ fn MissingGlyphs(glyphCount: u16) -> CompressedGlyph { impl CompressedGlyph { pure fn advance() -> GlyphStoreResult<au> { match self.is_simple() { - true => Simple(au::from_int(((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) as int)), + true => Simple(num::from_int(((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) as int)), false => Detailed(self.glyph_count()) } } diff --git a/src/servo/text/native_font.rs b/src/servo/text/native_font.rs index 03be27728c0..565d6df7f57 100644 --- a/src/servo/text/native_font.rs +++ b/src/servo/text/native_font.rs @@ -5,34 +5,32 @@ needed by the text shaper as well as access to the underlying font resources needed by the graphics layer to draw glyphs. */ -export NativeFont, create; - use glyph::GlyphIndex; use font_cache::native::NativeFontCache; #[cfg(target_os = "macos")] -type NativeFont/& = quartz_native_font::QuartzNativeFont; +pub type NativeFont/& = quartz_native_font::QuartzNativeFont; #[cfg(target_os = "linux")] -type NativeFont/& = ft_native_font::FreeTypeNativeFont; +pub type NativeFont/& = ft_native_font::FreeTypeNativeFont; #[cfg(target_os = "macos")] -fn create(_native_lib: &NativeFontCache, buf: @~[u8]) -> Result<NativeFont, ()> { +pub fn create(_native_lib: &NativeFontCache, buf: @~[u8]) -> Result<NativeFont, ()> { quartz_native_font::create(buf) } #[cfg(target_os = "linux")] -fn create(native_lib: &NativeFontCache, buf: @~[u8]) -> Result<NativeFont, ()> { +pub fn create(native_lib: &NativeFontCache, buf: @~[u8]) -> Result<NativeFont, ()> { ft_native_font::create(native_lib, buf) } #[cfg(target_os = "macos")] -fn with_test_native_font(f: fn@(nf: &NativeFont)) { +pub fn with_test_native_font(f: fn@(nf: &NativeFont)) { quartz_native_font::with_test_native_font(f); } #[cfg(target_os = "linux")] -fn with_test_native_font(f: fn@(nf: &NativeFont)) { +pub fn with_test_native_font(f: fn@(nf: &NativeFont)) { ft_native_font::with_test_native_font(f); } diff --git a/src/servo/text/native_font/ft_native_font.rs b/src/servo/text/native_font/ft_native_font.rs index 84115583a22..3b481afc692 100644 --- a/src/servo/text/native_font/ft_native_font.rs +++ b/src/servo/text/native_font/ft_native_font.rs @@ -84,7 +84,7 @@ impl FreeTypeNativeFont { } } -fn create(lib: &FT_Library, buf: @~[u8]) -> Result<FreeTypeNativeFont, ()> { +pub fn create(lib: &FT_Library, buf: @~[u8]) -> Result<FreeTypeNativeFont, ()> { assert lib.is_not_null(); let face: FT_Face = null(); return vec_as_buf(*buf, |cbuf, _len| { diff --git a/src/servo/text/native_font/quartz_native_font.rs b/src/servo/text/native_font/quartz_native_font.rs index 0e5f9a260df..a16ec298a74 100644 --- a/src/servo/text/native_font/quartz_native_font.rs +++ b/src/servo/text/native_font/quartz_native_font.rs @@ -23,58 +23,58 @@ use coretext::coretext::CFRelease; mod coretext { - type CTFontRef = *u8; - type UniChar = libc::c_ushort; - type CGGlyph = libc::c_ushort; - type CFIndex = libc::c_long; + pub type CTFontRef = *u8; + pub type UniChar = libc::c_ushort; + pub type CGGlyph = libc::c_ushort; + pub type CFIndex = libc::c_long; - type CTFontOrientation = u32; - const kCTFontDefaultOrientation: CTFontOrientation = 0; - const kCTFontHorizontalOrientation: CTFontOrientation = 1; - const kCTFontVerticalOrientation: CTFontOrientation = 2; + pub type CTFontOrientation = u32; + pub const kCTFontDefaultOrientation: CTFontOrientation = 0; + pub const kCTFontHorizontalOrientation: CTFontOrientation = 1; + pub const kCTFontVerticalOrientation: CTFontOrientation = 2; - type CGFloat = libc::c_double; + pub type CGFloat = libc::c_double; - struct CGSize { + pub struct CGSize { width: CGFloat, height: CGFloat, } - struct CGPoint { + pub struct CGPoint { x: CGFloat, y: CGFloat, } - struct CGRect { + pub struct CGRect { origin: CGPoint, size: CGSize } - type CGAffineTransform = (); - type CTFontDescriptorRef = *u8; + pub type CGAffineTransform = (); + pub type CTFontDescriptorRef = *u8; #[nolink] #[link_args = "-framework ApplicationServices"] - extern mod coretext { - fn CTFontCreateWithGraphicsFont(graphicsFont: CGFontRef, size: CGFloat, matrix: *CGAffineTransform, attributes: CTFontDescriptorRef) -> CTFontRef; - fn CTFontGetGlyphsForCharacters(font: CTFontRef, characters: *UniChar, glyphs: *CGGlyph, count: CFIndex) -> bool; - fn CTFontGetAdvancesForGlyphs(font: CTFontRef, orientation: CTFontOrientation, glyphs: *CGGlyph, advances: *CGSize, count: CFIndex) -> libc::c_double; + pub extern mod coretext { + pub fn CTFontCreateWithGraphicsFont(graphicsFont: CGFontRef, size: CGFloat, matrix: *CGAffineTransform, attributes: CTFontDescriptorRef) -> CTFontRef; + pub fn CTFontGetGlyphsForCharacters(font: CTFontRef, characters: *UniChar, glyphs: *CGGlyph, count: CFIndex) -> bool; + pub fn CTFontGetAdvancesForGlyphs(font: CTFontRef, orientation: CTFontOrientation, glyphs: *CGGlyph, advances: *CGSize, count: CFIndex) -> libc::c_double; /* metrics API */ - fn CTFontGetAscent(font: CTFontRef) -> libc::c_float; - fn CTFontGetDescent(font: CTFontRef) -> libc::c_float; - fn CTFontGetLeading(font: CTFontRef) -> libc::c_float; - fn CTFontGetUnitsPerEm(font: CTFontRef) -> libc::c_uint; - fn CTFontGetUnderlinePosition(font: CTFontRef) -> libc::c_float; - fn CTFontGetUnderlineThickness(font: CTFontRef) -> libc::c_float; - fn CTFontGetXHeight(font: CTFontRef) -> libc::c_float; - fn CTFontGetBoundingBox(font: CTFontRef) -> CGRect; + pub fn CTFontGetAscent(font: CTFontRef) -> libc::c_float; + pub fn CTFontGetDescent(font: CTFontRef) -> libc::c_float; + pub fn CTFontGetLeading(font: CTFontRef) -> libc::c_float; + pub fn CTFontGetUnitsPerEm(font: CTFontRef) -> libc::c_uint; + pub fn CTFontGetUnderlinePosition(font: CTFontRef) -> libc::c_float; + pub fn CTFontGetUnderlineThickness(font: CTFontRef) -> libc::c_float; + pub fn CTFontGetXHeight(font: CTFontRef) -> libc::c_float; + pub fn CTFontGetBoundingBox(font: CTFontRef) -> CGRect; - fn CFRelease(font: CTFontRef); + pub fn CFRelease(font: CTFontRef); } } -struct QuartzNativeFont { +pub struct QuartzNativeFont { fontprov: CGDataProviderRef, cgfont: CGFontRef, ctfont: CTFontRef, @@ -177,7 +177,7 @@ fn ctfont_from_cgfont(cgfont: CGFontRef) -> coretext::CTFontRef { CTFontCreateWithGraphicsFont(cgfont, 21f as CGFloat, null(), null()) } -fn create(buf: @~[u8]) -> Result<QuartzNativeFont, ()> { +pub fn create(buf: @~[u8]) -> Result<QuartzNativeFont, ()> { let fontprov = vec::as_imm_buf(*buf, |cbuf, len| { CGDataProviderCreateWithData( null(), @@ -196,7 +196,7 @@ fn create(buf: @~[u8]) -> Result<QuartzNativeFont, ()> { } -fn with_test_native_font(f: fn@(nf: &NativeFont)) { +pub fn with_test_native_font(f: fn@(nf: &NativeFont)) { use font::test_font_bin; use unwrap_result = result::unwrap; diff --git a/src/servo/text/shaper.rs b/src/servo/text/shaper.rs index 27e0816e77f..cae01b11f8d 100644 --- a/src/servo/text/shaper.rs +++ b/src/servo/text/shaper.rs @@ -7,7 +7,7 @@ use libc::types::common::c99::int32_t; use libc::{c_uint, c_int, c_void, c_char}; use font::Font; use glyph::{Glyph, GlyphPos, GlyphIndex}; -use ptr::{null, addr_of, offset}; +use ptr::{null, to_unsafe_ptr, offset}; use gfx::geometry::au; use geom::point::Point2D; use font_cache::FontCache; @@ -57,7 +57,7 @@ fn shape_text(font: &Font, text: &str) -> ~[Glyph] unsafe { let funcs = hb_font_funcs_create(); hb_font_funcs_set_glyph_func(funcs, glyph_func, null(), null()); hb_font_funcs_set_glyph_h_advance_func(funcs, glyph_h_advance_func, null(), null()); - hb_font_set_funcs(hbfont, funcs, reinterpret_cast(&addr_of(*font)), null()); + hb_font_set_funcs(hbfont, funcs, reinterpret_cast(&to_unsafe_ptr(font)), null()); let buffer = hb_buffer_create(); @@ -74,10 +74,10 @@ fn shape_text(font: &Font, text: &str) -> ~[Glyph] unsafe { hb_shape(hbfont, buffer, null(), 0 as c_uint); let info_len = 0 as c_uint; - let info_ = hb_buffer_get_glyph_infos(buffer, addr_of(info_len)); + let info_ = hb_buffer_get_glyph_infos(buffer, to_unsafe_ptr(&info_len)); assert info_.is_not_null(); let pos_len = 0 as c_uint; - let pos = hb_buffer_get_glyph_positions(buffer, addr_of(pos_len)); + let pos = hb_buffer_get_glyph_positions(buffer, to_unsafe_ptr(&pos_len)); assert pos.is_not_null(); assert info_len == pos_len; @@ -163,6 +163,6 @@ fn should_get_glyph_h_advance() { let font = lib.get_test_font(); 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| au::from_px(a)); + let expected = (~[6, 4, 7, 9, 8, 7, 10, 8, 9, 9, 7]).map(|a| au::from_px(*a)); assert expected == actual; } diff --git a/src/servo/text/text_run.rs b/src/servo/text/text_run.rs index bdbba729864..e7e908a79ad 100644 --- a/src/servo/text/text_run.rs +++ b/src/servo/text/text_run.rs @@ -34,10 +34,10 @@ impl TextRun { let mut candidate = copy curr_run; if candidate.is_not_empty() { - str::push_str(candidate, " "); // FIXME: just inserting spaces between words can't be right + str::push_str(&mut candidate, " "); // FIXME: just inserting spaces between words can't be right } - str::push_str(candidate, slice); + str::push_str(&mut candidate, slice); let glyphs = shape_text(font, candidate); let size = glyph_run_size(glyphs); @@ -82,8 +82,8 @@ fn glyph_run_size(glyphs: &[Glyph]) -> Size2D<au> { let pen_start_y = height; let pen_start = Point2D(pen_start_x, pen_start_y); let pen_end = glyphs.foldl(pen_start, |cur, glyph| { - 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)) + 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)) }); return Size2D(pen_end.x, pen_end.y); } diff --git a/src/servo/util/color.rs b/src/servo/util/color.rs index 456bf1c525a..2a5cd5d063a 100644 --- a/src/servo/util/color.rs +++ b/src/servo/util/color.rs @@ -9,7 +9,7 @@ use libc::types::os::arch::c95::c_double; use css_colors::*; use cmp::Eq; -enum Color = {red : u8, green : u8, blue : u8, alpha : float}; +pub enum Color = {red : u8, green : u8, blue : u8, alpha : float}; impl Color : Eq { pure fn eq(other: &Color) -> bool { @@ -21,15 +21,15 @@ impl Color : Eq { } } -fn rgba(r : u8, g : u8, b : u8, a : float) -> Color { +pub fn rgba(r : u8, g : u8, b : u8, a : float) -> Color { Color({red : r, green : g, blue : b, alpha : a}) } -fn rgb(r : u8, g : u8, b : u8) -> Color { +pub fn rgb(r : u8, g : u8, b : u8) -> Color { return rgba(r, g, b, 1.0); } -fn hsla(h : float, s : float, l : float, a : float) -> Color { +pub fn hsla(h : float, s : float, l : float, a : float) -> Color { // Algorithm for converting hsl to rbg taken from // http://www.w3.org/TR/2003/CR-css3-color-20030514/#hsl-color let m2 = if l <= 0.5 { l*(s + 1.0) } else { l + s - l*s }; @@ -55,7 +55,7 @@ fn hsla(h : float, s : float, l : float, a : float) -> Color { return rgba(r as u8, g as u8, b as u8, a); } -fn hsl(h : float, s : float, l : float) -> Color { +pub fn hsl(h : float, s : float, l : float) -> Color { return hsla(h, s, l, 1.0); } diff --git a/src/servo/util/time.rs b/src/servo/util/time.rs index 09a06966b50..975d7639055 100644 --- a/src/servo/util/time.rs +++ b/src/servo/util/time.rs @@ -1,7 +1,7 @@ // Timing functions. use std::time::precise_time_ns; -fn time(msg: ~str, callback: fn()) { +pub fn time(msg: ~str, callback: fn()) { let start_time = precise_time_ns(); callback(); let end_time = precise_time_ns(); diff --git a/src/servo/util/tree.rs b/src/servo/util/tree.rs index 32998d506ea..eaf220aea6b 100644 --- a/src/servo/util/tree.rs +++ b/src/servo/util/tree.rs @@ -4,7 +4,7 @@ use core::vec; // // TODO: Use traits. -type Tree<T> = { +pub type Tree<T> = { mut parent: Option<T>, mut first_child: Option<T>, mut last_child: Option<T>, @@ -12,15 +12,15 @@ type Tree<T> = { mut next_sibling: Option<T> }; -trait ReadMethods<T> { +pub trait ReadMethods<T> { fn with_tree_fields<R>(T, f: fn(Tree<T>) -> R) -> R; } -trait WriteMethods<T> { +pub trait WriteMethods<T> { fn with_tree_fields<R>(T, f: fn(Tree<T>) -> R) -> R; } -fn each_child<T:Copy,O:ReadMethods<T>>(ops: O, node: T, f: fn(T) -> bool) { +pub 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 { match copy p { @@ -33,7 +33,7 @@ fn each_child<T:Copy,O:ReadMethods<T>>(ops: O, node: T, f: fn(T) -> bool) { } } -fn empty<T>() -> Tree<T> { +pub fn empty<T>() -> Tree<T> { {mut parent: None, mut first_child: None, mut last_child: None, @@ -41,7 +41,7 @@ fn empty<T>() -> Tree<T> { mut next_sibling: None} } -fn add_child<T:Copy,O:WriteMethods<T>>(ops: O, parent: T, child: T) { +pub fn add_child<T:Copy,O:WriteMethods<T>>(ops: O, parent: T, child: T) { ops.with_tree_fields(child, |child_tf| { match child_tf.parent { @@ -72,7 +72,7 @@ fn add_child<T:Copy,O:WriteMethods<T>>(ops: O, parent: T, child: T) { }); } -fn get_parent<T:Copy,O:ReadMethods<T>>(ops: O, node: T) -> Option<T> { +pub fn get_parent<T:Copy,O:ReadMethods<T>>(ops: O, node: T) -> Option<T> { ops.with_tree_fields(node, |tf| tf.parent) } diff --git a/src/servo/util/url.rs b/src/servo/util/url.rs index 81766f4cd01..90462a45cad 100644 --- a/src/servo/util/url.rs +++ b/src/servo/util/url.rs @@ -17,7 +17,7 @@ Create a URL object from a string. Does various helpful browsery things like #[allow(non_implicitly_copyable_typarams)] fn make_url(str_url: ~str, current_url: Option<Url>) -> Url { let mut schm = url::get_scheme(str_url); - let str_url = if result::is_err(schm) { + let str_url = if result::is_err(&schm) { if current_url.is_none() { // If all we have is a filename, assume it's a local relative file // and build an absolute path with the cwd diff --git a/src/sharegl b/src/sharegl -Subproject 809ba9338f4ab67655786f6f05a60485c9cf56e +Subproject 3914125fc669da3441590a7d5ab76a1b8ff0e21 |