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 index 0b520a6caf1..c201bc1f2c6 160000 --- a/src/rust-azure +++ b/src/rust-azure @@ -1 +1 @@ -Subproject commit 0b520a6caf17b05d25db0026431873ae3f86a456 +Subproject commit c201bc1f2c6cb38d7a81647516f3f55892c8d89d diff --git a/src/rust-cocoa b/src/rust-cocoa index 5019635e3f4..7dff0d5d6dc 160000 --- a/src/rust-cocoa +++ b/src/rust-cocoa @@ -1 +1 @@ -Subproject commit 5019635e3f44851c08716bd44b70229b2d625aa7 +Subproject commit 7dff0d5d6dc40e53989f0db94df74be79bda91c9 diff --git a/src/rust-core-foundation b/src/rust-core-foundation index 22a7aa74798..9733c605bd1 160000 --- a/src/rust-core-foundation +++ b/src/rust-core-foundation @@ -1 +1 @@ -Subproject commit 22a7aa74798117d9dcfb4640290b35b0950f063b +Subproject commit 9733c605bd11dbd2ebbcd45e4629c157bb8cc01d diff --git a/src/rust-geom b/src/rust-geom index 5dea272fc5f..e56e41dc94e 160000 --- a/src/rust-geom +++ b/src/rust-geom @@ -1 +1 @@ -Subproject commit 5dea272fc5f6a9b3812a845d003724d1bcdaf0bb +Subproject commit e56e41dc94e8f8083d484866fcc22d44b7eb2efe diff --git a/src/rust-glut b/src/rust-glut index a038f14ebb1..2886e54d623 160000 --- a/src/rust-glut +++ b/src/rust-glut @@ -1 +1 @@ -Subproject commit a038f14ebb1219fb7ff9808dde98597ed8645482 +Subproject commit 2886e54d6230050ee7a25e590faad969f95a7d16 diff --git a/src/rust-harfbuzz b/src/rust-harfbuzz index fa1de008eb3..f1670147011 160000 --- a/src/rust-harfbuzz +++ b/src/rust-harfbuzz @@ -1 +1 @@ -Subproject commit fa1de008eb31d9401dbc3d6232d6fa4e87d54da3 +Subproject commit f1670147011cee03a94c751d6d77a30c2330ee4d diff --git a/src/rust-http-client b/src/rust-http-client index 28857cda6e8..8cab62f8095 160000 --- a/src/rust-http-client +++ b/src/rust-http-client @@ -1 +1 @@ -Subproject commit 28857cda6e86d4da58cb0e25206b7def6bd87534 +Subproject commit 8cab62f8095e7c99b858da256f4f7042d57d9712 diff --git a/src/rust-hubbub b/src/rust-hubbub index b1184364a73..546e7973848 160000 --- a/src/rust-hubbub +++ b/src/rust-hubbub @@ -1 +1 @@ -Subproject commit b1184364a73b2269b29897466d984aeb5d6e464f +Subproject commit 546e797384821679fe45f8fe549fc8735ba24617 diff --git a/src/rust-layers b/src/rust-layers index 9223fe2a99e..4d916307330 160000 --- a/src/rust-layers +++ b/src/rust-layers @@ -1 +1 @@ -Subproject commit 9223fe2a99ec5c76dc98a98ca99a10ff3513a845 +Subproject commit 4d916307330d5b7e5818c87d3aebda175477b9ae diff --git a/src/rust-mozjs b/src/rust-mozjs index a4ef0a56c99..21de9b86992 160000 --- a/src/rust-mozjs +++ b/src/rust-mozjs @@ -1 +1 @@ -Subproject commit a4ef0a56c990d979fa34fed93293c305a03f67cb +Subproject commit 21de9b86992e4a1d60ef82a8611c1fe08aa81641 diff --git a/src/rust-opengles b/src/rust-opengles index 5a32c07acfc..74a86cbf861 160000 --- a/src/rust-opengles +++ b/src/rust-opengles @@ -1 +1 @@ -Subproject commit 5a32c07acfc06c24bef948a1ddc60eed09a37929 +Subproject commit 74a86cbf8616b34b4fce4891fad21a181a253545 diff --git a/src/rust-stb-image b/src/rust-stb-image index 60b6a4ec1d2..5907c48bf0e 160000 --- a/src/rust-stb-image +++ b/src/rust-stb-image @@ -1 +1 @@ -Subproject commit 60b6a4ec1d2bd63b24383fe31865552d7eedada4 +Subproject commit 5907c48bf0e77562735b8a2fab286a6e5c33a20c 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; +pub type ContentTask = Chan; fn ContentTask(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 { } #[allow(non_implicitly_copyable_typarams)] -fn spawn_css_lexer_task(-url: Url, resource_task: ResourceTask) -> pipes::Port { +pub fn spawn_css_lexer_task(-url: Url, resource_task: ResourceTask) -> pipes::Port { 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 = 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) -> ~[~css::Rule] { +pub fn build_stylesheet(+stream : pipes::Port) -> ~[~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 { 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) } -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 = { mut layout_active: bool, mut free_list: ~[Handle], @@ -76,13 +71,13 @@ fn ScopeResource(d : ScopeData) -> ScopeResource { ScopeResource { d: d } } -type Scope = @ScopeResource; +pub type Scope = @ScopeResource; type HandleData = {mut read_ptr: *T, mut write_ptr: *mut T, mut read_aux: *A, mut next_dirty: Handle}; -enum Handle { +pub enum Handle { _Handle(*HandleData) } @@ -118,7 +113,7 @@ impl Handle { **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() -> Handle { _Handle(ptr::null()) } -fn Scope() -> Scope { +pub fn Scope() -> Scope { @ScopeResource({mut layout_active: false, mut free_list: ~[], mut first_dirty: null_handle()}) @@ -219,12 +214,12 @@ impl Scope { let d: *HandleData = cast::reinterpret_cast( &libc::malloc(sys::size_of::>() 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, } -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(+compositor: C) -> EngineTask { - let resource_task = ResourceTask(); - let image_cache_task = ImageCacheTask(resource_task); - EngineTask_(compositor, resource_task, image_cache_task) -} - -fn EngineTask_( - +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 { +pub struct Engine { 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 Engine { - fn run(+request: EngineProto::server::Running) { - use EngineProto::*; - let mut request = request; +pub fn Engine(compositor: C, + resource_task: ResourceTask, + image_cache_task: ImageCacheTask) -> Engine { + 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); - 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; - }, + 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 + } +} - Exit -> channel { - self.content_task.send(content_task::ExitMsg); - self.layout_task.send(layout_task::ExitMsg); +impl Engine { + fn start() -> comm::Chan { + do spawn_listener:: |request| { + while self.handle_request(request.recv()) { + // Go on... + } + } + } - let (response_chan, response_port) = pipes::stream(); - self.render_task.send(render_task::ExitMsg(response_chan)); - response_port.recv(); + 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; + } - self.image_cache_task.exit(); - self.resource_task.send(resource_task::Exit); + ExitMsg(sender) => { + self.content_task.send(content_task::ExitMsg); + self.layout_task.send(layout_task::ExitMsg); + + let (response_chan, response_port) = pipes::stream(); - server::Exited(channel); - break - } - } - ) + 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; + } } } } -proto! EngineProto( - Running:send { - LoadURL(Url) -> Running, - Exit -> Exiting - } - - Exiting:recv { - Exited -> ! - } -) +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, r: u8, g: u8, b: u8) -> DisplayItem { +pub fn SolidColor(bounds: Rect, 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, r: u8, g: u8, b: u8) -> DisplayItem { } } -fn Glyphs(bounds: Rect, run: GlyphRun) -> DisplayItem { +pub fn Glyphs(bounds: Rect, run: GlyphRun) -> DisplayItem { DisplayItem { draw: |self, ctx| draw_Glyphs(self, ctx), bounds: bounds, @@ -72,7 +72,7 @@ fn Glyphs(bounds: Rect, run: GlyphRun) -> DisplayItem { } // ARC should be cloned into ImageData, but Images are not sendable -fn Image(bounds: Rect, image: ARC<~image::base::Image>) -> DisplayItem { +pub fn Image(bounds: Rect, 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, 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(x: A, y: A, w: A, h: A) -> Rect { +pub fn box(x: A, y: A, w: A, h: A) -> Rect { Rect(Point2D(x, y), Size2D(w, h)) } -fn zero_rect() -> Rect { +pub fn zero_rect() -> Rect { let z = au(0); Rect(Point2D(z, z), Size2D(z, z)) } -fn zero_point() -> Point2D { +pub fn zero_point() -> Point2D { Point2D(au(0), au(0)) } -fn zero_size() -> Size2D { +pub fn zero_size() -> Size2D { 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; +pub type Renderer = comm::Chan; pub enum Msg { RenderMsg(dl::DisplayList), @@ -35,9 +36,9 @@ struct RenderContext { font_cache: @FontCache, } -type RenderTask = comm::Chan; +pub type RenderTask = comm::Chan; -fn RenderTask(+compositor: C) -> RenderTask { +pub fn RenderTask(+compositor: C) -> RenderTask { do task::spawn_listener |po: comm::Port| { 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, image: ARC<~Image>) { } pub fn draw_glyphs(ctx: &RenderContext, bounds: Rect, 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, 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, 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, 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, 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, format: format, buffer: ~[u8] @@ -30,7 +30,7 @@ impl format { } } -fn image_surface(size: Size2D, format: format) -> image_surface { +pub fn image_surface(size: Size2D, 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, 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, comm::Chan) = do task::spawn_conversation |css_port: comm::Port, @@ -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