servo: Update to Rust 754704ea9442ce92602f8022f6c979824b016842

This commit is contained in:
Patrick Walton 2012-10-18 17:03:08 -07:00
parent adeae3c46c
commit 162f1546b0
53 changed files with 597 additions and 594 deletions

@ -1 +1 @@
Subproject commit 1104c30097301728beb81694296ebd28a4d08a48
Subproject commit 6ef2001b3cddedff0a1d818845ea50f8ce18925d

@ -1 +1 @@
Subproject commit c01df253ddc93a36af6c23a67f87e803024a9275
Subproject commit b374a6ca92ed97088603fd54f00618fe6e569b04

@ -1 +1 @@
Subproject commit d34013f5ac8effdedd213b19c6685898be46dbf6
Subproject commit 89af41556ef59cacb2b2819d53e3235e7f46a859

@ -1 +1 @@
Subproject commit fe04eedea0cdb6ea6950b32264249d5a2aeca13d
Subproject commit a6e3cc961e75fef91e82e46c76db3d3acbbd8770

@ -1 +1 @@
Subproject commit 1558022390743fc5d29d43bcacc1aa500a9ff7a1
Subproject commit 479fb5152a64e81e649650df63d99f3b986d3329

View file

@ -45,7 +45,7 @@ use std::cell::Cell;
use js::glue::bindgen::RUST_JSVAL_TO_OBJECT;
use js::JSVAL_NULL;
use js::jsapi::{JSContext, jsval};
use js::jsapi::{JSContext, JSVal};
use js::jsapi::bindgen::{JS_CallFunctionValue, JS_GetContextPrivate};
use ptr::null;
@ -70,20 +70,23 @@ fn ContentTask(layout_task: LayoutTask,
let (control_chan, control_port) = pipes::stream();
let control_chan = pipes::SharedChan(control_chan);
let control_chan = pipes::SharedChan(move control_chan);
let control_chan_copy = control_chan.clone();
let control_port = Cell(control_port);
let dom_event_port = Cell(dom_event_port);
let dom_event_chan = Cell(dom_event_chan);
let control_port = Cell(move control_port);
let dom_event_port = Cell(move dom_event_port);
let dom_event_chan = Cell(move dom_event_chan);
do task().sched_mode(SingleThreaded).spawn {
do task().sched_mode(SingleThreaded).spawn |move layout_task, move control_port,
move control_chan_copy, move resource_task,
move img_cache_task, move dom_event_port,
move dom_event_chan| {
let content = Content(layout_task, control_port.take(), control_chan_copy.clone(),
resource_task, img_cache_task.clone(),
dom_event_port.take(), dom_event_chan.take());
content.start();
}
return control_chan;
return move control_chan;
}
struct Content {
@ -130,13 +133,13 @@ fn Content(layout_task: LayoutTask,
};
let content = @Content {
layout_task : layout_task,
layout_task : move layout_task,
layout_join_port : None,
image_cache_task : img_cache_task,
control_port : control_port,
control_chan : control_chan,
event_port : event_port,
event_chan : event_chan,
image_cache_task : move img_cache_task,
control_port : move control_port,
control_chan : move control_chan,
event_port : move event_port,
event_chan : move event_chan,
scope : NodeScope(),
jsrt : jsrt,
@ -198,12 +201,12 @@ impl Content {
debug!("js_scripts: %?", js_scripts);
let document = Document(root, self.scope, css_rules);
let document = Document(root, self.scope, move css_rules);
let window = Window(self.control_chan.clone());
self.relayout(&document, &url);
self.document = Some(@document);
self.window = Some(@window);
self.doc_url = Some(copy url);
self.document = Some(@move document);
self.window = Some(@move window);
self.doc_url = Some(move url);
let compartment = option::expect(&self.compartment, ~"TODO error checking");
compartment.define_functions(debug_fns);
@ -211,8 +214,8 @@ impl Content {
option::get(&self.document),
option::get(&self.window));
do vec::consume(js_scripts) |_i, bytes| {
self.cx.evaluate_script(compartment.global_obj, bytes, ~"???", 1u);
do vec::consume(move js_scripts) |_i, bytes| {
self.cx.evaluate_script(compartment.global_obj, move bytes, ~"???", 1u);
}
return true;
@ -226,7 +229,7 @@ impl Content {
compartment.global_obj.ptr
};
let rval = JSVAL_NULL;
//TODO: support extra args. requires passing a *jsval argv
//TODO: support extra args. requires passing a *JSVal argv
JS_CallFunctionValue(self.cx.ptr, thisValue, timerData.funval,
0, null(), ptr::to_unsafe_ptr(&rval));
self.relayout(self.document.get(), &self.doc_url.get());
@ -244,7 +247,7 @@ impl Content {
Ok(move bytes) => {
let compartment = option::expect(&self.compartment, ~"TODO error checking");
compartment.define_functions(debug_fns);
self.cx.evaluate_script(compartment.global_obj, bytes, copy url.path, 1u);
self.cx.evaluate_script(compartment.global_obj, move bytes, copy url.path, 1u);
}
}
return true;
@ -297,7 +300,7 @@ impl Content {
// Layout will let us know when it's done
let (join_chan, join_port) = pipes::stream();
self.layout_join_port = move Some(join_port);
self.layout_join_port = move Some(move join_port);
// Send new document and relevant styles to layout

View file

@ -60,7 +60,7 @@ impl CssLexer : CssLexerMethods {
};
#debug["token=%?", token];
return token;
return move token;
}
fn parse_css_relation(c : u8) -> Token {
@ -76,7 +76,7 @@ impl CssLexer : CssLexerMethods {
self.input_state.eat_whitespace();
return token;
return move token;
}
fn parse_css_element(c : u8) -> Token {
@ -98,7 +98,7 @@ impl CssLexer : CssLexerMethods {
self.parser_state = CssAttribute;
return Element(element);
return move Element(move element);
}
fn parse_css_attribute(c : u8) -> Token {
@ -130,21 +130,21 @@ impl CssLexer : CssLexerMethods {
}
if ch == ']' as u8 {
return Attr(css::values::Exists(attr_name));
return Attr(css::values::Exists(move attr_name));
} else if ch == '=' as u8 {
let attr_val = self.input_state.parse_ident();
self.input_state.expect(']' as u8);
return Attr(css::values::Exact(attr_name, attr_val));
return Attr(css::values::Exact(move attr_name, move attr_val));
} else if ch == '~' as u8 {
self.input_state.expect('=' as u8);
let attr_val = self.input_state.parse_ident();
self.input_state.expect(']' as u8);
return Attr(css::values::Includes(attr_name, attr_val));
return Attr(css::values::Includes(move attr_name, move attr_val));
} else if ch == '|' as u8 {
self.input_state.expect('=' as u8);
let attr_val = self.input_state.parse_ident();
self.input_state.expect(']' as u8);
return Attr(css::values::StartsWith(attr_name, attr_val));
return Attr(css::values::StartsWith(move attr_name, move attr_val));
}
fail #fmt("Unexpected symbol %c in attribute", ch as char);
@ -244,7 +244,7 @@ fn lex_css_from_bytes(input_port: comm::Port<ProgressMsg>, result_chan : &Chan<T
let token = lexer.parse_css();
let should_break = match token { Eof => true, _ => false };
result_chan.send(token);
result_chan.send(move token);
if should_break {
break;
@ -255,7 +255,7 @@ fn lex_css_from_bytes(input_port: comm::Port<ProgressMsg>, result_chan : &Chan<T
fn spawn_css_lexer_from_string(content : ~str) -> pipes::Port<Token> {
let (result_chan, result_port) = pipes::stream();
do task::spawn {
do task::spawn |move result_chan, move content| {
let input_port = comm::Port();
input_port.send(Payload(str::to_bytes(content)));
input_port.send(Done(Ok(())));
@ -263,14 +263,14 @@ fn spawn_css_lexer_from_string(content : ~str) -> pipes::Port<Token> {
lex_css_from_bytes(input_port, &result_chan);
}
return result_port;
return move result_port;
}
#[allow(non_implicitly_copyable_typarams)]
pub fn spawn_css_lexer_task(url: Url, resource_task: ResourceTask) -> pipes::Port<Token> {
let (result_chan, result_port) = pipes::stream();
do task::spawn || {
do task::spawn |move result_chan, move url| {
assert url.path.ends_with(".css");
let input_port = Port();
// TODO: change copy to move once the compiler permits it
@ -279,5 +279,5 @@ pub fn spawn_css_lexer_task(url: Url, resource_task: ResourceTask) -> pipes::Por
lex_css_from_bytes(input_port, &result_chan);
};
return result_port;
return move result_port;
}

View file

@ -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 mod tok = lexer;
use tok = lexer;
use lexer::Token;
use comm::recv;
use option::{map, is_none};
@ -34,7 +34,7 @@ impl TokenReader : TokenReaderMethods {
fn unget(tok : Token) {
assert is_none(&self.lookahead);
self.lookahead = Some(tok);
self.lookahead = Some(move tok);
}
}
@ -49,8 +49,8 @@ impl TokenReader : ParserMethods {
fn parse_element() -> Option<~css::Selector> {
// Get the current element type
let elmt_name = match self.get() {
tok::Element(tag) => { copy tag }
tok::Eof => { return None; }
lexer::Element(tag) => { copy tag }
lexer::Eof => { return None; }
_ => { fail ~"Expected an element" }
};
@ -60,9 +60,9 @@ impl TokenReader : ParserMethods {
loop {
let token = self.get();
match token {
tok::Attr(attr) => { push(&mut attr_list, copy attr); }
lexer::Attr(attr) => { push(&mut attr_list, copy attr); }
tok::StartDescription | tok::Descendant | tok::Child | tok::Sibling | tok::Comma => {
self.unget(token);
self.unget(move token);
break;
}
tok::Eof => { return None; }
@ -71,7 +71,7 @@ impl TokenReader : ParserMethods {
tok::Description(_, _) => fail ~"Unexpected description"
}
}
return Some(~css::Element(elmt_name, attr_list));
return Some(~css::Element(move elmt_name, move attr_list));
}
fn parse_selector() -> Option<~[~css::Selector]> {
@ -95,7 +95,7 @@ impl TokenReader : ParserMethods {
match self.parse_element() {
Some(elmt) => {
let new_sel = copy elmt;
cur_sel <- ~css::Descendant(built_sel, new_sel)
cur_sel <- ~css::Descendant(move built_sel, move new_sel)
}
None => { return None; }
}
@ -104,7 +104,7 @@ impl TokenReader : ParserMethods {
match self.parse_element() {
Some(elmt) => {
let new_sel = copy elmt;
cur_sel <- ~css::Child(built_sel, new_sel)
cur_sel <- ~css::Child(move built_sel, move new_sel)
}
None => { return None; }
}
@ -113,18 +113,18 @@ impl TokenReader : ParserMethods {
match self.parse_element() {
Some(elmt) => {
let new_sel = copy elmt;
cur_sel <- ~css::Sibling(built_sel, new_sel)
cur_sel <- ~css::Sibling(move built_sel, move new_sel)
}
None => { return None; }
}
}
tok::StartDescription => {
push(&mut sel_list, built_sel);
push(&mut sel_list, move built_sel);
self.unget(tok::StartDescription);
break;
}
tok::Comma => {
push(&mut sel_list, built_sel);
push(&mut sel_list, move built_sel);
self.unget(tok::Comma);
break;
}
@ -141,11 +141,11 @@ impl TokenReader : ParserMethods {
match tok {
tok::StartDescription => { break; }
tok::Comma => { }
_ => { self.unget(tok); }
_ => { self.unget(move tok); }
}
}
return Some(sel_list);
return Some(move sel_list);
}
fn parse_description() -> Option<~[StyleDeclaration]> {
@ -187,7 +187,7 @@ impl TokenReader : ParserMethods {
}
}
return Some(desc_list);
return Some(move desc_list);
}
fn parse_rule() -> Option<~css::Rule> {
@ -207,13 +207,13 @@ impl TokenReader : ParserMethods {
#debug("desc_list: %?", desc_list);
return Some(~(sel_list, desc_list));
return Some(~(move sel_list, move desc_list));
}
}
pub fn build_stylesheet(stream : pipes::Port<Token>) -> ~[~css::Rule] {
let mut rule_list = ~[];
let reader = {stream : stream, mut lookahead : None};
let reader = {stream : move stream, mut lookahead : None};
loop {
match reader.parse_rule() {
@ -222,5 +222,5 @@ pub fn build_stylesheet(stream : pipes::Port<Token>) -> ~[~css::Rule] {
}
}
return rule_list;
return move rule_list;
}

View file

@ -1,7 +1,7 @@
use js::rust::{compartment, bare_compartment, methods, jsobj};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED,
JSVAL_NULL, JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_DefineProperties};
@ -60,7 +60,7 @@ enum Element = int;
return 1;
}*/
extern fn getDocumentElement(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
extern fn getDocumentElement(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
-> JSBool unsafe {
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
if obj.is_null() {

View file

@ -3,7 +3,7 @@ use au::au;
use js::rust::{bare_compartment, methods, jsobj};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty};
@ -65,7 +65,7 @@ pub fn init(compartment: &bare_compartment) {
}
#[allow(non_implicitly_copyable_typarams)]
extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
-> JSBool unsafe {
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
if obj.is_null() {
@ -99,7 +99,7 @@ extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsva
}
#[allow(non_implicitly_copyable_typarams)]
extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
-> JSBool unsafe {
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
if obj.is_null() {
@ -125,7 +125,7 @@ extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsva
}
#[allow(non_implicitly_copyable_typarams)]
extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut JSVal)
-> JSBool {
unsafe {
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
@ -171,7 +171,7 @@ pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe {
//TODO error checking
let compartment = utils::get_compartment(cx);
let obj = result::unwrap(
compartment.new_object_with_proto(~"GenericElementInstance", proto,
compartment.new_object_with_proto(~"GenericElementInstance", move proto,
compartment.global_obj.ptr));
unsafe {

View file

@ -1,7 +1,7 @@
use js::rust::{bare_compartment, methods, jsobj};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
JS_THIS_OBJECT, JS_SET_RVAL, JSPROP_NATIVE_ACCESSORS};
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp, JSPropertySpec};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate};
@ -79,7 +79,7 @@ unsafe fn unwrap(obj: *JSObject) -> *rust_box<NodeBundle> {
}
#[allow(non_implicitly_copyable_typarams)]
extern fn getFirstChild(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBool {
extern fn getFirstChild(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
unsafe {
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
if obj.is_null() {
@ -103,7 +103,7 @@ extern fn getFirstChild(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBool
}
#[allow(non_implicitly_copyable_typarams)]
extern fn getNextSibling(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBool {
extern fn getNextSibling(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
unsafe {
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
if obj.is_null() {
@ -139,7 +139,7 @@ impl NodeBundle {
}
}
extern fn getNodeType(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBool {
extern fn getNodeType(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
unsafe {
let obj = JS_THIS_OBJECT(cx, cast::reinterpret_cast(&vp));
if obj.is_null() {

View file

@ -1,7 +1,7 @@
use js::rust::{compartment, bare_compartment, methods};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
JS_THIS_OBJECT, JS_SET_RVAL};
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate,
@ -27,12 +27,12 @@ unsafe fn squirrel_away<T>(x: @T) -> *rust_box<T> {
unsafe fn squirrel_away_unique<T>(x: ~T) -> *rust_box<T> {
let y: *rust_box<T> = cast::reinterpret_cast(&x);
cast::forget(x);
cast::forget(move x);
y
}
//XXX very incomplete
fn jsval_to_str(cx: *JSContext, v: jsval) -> Result<~str, ()> {
fn jsval_to_str(cx: *JSContext, v: JSVal) -> Result<~str, ()> {
let jsstr;
if RUST_JSVAL_IS_STRING(v) == 1 {
jsstr = RUST_JSVAL_TO_STRING(v)
@ -55,7 +55,7 @@ fn jsval_to_str(cx: *JSContext, v: jsval) -> Result<~str, ()> {
}
}
unsafe fn domstring_to_jsval(cx: *JSContext, str: &DOMString) -> jsval {
unsafe fn domstring_to_jsval(cx: *JSContext, str: &DOMString) -> JSVal {
match *str {
null_string => {
JSVAL_NULL
@ -80,7 +80,7 @@ pub fn get_compartment(cx: *JSContext) -> compartment {
}
}
extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *jsval, bp: *mut JSBool) -> JSBool {
extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *JSVal, bp: *mut JSBool) -> JSBool {
//XXXjdm this is totally broken for non-object values
let mut o = RUST_JSVAL_TO_OBJECT(unsafe {*v});
let obj = unsafe {*obj};
@ -95,8 +95,8 @@ extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *jsval, bp: *mut JSB
return 1;
}
pub fn prototype_jsclass(name: ~str) -> fn(compartment: bare_compartment) -> JSClass {
|compartment: bare_compartment| {
pub fn prototype_jsclass(name: ~str) -> fn(compartment: &bare_compartment) -> JSClass {
|compartment: &bare_compartment, move name| {
{name: compartment.add_name(copy name),
flags: 0,
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
@ -124,8 +124,8 @@ pub fn prototype_jsclass(name: ~str) -> fn(compartment: bare_compartment) -> JSC
}
pub fn instance_jsclass(name: ~str, finalize: *u8)
-> fn(compartment: bare_compartment) -> JSClass {
|compartment: bare_compartment| {
-> fn(compartment: &bare_compartment) -> JSClass {
|compartment: &bare_compartment, move name| {
{name: compartment.add_name(copy name),
flags: JSCLASS_HAS_RESERVED_SLOTS(1),
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
@ -160,7 +160,7 @@ pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: &bar
//TODO error checking
let obj = result::unwrap(
match move proto {
Some(move s) => compartment.new_object_with_proto(copy name, s,
Some(move s) => compartment.new_object_with_proto(copy name, move s,
compartment.global_obj.ptr),
None => compartment.new_object(copy name, null(), compartment.global_obj.ptr)
});
@ -169,6 +169,6 @@ pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: &bar
GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8,
JSPROP_ENUMERATE);
compartment.stash_global_proto(name, obj);
compartment.stash_global_proto(move name, obj);
return obj;
}

View file

@ -1,7 +1,7 @@
use js::rust::{bare_compartment, methods};
use js::{JS_ARGV, JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL,
JS_THIS_OBJECT, JS_SET_RVAL};
use js::jsapi::{JSContext, jsval, JSObject, JSBool, jsid, JSClass, JSFreeOp};
use js::jsapi::{JSContext, JSVal, JSObject, JSBool, jsid, JSClass, JSFreeOp};
use js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_ReportError,
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_DefineProperties, JS_EncodeString, JS_free};
@ -17,7 +17,7 @@ use dom::window::{Window, TimerMessage_Fire};
use dom::node::Node;
use dvec::DVec;
extern fn alert(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool {
extern fn alert(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool {
unsafe {
let argv = JS_ARGV(cx, vp);
assert (argc == 1);
@ -31,7 +31,7 @@ extern fn alert(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool {
1_i32
}
extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool unsafe {
extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool unsafe {
let argv = JS_ARGV(cx, vp);
assert (argc >= 2);
@ -45,7 +45,7 @@ extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool unsafe
return 1;
}
extern fn close(cx: *JSContext, _argc: c_uint, vp: *jsval) -> JSBool unsafe {
extern fn close(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool unsafe {
(*unwrap(JS_THIS_OBJECT(cx, vp))).payload.close();
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return 1;

View file

@ -78,7 +78,7 @@ struct ScopeResource<T:Send,A> {
}
fn ScopeResource<T:Send,A>(d : ScopeData<T,A>) -> ScopeResource<T,A> {
ScopeResource { d: d }
ScopeResource { d: move d }
}
pub type Scope<T:Send,A> = @ScopeResource<T,A>;

View file

@ -12,6 +12,6 @@ fn Document(root: Node, scope: NodeScope, css_rules: Stylesheet) -> Document {
Document {
root : root,
scope : scope,
css_rules : ARC(css_rules),
css_rules : ARC(move css_rules),
}
}

View file

@ -23,7 +23,7 @@ impl ElementData {
fn set_attr(name: &str, value: ~str) {
let idx = do self.attrs.position |attr| { name == attr.name };
match idx {
Some(idx) => self.attrs.set_elt(idx, ~Attr(name.to_str(), value)),
Some(idx) => self.attrs.set_elt(idx, ~Attr(name.to_str(), move value)),
None => {}
}
}
@ -31,8 +31,8 @@ impl ElementData {
fn ElementData(tag_name: ~str, kind: ~ElementKind) -> ElementData {
ElementData {
tag_name : tag_name,
kind : kind,
tag_name : move tag_name,
kind : move kind,
attrs : DVec(),
}
}
@ -44,8 +44,8 @@ struct Attr {
fn Attr(name: ~str, value: ~str) -> Attr {
Attr {
name : name,
value : value,
name : move name,
value : move value,
}
}

View file

@ -6,10 +6,9 @@ use dom::document::Document;
use dom::element::{Attr, ElementData};
use dom::window::Window;
use geom::size::Size2D;
use gfx::geometry::au;
use js::crust::*;
use js::glue::bindgen::RUST_OBJECT_TO_JSVAL;
use js::jsapi::{JSClass, JSObject, JSPropertySpec, JSContext, jsid, jsval, JSBool};
use js::jsapi::{JSClass, JSObject, JSPropertySpec, JSContext, jsid, JSVal, JSBool};
use js::rust::{bare_compartment, compartment, methods};
use js::{JSPROP_ENUMERATE, JSPROP_SHARED};
use layout::debug::DebugMethods;
@ -90,9 +89,9 @@ struct DoctypeData {
fn DoctypeData(name: ~str, public_id: Option<~str>,
system_id: Option<~str>, force_quirks: bool) -> DoctypeData {
DoctypeData {
name : name,
public_id : public_id,
system_id : system_id,
name : move name,
public_id : move public_id,
system_id : move system_id,
force_quirks : force_quirks,
}
}
@ -133,7 +132,7 @@ trait NodeScopeExtensions {
#[allow(non_implicitly_copyable_typarams)]
impl NodeScope : NodeScopeExtensions {
fn new_node(k: NodeKind) -> Node {
self.handle(&NodeData({tree: tree::empty(), kind: ~k}))
self.handle(&NodeData({tree: tree::empty(), kind: ~move k}))
}
}

View file

@ -1,6 +1,6 @@
use comm::{Port, Chan};
use content::content_task::{ControlMsg, Timer, ExitMsg};
use js::jsapi::jsval;
use js::jsapi::JSVal;
use dvec::DVec;
enum TimerControlMsg {
@ -21,11 +21,11 @@ struct Window {
// (ie. function value to invoke and all arguments to pass
// to the function when calling it)
pub struct TimerData {
funval: jsval,
args: DVec<jsval>,
funval: JSVal,
args: DVec<JSVal>,
}
pub 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(),
@ -37,7 +37,7 @@ pub fn TimerData(argc: libc::c_uint, argv: *jsval) -> TimerData unsafe {
i += 1;
};
data
move data
}
// FIXME: delayed_send shouldn't require Copy
@ -52,7 +52,7 @@ impl Window {
self.timer_chan.send(TimerMessage_TriggerExit);
}
fn setTimeout(&self, timeout: int, argc: libc::c_uint, argv: *jsval) {
fn setTimeout(&self, timeout: int, argc: libc::c_uint, argv: *JSVal) {
let timeout = int::max(0, timeout) as uint;
// Post a delayed message to the per-window timer task; it will dispatch it
@ -66,12 +66,13 @@ impl Window {
fn Window(content_chan: pipes::SharedChan<ControlMsg>) -> Window {
Window {
timer_chan: do task::spawn_listener |timer_port: Port<TimerControlMsg>| {
timer_chan: do task::spawn_listener |timer_port: Port<TimerControlMsg>,
move content_chan| {
loop {
match timer_port.recv() {
match move timer_port.recv() {
TimerMessage_Close => break,
TimerMessage_Fire(td) => {
content_chan.send(Timer(copy td));
TimerMessage_Fire(move td) => {
content_chan.send(Timer(move td));
}
TimerMessage_TriggerExit => content_chan.send(ExitMsg)
}

View file

@ -38,10 +38,11 @@ fn Engine<C:Compositor Send Copy>(compositor: C,
resource_task: ResourceTask,
image_cache_task: ImageCacheTask) -> EngineTask {
let dom_event_port = Cell(dom_event_port);
let dom_event_chan = Cell(dom_event_chan);
let dom_event_port = Cell(move dom_event_port);
let dom_event_chan = Cell(move dom_event_chan);
do spawn_listener::<Msg> |request, move dom_event_port, move dom_event_chan| {
do spawn_listener::<Msg> |request, move dom_event_port, move dom_event_chan,
move image_cache_task| {
let render_task = RenderTask(compositor);
let layout_task = LayoutTask(render_task, image_cache_task.clone());
let content_task = ContentTask(layout_task,
@ -53,9 +54,9 @@ fn Engine<C:Compositor Send Copy>(compositor: C,
compositor: compositor,
render_task: render_task,
resource_task: resource_task,
image_cache_task: image_cache_task,
layout_task: layout_task,
content_task: content_task
image_cache_task: image_cache_task.clone(),
layout_task: move layout_task,
content_task: move content_task
}.run();
}
}
@ -68,25 +69,23 @@ impl<C: Compositor Copy Send> Engine<C> {
}
fn handle_request(request: Msg) -> bool {
match request {
LoadURLMsg(url) => {
// TODO: change copy to move once we have match move
let url = copy url;
match move request {
LoadURLMsg(move url) => {
if url.path.ends_with(".js") {
self.content_task.send(ExecuteMsg(url))
self.content_task.send(ExecuteMsg(move url))
} else {
self.content_task.send(ParseMsg(url))
self.content_task.send(ParseMsg(move url))
}
return true;
}
ExitMsg(sender) => {
ExitMsg(move 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));
self.render_task.send(render_task::ExitMsg(move response_chan));
response_port.recv();
self.image_cache_task.exit();

View file

@ -16,7 +16,7 @@ pub use layout::display_list_builder::DisplayListBuilder;
// TODO: invert this so common data is nested inside each variant as first arg.
struct DisplayItem {
draw: ~fn((&DisplayItem), (&RenderContext)),
bounds : Rect<au>, // TODO: whose coordinate system should this use?
bounds : Rect<Au>, // TODO: whose coordinate system should this use?
data : DisplayItemData
}
@ -27,7 +27,7 @@ pub enum DisplayItemData {
// TODO: don't copy text runs, ever.
TextData(~SendableTextRun, Range),
ImageData(ARC<~image::base::Image>),
BorderData(au, u8, u8, u8)
BorderData(Au, u8, u8, u8)
}
fn draw_SolidColor(self: &DisplayItem, ctx: &RenderContext) {
@ -61,7 +61,7 @@ fn draw_Border(self: &DisplayItem, ctx: &RenderContext) {
}
}
pub 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 {
draw: |self, ctx| draw_SolidColor(self, ctx),
bounds: bounds,
@ -69,7 +69,7 @@ pub fn SolidColor(bounds: Rect<au>, r: u8, g: u8, b: u8) -> DisplayItem {
}
}
pub fn Border(bounds: Rect<au>, width: au, r: u8, g: u8, b: u8) -> DisplayItem {
pub fn Border(bounds: Rect<Au>, width: Au, r: u8, g: u8, b: u8) -> DisplayItem {
DisplayItem {
draw: |self, ctx| draw_Border(self, ctx),
bounds: bounds,
@ -77,20 +77,20 @@ pub fn Border(bounds: Rect<au>, width: au, r: u8, g: u8, b: u8) -> DisplayItem {
}
}
pub fn Text(bounds: Rect<au>, run: ~SendableTextRun, range: Range) -> DisplayItem {
pub fn Text(bounds: Rect<Au>, run: ~SendableTextRun, range: Range) -> DisplayItem {
DisplayItem {
draw: |self, ctx| draw_Text(self, ctx),
bounds: bounds,
data: TextData(run, range)
data: TextData(move run, move range)
}
}
// ARC should be cloned into ImageData, but Images are not sendable
pub fn Image(bounds: Rect<au>, image: ARC<~image::base::Image>) -> DisplayItem {
pub fn Image(bounds: Rect<Au>, image: ARC<~image::base::Image>) -> DisplayItem {
DisplayItem {
draw: |self, ctx| draw_Image(self, ctx),
bounds: bounds,
data: ImageData(image)
data: ImageData(move image)
}
}

View file

@ -3,74 +3,74 @@ use geom::rect::Rect;
use geom::size::Size2D;
use num::{Num, from_int};
pub 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 neg() -> au { au(-*self) }
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 neg() -> Au { Au(-*self) }
pure fn to_int() -> int { *self as int }
static pure fn from_int(n: int) -> au {
au((n & (i32::max_value as int)) as i32)
static pure fn from_int(n: int) -> Au {
Au((n & (i32::max_value as int)) as i32)
}
}
impl au : cmp::Ord {
pure fn lt(other: &au) -> bool { *self < **other }
pure fn le(other: &au) -> bool { *self <= **other }
pure fn ge(other: &au) -> bool { *self >= **other }
pure fn gt(other: &au) -> bool { *self > **other }
impl Au : cmp::Ord {
pure fn lt(other: &Au) -> bool { *self < **other }
pure fn le(other: &Au) -> bool { *self <= **other }
pure fn ge(other: &Au) -> bool { *self >= **other }
pure fn gt(other: &Au) -> bool { *self > **other }
}
impl au : cmp::Eq {
pure fn eq(other: &au) -> bool { *self == **other }
pure fn ne(other: &au) -> bool { *self != **other }
impl Au : cmp::Eq {
pure fn eq(other: &Au) -> bool { *self == **other }
pure fn ne(other: &Au) -> bool { *self != **other }
}
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 } }
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 } }
pub fn box<A:Copy Num>(x: A, y: A, w: A, h: A) -> Rect<A> {
Rect(Point2D(x, y), Size2D(w, h))
}
impl au {
pub fn scale_by(factor: float) -> au {
au(((*self as float) * factor) as i32)
impl Au {
pub fn scale_by(factor: float) -> Au {
Au(((*self as float) * factor) as i32)
}
}
pub pure fn zero_rect() -> Rect<au> {
let z = au(0);
pub pure fn zero_rect() -> Rect<Au> {
let z = Au(0);
Rect(Point2D(z, z), Size2D(z, z))
}
pub pure fn zero_point() -> Point2D<au> {
Point2D(au(0), au(0))
pub pure fn zero_point() -> Point2D<Au> {
Point2D(Au(0), Au(0))
}
pub pure fn zero_size() -> Size2D<au> {
Size2D(au(0), au(0))
pub pure fn zero_size() -> Size2D<Au> {
Size2D(Au(0), Au(0))
}
pub pure fn from_frac_px(f: float) -> au {
au((f * 60f) as i32)
pub pure fn from_frac_px(f: float) -> Au {
Au((f * 60f) as i32)
}
pub pure fn from_px(i: int) -> au {
pub pure fn from_px(i: int) -> Au {
from_int(i * 60)
}
pub pure fn to_px(au: au) -> int {
pub pure fn to_px(au: Au) -> int {
(*au / 60) as int
}
// assumes 72 points per inch, and 96 px per inch
pub pure fn from_pt(f: float) -> au {
pub pure fn from_pt(f: float) -> Au {
from_px((f / 72f * 96f) as int)
}
}

View file

@ -40,10 +40,10 @@ pub enum Msg {
impl Chan<Msg> : Compositor {
fn begin_drawing(next_dt: pipes::Chan<LayerBuffer>) {
self.send(BeginDrawing(next_dt))
self.send(BeginDrawing(move next_dt))
}
fn draw(next_dt: pipes::Chan<LayerBuffer>, draw_me: LayerBuffer) {
self.send(Draw(next_dt, draw_me))
self.send(Draw(move next_dt, move draw_me))
}
}
@ -66,7 +66,7 @@ pub fn PngCompositor(output: Chan<~[u8]>) -> PngCompositor {
}
Draw(move sender, move layer_buffer) => {
debug!("png_compositor: draw");
do_draw(sender, layer_buffer, output, &cairo_surface);
do_draw(move sender, move layer_buffer, output, &cairo_surface);
}
Exit => break
}
@ -80,7 +80,7 @@ fn do_draw(sender: pipes::Chan<LayerBuffer>,
cairo_surface: &ImageSurface) {
let buffer = BytesWriter();
cairo_surface.write_to_png_stream(&buffer);
output.send(buffer.buf.get());
output.send(buffer.bytes.get());
// Send the next draw target to the renderer
sender.send(move layer_buffer);

View file

@ -1,11 +1,11 @@
use mod au = geometry;
use au = geometry;
use compositor::LayerBuffer;
use text::font::Font;
use text::text_run::TextRun;
use text::font_cache::FontCache;
use image::base::Image;
use au = au::au;
use au::Au;
use util::range::Range;
use core::libc::types::common::c99::uint16_t;
@ -28,7 +28,7 @@ struct RenderContext {
}
impl RenderContext {
pub fn draw_solid_color(&self, bounds: &Rect<au>, r: u8, g: u8, b: u8) {
pub fn draw_solid_color(&self, bounds: &Rect<Au>, r: u8, g: u8, b: u8) {
let color = Color(r.to_float() as AzFloat,
g.to_float() as AzFloat,
b.to_float() as AzFloat,
@ -37,7 +37,7 @@ impl RenderContext {
self.canvas.draw_target.fill_rect(&bounds.to_azure_rect(), &ColorPattern(color));
}
pub fn draw_border(&self, bounds: &Rect<au>, width: au, r: u8, g: u8, b: u8) {
pub fn draw_border(&self, bounds: &Rect<Au>, width: Au, r: u8, g: u8, b: u8) {
let rect = bounds.to_azure_rect();
let color = Color(r.to_float() as AzFloat,
g.to_float() as AzFloat,
@ -51,7 +51,7 @@ impl RenderContext {
self.canvas.draw_target.stroke_rect(&rect, &pattern, &stroke_opts, &draw_opts);
}
pub fn draw_image(&self, bounds: Rect<au>, image: ARC<~Image>) {
pub fn draw_image(&self, bounds: Rect<Au>, image: ARC<~Image>) {
let image = std::arc::get(&image);
let size = Size2D(image.width as i32, image.height as i32);
let stride = image.width * 4;
@ -64,11 +64,11 @@ impl RenderContext {
let dest_rect = bounds.to_azure_rect();
let draw_surface_options = DrawSurfaceOptions(Linear, true);
let draw_options = DrawOptions(1.0f as AzFloat, 0);
draw_target_ref.draw_surface(azure_surface, dest_rect, source_rect, draw_surface_options,
draw_options);
draw_target_ref.draw_surface(move azure_surface, dest_rect, source_rect,
draw_surface_options, draw_options);
}
pub fn draw_text(&self, bounds: Rect<au>, run: &TextRun, range: Range) {
pub fn draw_text(&self, bounds: Rect<Au>, run: &TextRun, range: Range) {
use ptr::{null};
use vec::raw::to_ptr;
use libc::types::common::c99::{uint16_t, uint32_t};
@ -164,7 +164,7 @@ trait ToAzureRect {
fn to_azure_rect() -> Rect<AzFloat>;
}
impl Rect<au> : ToAzureRect {
impl Rect<Au> : ToAzureRect {
fn to_azure_rect() -> Rect<AzFloat> {
Rect(Point2D(au::to_px(self.origin.x) as AzFloat, au::to_px(self.origin.y) as AzFloat),
Size2D(au::to_px(self.size.width) as AzFloat, au::to_px(self.size.height) as AzFloat))

View file

@ -19,7 +19,7 @@ pub struct RenderLayer {
pub fn render_layers(layer: &RenderLayer,
buffer: LayerBuffer,
f: &fn(layer: &RenderLayer, buffer: &LayerBuffer) -> bool) -> LayerBuffer {
let mut buffer = buffer;
let mut buffer = move buffer;
if buffer.size != layer.size {
// Create a new buffer.
let cairo_surface = ImageSurface(CAIRO_FORMAT_RGB24,

View file

@ -1,5 +1,5 @@
use au = gfx::geometry;
use au::au;
use au::Au;
use comm::*;
use compositor::{Compositor, LayerBuffer};
use dl = display_list;
@ -22,15 +22,17 @@ pub enum Msg {
pub type RenderTask = comm::Chan<Msg>;
pub fn RenderTask<C: Compositor Send>(compositor: C) -> RenderTask {
do task::spawn_listener |po: comm::Port<Msg>| {
let compositor_cell = Cell(move compositor);
do task::spawn_listener |po: comm::Port<Msg>, move compositor_cell| {
let (layer_buffer_channel, layer_buffer_port) = pipes::stream();
let compositor = compositor_cell.take();
compositor.begin_drawing(move layer_buffer_channel);
Renderer {
port: po,
compositor: compositor,
mut layer_buffer_port: Cell(layer_buffer_port),
compositor: move compositor,
mut layer_buffer_port: Cell(move layer_buffer_port),
font_cache: FontCache(),
}.start();
}
@ -49,7 +51,7 @@ impl<C: Compositor Send> Renderer<C> {
loop {
match self.port.recv() {
RenderMsg(move render_layer) => self.render(render_layer),
RenderMsg(move render_layer) => self.render(move render_layer),
ExitMsg(response_ch) => {
response_ch.send(());
break;
@ -69,10 +71,10 @@ impl<C: Compositor Send> Renderer<C> {
let layer_buffer = layer_buffer_port.recv();
let (layer_buffer_channel, new_layer_buffer_port) = pipes::stream();
self.layer_buffer_port.put_back(new_layer_buffer_port);
self.layer_buffer_port.put_back(move new_layer_buffer_port);
let render_layer_cell = Cell(move render_layer);
let layer_buffer_cell = Cell(layer_buffer);
let layer_buffer_cell = Cell(move layer_buffer);
let layer_buffer_channel_cell = Cell(move layer_buffer_channel);
#debug("renderer: rendering");
@ -93,7 +95,7 @@ impl<C: Compositor Send> Renderer<C> {
};
#debug("renderer: returning surface");
self.compositor.draw(layer_buffer_channel, move layer_buffer);
self.compositor.draw(move layer_buffer_channel, move layer_buffer);
}
}
}
}

View file

@ -53,29 +53,29 @@ fn css_link_listener(to_parent : comm::Chan<Stylesheet>, from_parent : comm::Por
loop {
match from_parent.recv() {
CSSTaskNewFile(url) => {
let result_port = comm::Port();
let result_chan = comm::Chan(&result_port);
// TODO: change copy to move once we have match move
let url = copy url;
task::spawn(|| {
// TODO: change copy to move once we can move into closures
let css_stream = css::lexer::spawn_css_lexer_task(copy url, resource_task);
let mut css_rules = css::parser::build_stylesheet(css_stream);
result_chan.send(css_rules);
});
CSSTaskNewFile(url) => {
let result_port = comm::Port();
let result_chan = comm::Chan(&result_port);
// TODO: change copy to move once we have match move
let url = copy url;
do task::spawn |move url, copy resource_task| {
// TODO: change copy to move once we can move out of closures
let css_stream = css::lexer::spawn_css_lexer_task(copy url, resource_task);
let mut css_rules = css::parser::build_stylesheet(move css_stream);
result_chan.send(move css_rules);
}
vec::push(&mut result_vec, result_port);
}
CSSTaskExit => {
break;
}
vec::push(&mut result_vec, result_port);
}
CSSTaskExit => {
break;
}
}
}
let css_rules = vec::flat_map(result_vec, |result_port| { result_port.recv() });
to_parent.send(css_rules);
to_parent.send(move css_rules);
}
fn js_script_listener(to_parent : comm::Chan<~[~[u8]]>, from_parent : comm::Port<JSMessage>,
@ -84,42 +84,40 @@ fn js_script_listener(to_parent : comm::Chan<~[~[u8]]>, from_parent : comm::Port
loop {
match from_parent.recv() {
JSTaskNewFile(url) => {
let result_port = comm::Port();
let result_chan = comm::Chan(&result_port);
// TODO: change copy to move once we have match move
let url = copy url;
do 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()));
JSTaskNewFile(move url) => {
let result_port = comm::Port();
let result_chan = comm::Chan(&result_port);
do task::spawn |move url| {
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 mut buf = ~[];
loop {
match input_port.recv() {
Payload(data) => {
buf += data;
}
Done(Ok(*)) => {
result_chan.send(buf);
break;
}
Done(Err(*)) => {
#error("error loading script %s", url.to_str());
}
let mut buf = ~[];
loop {
match input_port.recv() {
Payload(move data) => {
buf += data;
}
Done(Ok(*)) => {
result_chan.send(move buf);
break;
}
Done(Err(*)) => {
#error("error loading script %s", url.to_str());
}
}
}
}
vec::push(&mut result_vec, result_port);
}
JSTaskExit => {
break;
}
vec::push(&mut result_vec, result_port);
}
JSTaskExit => {
break;
}
}
}
let js_scripts = vec::map(result_vec, |result_port| result_port.recv());
to_parent.send(js_scripts);
to_parent.send(move js_scripts);
}
fn build_element_kind(tag: &str) -> ~ElementKind {
@ -183,7 +181,7 @@ pub fn parse_html(scope: NodeScope,
js_script_listener(js_chan, js_port, resource_task);
};
let (scope, url) = (@copy scope, @url);
let (scope, url) = (@copy scope, @move url);
// Build the root node.
let root = scope.new_node(Element(ElementData(~"html", ~HTMLDivElement)));
@ -209,14 +207,15 @@ pub fn parse_html(scope: NodeScope,
None => None,
Some(id) => Some(from_slice(id))
};
let data = DoctypeData(name, public_id, system_id, doctype.force_quirks);
let new_node = scope.new_node(Doctype(data));
let data = DoctypeData(move name, move public_id, move system_id,
doctype.force_quirks);
let new_node = scope.new_node(Doctype(move data));
unsafe { reinterpret_cast(&new_node) }
},
create_element: |tag: &hubbub::Tag| {
create_element: |tag: &hubbub::Tag, move image_cache_task| {
debug!("create element");
let elem_kind = build_element_kind(tag.name);
let elem = ElementData(from_slice(tag.name), elem_kind);
let elem = ElementData(from_slice(tag.name), move elem_kind);
debug!("attach attrs");
for tag.attributes.each |attribute| {
elem.attrs.push(~Attr(from_slice(attribute.name),
@ -231,13 +230,14 @@ pub fn parse_html(scope: NodeScope,
(Some(move rel), Some(move href)) => {
if rel == ~"stylesheet" {
debug!("found CSS stylesheet: %s", href);
css_chan.send(CSSTaskNewFile(make_url(href, Some(copy *url))));
css_chan.send(CSSTaskNewFile(make_url(move href,
Some(copy *url))));
}
}
_ => {}
}
},
~HTMLImageElement(d) => {
~HTMLImageElement(copy d) => { // FIXME: Bad copy.
do elem.get_attr(~"src").iter |img_url_str| {
let img_url = make_url(copy *img_url_str, Some(copy *url));
d.image = Some(copy img_url);
@ -249,7 +249,7 @@ pub fn parse_html(scope: NodeScope,
//TODO (Issue #86): handle inline styles ('style' attr)
_ => {}
}
let node = scope.new_node(Element(elem));
let node = scope.new_node(Element(move elem));
unsafe { reinterpret_cast(&node) }
},
create_text: |data| {
@ -310,8 +310,8 @@ pub fn parse_html(scope: NodeScope,
match element.get_attr(~"src") {
Some(move src) => {
debug!("found script: %s", src);
let new_url = make_url(src, Some(copy *url));
js_chan.send(JSTaskNewFile(new_url));
let new_url = make_url(move src, Some(copy *url));
js_chan.send(JSTaskNewFile(move new_url));
}
None => {}
}

View file

@ -12,7 +12,7 @@ use stb_image = stb_image::image;
pub type Image = stb_image::Image;
pub fn Image(width: uint, height: uint, depth: uint, data: ~[u8]) -> Image {
stb_image::new_image(width, height, depth, data)
stb_image::new_image(width, height, depth, move data)
}
const TEST_IMAGE: [u8 * 4962] = #include_bin("test.jpeg");
@ -40,6 +40,6 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
assert image.data.len() == data.len();
Image(image.width, image.height, image.depth, data)
Image(image.width, image.height, image.depth, move data)
}
}

View file

@ -20,7 +20,7 @@ pub struct ImageHolder {
fn ImageHolder(url : Url, local_image_cache: @LocalImageCache) -> ImageHolder {
debug!("ImageHolder() %?", url.to_str());
let holder = ImageHolder {
url : url,
url : move url,
image : None,
cached_size : Size2D(0,0),
local_image_cache: local_image_cache,
@ -34,7 +34,7 @@ fn ImageHolder(url : Url, local_image_cache: @LocalImageCache) -> ImageHolder {
local_image_cache.prefetch(&holder.url);
local_image_cache.decode(&holder.url);
holder
move holder
}
impl ImageHolder {
@ -71,7 +71,7 @@ impl ImageHolder {
if self.image.is_none() {
match self.local_image_cache.get_image(&self.url).recv() {
ImageReady(move image) => {
self.image = Some(image);
self.image = Some(move image);
}
ImageNotReady => {
debug!("image not ready for %s", self.url.to_str());
@ -92,6 +92,6 @@ impl ImageHolder {
replace(&mut self.image, move image);
return result;
return move result;
}
}

View file

@ -4,7 +4,7 @@ use dl = gfx::display_list;
use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use gfx::geometry::au;
use gfx::geometry::Au;
use layout::box::{RenderBox};
use layout::context::LayoutContext;
use layout::flow::{FlowContext, FlowTree, InlineBlockFlow, BlockFlow, RootFlow};
@ -27,8 +27,8 @@ trait BlockLayout {
fn bubble_widths_block(@self, ctx: &LayoutContext);
fn assign_widths_block(@self, ctx: &LayoutContext);
fn assign_height_block(@self, ctx: &LayoutContext);
fn build_display_list_block(@self, a: &dl::DisplayListBuilder, b: &Rect<au>,
c: &Point2D<au>, d: &dl::DisplayList);
fn build_display_list_block(@self, a: &dl::DisplayListBuilder, b: &Rect<Au>,
c: &Point2D<Au>, d: &dl::DisplayList);
}
impl FlowContext : BlockLayout {
@ -68,8 +68,8 @@ impl FlowContext : BlockLayout {
fn bubble_widths_block(@self, ctx: &LayoutContext) {
assert self.starts_block_flow();
let mut min_width = au(0);
let mut pref_width = au(0);
let mut min_width = Au(0);
let mut pref_width = Au(0);
/* find max width from child block contexts */
for FlowTree.each_child(self) |child_ctx| {
@ -101,8 +101,8 @@ impl FlowContext : BlockLayout {
assert self.starts_block_flow();
let mut remaining_width = self.d().position.size.width;
let mut _right_used = au(0);
let mut left_used = au(0);
let mut _right_used = Au(0);
let mut left_used = Au(0);
/* Let the box consume some width. It will return the amount remaining
for its children. */
@ -122,7 +122,7 @@ impl FlowContext : BlockLayout {
fn assign_height_block(@self, _ctx: &LayoutContext) {
assert self.starts_block_flow();
let mut cur_y = au(0);
let mut cur_y = Au(0);
for FlowTree.each_child(self) |child_ctx| {
child_ctx.d().position.origin.y = cur_y;
@ -131,18 +131,18 @@ impl FlowContext : BlockLayout {
self.d().position.size.height = cur_y;
let _used_top = au(0);
let _used_bot = au(0);
let _used_top = Au(0);
let _used_bot = Au(0);
do self.with_block_box |box| {
box.d().position.origin.y = au(0);
box.d().position.origin.y = Au(0);
box.d().position.size.height = cur_y;
let (_used_top, _used_bot) = box.get_used_height();
}
}
fn build_display_list_block(@self, builder: &dl::DisplayListBuilder, dirty: &Rect<au>,
offset: &Point2D<au>, list: &dl::DisplayList) {
fn build_display_list_block(@self, builder: &dl::DisplayListBuilder, dirty: &Rect<Au>,
offset: &Point2D<Au>, list: &dl::DisplayList) {
assert self.starts_block_flow();

View file

@ -4,7 +4,7 @@ use servo_util::color::rgb;
use arc = std::arc;
use arc::ARC;
use au = gfx::geometry;
use au::au;
use au::Au;
use core::dvec::DVec;
use core::to_str::ToStr;
use core::rand;
@ -74,7 +74,7 @@ struct RenderBoxData {
participates in */
ctx : @FlowContext,
/* position of this box relative to owning flow */
mut position : Rect<au>,
mut position : Rect<Au>,
font_size : Length,
/* TODO (Issue #87): debug only */
mut id: int
@ -114,18 +114,18 @@ trait RenderBoxMethods {
pure fn is_whitespace_only() -> bool;
pure fn can_merge_with_box(@self, other: @RenderBox) -> bool;
pure fn requires_inline_spacers() -> bool;
pure fn content_box() -> Rect<au>;
pure fn border_box() -> Rect<au>;
pure fn margin_box() -> Rect<au>;
pure fn content_box() -> Rect<Au>;
pure fn border_box() -> Rect<Au>;
pure fn margin_box() -> Rect<Au>;
fn split_to_width(@self, &LayoutContext, au, starts_line: bool) -> SplitBoxResult;
fn get_min_width(&LayoutContext) -> au;
fn get_pref_width(&LayoutContext) -> au;
fn get_used_width() -> (au, au);
fn get_used_height() -> (au, au);
fn split_to_width(@self, &LayoutContext, Au, starts_line: bool) -> SplitBoxResult;
fn get_min_width(&LayoutContext) -> Au;
fn get_pref_width(&LayoutContext) -> Au;
fn get_used_width() -> (Au, Au);
fn get_used_height() -> (Au, Au);
fn create_inline_spacer_for_side(&LayoutContext, InlineSpacerSide) -> Option<@RenderBox>;
fn build_display_list(@self, &dl::DisplayListBuilder, dirty: &Rect<au>,
offset: &Point2D<au>, &dl::DisplayList);
fn build_display_list(@self, &dl::DisplayListBuilder, dirty: &Rect<Au>,
offset: &Point2D<Au>, &dl::DisplayList);
}
fn RenderBoxData(node: Node, ctx: @FlowContext, id: int) -> RenderBoxData {
@ -179,7 +179,7 @@ impl RenderBox : RenderBoxMethods {
}
}
fn split_to_width(@self, _ctx: &LayoutContext, max_width: au, starts_line: bool) -> SplitBoxResult {
fn split_to_width(@self, _ctx: &LayoutContext, max_width: Au, starts_line: bool) -> SplitBoxResult {
match self {
@GenericBox(*) => CannotSplit(self),
@ImageBox(*) => CannotSplit(self),
@ -187,7 +187,7 @@ impl RenderBox : RenderBoxMethods {
@TextBox(_,data) => {
let mut pieces_processed_count : uint = 0;
let mut remaining_width : au = max_width;
let mut remaining_width : Au = max_width;
let left_range = MutableRange(data.range.begin(), 0);
let mut right_range : Option<Range> = None;
debug!("split_to_width: splitting text box (strlen=%u, range=%?, avail_width=%?)",
@ -255,14 +255,14 @@ impl RenderBox : RenderBoxMethods {
* may cause glyphs to be allocated. For now, it's impure because of
* holder.get_image()
*/
fn get_min_width(_ctx: &LayoutContext) -> au {
fn get_min_width(_ctx: &LayoutContext) -> Au {
match self {
// TODO: this should account for min/pref widths of the
// box element in isolation. That includes
// border/margin/padding but not child widths. The block
// FlowContext will combine the width of this element and
// that of its children to arrive at the context width.
GenericBox(*) => au(0),
GenericBox(*) => Au(0),
// TODO: consult CSS 'width', margin, border.
// TODO: If image isn't available, consult 'width'.
ImageBox(_,i) => au::from_px(i.get_size().get_default(Size2D(0,0)).width),
@ -271,14 +271,14 @@ impl RenderBox : RenderBoxMethods {
}
}
fn get_pref_width(_ctx: &LayoutContext) -> au {
fn get_pref_width(_ctx: &LayoutContext) -> Au {
match self {
// TODO: this should account for min/pref widths of the
// box element in isolation. That includes
// border/margin/padding but not child widths. The block
// FlowContext will combine the width of this element and
// that of its children to arrive at the context width.
GenericBox(*) => au(0),
GenericBox(*) => Au(0),
ImageBox(_,i) => au::from_px(i.get_size().get_default(Size2D(0,0)).width),
// a text box cannot span lines, so assume that this is an unsplit text box.
@ -288,9 +288,9 @@ impl RenderBox : RenderBoxMethods {
// maybe text boxes should report nothing, and the parent flow could
// factor in min/pref widths of any text runs that it owns.
TextBox(_,d) => {
let mut max_line_width: au = au(0);
let mut max_line_width: Au = Au(0);
for d.run.iter_natural_lines_for_range(d.range) |line_range| {
let mut line_width: au = au(0);
let mut line_width: Au = Au(0);
for d.run.glyphs.iter_glyphs_for_range(line_range) |_char_i, glyph| {
line_width += glyph.advance()
}
@ -305,20 +305,20 @@ impl RenderBox : RenderBoxMethods {
/* Returns the amount of left, right "fringe" used by this
box. This should be based on margin, border, padding, width. */
fn get_used_width() -> (au, au) {
fn get_used_width() -> (Au, Au) {
// TODO: this should actually do some computation!
// See CSS 2.1, Section 10.3, 10.4.
(au(0), au(0))
(Au(0), Au(0))
}
/* Returns the amount of left, right "fringe" used by this
box. This should be based on margin, border, padding, width. */
fn get_used_height() -> (au, au) {
fn get_used_height() -> (Au, Au) {
// TODO: this should actually do some computation!
// See CSS 2.1, Section 10.5, 10.6.
(au(0), au(0))
(Au(0), Au(0))
}
/* Whether "spacer" boxes are needed to stand in for this DOM node */
@ -328,7 +328,7 @@ impl RenderBox : RenderBoxMethods {
/* The box formed by the content edge, as defined in CSS 2.1 Section 8.1.
Coordinates are relative to the owning flow. */
pure fn content_box() -> Rect<au> {
pure fn content_box() -> Rect<Au> {
match self {
ImageBox(_,i) => {
let size = i.size();
@ -362,14 +362,14 @@ impl RenderBox : RenderBoxMethods {
/* The box formed by the border edge, as defined in CSS 2.1 Section 8.1.
Coordinates are relative to the owning flow. */
pure fn border_box() -> Rect<au> {
pure fn border_box() -> Rect<Au> {
// TODO: actually compute content_box + padding + border
self.content_box()
}
/* The box fromed by the margin edge, as defined in CSS 2.1 Section 8.1.
Coordinates are relative to the owning flow. */
pure fn margin_box() -> Rect<au> {
pure fn margin_box() -> Rect<Au> {
// TODO: actually compute content_box + padding + border + margin
self.content_box()
}
@ -397,11 +397,11 @@ impl RenderBox : RenderBoxMethods {
* `origin` - Total offset from display list root flow to this box's owning flow
* `list` - List to which items should be appended
*/
fn build_display_list(@self, builder: &dl::DisplayListBuilder, dirty: &Rect<au>,
offset: &Point2D<au>, list: &dl::DisplayList) {
fn build_display_list(@self, builder: &dl::DisplayListBuilder, dirty: &Rect<Au>,
offset: &Point2D<Au>, list: &dl::DisplayList) {
let style = self.d().node.style();
let box_bounds : Rect<au> = match style.position {
let box_bounds : Rect<Au> = match style.position {
Specified(PosAbsolute) => {
let x_offset = match style.left {
Specified(Px(px)) => au::from_frac_px(px),
@ -452,7 +452,7 @@ impl RenderBox : RenderBoxMethods {
self.add_border_to_list(list, abs_box_bounds);
}
fn add_bgcolor_to_list(list: &dl::DisplayList, abs_bounds: &Rect<au>) {
fn add_bgcolor_to_list(list: &dl::DisplayList, abs_bounds: &Rect<Au>) {
use std::cmp::FuzzyEq;
// TODO: shouldn't need to unbox CSSValue by now
let boxed_bgcolor = self.d().node.style().background_color;
@ -465,7 +465,7 @@ impl RenderBox : RenderBoxMethods {
}
}
fn add_border_to_list(list: &dl::DisplayList, abs_bounds: Rect<au>) {
fn add_border_to_list(list: &dl::DisplayList, abs_bounds: Rect<Au>) {
let style = self.d().node.style();
match style.border_width {
Specified(Px(px)) => {
@ -473,8 +473,8 @@ impl RenderBox : RenderBoxMethods {
let border_width = au::from_frac_px(px);
let abs_bounds = Rect {
origin: Point2D {
x: abs_bounds.origin.x - border_width / au(2),
y: abs_bounds.origin.y - border_width / au(2),
x: abs_bounds.origin.x - border_width / Au(2),
y: abs_bounds.origin.y - border_width / Au(2),
},
size: Size2D {
width: abs_bounds.size.width + border_width,

View file

@ -254,13 +254,13 @@ impl LayoutTreeBuilder {
fn make_flow(ty : FlowContextType) -> @FlowContext {
let data = FlowData(self.next_flow_id());
let ret = match ty {
Flow_Absolute => @AbsoluteFlow(data),
Flow_Block => @BlockFlow(data, BlockFlowData()),
Flow_Float => @FloatFlow(data),
Flow_InlineBlock => @InlineBlockFlow(data),
Flow_Inline => @InlineFlow(data, InlineFlowData()),
Flow_Root => @RootFlow(data, RootFlowData()),
Flow_Table => @TableFlow(data)
Flow_Absolute => @AbsoluteFlow(move data),
Flow_Block => @BlockFlow(move data, BlockFlowData()),
Flow_Float => @FloatFlow(move data),
Flow_InlineBlock => @InlineBlockFlow(move data),
Flow_Inline => @InlineFlow(move data, InlineFlowData()),
Flow_Root => @RootFlow(move data, RootFlowData()),
Flow_Table => @TableFlow(move data)
};
debug!("LayoutTreeBuilder: created flow: %s", ret.debug_str());
ret
@ -295,7 +295,7 @@ impl LayoutTreeBuilder {
let holder = ImageHolder({copy *d.image.get_ref()},
layout_ctx.image_cache);
@ImageBox(RenderBoxData(node, ctx, self.next_box_id()), holder)
@ImageBox(RenderBoxData(node, ctx, self.next_box_id()), move holder)
} else {
info!("Tried to make image box, but couldn't find image. Made generic box instead.");
self.make_generic_box(layout_ctx, node, ctx)

View file

@ -2,7 +2,7 @@ use resource::local_image_cache::LocalImageCache;
use servo_text::font_cache::FontCache;
use std::net::url::Url;
use geom::rect::Rect;
use au = gfx::geometry::au;
use gfx::geometry::Au;
/* Represents layout task context. */
@ -10,5 +10,5 @@ struct LayoutContext {
font_cache: @FontCache,
image_cache: @LocalImageCache,
doc_url: Url,
screen_size: Rect<au>
}
screen_size: Rect<Au>
}

View file

@ -1,7 +1,7 @@
export DisplayListBuilder;
use au = gfx::geometry;
use au::au;
use au::Au;
use css::values::{BgColor, BgColorTransparent, Specified};
use dl = gfx::display_list;
use dom::node::{Text, NodeScope};
@ -32,20 +32,20 @@ pub struct DisplayListBuilder {
trait FlowDisplayListBuilderMethods {
fn build_display_list(@self, a: &DisplayListBuilder, b: &Rect<au>, c: &dl::DisplayList);
fn build_display_list(@self, a: &DisplayListBuilder, b: &Rect<Au>, c: &dl::DisplayList);
fn build_display_list_for_child(@self, a: &DisplayListBuilder, b: @FlowContext,
c: &Rect<au>, d: &Point2D<au>, e: &dl::DisplayList);
c: &Rect<Au>, d: &Point2D<Au>, e: &dl::DisplayList);
}
impl FlowContext: FlowDisplayListBuilderMethods {
fn build_display_list(@self, builder: &DisplayListBuilder, dirty: &Rect<au>, list: &dl::DisplayList) {
fn build_display_list(@self, builder: &DisplayListBuilder, dirty: &Rect<Au>, list: &dl::DisplayList) {
let zero = au::zero_point();
self.build_display_list_recurse(builder, dirty, &zero, list);
}
fn build_display_list_for_child(@self, builder: &DisplayListBuilder, child_flow: @FlowContext,
dirty: &Rect<au>, offset: &Point2D<au>,
dirty: &Rect<Au>, offset: &Point2D<Au>,
list: &dl::DisplayList) {
// adjust the dirty rect to child flow context coordinates

View file

@ -1,5 +1,5 @@
use au = gfx::geometry;
use au::au;
use au::Au;
use core::dvec::DVec;
use dl = gfx::display_list;
use dom::node::Node;
@ -72,8 +72,8 @@ trait FlowContextMethods {
fn bubble_widths(@self, &LayoutContext);
fn assign_widths(@self, &LayoutContext);
fn assign_height(@self, &LayoutContext);
fn build_display_list_recurse(@self, &dl::DisplayListBuilder, dirty: &Rect<au>,
offset: &Point2D<au>, &dl::DisplayList);
fn build_display_list_recurse(@self, &dl::DisplayListBuilder, dirty: &Rect<Au>,
offset: &Point2D<Au>, &dl::DisplayList);
pure fn foldl_boxes_for_node<B: Copy>(Node, +seed: B, cb: pure fn&(+a: B,@RenderBox) -> B) -> B;
pure fn iter_boxes_for_node<T>(Node, cb: pure fn&(@RenderBox) -> T);
}
@ -90,9 +90,9 @@ struct FlowData {
/* layout computations */
// TODO: min/pref and position are used during disjoint phases of
// layout; maybe combine into a single enum to save space.
mut min_width: au,
mut pref_width: au,
mut position: Rect<au>,
mut min_width: Au,
mut pref_width: Au,
mut position: Rect<Au>,
}
fn FlowData(id: int) -> FlowData {
@ -101,8 +101,8 @@ fn FlowData(id: int) -> FlowData {
tree: tree::empty(),
id: id,
min_width: au(0),
pref_width: au(0),
min_width: Au(0),
pref_width: Au(0),
position: au::zero_rect()
}
}
@ -183,7 +183,7 @@ impl BoxConsumer {
range: MutableRange(entry.start_idx, final_span_length)
};
debug!("BoxConsumer: adding element range=%?", mapping.range);
self.flow.inline().elems.push(mapping);
self.flow.inline().elems.push(move mapping);
},
@BlockFlow(*) => {
assert self.stack.len() == 0;
@ -261,8 +261,8 @@ impl FlowContext : FlowContextMethods {
}
}
fn build_display_list_recurse(@self, builder: &dl::DisplayListBuilder, dirty: &Rect<au>,
offset: &Point2D<au>, list: &dl::DisplayList) {
fn build_display_list_recurse(@self, builder: &dl::DisplayListBuilder, dirty: &Rect<Au>,
offset: &Point2D<Au>, list: &dl::DisplayList) {
debug!("FlowContext::build_display_list at %?: %s", self.d().position, self.debug_str());
match self {
@ -361,7 +361,8 @@ impl FlowContext : BoxedDebugMethods {
let mut s = self.inline().boxes.foldl(~"InlineFlow(children=", |s, box| {
fmt!("%s b%d", *s, box.d().id)
});
s += ~")"; s
s += ~")";
move s
},
BlockFlow(*) => {
match self.block().box {

View file

@ -7,7 +7,7 @@ use dom::node::Node;
use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use gfx::geometry::au;
use gfx::geometry::Au;
use layout::box::*;
use layout::context::LayoutContext;
use layout::flow::{FlowContext, InlineFlow};
@ -100,7 +100,7 @@ impl TextRunScanner {
debug!("TextRunScanner: swapping out boxes.");
// swap out old and new box list of flow, by supplying
// temp boxes as return value to boxes.swap |...|
dvec::unwrap(out_boxes)
dvec::unwrap(move out_boxes)
}
// helper functions
@ -271,7 +271,7 @@ struct LineboxScanner {
flow: @FlowContext,
new_boxes: DVec<@RenderBox>,
work_list: DList<@RenderBox>,
pending_line: {range: MutableRange, mut width: au},
pending_line: {range: MutableRange, mut width: Au},
line_spans: DVec<Range>
}
@ -282,7 +282,7 @@ fn LineboxScanner(inline: @FlowContext) -> LineboxScanner {
flow: inline,
new_boxes: DVec(),
work_list: DList(),
pending_line: {range: util::range::empty_mut(), mut width: au(0)},
pending_line: {range: util::range::empty_mut(), mut width: Au(0)},
line_spans: DVec()
}
}
@ -297,7 +297,7 @@ impl LineboxScanner {
priv fn reset_linebox() {
self.pending_line.range.reset(0,0);
self.pending_line.width = au(0);
self.pending_line.width = Au(0);
}
pub fn scan_for_lines(ctx: &LayoutContext) {
@ -342,11 +342,11 @@ impl LineboxScanner {
self.line_spans.len(), self.flow.d().id);
// TODO: repair Node->box mappings, using strategy similar to TextRunScanner
do self.new_boxes.swap |boxes| {
self.flow.inline().boxes.set(boxes);
self.flow.inline().boxes.set(move boxes);
~[]
};
do self.line_spans.swap |boxes| {
self.flow.inline().lines.set(boxes);
self.flow.inline().lines.set(move boxes);
~[]
};
}
@ -356,7 +356,7 @@ impl LineboxScanner {
self.line_spans.len(), self.pending_line);
// set box horizontal offsets
let line_range = self.pending_line.range.as_immutable();
let mut offset_x = au(0);
let mut offset_x = Au(0);
// TODO: interpretation of CSS 'text-direction' and 'text-align'
// will change from which side we start laying out the line.
debug!("LineboxScanner: Setting horizontal offsets for boxes in line %u range: %?",
@ -369,7 +369,7 @@ impl LineboxScanner {
// clear line and add line mapping
debug!("LineboxScanner: Saving information for flushed line %u.", self.line_spans.len());
self.line_spans.push(line_range);
self.line_spans.push(move line_range);
self.reset_linebox();
}
@ -494,7 +494,7 @@ trait InlineLayout {
fn bubble_widths_inline(@self, ctx: &LayoutContext);
fn assign_widths_inline(@self, ctx: &LayoutContext);
fn assign_height_inline(@self, ctx: &LayoutContext);
fn build_display_list_inline(@self, a: &dl::DisplayListBuilder, b: &Rect<au>, c: &Point2D<au>, d: &dl::DisplayList);
fn build_display_list_inline(@self, a: &dl::DisplayListBuilder, b: &Rect<Au>, c: &Point2D<Au>, d: &dl::DisplayList);
}
impl FlowContext : InlineLayout {
@ -506,8 +506,8 @@ impl FlowContext : InlineLayout {
let scanner = TextRunScanner(self);
scanner.scan_for_runs(ctx);
let mut min_width = au(0);
let mut pref_width = au(0);
let mut min_width = Au(0);
let mut pref_width = Au(0);
for self.inline().boxes.each |box| {
debug!("FlowContext[%d]: measuring %s", self.d().id, box.debug_str());
@ -554,7 +554,7 @@ impl FlowContext : InlineLayout {
fn assign_height_inline(@self, _ctx: &LayoutContext) {
// TODO: get from CSS 'line-height' property
let line_height = au::from_px(20);
let mut cur_y = au(0);
let mut cur_y = Au(0);
for self.inline().lines.eachi |i, line_span| {
debug!("assign_height_inline: processing line %u with box span: %?", i, line_span);
@ -582,13 +582,13 @@ impl FlowContext : InlineLayout {
// TODO: account for padding, margin, border in bounding box?
@ImageBox(*) | @GenericBox(*) => {
let box_bounds = cur_box.d().position;
box_bounds.translate(&Point2D(au(0), -cur_box.d().position.size.height))
box_bounds.translate(&Point2D(Au(0), -cur_box.d().position.size.height))
},
// adjust bounding box metric to box's horizontal offset
// TODO: can we trust the leading provided by font metrics?
@TextBox(_, data) => {
let text_bounds = data.run.metrics_for_range(data.range).bounding_box;
text_bounds.translate(&Point2D(cur_box.d().position.origin.x, au(0)))
text_bounds.translate(&Point2D(cur_box.d().position.origin.x, Au(0)))
},
_ => fail fmt!("Tried to compute bounding box of unknown Box variant: %s", cur_box.debug_str())
};
@ -604,8 +604,8 @@ impl FlowContext : InlineLayout {
self.d().position.size.height = cur_y;
}
fn build_display_list_inline(@self, builder: &dl::DisplayListBuilder, dirty: &Rect<au>,
offset: &Point2D<au>, list: &dl::DisplayList) {
fn build_display_list_inline(@self, builder: &dl::DisplayListBuilder, dirty: &Rect<Au>,
offset: &Point2D<Au>, list: &dl::DisplayList) {
assert self.starts_inline_flow();

View file

@ -4,7 +4,7 @@
*/
use au = gfx::geometry;
use au::au;
use au::Au;
use content::content_task;
use core::dvec::DVec;
use css::resolve::apply::apply_style;
@ -63,7 +63,7 @@ struct BuildData {
fn LayoutTask(render_task: RenderTask,
img_cache_task: ImageCacheTask) -> LayoutTask {
do spawn_listener::<Msg> |from_content| {
do spawn_listener::<Msg> |from_content, move img_cache_task| {
Layout(render_task, img_cache_task.clone(), from_content).start();
}
}
@ -105,7 +105,7 @@ impl Layout {
match self.from_content.recv() {
BuildMsg(move data) => {
let data = Cell(data);
let data = Cell(move data);
do time("layout: performing layout") {
self.handle_build(data.take());
@ -147,8 +147,8 @@ impl Layout {
let layout_ctx = LayoutContext {
image_cache: self.local_image_cache,
font_cache: self.font_cache,
doc_url: doc_url,
screen_size: Rect(Point2D(au(0), au(0)), screen_size)
doc_url: move doc_url,
screen_size: Rect(Point2D(Au(0), Au(0)), screen_size)
};
let layout_root: @FlowContext = do time("layout: tree construction") {
@ -210,7 +210,7 @@ impl Layout {
let response = match node.aux(|a| copy *a).flow {
None => Err(()),
Some(flow) => {
let start_val : Option<Rect<au>> = None;
let start_val : Option<Rect<Au>> = None;
let rect = do flow.foldl_boxes_for_node(node, start_val) |acc, box| {
match acc {
Some(acc) => Some(acc.union(&box.content_box())),
@ -249,7 +249,7 @@ impl Layout {
let f: ~fn(ImageResponseMsg) = |_msg, move dom_event_chan| {
dom_event_chan.send(ReflowEvent)
};
f
move f
};
return f;
}

View file

@ -3,7 +3,7 @@ use css::values::*;
use dl = gfx::display_list;
use geom::point::Point2D;
use geom::rect::Rect;
use gfx::geometry::au;
use gfx::geometry::Au;
use layout::box::RenderBox;
use layout::context::LayoutContext;
use layout::flow::{FlowContext, FlowTree, InlineBlockFlow, BlockFlow, RootFlow};
@ -25,8 +25,8 @@ trait RootLayout {
fn bubble_widths_root(@self, ctx: &LayoutContext);
fn assign_widths_root(@self, ctx: &LayoutContext);
fn assign_height_root(@self, ctx: &LayoutContext);
fn build_display_list_root(@self, a: &dl::DisplayListBuilder, b: &Rect<au>,
c: &Point2D<au>, d: &dl::DisplayList);
fn build_display_list_root(@self, a: &dl::DisplayListBuilder, b: &Rect<Au>,
c: &Point2D<Au>, d: &dl::DisplayList);
}
impl FlowContext : RootLayout {
@ -57,8 +57,8 @@ impl FlowContext : RootLayout {
self.assign_height_block(ctx);
}
fn build_display_list_root(@self, builder: &dl::DisplayListBuilder, dirty: &Rect<au>,
offset: &Point2D<au>, list: &dl::DisplayList) {
fn build_display_list_root(@self, builder: &dl::DisplayListBuilder, dirty: &Rect<Au>,
offset: &Point2D<Au>, list: &dl::DisplayList) {
assert self.starts_root_flow();
self.build_display_list_block(builder, dirty, offset, list);

View file

@ -32,13 +32,13 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
copy opt_match.free
};
let render_mode = match getopts::opt_maybe_str(opt_match, ~"o") {
Some(output_file) => { Png(copy output_file) }
let render_mode = match getopts::opt_maybe_str(move opt_match, ~"o") {
Some(move output_file) => { Png(move output_file) }
None => { Screen }
};
{
urls: urls,
render_mode: render_mode
urls: move urls,
render_mode: move render_mode
}
}

View file

@ -37,8 +37,8 @@ pub enum Msg {
}
fn OSMain(dom_event_chan: pipes::SharedChan<Event>) -> OSMain {
let dom_event_chan = Cell(dom_event_chan);
do on_osmain::<Msg> |po| {
let dom_event_chan = Cell(move dom_event_chan);
do on_osmain::<Msg> |po, move dom_event_chan| {
do platform::runmain {
#debug("preparing to enter main loop");
@ -104,32 +104,31 @@ fn mainloop(mode: Mode, po: comm::Port<Msg>, dom_event_chan: pipes::SharedChan<E
#debug("osmain: peeking");
while po.peek() {
match po.recv() {
AddKeyHandler(move key_ch) => key_handlers.push(move key_ch),
BeginDrawing(move sender) => lend_surface(surfaces, sender),
Draw(move sender, move dt) => {
#debug("osmain: received new frame");
return_surface(surfaces, dt);
lend_surface(surfaces, sender);
AddKeyHandler(move key_ch) => key_handlers.push(move key_ch),
BeginDrawing(move sender) => lend_surface(surfaces, move sender),
Draw(move sender, move dt) => {
#debug("osmain: received new frame");
return_surface(surfaces, move dt);
lend_surface(surfaces, move sender);
let width = surfaces.front.layer_buffer.size.width as uint;
let height = surfaces.front.layer_buffer.size.height as uint;
let width = surfaces.front.layer_buffer.size.width as uint;
let height = surfaces.front.layer_buffer.size.height as uint;
let buffer = surfaces.front.layer_buffer.cairo_surface.data();
let image = @layers::layers::Image(width, height, layers::layers::ARGB32Format,
buffer);
image_layer.set_image(image);
image_layer.common.set_transform(original_layer_transform.scale(&(width as f32),
&(height as f32),
&1.0f32));
let buffer = surfaces.front.layer_buffer.cairo_surface.data();
let image = @layers::layers::Image(
width, height, layers::layers::ARGB32Format, move buffer);
image_layer.set_image(image);
image_layer.common.set_transform(original_layer_transform.scale(
&(width as f32), &(height as f32), &1.0f32));
// FIXME: Cross-crate struct mutability is broken.
let size: &mut Size2D<f32>;
unsafe { size = cast::transmute(&scene.size); }
*size = Size2D(width as f32, height as f32);
}
Exit => {
*done = true;
}
// FIXME: Cross-crate struct mutability is broken.
let size: &mut Size2D<f32>;
unsafe { size = cast::transmute(&scene.size); }
*size = Size2D(width as f32, height as f32);
}
Exit => {
*done = true;
}
}
}
};
@ -180,10 +179,10 @@ compositor for the renderer
*/
impl OSMain : Compositor {
fn begin_drawing(next_dt: pipes::Chan<LayerBuffer>) {
self.send(BeginDrawing(next_dt))
self.send(BeginDrawing(move next_dt))
}
fn draw(next_dt: pipes::Chan<LayerBuffer>, draw_me: LayerBuffer) {
self.send(Draw(next_dt, draw_me))
self.send(Draw(move next_dt, move draw_me))
}
}
@ -203,7 +202,7 @@ fn lend_surface(surfaces: &SurfaceSet, receiver: pipes::Chan<LayerBuffer>) {
size: copy surfaces.front.layer_buffer.size
};
#debug("osmain: lending surface %?", layer_buffer);
receiver.send(layer_buffer);
receiver.send(move layer_buffer);
// Now we don't have it
surfaces.front.have = false;
// But we (hopefully) have another!
@ -246,7 +245,7 @@ fn Surface() -> Surface {
/// A function for spawning into the platform's main thread
fn on_osmain<T: Send>(f: fn~(po: comm::Port<T>)) -> comm::Chan<T> {
task::task().sched_mode(task::PlatformThread).spawn_listener(f)
task::task().sched_mode(task::PlatformThread).spawn_listener(move f)
}
// #[cfg(target_os = "linux")]

View file

@ -11,18 +11,19 @@ const READ_SIZE: uint = 1024;
pub fn factory(url: Url, progress_chan: Chan<ProgressMsg>) {
assert url.scheme == ~"file";
do spawn {
do spawn |move url| {
// FIXME: Resolve bug prevents us from moving the path out of the URL.
match file_reader(&Path(url.path)) {
Ok(reader) => {
while !reader.eof() {
let data = reader.read_bytes(READ_SIZE);
progress_chan.send(Payload(data));
Ok(reader) => {
while !reader.eof() {
let data = reader.read_bytes(READ_SIZE);
progress_chan.send(Payload(move data));
}
progress_chan.send(Done(Ok(())));
}
Err(*) => {
progress_chan.send(Done(Err(())));
}
progress_chan.send(Done(Ok(())));
}
Err(*) => {
progress_chan.send(Done(Err(())));
}
};
}
}

View file

@ -9,27 +9,25 @@ use http_client::{uv_http_request};
pub fn factory(url: Url, progress_chan: Chan<ProgressMsg>) {
assert url.scheme == ~"http";
do spawn {
let url = copy url;
do spawn |move url| {
#debug("http_loader: requesting via http: %?", copy url);
let request = uv_http_request(copy url);
let errored = @mut false;
do request.begin |event| {
do request.begin |event, copy url| {
let url = copy url;
match event {
http_client::Status(*) => { }
http_client::Payload(data) => {
#debug("http_loader: got data from %?", url);
let mut crap = None;
*data <-> crap;
progress_chan.send(Payload(option::unwrap(crap)));
}
http_client::Error(*) => {
#debug("http_loader: error loading %?", url);
*errored = true;
progress_chan.send(Done(Err(())));
}
http_client::Status(*) => { }
http_client::Payload(data) => {
#debug("http_loader: got data from %?", url);
let mut junk = None;
*data <-> junk;
progress_chan.send(Payload(option::unwrap(move junk)));
}
http_client::Error(*) => {
#debug("http_loader: error loading %?", url);
*errored = true;
progress_chan.send(Done(Err(())));
}
}
}

View file

@ -105,14 +105,14 @@ pub fn ImageCacheTask_(resource_task: ResourceTask, decoder_factory: DecoderFact
}.run();
}
chan
move chan
}
fn SyncImageCacheTask(resource_task: ResourceTask) -> ImageCacheTask {
let (chan, port) = stream();
let port_cell = Cell(move port);
do spawn |move port_cell| {
do spawn |move port_cell, move resource_task| {
let port = port_cell.take();
let inner_cache = ImageCacheTask(resource_task);
@ -120,17 +120,19 @@ fn SyncImageCacheTask(resource_task: ResourceTask) -> ImageCacheTask {
let msg: Msg = port.recv();
match move msg {
GetImage(move url, move response) => inner_cache.send(WaitForImage(url, response)),
Exit(move response) => {
inner_cache.send(Exit(response));
break;
}
move msg => inner_cache.send(msg)
GetImage(move url, move response) => {
inner_cache.send(WaitForImage(move url, move response));
}
Exit(move response) => {
inner_cache.send(Exit(move response));
break;
}
move msg => inner_cache.send(move msg)
}
}
}
return SharedChan(chan);
return move SharedChan(move chan);
}
struct ImageCache {
@ -178,17 +180,21 @@ impl ImageCache {
#debug("image_cache_task: received: %?", msg);
match move msg {
Prefetch(move url) => self.prefetch(url),
StorePrefetchedImageData(move url, move data) => self.store_prefetched_image_data(url, data),
Decode(move url) => self.decode(url),
StoreImage(move url, move image) => self.store_image(url, image),
GetImage(move url, move response) => self.get_image(url, response),
WaitForImage(move url, move response) => self.wait_for_image(url, response),
OnMsg(move handler) => msg_handlers += [copy handler],
Exit(move response) => {
assert self.need_exit.is_none();
self.need_exit = Some(response);
}
Prefetch(move url) => self.prefetch(move url),
StorePrefetchedImageData(move url, move data) => {
self.store_prefetched_image_data(move url, move data);
}
Decode(move url) => self.decode(move url),
StoreImage(move url, move image) => self.store_image(move url, move image),
GetImage(move url, move response) => self.get_image(move url, move response),
WaitForImage(move url, move response) => {
self.wait_for_image(move url, move response)
}
OnMsg(move handler) => msg_handlers += [move handler],
Exit(move response) => {
assert self.need_exit.is_none();
self.need_exit = Some(move response);
}
}
let need_exit = replace(&mut self.need_exit, None);
@ -223,14 +229,14 @@ impl ImageCache {
}
priv fn get_state(url: Url) -> ImageState {
match self.state_map.find(url) {
Some(state) => state,
None => Init
match move self.state_map.find(move url) {
Some(move state) => move state,
None => Init
}
}
priv fn set_state(url: Url, state: ImageState) {
self.state_map.insert(url, state);
self.state_map.insert(move url, move state);
}
priv fn prefetch(url: Url) {
@ -240,22 +246,22 @@ impl ImageCache {
let resource_task = self.resource_task;
let url_cell = Cell(copy url);
do spawn |move url_cell| {
do spawn |move to_cache, move url_cell| {
let url = url_cell.take();
#debug("image_cache_task: started fetch for %s", url.to_str());
let image = load_image_data(copy url, resource_task);
let result = if image.is_ok() {
Ok(Cell(result::unwrap(image)))
Ok(Cell(result::unwrap(move image)))
} else {
Err(())
};
to_cache.send(StorePrefetchedImageData(copy url, result));
to_cache.send(StorePrefetchedImageData(copy url, move result));
#debug("image_cache_task: ended fetch for %s", (copy url).to_str());
}
self.set_state(url, Prefetching(DoNotDecode));
self.set_state(move url, Prefetching(DoNotDecode));
}
Prefetching(*)
@ -274,15 +280,15 @@ impl ImageCache {
match data {
Ok(data_cell) => {
let data = data_cell.take();
self.set_state(copy url, Prefetched(@Cell(data)));
self.set_state(copy url, Prefetched(@Cell(move data)));
match next_step {
DoDecode => self.decode(url),
DoDecode => self.decode(move url),
_ => ()
}
}
Err(*) => {
self.set_state(copy url, Failed);
self.purge_waiters(url, || ImageFailed);
self.purge_waiters(move url, || ImageFailed);
}
}
}
@ -298,48 +304,45 @@ impl ImageCache {
}
priv fn decode(url: Url) {
match self.get_state(copy url) {
Init => fail ~"decoding image before prefetch",
Init => fail ~"decoding image before prefetch",
Prefetching(DoNotDecode) => {
// We don't have the data yet, queue up the decode
self.set_state(url, Prefetching(DoDecode))
}
Prefetching(DoDecode) => {
// We don't have the data yet, but the decode request is queued up
}
Prefetched(data_cell) => {
assert !data_cell.is_empty();
let data = data_cell.take();
let to_cache = self.chan.clone();
let url_cell = Cell(copy url);
let decode = self.decoder_factory();
do spawn |move url_cell, move decode| {
let url = url_cell.take();
#debug("image_cache_task: started image decode for %s", url.to_str());
let image = decode(data);
let image = if image.is_some() {
Some(ARC(~option::unwrap(image)))
} else {
None
};
to_cache.send(StoreImage(copy url, move image));
#debug("image_cache_task: ended image decode for %s", url.to_str());
Prefetching(DoNotDecode) => {
// We don't have the data yet, queue up the decode
self.set_state(move url, Prefetching(DoDecode))
}
self.set_state(url, Decoding);
}
Prefetching(DoDecode) => {
// We don't have the data yet, but the decode request is queued up
}
Decoding
| Decoded(*)
| Failed => {
// We've already begun decoding
}
Prefetched(data_cell) => {
assert !data_cell.is_empty();
let data = data_cell.take();
let to_cache = self.chan.clone();
let url_cell = Cell(copy url);
let decode = self.decoder_factory();
do spawn |move url_cell, move decode, move data, move to_cache| {
let url = url_cell.take();
#debug("image_cache_task: started image decode for %s", url.to_str());
let image = decode(data);
let image = if image.is_some() {
Some(ARC(~option::unwrap(move image)))
} else {
None
};
to_cache.send(StoreImage(copy url, move image));
#debug("image_cache_task: ended image decode for %s", url.to_str());
}
self.set_state(move url, Decoding);
}
Decoding | Decoded(*) | Failed => {
// We've already begun decoding
}
}
}
@ -350,11 +353,11 @@ impl ImageCache {
match image {
Some(image) => {
self.set_state(copy url, Decoded(@clone_arc(&image)));
self.purge_waiters(url, || ImageReady(clone_arc(&image)) );
self.purge_waiters(move url, || ImageReady(clone_arc(&image)) );
}
None => {
self.set_state(copy url, Failed);
self.purge_waiters(url, || ImageFailed );
self.purge_waiters(move url, || ImageFailed );
}
}
}
@ -376,7 +379,7 @@ impl ImageCache {
for waiters.each |response| {
response.send(f());
}
self.wait_map.remove(url);
self.wait_map.remove(move url);
}
None => ()
}
@ -410,33 +413,30 @@ impl ImageCache {
}
priv fn wait_for_image(url: Url, response: Chan<ImageResponseMsg>) {
match self.get_state(copy url) {
Init => fail ~"request for image before prefetch",
Init => fail ~"request for image before prefetch",
Prefetching(DoNotDecode)
| Prefetched(*) => fail ~"request for image before decode",
Prefetching(DoNotDecode) | Prefetched(*) => fail ~"request for image before decode",
Prefetching(DoDecode)
| Decoding => {
// We don't have this image yet
match self.wait_map.find(copy url) {
Some(waiters) => {
vec::push(&mut *waiters, response);
}
None => {
self.wait_map.insert(url, @mut ~[response]);
}
Prefetching(DoDecode) | Decoding => {
// We don't have this image yet
match self.wait_map.find(copy url) {
Some(waiters) => {
vec::push(&mut *waiters, move response);
}
None => {
self.wait_map.insert(move url, @mut ~[move response]);
}
}
}
}
Decoded(image) => {
response.send(ImageReady(clone_arc(image)));
}
Decoded(image) => {
response.send(ImageReady(clone_arc(image)));
}
Failed => {
response.send(ImageFailed);
}
Failed => {
response.send(ImageFailed);
}
}
}
@ -451,7 +451,7 @@ impl ImageCacheTask: ImageCacheTaskClient {
fn exit() {
let (response_chan, response_port) = stream();
self.send(Exit(response_chan));
self.send(Exit(move response_chan));
response_port.recv();
}
@ -459,21 +459,21 @@ impl ImageCacheTask: ImageCacheTaskClient {
fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<~[u8], ()> {
let response_port = Port();
resource_task.send(resource_task::Load(url, response_port.chan()));
resource_task.send(resource_task::Load(move url, response_port.chan()));
let mut image_data = ~[];
loop {
match response_port.recv() {
resource_task::Payload(data) => {
image_data += data;
}
resource_task::Done(result::Ok(*)) => {
return Ok(image_data);
}
resource_task::Done(result::Err(*)) => {
return Err(());
}
resource_task::Payload(data) => {
image_data += data;
}
resource_task::Done(result::Ok(*)) => {
return Ok(move image_data);
}
resource_task::Done(result::Err(*)) => {
return Err(());
}
}
}
}

View file

@ -10,11 +10,9 @@ use pipes::{Port, Chan, stream};
use image_cache_task::{ImageCacheTask, ImageResponseMsg, Prefetch, Decode, GetImage, WaitForImage, ImageReady, ImageNotReady, ImageFailed};
use util::url::{UrlMap, url_map};
pub fn LocalImageCache(
image_cache_task: ImageCacheTask
) -> LocalImageCache {
pub fn LocalImageCache(image_cache_task: ImageCacheTask) -> LocalImageCache {
LocalImageCache {
image_cache_task: image_cache_task,
image_cache_task: move image_cache_task,
round_number: 1,
mut on_image_available: None,
state_map: url_map()
@ -76,14 +74,14 @@ pub impl LocalImageCache {
unsafe {
let (chan, port) = pipes::stream();
chan.send(ImageReady(clone_arc(image)));
return port;
return move port;
}
}
ImageNotReady => {
if last_round == self.round_number {
let (chan, port) = pipes::stream();
chan.send(ImageNotReady);
return port;
return move port;
} else {
// We haven't requested the image from the
// remote cache this round
@ -92,12 +90,12 @@ pub impl LocalImageCache {
ImageFailed => {
let (chan, port) = pipes::stream();
chan.send(ImageFailed);
return port;
return move port;
}
}
let (response_chan, response_port) = pipes::stream();
self.image_cache_task.send(GetImage(copy *url, response_chan));
self.image_cache_task.send(GetImage(copy *url, move response_chan));
let response = response_port.recv();
match response {
@ -111,9 +109,9 @@ pub impl LocalImageCache {
assert self.on_image_available.is_some();
let on_image_available = self.on_image_available.get()();
let url = copy *url;
do task::spawn |move url, move on_image_available| {
do task::spawn |move url, move on_image_available, move image_cache_task| {
let (response_chan, response_port) = pipes::stream();
image_cache_task.send(WaitForImage(copy url, response_chan));
image_cache_task.send(WaitForImage(copy url, move response_chan));
on_image_available(response_port.recv());
}
}
@ -129,8 +127,8 @@ pub impl LocalImageCache {
state.last_response = move response_copy;
let (chan, port) = pipes::stream();
chan.send(response);
return port;
chan.send(move response);
return move port;
}
priv fn get_state(url: &Url) -> @ImageState {

View file

@ -55,12 +55,12 @@ fn ResourceTask() -> ResourceTask {
(~"file", file_loader::factory),
(~"http", http_loader::factory)
];
create_resource_task_with_loaders(loaders)
create_resource_task_with_loaders(move loaders)
}
fn create_resource_task_with_loaders(loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceTask {
do spawn_listener |from_client| {
// TODO: change copy to move once we can move into closures
do spawn_listener |from_client, move loaders| {
// TODO: change copy to move once we can move out of closures
ResourceManager(from_client, copy loaders).start()
}
}
@ -75,8 +75,8 @@ pub struct ResourceManager {
pub fn ResourceManager(from_client: Port<ControlMsg>,
loaders: ~[(~str, LoaderTaskFactory)]) -> ResourceManager {
ResourceManager {
from_client : from_client,
loaders : loaders,
from_client : move from_client,
loaders : move loaders,
}
}
@ -98,14 +98,14 @@ impl ResourceManager {
fn load(url: Url, progress_chan: Chan<ProgressMsg>) {
match self.get_loader_factory(&url) {
Some(loader_factory) => {
#debug("resource_task: loading url: %s", to_str(copy url));
loader_factory(url, progress_chan);
}
None => {
#debug("resource_task: no loader for scheme %s", url.scheme);
progress_chan.send(Done(Err(())));
}
Some(loader_factory) => {
#debug("resource_task: loading url: %s", to_str(copy url));
loader_factory(move url, progress_chan);
}
None => {
#debug("resource_task: no loader for scheme %s", url.scheme);
progress_chan.send(Done(Err(())));
}
}
}
@ -113,7 +113,7 @@ impl ResourceManager {
for self.loaders.each |scheme_loader| {
let (scheme, loader_factory) = copy *scheme_loader;
if scheme == url.scheme {
return Some(loader_factory);
return Some(move loader_factory);
}
}
return None;

View file

@ -40,17 +40,18 @@ fn run_pipeline_screen(urls: &[~str]) {
// Send each file to render then wait for keypress
let (keypress_to_engine, keypress_from_osmain) = pipes::stream();
osmain.send(AddKeyHandler(keypress_to_engine));
osmain.send(AddKeyHandler(move keypress_to_engine));
// Create a servo instance
let resource_task = ResourceTask();
let image_cache_task = ImageCacheTask(resource_task);
let engine_task = Engine(osmain, dom_event_port, dom_event_chan, resource_task, image_cache_task);
let image_cache_task = ImageCacheTask(copy resource_task);
let engine_task = Engine(osmain, move dom_event_port, move dom_event_chan, move resource_task,
move image_cache_task);
for urls.each |filename| {
let url = make_url(copy *filename, None);
#debug["master: Sending url `%s`", url.to_str()];
engine_task.send(LoadURLMsg(url));
engine_task.send(LoadURLMsg(move url));
#debug["master: Waiting for keypress"];
match keypress_from_osmain.try_recv() {
@ -62,7 +63,7 @@ fn run_pipeline_screen(urls: &[~str]) {
// Shut everything down
#debug["master: Shut down"];
let (exit_chan, exit_response_from_engine) = pipes::stream();
engine_task.send(engine::ExitMsg(exit_chan));
engine_task.send(engine::ExitMsg(move exit_chan));
exit_response_from_engine.recv();
osmain.send(osmain::Exit);
@ -85,7 +86,8 @@ fn run_pipeline_png(url: ~str, outfile: &str) {
// 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 = Engine(compositor, dom_event_port, dom_event_chan, resource_task, image_cache_task);
let engine_task = Engine(copy compositor, move dom_event_port, move dom_event_chan,
move resource_task, move image_cache_task);
engine_task.send(LoadURLMsg(make_url(copy url, None)));
match buffered_file_writer(&Path(outfile)) {
@ -94,7 +96,7 @@ fn run_pipeline_png(url: ~str, outfile: &str) {
}
let (exit_chan, exit_response_from_engine) = pipes::stream();
engine_task.send(engine::ExitMsg(exit_chan));
engine_task.send(engine::ExitMsg(move exit_chan));
exit_response_from_engine.recv();
compositor.send(png_compositor::Exit);
})

View file

@ -1,7 +1,7 @@
pub use font_cache::FontCache;
use au = gfx::geometry;
use au::au;
use au::Au;
use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
@ -30,14 +30,14 @@ struct Font {
struct RunMetrics {
// may be negative due to negative width
advance_width: au,
advance_width: Au,
ascent: au, // nonzero
descent: au, // nonzero
ascent: Au, // nonzero
descent: Au, // nonzero
// this bounding box is relative to the left origin baseline.
// so, bounding_box.position.y = -ascent
bounding_box: Rect<au>
bounding_box: Rect<Au>
}
// Public API
@ -57,11 +57,11 @@ pub impl Font : FontMethods {
// TODO: alter advance direction for RTL
// TODO(Issue #98): using inter-char and inter-word spacing settings when measuring text
let mut advance = au(0);
let mut advance = Au(0);
for run.glyphs.iter_glyphs_for_range(range) |_i, glyph| {
advance += glyph.advance();
}
let mut bounds = Rect(Point2D(au(0), -self.metrics.ascent),
let mut bounds = Rect(Point2D(Au(0), -self.metrics.ascent),
Size2D(advance, self.metrics.ascent + self.metrics.descent));
// TODO(Issue #125): support loose and tight bounding boxes; using the
@ -108,14 +108,14 @@ fn Font(lib: @FontCache, fontbuf: @~[u8], native_font: NativeFont) -> Font {
}
struct FontMetrics {
underline_size: au,
underline_offset: au,
leading: au,
x_height: au,
em_size: au,
ascent: au,
descent: au,
max_advance: au
underline_size: Au,
underline_offset: Au,
leading: Au,
x_height: Au,
em_size: Au,
ascent: Au,
descent: Au,
max_advance: Au
}
const TEST_FONT: [u8 * 33004] = #include_bin("JosefinSans-SemiBold.ttf");

View file

@ -40,11 +40,11 @@ fn create_font(lib: @FontCache, native_lib: &native::NativeFontCache) -> Result<
let font_bin = @test_font_bin();
let native_font = native_font::create(native_lib, font_bin);
let native_font = if native_font.is_ok() {
result::unwrap(native_font)
result::unwrap(move native_font)
} else {
return Err(native_font.get_err());
};
return Ok(@Font(lib, font_bin, native_font));
return Ok(@Font(lib, font_bin, move native_font));
}
#[cfg(target_os = "linux")]

View file

@ -1,5 +1,5 @@
use au = gfx::geometry;
use au::au;
use au::Au;
use core::cmp::{Ord, Eq};
use core::dvec::DVec;
use core::u16;
@ -64,7 +64,7 @@ const FLAG_CAN_BREAK_MASK : u32 = 0x60000000u32;
const FLAG_CAN_BREAK_SHIFT : u32 = 29;
const FLAG_IS_SIMPLE_GLYPH : u32 = 0x80000000u32;
// glyph advance; in au's.
// glyph advance; in Au's.
const GLYPH_ADVANCE_MASK : u32 = 0x0FFF0000u32;
const GLYPH_ADVANCE_SHIFT : u32 = 16;
const GLYPH_ID_MASK : u32 = 0x0000FFFFu32;
@ -95,7 +95,7 @@ pure fn is_simple_glyph_id(glyphId: GlyphIndex) -> bool {
((glyphId as u32) & GLYPH_ID_MASK) == glyphId
}
pure fn is_simple_advance(advance: au) -> bool {
pure fn is_simple_advance(advance: Au) -> bool {
let unsignedAu = advance.to_int() as u32;
(unsignedAu & (GLYPH_ADVANCE_MASK >> GLYPH_ADVANCE_SHIFT)) == unsignedAu
}
@ -107,7 +107,7 @@ pure fn InitialGlyphEntry() -> GlyphEntry {
}
// Creates a GlyphEntry for the common case
pure fn SimpleGlyphEntry(index: GlyphIndex, advance: au) -> GlyphEntry {
pure fn SimpleGlyphEntry(index: GlyphIndex, advance: Au) -> GlyphEntry {
assert is_simple_glyph_id(index);
assert is_simple_advance(advance);
@ -153,7 +153,7 @@ pure fn MissingGlyphsEntry(glyphCount: uint) -> GlyphEntry {
// because GlyphEntry is immutable and only a u32 in size.
impl GlyphEntry {
// getter methods
pure fn advance() -> au {
pure fn advance() -> Au {
assert self.is_simple();
from_int(((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) as int)
}
@ -163,9 +163,9 @@ impl GlyphEntry {
self.value & GLYPH_ID_MASK
}
pure fn offset() -> Point2D<au> {
pure fn offset() -> Point2D<Au> {
assert self.is_simple();
Point2D(au(0), au(0))
Point2D(Au(0), Au(0))
}
pure fn is_ligature_start() -> bool {
@ -243,14 +243,14 @@ impl GlyphEntry {
struct DetailedGlyph {
index: GlyphIndex,
// glyph's advance, in the text's direction (RTL or RTL)
advance: au,
advance: Au,
// glyph's offset from the font's em-box (from top-left)
offset: Point2D<au>
offset: Point2D<Au>
}
fn DetailedGlyph(index: GlyphIndex,
advance: au, offset: Point2D<au>) -> DetailedGlyph {
advance: Au, offset: Point2D<Au>) -> DetailedGlyph {
DetailedGlyph {
index: index,
advance: advance,
@ -381,16 +381,16 @@ impl DetailedGlyphStore {
// It should be allocated on the stack and passed by reference to GlyphStore.
struct GlyphData {
index: GlyphIndex,
advance: au,
offset: Point2D<au>,
advance: Au,
offset: Point2D<Au>,
is_missing: bool,
cluster_start: bool,
ligature_start: bool,
}
pure fn GlyphData(index: GlyphIndex,
advance: au,
offset: Option<Point2D<au>>,
advance: Au,
offset: Option<Point2D<Au>>,
is_missing: bool,
cluster_start: bool,
ligature_start: bool) -> GlyphData {
@ -427,14 +427,14 @@ impl GlyphInfo {
}
}
fn advance() -> au {
fn advance() -> Au {
match self {
SimpleGlyphInfo(store, entry_i) => store.entry_buffer[entry_i].advance(),
DetailGlyphInfo(store, entry_i, detail_j) => store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).advance
}
}
fn offset() -> Option<Point2D<au>> {
fn offset() -> Option<Point2D<Au>> {
match self {
SimpleGlyphInfo(_, _) => None,
DetailGlyphInfo(store, entry_i, detail_j) => Some(store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).offset)
@ -471,7 +471,7 @@ fn GlyphStore(length: uint) -> GlyphStore {
let buffer = vec::from_elem(length, InitialGlyphEntry());
GlyphStore {
entry_buffer: dvec::from_vec(buffer),
entry_buffer: dvec::from_vec(move buffer),
detail_store: DetailedGlyphStore(),
}
}

View file

@ -211,6 +211,6 @@ pub fn with_test_native_font(f: fn@(nf: &NativeFont)) {
let buf = @test_font_bin();
let res = create(buf);
let font = unwrap_result(res);
let font = unwrap_result(move res);
f(&font);
}

View file

@ -1,7 +1,7 @@
extern mod harfbuzz;
use au = gfx::geometry;
use au::au;
use au::Au;
use core::num::from_int;
use font::Font;
use font_cache::FontCache;
@ -110,7 +110,7 @@ pub fn shape_textrun(run: &TextRun) {
let hb_info: hb_glyph_info_t = *offset(info_buf, i);
let hb_pos: hb_glyph_position_t = *offset(pos_buf, i);
let codepoint = hb_info.codepoint as GlyphIndex;
let advance: au = au::from_frac_px(fixed_to_float_hb(hb_pos.x_advance));
let advance: Au = au::from_frac_px(fixed_to_float_hb(hb_pos.x_advance));
let offset = match (hb_pos.x_offset, hb_pos.y_offset) {
(0, 0) => None,
(x, y) => Some(Point2D(au::from_frac_px(fixed_to_float_hb(x)),

View file

@ -5,7 +5,7 @@ use font::{RunMetrics, Font};
use font_cache::FontCache;
use geom::point::Point2D;
use geom::size::Size2D;
use gfx::geometry::au;
use gfx::geometry::Au;
use glyph::GlyphStore;
use layout::context::LayoutContext;
use libc::{c_void};
@ -54,7 +54,7 @@ trait TextRunMethods {
pure fn range_is_trimmable_whitespace(&self, range: Range) -> bool;
fn metrics_for_range(&self, range: Range) -> RunMetrics;
fn min_width_for_range(&self, range: Range) -> au;
fn min_width_for_range(&self, range: Range) -> Au;
fn iter_natural_lines_for_range(&self, range: Range, f: fn&(Range) -> bool);
}
@ -79,10 +79,10 @@ impl TextRun : TextRunMethods {
self.font.measure_text(self, range)
}
fn min_width_for_range(&self, range: Range) -> au {
fn min_width_for_range(&self, range: Range) -> Au {
assert range.is_valid_for_string(self.text);
let mut max_piece_width = au(0);
let mut max_piece_width = Au(0);
for self.iter_indivisible_pieces_for_range(range) |piece_range| {
let metrics = self.font.measure_text(self, piece_range);
max_piece_width = au::max(max_piece_width, metrics.advance_width);
@ -163,13 +163,13 @@ impl TextRun : TextRunMethods {
fn TextRun(font: @Font, text: ~str) -> TextRun {
let glyph_store = GlyphStore(text.len());
let run = TextRun {
text: text,
text: move text,
font: font,
glyphs: glyph_store,
glyphs: move glyph_store,
};
shape_textrun(&run);
return run;
return move run;
}
// this test can't run until LayoutContext is removed as an argument
@ -178,7 +178,7 @@ fn TextRun(font: @Font, text: ~str) -> TextRun {
#[test]
fn test_calc_min_break_width() {
fn test_min_width_for_run(text: ~str, width: au) {
fn test_min_width_for_run(text: ~str, width: Au) {
let flib = FontCache();
let font = flib.get_test_font();
let run = TextRun(font, text);

View file

@ -81,7 +81,7 @@ pub fn transform_text(text: &str, mode: CompressionMode) -> ~str {
}
}
return out_str;
return move out_str;
fn is_discardable_char(ch: char, mode: CompressionMode) -> bool {
if is_always_discardable_char(ch) {

View file

@ -30,13 +30,13 @@ fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
} else {
let path = str::split_char(current_url.path, '/');
let path = path.init();
let path = str::connect(path + ~[str_url], "/");
let path = str::connect(path + ~[move str_url], "/");
current_url.scheme + "://" + current_url.host + path
}
}
} else {
str_url
move str_url
};
// FIXME: Need to handle errors