Update for language changes

This commit is contained in:
Patrick Walton 2013-02-19 18:42:16 -08:00
parent 2483797f48
commit a64821b151
34 changed files with 229 additions and 206 deletions

@ -1 +1 @@
Subproject commit f060d17c2e738f0136a3a1a57eb6363eddf9ca78 Subproject commit 474721fb86731c37f8c56a8dee28f96f22fe30b9

View file

@ -76,7 +76,7 @@ pub fn ContentTask(layout_task: LayoutTask,
content.start(); content.start();
} }
return move control_chan; return control_chan;
} }
pub struct Content { pub struct Content {
@ -126,27 +126,27 @@ pub fn Content(layout_task: LayoutTask,
}; };
let content = @Content { let content = @Content {
layout_task : move layout_task, layout_task: layout_task,
layout_join_port : None, layout_join_port: None,
image_cache_task : move img_cache_task, image_cache_task: img_cache_task,
control_port : move control_port, control_port: control_port,
control_chan : move control_chan, control_chan: control_chan,
event_port : move event_port, event_port: event_port,
event_chan : move event_chan, event_chan: event_chan,
scope : NodeScope(), scope: NodeScope(),
jsrt : jsrt, jsrt: jsrt,
cx : cx, cx: cx,
document : None, document: None,
window : None, window: None,
doc_url : None, doc_url: None,
window_size : Size2D(800u, 600u), window_size: Size2D(800u, 600u),
resource_task : resource_task, resource_task: resource_task,
compartment : compartment, compartment: compartment,
damage : MatchSelectorsDamage, damage: MatchSelectorsDamage,
}; };
cx.set_cx_private(ptr::to_unsafe_ptr(&*content) as *()); cx.set_cx_private(ptr::to_unsafe_ptr(&*content) as *());
@ -176,8 +176,8 @@ impl Content {
} }
fn handle_control_msg(control_msg: ControlMsg) -> bool { fn handle_control_msg(control_msg: ControlMsg) -> bool {
match move control_msg { match control_msg {
ParseMsg(move url) => { ParseMsg(url) => {
debug!("content: Received url `%s` to parse", url_to_str(&url)); debug!("content: Received url `%s` to parse", url_to_str(&url));
// Note: we can parse the next document in parallel // Note: we can parse the next document in parallel
@ -195,8 +195,8 @@ impl Content {
// and do not need to stop here in the content task // and do not need to stop here in the content task
loop { loop {
match result.style_port.recv() { match result.style_port.recv() {
Some(move sheet) => { Some(sheet) => {
self.layout_task.send(AddStylesheet(move sheet)); self.layout_task.send(AddStylesheet(sheet));
} }
None => break None => break
} }
@ -211,9 +211,9 @@ impl Content {
self.damage.add(MatchSelectorsDamage); self.damage.add(MatchSelectorsDamage);
self.relayout(&document, &url); self.relayout(&document, &url);
self.document = Some(@move document); self.document = Some(@document);
self.window = Some(@move window); self.window = Some(@window);
self.doc_url = Some(move url); self.doc_url = Some(url);
let compartment = option::expect(self.compartment, ~"TODO error checking"); let compartment = option::expect(self.compartment, ~"TODO error checking");
compartment.define_functions(debug_fns); compartment.define_functions(debug_fns);
@ -221,8 +221,8 @@ impl Content {
option::get(self.document), option::get(self.document),
option::get(self.window)); option::get(self.window));
do vec::consume(move js_scripts) |_i, bytes| { do vec::consume(js_scripts) |_i, bytes| {
self.cx.evaluate_script(compartment.global_obj, move bytes, ~"???", 1u); self.cx.evaluate_script(compartment.global_obj, bytes, ~"???", 1u);
} }
return true; return true;
@ -251,10 +251,10 @@ impl Content {
Err(msg) => { Err(msg) => {
println(fmt!("Error opening %s: %s", url_to_str(&url), msg)); println(fmt!("Error opening %s: %s", url_to_str(&url), msg));
} }
Ok(move bytes) => { Ok(bytes) => {
let compartment = option::expect(self.compartment, ~"TODO error checking"); let compartment = option::expect(self.compartment, ~"TODO error checking");
compartment.define_functions(debug_fns); compartment.define_functions(debug_fns);
self.cx.evaluate_script(compartment.global_obj, move bytes, copy url.path, 1u); self.cx.evaluate_script(compartment.global_obj, bytes, copy url.path, 1u);
} }
} }
return true; return true;
@ -307,7 +307,7 @@ impl Content {
// Layout will let us know when it's done // Layout will let us know when it's done
let (join_port, join_chan) = pipes::stream(); let (join_port, join_chan) = pipes::stream();
self.layout_join_port = move Some(move join_port); self.layout_join_port = Some(join_port);
// Send new document and relevant styles to layout // Send new document and relevant styles to layout
@ -316,11 +316,11 @@ impl Content {
url: copy *doc_url, url: copy *doc_url,
dom_event_chan: self.event_chan.clone(), dom_event_chan: self.event_chan.clone(),
window_size: self.window_size, window_size: self.window_size,
content_join_chan: move join_chan, content_join_chan: join_chan,
damage: replace(&mut self.damage, NoDamage), damage: replace(&mut self.damage, NoDamage),
}; };
self.layout_task.send(BuildMsg(move data)); self.layout_task.send(BuildMsg(data));
// Indicate that reader was forked so any further // Indicate that reader was forked so any further
// changes will be isolated. // changes will be isolated.

View file

@ -13,7 +13,7 @@ pub trait MatchMethods {
fn restyle_subtree(select_ctx: &SelectCtx); fn restyle_subtree(select_ctx: &SelectCtx);
} }
impl Node : MatchMethods { impl MatchMethods for Node {
/** /**
* Performs CSS selector matching on a subtree. * Performs CSS selector matching on a subtree.
@ -30,8 +30,8 @@ impl Node : MatchMethods {
}; };
let incomplete_results = select_ctx.select_style(&self, &select_handler); let incomplete_results = select_ctx.select_style(&self, &select_handler);
// Combine this node's results with its parent's to resolve all inherited values // Combine this node's results with its parent's to resolve all inherited values
let complete_results = compose_results(&self, move incomplete_results); let complete_results = compose_results(&self, incomplete_results);
self.set_css_select_results(move complete_results); self.set_css_select_results(complete_results);
} }
let mut i = 0u; let mut i = 0u;
@ -45,10 +45,10 @@ impl Node : MatchMethods {
fn compose_results(node: &Node, results: SelectResults) -> CompleteSelectResults { fn compose_results(node: &Node, results: SelectResults) -> CompleteSelectResults {
match find_parent_element_node(node) { match find_parent_element_node(node) {
None => CompleteSelectResults::new_root(move results), None => CompleteSelectResults::new_root(results),
Some(parent_node) => { Some(parent_node) => {
let parent_results = parent_node.get_css_select_results(); let parent_results = parent_node.get_css_select_results();
CompleteSelectResults::new_from_parent(parent_results, move results) CompleteSelectResults::new_from_parent(parent_results, results)
} }
} }
} }

View file

@ -9,7 +9,7 @@ pub trait StyledNode {
fn style(&self) -> CompleteStyle/&self; fn style(&self) -> CompleteStyle/&self;
} }
impl Node: StyledNode { impl StyledNode for Node {
fn style(&self) -> CompleteStyle/&self { fn style(&self) -> CompleteStyle/&self {
assert self.is_element(); // Only elements can have styles assert self.is_element(); // Only elements can have styles
let results = self.get_css_select_results(); let results = self.get_css_select_results();

View file

@ -31,7 +31,7 @@ impl NodeUtil for Node {
Update the computed style of an HTML element with a style specified by CSS. Update the computed style of an HTML element with a style specified by CSS.
*/ */
fn set_css_select_results(decl : CompleteSelectResults) { fn set_css_select_results(decl : CompleteSelectResults) {
let decl = Cell(move decl); let decl = Cell(decl);
do self.aux |data| { do self.aux |data| {
data.style = Some(decl.take()) data.style = Some(decl.take())
} }

View file

@ -6,7 +6,7 @@ use dom::node::Node;
extern mod netsurfcss; extern mod netsurfcss;
use css::node_void_ptr::netsurfcss::util::VoidPtrLike; use css::node_void_ptr::netsurfcss::util::VoidPtrLike;
impl Node: VoidPtrLike { impl VoidPtrLike for Node {
static fn from_void_ptr(node: *libc::c_void) -> Node { static fn from_void_ptr(node: *libc::c_void) -> Node {
assert node.is_not_null(); assert node.is_not_null();
unsafe { cast::reinterpret_cast(&node) } unsafe { cast::reinterpret_cast(&node) }

View file

@ -10,7 +10,7 @@ pub fn new_css_select_ctx() -> SelectCtx {
let mut ctx = SelectCtx::new(); let mut ctx = SelectCtx::new();
ctx.append_sheet(html4_default_style(), OriginUA); ctx.append_sheet(html4_default_style(), OriginUA);
ctx.append_sheet(servo_default_style(), OriginUA); ctx.append_sheet(servo_default_style(), OriginUA);
return move ctx; return ctx;
} }
fn html4_default_style() -> Stylesheet { fn html4_default_style() -> Stylesheet {
@ -29,7 +29,7 @@ fn default_url(name: &str) -> Url {
fn style_stream(style: &str) -> DataStream { fn style_stream(style: &str) -> DataStream {
let style = Cell(str::to_bytes(style)); let style = Cell(str::to_bytes(style));
let d: DataStream = |move style| if !style.is_empty() { let d: DataStream = || if !style.is_empty() {
Some(style.take()) Some(style.take())
} else { } else {
None None
@ -123,4 +123,4 @@ ul, ol, dl { page-break-before: avoid }
fn servo_default_style_str() -> ~str { fn servo_default_style_str() -> ~str {
// libcss want's this to default to 2px.. // libcss want's this to default to 2px..
~"* { border-width: 0px; }" ~"* { border-width: 0px; }"
} }

View file

@ -13,7 +13,7 @@ fn with_node_name<R>(data: &NodeData, f: &fn(&str) -> R) -> R {
} }
} }
impl NodeSelectHandler: SelectHandler<Node> { impl SelectHandler<Node> for NodeSelectHandler {
fn with_node_name<R>(node: &Node, f: &fn(&str) -> R) -> R { fn with_node_name<R>(node: &Node, f: &fn(&str) -> R) -> R {
do node.read |data| { do node.read |data| {
with_node_name(data, f) with_node_name(data, f)

View file

@ -99,6 +99,11 @@ pub fn init(compartment: @mut Compartment, doc: @Document) {
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: getDocumentElement, info: null()}, getter: {op: getDocumentElement, info: null()},
setter: {op: null(), info: null()}},
{name: null(),
tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: null(), info: null()},
setter: {op: null(), info: null()}}]; setter: {op: null(), info: null()}}];
vec::push(&mut compartment.global_props, attrs); vec::push(&mut compartment.global_props, attrs);
vec::as_imm_buf(*attrs, |specs, _len| { vec::as_imm_buf(*attrs, |specs, _len| {

View file

@ -36,6 +36,11 @@ pub fn init(compartment: @mut Compartment) {
tinyid: 0, tinyid: 0,
flags: (JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: getTagName, info: null()}, getter: {op: getTagName, info: null()},
setter: {op: null(), info: null()}},
{name: null(),
tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: null(), info: null()},
setter: {op: null(), info: null()}}]; setter: {op: null(), info: null()}}];
vec::push(&mut compartment.global_props, attrs); vec::push(&mut compartment.global_props, attrs);
vec::as_imm_buf(*attrs, |specs, _len| { vec::as_imm_buf(*attrs, |specs, _len| {
@ -56,7 +61,12 @@ pub fn init(compartment: @mut Compartment) {
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: HTMLImageElement_getWidth, info: null()}, getter: {op: HTMLImageElement_getWidth, info: null()},
setter: {op: HTMLImageElement_setWidth, info: null()}}]; setter: {op: HTMLImageElement_setWidth, info: null()}},
{name: null(),
tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: null(), info: null()},
setter: {op: null(), info: null()}}];
vec::push(&mut compartment.global_props, attrs); vec::push(&mut compartment.global_props, attrs);
vec::as_imm_buf(*attrs, |specs, _len| { vec::as_imm_buf(*attrs, |specs, _len| {
JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs); JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs);
@ -173,9 +183,9 @@ pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj {
//XXXjdm the parent should probably be the node parent instead of the global //XXXjdm the parent should probably be the node parent instead of the global
//TODO error checking //TODO error checking
let compartment = utils::get_compartment(cx); let compartment = utils::get_compartment(cx);
let obj = result::unwrap( let obj = result::unwrap(compartment.new_object_with_proto(~"GenericElementInstance",
compartment.new_object_with_proto(~"GenericElementInstance", move proto, proto,
compartment.global_obj.ptr)); compartment.global_obj.ptr));
unsafe { unsafe {
let raw_ptr: *libc::c_void = let raw_ptr: *libc::c_void =

View file

@ -38,6 +38,12 @@ pub fn init(compartment: @mut Compartment) {
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: getNodeType, info: null()}, getter: {op: getNodeType, info: null()},
setter: {op: null(), info: null()}},
{name: null(),
tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: null(), info: null()},
setter: {op: null(), info: null()}}]; setter: {op: null(), info: null()}}];
vec::push(&mut compartment.global_props, attrs); vec::push(&mut compartment.global_props, attrs);
vec::as_imm_buf(*attrs, |specs, _len| { vec::as_imm_buf(*attrs, |specs, _len| {

View file

@ -28,7 +28,7 @@ pub unsafe fn squirrel_away<T>(x: @T) -> *rust_box<T> {
pub unsafe fn squirrel_away_unique<T>(x: ~T) -> *rust_box<T> { pub unsafe fn squirrel_away_unique<T>(x: ~T) -> *rust_box<T> {
let y: *rust_box<T> = cast::reinterpret_cast(&x); let y: *rust_box<T> = cast::reinterpret_cast(&x);
cast::forget(move x); cast::forget(x);
y y
} }
@ -97,7 +97,7 @@ extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *JSVal, bp: *mut JSB
} }
pub fn prototype_jsclass(name: ~str) -> @fn(compartment: @mut Compartment) -> JSClass { pub fn prototype_jsclass(name: ~str) -> @fn(compartment: @mut Compartment) -> JSClass {
let f: @fn(@mut Compartment) -> JSClass = |compartment: @mut Compartment, move name| { let f: @fn(@mut Compartment) -> JSClass = |compartment: @mut Compartment| {
JSClass { JSClass {
name: compartment.add_name(copy name), name: compartment.add_name(copy name),
flags: 0, flags: 0,
@ -129,7 +129,7 @@ pub fn prototype_jsclass(name: ~str) -> @fn(compartment: @mut Compartment) -> JS
pub fn instance_jsclass(name: ~str, finalize: *u8) pub fn instance_jsclass(name: ~str, finalize: *u8)
-> @fn(compartment: @mut Compartment) -> JSClass { -> @fn(compartment: @mut Compartment) -> JSClass {
let f: @fn(@mut Compartment) -> JSClass = |compartment: @mut Compartment, move name| { let f: @fn(@mut Compartment) -> JSClass = |compartment: @mut Compartment| {
JSClass { JSClass {
name: compartment.add_name(copy name), name: compartment.add_name(copy name),
flags: JSCLASS_HAS_RESERVED_SLOTS(1), flags: JSCLASS_HAS_RESERVED_SLOTS(1),
@ -166,9 +166,10 @@ pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut
//TODO error checking //TODO error checking
let obj = result::unwrap( let obj = result::unwrap(
match move proto { match proto {
Some(move s) => compartment.new_object_with_proto(copy name, move s, Some(s) => compartment.new_object_with_proto(copy name,
compartment.global_obj.ptr), s,
compartment.global_obj.ptr),
None => compartment.new_object(copy name, null(), compartment.global_obj.ptr) None => compartment.new_object(copy name, null(), compartment.global_obj.ptr)
}); });
@ -176,6 +177,6 @@ pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut
GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8, GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8,
JSPROP_ENUMERATE); JSPROP_ENUMERATE);
compartment.stash_global_proto(move name, obj); compartment.stash_global_proto(name, obj);
return obj; return obj;
} }

View file

@ -80,7 +80,7 @@ struct ScopeResource<T,A> {
} }
fn ScopeResource<T:Owned,A>(d : ScopeData<T,A>) -> ScopeResource<T,A> { fn ScopeResource<T:Owned,A>(d : ScopeData<T,A>) -> ScopeResource<T,A> {
ScopeResource { d: move d } ScopeResource { d: d }
} }
pub type Scope<T,A> = @ScopeResource<T,A>; pub type Scope<T,A> = @ScopeResource<T,A>;
@ -143,7 +143,7 @@ impl<T:Owned,A> Handle<T,A> {
} }
} }
impl <T: Owned,A> Handle<T,A> : cmp::Eq { impl<T:Owned,A> cmp::Eq for Handle<T,A> {
pure fn eq(&self, other: &Handle<T,A>) -> bool { **self == **other } pure fn eq(&self, other: &Handle<T,A>) -> bool { **self == **other }
pure fn ne(&self, other: &Handle<T,A>) -> bool { **self != **other } pure fn ne(&self, other: &Handle<T,A>) -> bool { **self != **other }
} }
@ -166,7 +166,7 @@ impl<T: Copy Owned,A> Scope<T,A> {
} }
unsafe fn free<T>(t: *T) { unsafe fn free<T>(t: *T) {
let _x = move *cast::reinterpret_cast::<*T,*mut T>(&t); let _x = *cast::reinterpret_cast::<*T,*mut T>(&t);
libc::free(cast::reinterpret_cast(&t)); libc::free(cast::reinterpret_cast(&t));
} }

View file

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

View file

@ -35,7 +35,7 @@ impl NodeTree {
} }
} }
impl NodeTree : tree::ReadMethods<Node> { impl tree::ReadMethods<Node> for NodeTree {
fn with_tree_fields<R>(n: &Node, f: fn(&tree::Tree<Node>) -> R) -> R { fn with_tree_fields<R>(n: &Node, f: fn(&tree::Tree<Node>) -> R) -> R {
n.read(|n| f(&n.tree)) n.read(|n| f(&n.tree))
} }
@ -53,7 +53,7 @@ impl Node {
} }
} }
impl Node : DebugMethods { impl DebugMethods for Node {
/* Dumps the subtree rooted at this node, for debugging. */ /* Dumps the subtree rooted at this node, for debugging. */
pure fn dump(&self) { pure fn dump(&self) {
self.dump_indent(0u); self.dump_indent(0u);
@ -106,9 +106,9 @@ pub struct DoctypeData {
pub fn DoctypeData(name: ~str, public_id: Option<~str>, pub fn DoctypeData(name: ~str, public_id: Option<~str>,
system_id: Option<~str>, force_quirks: bool) -> DoctypeData { system_id: Option<~str>, force_quirks: bool) -> DoctypeData {
DoctypeData { DoctypeData {
name : move name, name : name,
public_id : move public_id, public_id : public_id,
system_id : move system_id, system_id : system_id,
force_quirks : force_quirks, force_quirks : force_quirks,
} }
} }
@ -146,9 +146,9 @@ pub trait NodeScopeExtensions {
} }
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
impl NodeScope : NodeScopeExtensions { impl NodeScopeExtensions for NodeScope {
fn new_node(k: NodeKind) -> Node { fn new_node(k: NodeKind) -> Node {
self.handle(&NodeData({tree: tree::empty(), kind: ~move k})) self.handle(&NodeData({tree: tree::empty(), kind: ~k}))
} }
} }
@ -163,7 +163,7 @@ impl NodeScope {
} }
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
impl NodeScope : tree::ReadMethods<Node> { impl tree::ReadMethods<Node> for NodeScope {
fn with_tree_fields<R>(node: &Node, f: fn(&tree::Tree<Node>) -> R) -> R { fn with_tree_fields<R>(node: &Node, f: fn(&tree::Tree<Node>) -> R) -> R {
self.read(node, |n| f(&n.tree)) self.read(node, |n| f(&n.tree))
} }
@ -176,7 +176,7 @@ impl NodeScope {
} }
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
impl NodeScope : tree::WriteMethods<Node> { impl tree::WriteMethods<Node> for NodeScope {
pure fn tree_eq(a: &Node, b: &Node) -> bool { a == b } pure fn tree_eq(a: &Node, b: &Node) -> bool { a == b }
fn with_tree_fields<R>(node: &Node, f: fn(&tree::Tree<Node>) -> R) -> R { fn with_tree_fields<R>(node: &Node, f: fn(&tree::Tree<Node>) -> R) -> R {

View file

@ -41,7 +41,7 @@ pub fn TimerData(argc: libc::c_uint, argv: *JSVal) -> TimerData {
i += 1; i += 1;
}; };
move data data
} }
} }
@ -72,13 +72,12 @@ impl Window {
pub fn Window(content_chan: pipes::SharedChan<ControlMsg>) -> Window { pub fn Window(content_chan: pipes::SharedChan<ControlMsg>) -> Window {
Window { Window {
timer_chan: do spawn_listener |timer_port: Port<TimerControlMsg>, timer_chan: do spawn_listener |timer_port: Port<TimerControlMsg>| {
move content_chan| {
loop { loop {
match move timer_port.recv() { match timer_port.recv() {
TimerMessage_Close => break, TimerMessage_Close => break,
TimerMessage_Fire(move td) => { TimerMessage_Fire(td) => {
content_chan.send(Timer(move td)); content_chan.send(Timer(td));
} }
TimerMessage_TriggerExit => content_chan.send(ExitMsg) TimerMessage_TriggerExit => content_chan.send(ExitMsg)
} }

View file

@ -59,8 +59,8 @@ pub fn Engine<C:Compositor + Owned + Clone>(compositor: C,
render_task: render_task, render_task: render_task,
resource_task: resource_task.clone(), resource_task: resource_task.clone(),
image_cache_task: image_cache_task.clone(), image_cache_task: image_cache_task.clone(),
layout_task: move layout_task, layout_task: layout_task,
content_task: move content_task content_task: content_task
}.run(); }.run();
} }
} }
@ -73,23 +73,23 @@ impl<C:Compositor + Owned + Clone> Engine<C> {
} }
fn handle_request(request: Msg) -> bool { fn handle_request(request: Msg) -> bool {
match move request { match request {
LoadURLMsg(move url) => { LoadURLMsg(url) => {
if url.path.ends_with(".js") { if url.path.ends_with(".js") {
self.content_task.send(ExecuteMsg(move url)) self.content_task.send(ExecuteMsg(url))
} else { } else {
self.content_task.send(ParseMsg(move url)) self.content_task.send(ParseMsg(url))
} }
return true; return true;
} }
ExitMsg(move sender) => { ExitMsg(sender) => {
self.content_task.send(content_task::ExitMsg); self.content_task.send(content_task::ExitMsg);
self.layout_task.send(layout_task::ExitMsg); self.layout_task.send(layout_task::ExitMsg);
let (response_port, response_chan) = pipes::stream(); let (response_port, response_chan) = pipes::stream();
self.render_task.send(render_task::ExitMsg(move response_chan)); self.render_task.send(render_task::ExitMsg(response_chan));
response_port.recv(); response_port.recv();
self.image_cache_task.exit(); self.image_cache_task.exit();

View file

@ -24,12 +24,12 @@ pub fn spawn_css_parser(provenance: StylesheetProvenance,
-> Port<Stylesheet> { -> Port<Stylesheet> {
let (result_port, result_chan) = pipes::stream(); let (result_port, result_chan) = pipes::stream();
let provenance_cell = Cell(move provenance); let provenance_cell = Cell(provenance);
do task::spawn |move provenance_cell, copy resource_task| { do task::spawn |copy resource_task| {
let url = do provenance_cell.with_ref |p| { let url = do provenance_cell.with_ref |p| {
match *p { match *p {
UrlProvenance(copy the_url) => move the_url, UrlProvenance(copy the_url) => the_url,
InlineProvenance(copy the_url, _) => move the_url InlineProvenance(copy the_url, _) => the_url
} }
}; };
@ -42,14 +42,14 @@ pub fn spawn_css_parser(provenance: StylesheetProvenance,
} }
fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) -> DataStream { fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) -> DataStream {
match move provenance { match provenance {
UrlProvenance(move url) => { UrlProvenance(url) => {
let (input_port, input_chan) = pipes::stream(); let (input_port, input_chan) = pipes::stream();
resource_task.send(Load(move url, input_chan)); resource_task.send(Load(url, input_chan));
resource_port_to_data_stream(input_port) resource_port_to_data_stream(input_port)
} }
InlineProvenance(_, move data) => { InlineProvenance(_, data) => {
data_to_data_stream(move data) data_to_data_stream(data)
} }
} }
} }
@ -57,15 +57,15 @@ fn data_stream(provenance: StylesheetProvenance, resource_task: ResourceTask) ->
fn resource_port_to_data_stream(input_port: Port<ProgressMsg>) -> DataStream { fn resource_port_to_data_stream(input_port: Port<ProgressMsg>) -> DataStream {
return || { return || {
match input_port.recv() { match input_port.recv() {
Payload(move data) => Some(move data), Payload(data) => Some(data),
Done(*) => None Done(*) => None
} }
} }
} }
fn data_to_data_stream(data: ~str) -> DataStream { fn data_to_data_stream(data: ~str) -> DataStream {
let data_cell = Cell(move data); let data_cell = Cell(data);
return |move data_cell| { return || {
if data_cell.is_empty() { if data_cell.is_empty() {
None None
} else { } else {

View file

@ -70,7 +70,7 @@ fn css_link_listener(to_parent: Chan<Option<Stylesheet>>,
// Send the sheets back in order // Send the sheets back in order
// FIXME: Shouldn't wait until after we've recieved CSSTaskExit to start sending these // FIXME: Shouldn't wait until after we've recieved CSSTaskExit to start sending these
do vec::consume(move result_vec) |_i, port| { do vec::consume(result_vec) |_i, port| {
to_parent.send(Some(port.recv())); to_parent.send(Some(port.recv()));
} }
to_parent.send(None); to_parent.send(None);
@ -83,7 +83,7 @@ fn js_script_listener(to_parent: Chan<~[~[u8]]>,
loop { loop {
match from_parent.recv() { match from_parent.recv() {
JSTaskNewFile(move url) => { JSTaskNewFile(url) => {
let (result_port, result_chan) = pipes::stream(); let (result_port, result_chan) = pipes::stream();
let resource_task = resource_task.clone(); let resource_task = resource_task.clone();
do task::spawn { do task::spawn {
@ -94,11 +94,11 @@ fn js_script_listener(to_parent: Chan<~[~[u8]]>,
let mut buf = ~[]; let mut buf = ~[];
loop { loop {
match input_port.recv() { match input_port.recv() {
Payload(move data) => { Payload(data) => {
buf += data; buf += data;
} }
Done(Ok(*)) => { Done(Ok(*)) => {
result_chan.send(move buf); result_chan.send(buf);
break; break;
} }
Done(Err(*)) => { Done(Err(*)) => {
@ -116,7 +116,7 @@ fn js_script_listener(to_parent: Chan<~[~[u8]]>,
} }
let js_scripts = vec::map(result_vec, |result_port| result_port.recv()); let js_scripts = vec::map(result_vec, |result_port| result_port.recv());
to_parent.send(move js_scripts); to_parent.send(js_scripts);
} }
fn build_element_kind(tag: &str) -> ~ElementKind { fn build_element_kind(tag: &str) -> ~ElementKind {
@ -185,7 +185,7 @@ pub fn parse_html(scope: NodeScope,
}; };
let js_chan = SharedChan(js_chan); let js_chan = SharedChan(js_chan);
let (scope, url) = (@copy scope, @move url); let (scope, url) = (@copy scope, @url);
unsafe { unsafe {
// Build the root node. // Build the root node.
@ -208,9 +208,9 @@ pub fn parse_html(scope: NodeScope,
~HTMLStyleElement => { ~HTMLStyleElement => {
debug!("found inline CSS stylesheet"); debug!("found inline CSS stylesheet");
let url = url::from_str("http://example.com/"); // FIXME let url = url::from_str("http://example.com/"); // FIXME
let provenance = InlineProvenance(result::unwrap(move url), let provenance = InlineProvenance(result::unwrap(url),
copy *data); copy *data);
css_chan2.send(CSSTaskNewFile(move provenance)); css_chan2.send(CSSTaskNewFile(provenance));
} }
_ => {} // Nothing to do. _ => {} // Nothing to do.
} }
@ -225,7 +225,7 @@ pub fn parse_html(scope: NodeScope,
parser.set_tree_handler(@hubbub::TreeHandler { parser.set_tree_handler(@hubbub::TreeHandler {
create_comment: |data: ~str| { create_comment: |data: ~str| {
debug!("create comment"); debug!("create comment");
let new_node = scope.new_node(Comment(move data)); let new_node = scope.new_node(Comment(data));
unsafe { cast::transmute(cow::unwrap(new_node)) } unsafe { cast::transmute(cow::unwrap(new_node)) }
}, },
create_doctype: |doctype: ~hubbub::Doctype| { create_doctype: |doctype: ~hubbub::Doctype| {
@ -240,17 +240,19 @@ pub fn parse_html(scope: NodeScope,
&None => None, &None => None,
&Some(ref id) => Some(copy *id) &Some(ref id) => Some(copy *id)
}; };
let data = DoctypeData(copy doctype.name, move public_id, move system_id, let data = DoctypeData(copy doctype.name,
public_id,
system_id,
copy doctype.force_quirks); copy doctype.force_quirks);
let new_node = scope.new_node(Doctype(move data)); let new_node = scope.new_node(Doctype(data));
unsafe { cast::transmute(cow::unwrap(new_node)) } unsafe { cast::transmute(cow::unwrap(new_node)) }
}, },
create_element: |tag: ~hubbub::Tag, move image_cache_task| { create_element: |tag: ~hubbub::Tag| {
debug!("create element"); debug!("create element");
// TODO: remove copying here by using struct pattern matching to // TODO: remove copying here by using struct pattern matching to
// move all ~strs at once (blocked on Rust #3845, #3846, #3847) // move all ~strs at once (blocked on Rust #3845, #3846, #3847)
let elem_kind = build_element_kind(tag.name); let elem_kind = build_element_kind(tag.name);
let elem = ElementData(copy tag.name, move elem_kind); let elem = ElementData(copy tag.name, elem_kind);
debug!("-- attach attrs"); debug!("-- attach attrs");
for tag.attributes.each |attr| { for tag.attributes.each |attr| {
@ -262,7 +264,7 @@ pub fn parse_html(scope: NodeScope,
//Handle CSS style sheets from <link> elements //Handle CSS style sheets from <link> elements
~HTMLLinkElement => { ~HTMLLinkElement => {
match (elem.get_attr(~"rel"), elem.get_attr(~"href")) { match (elem.get_attr(~"rel"), elem.get_attr(~"href")) {
(Some(move rel), Some(move href)) => { (Some(rel), Some(href)) => {
if rel == ~"stylesheet" { if rel == ~"stylesheet" {
debug!("found CSS stylesheet: %s", href); debug!("found CSS stylesheet: %s", href);
css_chan2.send(CSSTaskNewFile(UrlProvenance(make_url( css_chan2.send(CSSTaskNewFile(UrlProvenance(make_url(
@ -278,18 +280,18 @@ pub fn parse_html(scope: NodeScope,
d.image = Some(copy img_url); d.image = Some(copy img_url);
// inform the image cache to load this, but don't store a handle. // inform the image cache to load this, but don't store a handle.
// TODO (Issue #84): don't prefetch if we are within a <noscript> tag. // TODO (Issue #84): don't prefetch if we are within a <noscript> tag.
image_cache_task.send(image_cache_task::Prefetch(move img_url)); image_cache_task.send(image_cache_task::Prefetch(img_url));
} }
} }
//TODO (Issue #86): handle inline styles ('style' attr) //TODO (Issue #86): handle inline styles ('style' attr)
_ => {} _ => {}
} }
let node = scope.new_node(Element(move elem)); let node = scope.new_node(Element(elem));
unsafe { cast::transmute(cow::unwrap(node)) } unsafe { cast::transmute(cow::unwrap(node)) }
}, },
create_text: |data: ~str| { create_text: |data: ~str| {
debug!("create text"); debug!("create text");
let new_node = scope.new_node(Text(move data)); let new_node = scope.new_node(Text(data));
unsafe { cast::transmute(cow::unwrap(new_node)) } unsafe { cast::transmute(cow::unwrap(new_node)) }
}, },
ref_node: |_node| {}, ref_node: |_node| {},
@ -318,7 +320,7 @@ pub fn parse_html(scope: NodeScope,
if deep { error!("-- deep clone unimplemented"); } if deep { error!("-- deep clone unimplemented"); }
let n: Node = cow::wrap(cast::transmute(node)); let n: Node = cow::wrap(cast::transmute(node));
let data = n.read(|read_data| copy *read_data.kind); let data = n.read(|read_data| copy *read_data.kind);
let new_node = scope.new_node(move data); let new_node = scope.new_node(data);
cast::transmute(cow::unwrap(new_node)) cast::transmute(cow::unwrap(new_node))
} }
}, },
@ -358,10 +360,10 @@ pub fn parse_html(scope: NodeScope,
match *node_contents.kind { match *node_contents.kind {
Element(ref element) if element.tag_name == ~"script" => { Element(ref element) if element.tag_name == ~"script" => {
match element.get_attr(~"src") { match element.get_attr(~"src") {
Some(move src) => { Some(src) => {
debug!("found script: %s", src); debug!("found script: %s", src);
let new_url = make_url(move src, Some(copy *url)); let new_url = make_url(src, Some(copy *url));
js_chan.send(JSTaskNewFile(move new_url)); js_chan.send(JSTaskNewFile(new_url));
} }
None => {} None => {}
} }

View file

@ -10,7 +10,7 @@ pub trait LayoutAuxMethods {
fn initialize_style_for_subtree(refs: &DVec<@LayoutData>); fn initialize_style_for_subtree(refs: &DVec<@LayoutData>);
} }
impl Node : LayoutAuxMethods { impl LayoutAuxMethods for Node {
/** If none exists, creates empty layout data for the node (the reader-auxiliary /** If none exists, creates empty layout data for the node (the reader-auxiliary
* box in the COW model) and populates it with an empty style object. * box in the COW model) and populates it with an empty style object.
*/ */
@ -40,4 +40,4 @@ impl Node : LayoutAuxMethods {
} }
} }
} }

View file

@ -40,8 +40,7 @@ pub trait BlockLayout {
d: &Mut<DisplayList>); d: &Mut<DisplayList>);
} }
impl FlowContext : BlockLayout { impl BlockLayout for FlowContext {
pure fn starts_block_flow() -> bool { pure fn starts_block_flow() -> bool {
match self { match self {
RootFlow(*) | BlockFlow(*) | InlineBlockFlow(*) => true, RootFlow(*) | BlockFlow(*) | InlineBlockFlow(*) => true,

View file

@ -560,7 +560,7 @@ impl RenderBox {
weight: FontWeight300, weight: FontWeight300,
italic: italic, italic: italic,
oblique: oblique, oblique: oblique,
families: move font_families, families: font_families,
} }
} }
} }
@ -573,7 +573,7 @@ impl RenderBox {
} }
} }
impl RenderBox : BoxedDebugMethods { impl BoxedDebugMethods for RenderBox {
pure fn dump(@self) { pure fn dump(@self) {
self.dump_indent(0u); self.dump_indent(0u);
} }
@ -609,7 +609,7 @@ impl RenderBox {
while !node.is_element() { while !node.is_element() {
match NodeTree.get_parent(&node) { match NodeTree.get_parent(&node) {
None => fail!(~"no nearest element?!"), None => fail!(~"no nearest element?!"),
Some(move parent) => node = move parent, Some(parent) => node = parent,
} }
} }
node node
@ -621,7 +621,7 @@ trait ToGfxColor {
fn to_gfx_color(&self) -> gfx::color::Color; fn to_gfx_color(&self) -> gfx::color::Color;
} }
impl Color: ToGfxColor { impl ToGfxColor for Color {
fn to_gfx_color(&self) -> gfx::color::Color { fn to_gfx_color(&self) -> gfx::color::Color {
gfx::color::rgba(self.red, gfx::color::rgba(self.red,
self.green, self.green,

View file

@ -270,7 +270,7 @@ impl BuilderContext {
_ => self.clone() _ => self.clone()
}; };
Some(move containing_context) Some(containing_context)
} }
} }
@ -284,8 +284,8 @@ impl LayoutTreeBuilder {
fn construct_recursively(layout_ctx: &LayoutContext, cur_node: Node, parent_ctx: &BuilderContext) { fn construct_recursively(layout_ctx: &LayoutContext, cur_node: Node, parent_ctx: &BuilderContext) {
debug!("Considering node: %s", cur_node.debug_str()); debug!("Considering node: %s", cur_node.debug_str());
let this_ctx = match move parent_ctx.containing_context_for_node(cur_node, &self) { let this_ctx = match parent_ctx.containing_context_for_node(cur_node, &self) {
Some(move ctx) => move ctx, Some(ctx) => ctx,
None => { return; } // no context because of display: none. Stop building subtree. None => { return; } // no context because of display: none. Stop building subtree.
}; };
debug!("point a: %s", cur_node.debug_str()); debug!("point a: %s", cur_node.debug_str());
@ -389,13 +389,13 @@ impl LayoutTreeBuilder {
fn make_flow(ty : FlowContextType) -> @FlowContext { fn make_flow(ty : FlowContextType) -> @FlowContext {
let data = FlowData(self.next_flow_id()); let data = FlowData(self.next_flow_id());
let ret = match ty { let ret = match ty {
Flow_Absolute => @AbsoluteFlow(move data), Flow_Absolute => @AbsoluteFlow(data),
Flow_Block => @BlockFlow(move data, BlockFlowData()), Flow_Block => @BlockFlow(data, BlockFlowData()),
Flow_Float => @FloatFlow(move data), Flow_Float => @FloatFlow(data),
Flow_InlineBlock => @InlineBlockFlow(move data), Flow_InlineBlock => @InlineBlockFlow(data),
Flow_Inline => @InlineFlow(move data, InlineFlowData()), Flow_Inline => @InlineFlow(data, InlineFlowData()),
Flow_Root => @RootFlow(move data, RootFlowData()), Flow_Root => @RootFlow(data, RootFlowData()),
Flow_Table => @TableFlow(move data) Flow_Table => @TableFlow(data)
}; };
debug!("LayoutTreeBuilder: created flow: %s", ret.debug_str()); debug!("LayoutTreeBuilder: created flow: %s", ret.debug_str());
ret ret
@ -430,7 +430,7 @@ impl LayoutTreeBuilder {
let holder = ImageHolder::new({copy *d.image.get_ref()}, let holder = ImageHolder::new({copy *d.image.get_ref()},
layout_ctx.image_cache); layout_ctx.image_cache);
@ImageBox(RenderBoxData(node, ctx, self.next_box_id()), move holder) @ImageBox(RenderBoxData(node, ctx, self.next_box_id()), holder)
} else { } else {
info!("Tried to make image box, but couldn't find image. Made generic box instead."); info!("Tried to make image box, but couldn't find image. Made generic box instead.");
self.make_generic_box(layout_ctx, node, ctx) self.make_generic_box(layout_ctx, node, ctx)

View file

@ -211,7 +211,7 @@ impl FlowTree {
} }
} }
impl FlowTree : tree::ReadMethods<@FlowContext> { impl tree::ReadMethods<@FlowContext> for FlowTree {
fn with_tree_fields<R>(box: &@FlowContext, f: fn(&tree::Tree<@FlowContext>) -> R) -> R { fn with_tree_fields<R>(box: &@FlowContext, f: fn(&tree::Tree<@FlowContext>) -> R) -> R {
f(&box.d().tree) f(&box.d().tree)
} }
@ -223,8 +223,7 @@ impl FlowTree {
} }
} }
impl FlowTree : tree::WriteMethods<@FlowContext> { impl tree::WriteMethods<@FlowContext> for FlowTree {
pure fn tree_eq(a: &@FlowContext, b: &@FlowContext) -> bool { core::managed::ptr_eq(*a, *b) } pure fn tree_eq(a: &@FlowContext, b: &@FlowContext) -> bool { core::managed::ptr_eq(*a, *b) }
fn with_tree_fields<R>(box: &@FlowContext, f: fn(&tree::Tree<@FlowContext>) -> R) -> R { fn with_tree_fields<R>(box: &@FlowContext, f: fn(&tree::Tree<@FlowContext>) -> R) -> R {
@ -233,7 +232,7 @@ impl FlowTree : tree::WriteMethods<@FlowContext> {
} }
impl FlowContext : BoxedDebugMethods { impl BoxedDebugMethods for FlowContext {
pure fn dump(@self) { pure fn dump(@self) {
self.dump_indent(0u); self.dump_indent(0u);
} }
@ -263,7 +262,7 @@ impl FlowContext : BoxedDebugMethods {
fmt!("%s b%d", *s, box.d().id) fmt!("%s b%d", *s, box.d().id)
}); });
s += ~")"; s += ~")";
move s s
}, },
BlockFlow(*) => { BlockFlow(*) => {
match self.block().box { match self.block().box {

View file

@ -183,7 +183,7 @@ priv impl TextRunScanner {
debug!("TextRunScanner: swapping out boxes."); debug!("TextRunScanner: swapping out boxes.");
// swap out old and new box list of flow, by supplying // swap out old and new box list of flow, by supplying
// temp boxes as return value to boxes.swap |...| // temp boxes as return value to boxes.swap |...|
dvec::unwrap(move out_boxes) dvec::unwrap(out_boxes)
} }
// helper functions // helper functions
@ -245,7 +245,7 @@ priv impl TextRunScanner {
// this is probably achieved by creating fontgroup above, and then letting FontGroup decide // this is probably achieved by creating fontgroup above, and then letting FontGroup decide
// which Font to stick into the TextRun. // which Font to stick into the TextRun.
let fontgroup = ctx.font_ctx.get_resolved_font_for_style(&font_style); let fontgroup = ctx.font_ctx.get_resolved_font_for_style(&font_style);
let run = @fontgroup.create_textrun(move transformed_text); let run = @fontgroup.create_textrun(transformed_text);
debug!("TextRunScanner: pushing single text box in range: %?", self.clump); debug!("TextRunScanner: pushing single text box in range: %?", self.clump);
let new_box = layout::text::adapt_textbox_with_range(old_box.d(), let new_box = layout::text::adapt_textbox_with_range(old_box.d(),
run, run,
@ -284,7 +284,7 @@ priv impl TextRunScanner {
// which Font to stick into the TextRun. // which Font to stick into the TextRun.
let font_style = in_boxes[self.clump.begin()].font_style(); let font_style = in_boxes[self.clump.begin()].font_style();
let fontgroup = ctx.font_ctx.get_resolved_font_for_style(&font_style); let fontgroup = ctx.font_ctx.get_resolved_font_for_style(&font_style);
let run = @TextRun::new(fontgroup.fonts[0], move run_str); let run = @TextRun::new(fontgroup.fonts[0], run_str);
debug!("TextRunScanner: pushing box(es) in range: %?", self.clump); debug!("TextRunScanner: pushing box(es) in range: %?", self.clump);
let clump = self.clump; let clump = self.clump;
for clump.eachi |i| { for clump.eachi |i| {
@ -401,11 +401,11 @@ impl LineboxScanner {
self.line_spans.len(), self.flow.d().id); self.line_spans.len(), self.flow.d().id);
do self.new_boxes.swap |boxes| { do self.new_boxes.swap |boxes| {
self.flow.inline().boxes.set(move boxes); self.flow.inline().boxes.set(boxes);
~[] ~[]
}; };
do self.line_spans.swap |boxes| { do self.line_spans.swap |boxes| {
self.flow.inline().lines.set(move boxes); self.flow.inline().lines.set(boxes);
~[] ~[]
}; };
} }
@ -462,7 +462,7 @@ impl LineboxScanner {
} }
// clear line and add line mapping // clear line and add line mapping
debug!("LineboxScanner: Saving information for flushed line %u.", self.line_spans.len()); debug!("LineboxScanner: Saving information for flushed line %u.", self.line_spans.len());
self.line_spans.push(move line_range); self.line_spans.push(line_range);
self.reset_linebox(); self.reset_linebox();
} }
@ -591,7 +591,7 @@ pub trait InlineLayout {
d: &Mut<DisplayList>); d: &Mut<DisplayList>);
} }
impl FlowContext : InlineLayout { impl InlineLayout for FlowContext {
pure fn starts_inline_flow() -> bool { match self { InlineFlow(*) => true, _ => false } } pure fn starts_inline_flow() -> bool { match self { InlineFlow(*) => true, _ => false } }
fn bubble_widths_inline(@self, ctx: &LayoutContext) { fn bubble_widths_inline(@self, ctx: &LayoutContext) {

View file

@ -115,7 +115,7 @@ fn Layout(render_task: RenderTask,
Layout { Layout {
render_task: render_task, render_task: render_task,
image_cache_task: image_cache_task.clone(), image_cache_task: image_cache_task.clone(),
local_image_cache: @LocalImageCache(move image_cache_task), local_image_cache: @LocalImageCache(image_cache_task),
from_content: from_content, from_content: from_content,
font_ctx: fctx, font_ctx: fctx,
layout_refs: DVec(), layout_refs: DVec(),
@ -134,11 +134,11 @@ impl Layout {
fn handle_request() -> bool { fn handle_request() -> bool {
match self.from_content.recv() { match self.from_content.recv() {
AddStylesheet(move sheet) => { AddStylesheet(sheet) => {
self.handle_add_stylesheet(move sheet); self.handle_add_stylesheet(sheet);
} }
BuildMsg(move data) => { BuildMsg(data) => {
let data = Cell(move data); let data = Cell(data);
do time("layout: performing layout") { do time("layout: performing layout") {
self.handle_build(data.take()); self.handle_build(data.take());
@ -161,7 +161,7 @@ impl Layout {
} }
fn handle_add_stylesheet(sheet: Stylesheet) { fn handle_add_stylesheet(sheet: Stylesheet) {
let sheet = Cell(move sheet); let sheet = Cell(sheet);
do self.css_select_ctx.borrow_mut |ctx| { do self.css_select_ctx.borrow_mut |ctx| {
ctx.append_sheet(sheet.take(), OriginAuthor); ctx.append_sheet(sheet.take(), OriginAuthor);
} }
@ -180,7 +180,7 @@ impl Layout {
debug!("%?", node.dump()); debug!("%?", node.dump());
// Reset the image cache // Reset the image cache
self.local_image_cache.next_round(self.make_on_image_available_cb(move dom_event_chan)); self.local_image_cache.next_round(self.make_on_image_available_cb(dom_event_chan));
let screen_size = Size2D(Au::from_px(data.window_size.width as int), let screen_size = Size2D(Au::from_px(data.window_size.width as int),
Au::from_px(data.window_size.height as int)); Au::from_px(data.window_size.height as int));
@ -188,7 +188,7 @@ impl Layout {
let layout_ctx = LayoutContext { let layout_ctx = LayoutContext {
image_cache: self.local_image_cache, image_cache: self.local_image_cache,
font_ctx: self.font_ctx, font_ctx: self.font_ctx,
doc_url: move doc_url, doc_url: doc_url,
screen_size: Rect(Point2D(Au(0), Au(0)), screen_size) screen_size: Rect(Point2D(Au(0), Au(0)), screen_size)
}; };
@ -249,7 +249,7 @@ impl Layout {
screen_size.height.to_px() as uint) screen_size.height.to_px() as uint)
}; };
self.render_task.send(RenderMsg(move render_layer)); self.render_task.send(RenderMsg(render_layer));
} // time(layout: display list building) } // time(layout: display list building)
// Tell content we're done // Tell content we're done
@ -278,7 +278,7 @@ impl Layout {
Some(rect) => { Some(rect) => {
let size = Size2D(rect.size.width.to_px(), let size = Size2D(rect.size.width.to_px(),
rect.size.height.to_px()); rect.size.height.to_px());
Ok(ContentSize(move size)) Ok(ContentSize(size))
} }
} }
} }
@ -300,12 +300,12 @@ impl Layout {
// make multiple copies of the callback, and the dom event // make multiple copies of the callback, and the dom event
// channel is not a copyable type, so this is actually a // channel is not a copyable type, so this is actually a
// little factory to produce callbacks // little factory to produce callbacks
let f: @fn() -> ~fn(ImageResponseMsg) = |move dom_event_chan| { let f: @fn() -> ~fn(ImageResponseMsg) = || {
let dom_event_chan = dom_event_chan.clone(); let dom_event_chan = dom_event_chan.clone();
let f: ~fn(ImageResponseMsg) = |_msg, move dom_event_chan| { let f: ~fn(ImageResponseMsg) = |_| {
dom_event_chan.send(ReflowEvent) dom_event_chan.send(ReflowEvent)
}; };
move f f
}; };
return f; return f;
} }

View file

@ -32,8 +32,7 @@ pub trait RootLayout {
c: &Point2D<Au>, d: &Mut<DisplayList>); c: &Point2D<Au>, d: &Mut<DisplayList>);
} }
impl FlowContext : RootLayout { impl RootLayout for FlowContext {
pure fn starts_root_flow() -> bool { pure fn starts_root_flow() -> bool {
match self { match self {
RootFlow(*) => true, RootFlow(*) => true,

View file

@ -29,14 +29,14 @@ pub fn adapt_textbox_with_range(box_data: &RenderBoxData, run: @TextRun,
let new_text_data = TextBoxData(run, range); let new_text_data = TextBoxData(run, range);
let metrics = run.metrics_for_range(range); let metrics = run.metrics_for_range(range);
new_box_data.position.size = metrics.bounding_box.size; new_box_data.position.size = metrics.bounding_box.size;
@TextBox(move new_box_data, move new_text_data) @TextBox(new_box_data, new_text_data)
} }
pub trait UnscannedMethods { pub trait UnscannedMethods {
pure fn raw_text(&self) -> ~str; pure fn raw_text(&self) -> ~str;
} }
impl RenderBox : UnscannedMethods { impl UnscannedMethods for RenderBox {
pure fn raw_text(&self) -> ~str { pure fn raw_text(&self) -> ~str {
match self { match self {
&UnscannedTextBox(_, ref s) => copy *s, &UnscannedTextBox(_, ref s) => copy *s,

View file

@ -6,7 +6,7 @@ trait FlowContextTraversals {
fn traverse_postorder(postorder_cb: &fn(@FlowContext)); fn traverse_postorder(postorder_cb: &fn(@FlowContext));
} }
impl @FlowContext : FlowContextTraversals { impl FlowContextTraversals for @FlowContext {
fn traverse_preorder(preorder_cb: &fn(@FlowContext)) { fn traverse_preorder(preorder_cb: &fn(@FlowContext)) {
preorder_cb(self); preorder_cb(self);
do FlowTree.each_child(self) |child| { child.traverse_preorder(preorder_cb); true } do FlowTree.each_child(self) |child| { child.traverse_preorder(preorder_cb); true }

View file

@ -30,7 +30,7 @@
] )* ] )*
} => { } => {
if $index == $count { if $index == $count {
match move pipes::try_recv($port) { match pipes::try_recv($port) {
$(Some($message($($(ref $x,)+)* ref next)) => { $(Some($message($($(ref $x,)+)* ref next)) => {
// FIXME (#2329) we really want move out of enum here. // FIXME (#2329) we really want move out of enum here.
let $next = move_ref!(next); let $next = move_ref!(next);

View file

@ -55,7 +55,7 @@ pub enum Msg {
pub fn OSMain(dom_event_chan: pipes::SharedChan<Event>, opts: Opts) -> OSMain { pub fn OSMain(dom_event_chan: pipes::SharedChan<Event>, opts: Opts) -> OSMain {
let dom_event_chan = Cell(dom_event_chan); let dom_event_chan = Cell(dom_event_chan);
OSMain { OSMain {
chan: SharedChan(on_osmain::<Msg>(|po, move dom_event_chan, move opts| { chan: SharedChan(on_osmain::<Msg>(|po| {
let po = Cell(po); let po = Cell(po);
do platform::runmain { do platform::runmain {
debug!("preparing to enter main loop"); debug!("preparing to enter main loop");
@ -80,7 +80,7 @@ struct AzureDrawTargetImageData {
size: Size2D<uint> size: Size2D<uint>
} }
impl AzureDrawTargetImageData : layers::layers::ImageData { impl layers::layers::ImageData for AzureDrawTargetImageData {
fn size() -> Size2D<uint> { self.size } fn size() -> Size2D<uint> { self.size }
fn stride() -> uint { self.data_source_surface.get_size().width as uint } fn stride() -> uint { self.data_source_surface.get_size().width as uint }
fn format() -> layers::layers::Format { fn format() -> layers::layers::Format {
@ -107,13 +107,13 @@ fn mainloop(mode: Mode,
glut::init_display_mode(glut::DOUBLE); glut::init_display_mode(glut::DOUBLE);
let glut_window = glut::create_window(~"Servo"); let glut_window = glut::create_window(~"Servo");
glut::reshape_window(glut_window, 800, 600); glut::reshape_window(glut_window, 800, 600);
window = GlutWindow(move glut_window); window = GlutWindow(glut_window);
} }
ShareMode => { ShareMode => {
let size = Size2D(800, 600); let size = Size2D(800, 600);
let share_context: ShareGlContext = sharegl::base::ShareContext::new(size); let share_context: ShareGlContext = sharegl::base::ShareContext::new(size);
io::println(fmt!("Sharing ID is %d", share_context.id())); io::println(fmt!("Sharing ID is %d", share_context.id()));
window = ShareWindow(move share_context); window = ShareWindow(share_context);
} }
} }
@ -141,7 +141,7 @@ fn mainloop(mode: Mode,
identity()); identity());
let done = @mut false; let done = @mut false;
let resize_rate_limiter = @ResizeRateLimiter(move dom_event_chan); let resize_rate_limiter = @ResizeRateLimiter(dom_event_chan);
let check_for_messages = fn@() { let check_for_messages = fn@() {
// Periodically check if content responded to our last resize event // Periodically check if content responded to our last resize event
@ -151,12 +151,12 @@ fn mainloop(mode: Mode,
//#debug("osmain: peeking"); //#debug("osmain: peeking");
while po.peek() { while po.peek() {
match po.recv() { match po.recv() {
AddKeyHandler(move key_ch) => key_handlers.push(move key_ch), AddKeyHandler(key_ch) => key_handlers.push(key_ch),
BeginDrawing(move sender) => lend_surface(surfaces, move sender), BeginDrawing(sender) => lend_surface(surfaces, sender),
Draw(move sender, move draw_target) => { Draw(sender, draw_target) => {
debug!("osmain: received new frame"); debug!("osmain: received new frame");
return_surface(surfaces, move draw_target); return_surface(surfaces, draw_target);
lend_surface(surfaces, move sender); lend_surface(surfaces, sender);
// Iterate over the children of the container layer. // Iterate over the children of the container layer.
let mut current_layer_child = root_layer.first_child; let mut current_layer_child = root_layer.first_child;
@ -207,7 +207,7 @@ fn mainloop(mode: Mode,
original_layer_transform.translate(x, y, 0.0) original_layer_transform.translate(x, y, 0.0)
.scale(width as f32, height as f32, 1.0)); .scale(width as f32, height as f32, 1.0));
} }
surfaces.front.layer_buffer_set.buffers = move buffers; surfaces.front.layer_buffer_set.buffers = buffers;
} }
Exit => { Exit => {
*done = true; *done = true;
@ -277,10 +277,10 @@ compositor for the renderer
*/ */
impl Compositor for OSMain { impl Compositor for OSMain {
fn begin_drawing(next_dt: pipes::Chan<LayerBufferSet>) { fn begin_drawing(next_dt: pipes::Chan<LayerBufferSet>) {
self.chan.send(BeginDrawing(move next_dt)) self.chan.send(BeginDrawing(next_dt))
} }
fn draw(next_dt: pipes::Chan<LayerBufferSet>, draw_me: LayerBufferSet) { fn draw(next_dt: pipes::Chan<LayerBufferSet>, draw_me: LayerBufferSet) {
self.chan.send(Draw(move next_dt, move draw_me)) self.chan.send(Draw(next_dt, draw_me))
} }
} }
@ -302,12 +302,12 @@ fn lend_surface(surfaces: &SurfaceSet, receiver: pipes::Chan<LayerBufferSet>) {
stride: layer_buffer.stride stride: layer_buffer.stride
}; };
debug!("osmain: lending surface %?", layer_buffer); debug!("osmain: lending surface %?", layer_buffer);
move layer_buffer layer_buffer
}; };
surfaces.front.layer_buffer_set.buffers = move old_layer_buffers; surfaces.front.layer_buffer_set.buffers = old_layer_buffers;
let new_layer_buffer_set = LayerBufferSet { buffers: move new_layer_buffers }; let new_layer_buffer_set = LayerBufferSet { buffers: new_layer_buffers };
receiver.send(move new_layer_buffer_set); receiver.send(new_layer_buffer_set);
// Now we don't have it // Now we don't have it
surfaces.front.have = false; surfaces.front.have = false;
// But we (hopefully) have another! // But we (hopefully) have another!
@ -322,7 +322,7 @@ fn return_surface(surfaces: &SurfaceSet, layer_buffer_set: LayerBufferSet) {
assert surfaces.front.have; assert surfaces.front.have;
assert !surfaces.back.have; assert !surfaces.back.have;
surfaces.back.layer_buffer_set = move layer_buffer_set; surfaces.back.layer_buffer_set = layer_buffer_set;
// Now we have it again // Now we have it again
surfaces.back.have = true; surfaces.back.have = true;
@ -343,17 +343,17 @@ fn Surface(backend: BackendType) -> Surface {
rect: Rect(Point2D(0u, 0u), Size2D(800u, 600u)), rect: Rect(Point2D(0u, 0u), Size2D(800u, 600u)),
stride: 800 stride: 800
}; };
let layer_buffer_set = LayerBufferSet { buffers: ~[ move layer_buffer ] }; let layer_buffer_set = LayerBufferSet { buffers: ~[ layer_buffer ] };
Surface { layer_buffer_set: move layer_buffer_set, have: true } Surface { layer_buffer_set: layer_buffer_set, have: true }
} }
/// A function for spawning into the platform's main thread /// A function for spawning into the platform's main thread
fn on_osmain<T: Owned>(f: fn~(po: Port<T>)) -> Chan<T> { fn on_osmain<T: Owned>(f: fn~(po: Port<T>)) -> Chan<T> {
let (setup_po, setup_ch) = pipes::stream(); let (setup_po, setup_ch) = pipes::stream();
do task::task().sched_mode(task::PlatformThread).spawn |move f| { do task::task().sched_mode(task::PlatformThread).spawn {
let (po, ch) = pipes::stream(); let (po, ch) = pipes::stream();
setup_ch.send(ch); setup_ch.send(ch);
f(move po); f(po);
} }
setup_po.recv() setup_po.recv()
} }

View file

@ -18,7 +18,7 @@ pub struct ResizeRateLimiter {
pub fn ResizeRateLimiter(dom_event_chan: pipes::SharedChan<Event>) -> ResizeRateLimiter { pub fn ResizeRateLimiter(dom_event_chan: pipes::SharedChan<Event>) -> ResizeRateLimiter {
ResizeRateLimiter { ResizeRateLimiter {
dom_event_chan: move dom_event_chan, dom_event_chan: dom_event_chan,
last_response_port: None, last_response_port: None,
next_resize_event: None next_resize_event: None
} }
@ -60,7 +60,7 @@ impl ResizeRateLimiter {
priv fn send_event(width: uint, height: uint) { priv fn send_event(width: uint, height: uint) {
let (port, chan) = pipes::stream(); let (port, chan) = pipes::stream();
self.dom_event_chan.send(ResizeEvent(width, height, move chan)); self.dom_event_chan.send(ResizeEvent(width, height, chan));
self.last_response_port = Some(move port); self.last_response_port = Some(port);
} }
} }

View file

@ -127,14 +127,14 @@ fn run(opts: &Opts) {
fn run_pipeline_screen(opts: &Opts) { fn run_pipeline_screen(opts: &Opts) {
let (dom_event_port, dom_event_chan) = pipes::stream(); let (dom_event_port, dom_event_chan) = pipes::stream();
let dom_event_chan = pipes::SharedChan(move dom_event_chan); let dom_event_chan = pipes::SharedChan(dom_event_chan);
// The platform event handler thread // The platform event handler thread
let osmain = OSMain(dom_event_chan.clone(), copy *opts); let osmain = OSMain(dom_event_chan.clone(), copy *opts);
// Send each file to render then wait for keypress // Send each file to render then wait for keypress
let (keypress_from_osmain, keypress_to_engine) = pipes::stream(); let (keypress_from_osmain, keypress_to_engine) = pipes::stream();
osmain.chan.send(AddKeyHandler(move keypress_to_engine)); osmain.chan.send(AddKeyHandler(keypress_to_engine));
// Create a servo instance // Create a servo instance
let resource_task = ResourceTask(); let resource_task = ResourceTask();
@ -149,7 +149,7 @@ fn run_pipeline_screen(opts: &Opts) {
for opts.urls.each |filename| { for opts.urls.each |filename| {
let url = make_url(copy *filename, None); let url = make_url(copy *filename, None);
debug!("master: Sending url `%s`", url.to_str()); debug!("master: Sending url `%s`", url.to_str());
engine_task.send(LoadURLMsg(move url)); engine_task.send(LoadURLMsg(url));
debug!("master: Waiting for keypress"); debug!("master: Waiting for keypress");
match keypress_from_osmain.try_recv() { match keypress_from_osmain.try_recv() {
@ -161,7 +161,7 @@ fn run_pipeline_screen(opts: &Opts) {
// Shut everything down // Shut everything down
debug!("master: Shut down"); debug!("master: Shut down");
let (exit_response_from_engine, exit_chan) = pipes::stream(); let (exit_response_from_engine, exit_chan) = pipes::stream();
engine_task.send(engine::ExitMsg(move exit_chan)); engine_task.send(engine::ExitMsg(exit_chan));
exit_response_from_engine.recv(); exit_response_from_engine.recv();
osmain.chan.send(platform::osmain::Exit); osmain.chan.send(platform::osmain::Exit);
@ -182,15 +182,18 @@ fn run_pipeline_png(url: ~str, outfile: &str) {
listen(|pngdata_from_compositor| { listen(|pngdata_from_compositor| {
let (dom_event_port, dom_event_chan) = pipes::stream(); let (dom_event_port, dom_event_chan) = pipes::stream();
let dom_event_chan = pipes::SharedChan(move dom_event_chan); let dom_event_chan = pipes::SharedChan(dom_event_chan);
let compositor = PngCompositor(pngdata_from_compositor); let compositor = PngCompositor(pngdata_from_compositor);
let resource_task = ResourceTask(); let resource_task = ResourceTask();
// For the PNG pipeline we are using a synchronous image task so that all images will be // For the PNG pipeline we are using a synchronous image task so that all images will be
// fulfilled before the first paint. // fulfilled before the first paint.
let image_cache_task = SyncImageCacheTask(resource_task); let image_cache_task = SyncImageCacheTask(resource_task);
let engine_task = Engine(copy compositor, move dom_event_port, move dom_event_chan, let engine_task = Engine(copy compositor,
move resource_task, move image_cache_task); dom_event_port,
dom_event_chan,
resource_task,
image_cache_task);
engine_task.send(LoadURLMsg(make_url(copy url, None))); engine_task.send(LoadURLMsg(make_url(copy url, None)));
match buffered_file_writer(&Path(outfile)) { match buffered_file_writer(&Path(outfile)) {
@ -199,7 +202,7 @@ fn run_pipeline_png(url: ~str, outfile: &str) {
} }
let (exit_chan, exit_response_from_engine) = pipes::stream(); let (exit_chan, exit_response_from_engine) = pipes::stream();
engine_task.send(engine::ExitMsg(move exit_chan)); engine_task.send(engine::ExitMsg(exit_chan));
exit_response_from_engine.recv(); exit_response_from_engine.recv();
compositor.send(png_compositor::Exit); compositor.send(png_compositor::Exit);
}) })

View file

@ -166,13 +166,13 @@ mod test {
enum dtree { dtree } enum dtree { dtree }
impl dtree : ReadMethods<@dummy> { impl ReadMethods<@dummy> for dtree {
fn with_tree_fields<R>(d: &@dummy, f: fn(&Tree<@dummy>) -> R) -> R { fn with_tree_fields<R>(d: &@dummy, f: fn(&Tree<@dummy>) -> R) -> R {
f(&d.fields) f(&d.fields)
} }
} }
impl dtree : WriteMethods<@dummy> { impl WriteMethods<@dummy> for dtree {
fn with_tree_fields<R>(d: &@dummy, f: fn(&Tree<@dummy>) -> R) -> R { fn with_tree_fields<R>(d: &@dummy, f: fn(&Tree<@dummy>) -> R) -> R {
f(&d.fields) f(&d.fields)
} }
@ -193,7 +193,7 @@ mod test {
add_child(&dtree, p, *c); add_child(&dtree, p, *c);
} }
return {p: p, children: move children}; return {p: p, children: children};
} }
#[test] #[test]