mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Eliminate copy warnings
This commit is contained in:
parent
d979b9fbc6
commit
85301fb98e
10 changed files with 61 additions and 49 deletions
|
@ -143,22 +143,22 @@ impl Content {
|
|||
}
|
||||
|
||||
fn handle_msg(+msg: Either<ControlMsg,Event>) -> bool {
|
||||
match msg {
|
||||
Left(control_msg) => self.handle_control_msg(control_msg),
|
||||
Right(event) => self.handle_event(event)
|
||||
match move msg {
|
||||
Left(move control_msg) => self.handle_control_msg(control_msg),
|
||||
Right(move event) => self.handle_event(event)
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_control_msg(+control_msg: ControlMsg) -> bool {
|
||||
match control_msg {
|
||||
ParseMsg(url) => {
|
||||
match move control_msg {
|
||||
ParseMsg(move url) => {
|
||||
debug!("content: Received url `%s` to parse", url_to_str(copy url));
|
||||
|
||||
// Note: we can parse the next document in parallel
|
||||
// with any previous documents.
|
||||
|
||||
let result = html::hubbub_html_parser::parse_html(self.scope,
|
||||
url,
|
||||
copy url,
|
||||
self.resource_task,
|
||||
self.image_cache_task);
|
||||
|
||||
|
@ -184,8 +184,8 @@ impl Content {
|
|||
option::get(&self.document),
|
||||
option::get(&self.window));
|
||||
|
||||
for vec::each(js_scripts) |bytes| {
|
||||
self.cx.evaluate_script(compartment.global_obj, *bytes, ~"???", 1u);
|
||||
do vec::consume(js_scripts) |_i, bytes| {
|
||||
self.cx.evaluate_script(compartment.global_obj, bytes, ~"???", 1u);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -214,10 +214,10 @@ impl Content {
|
|||
Err(msg) => {
|
||||
println(fmt!("Error opening %s: %s", url_to_str(copy url), msg));
|
||||
}
|
||||
Ok(bytes) => {
|
||||
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, url.path, 1u);
|
||||
self.cx.evaluate_script(compartment.global_obj, bytes, copy url.path, 1u);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -107,8 +107,8 @@ impl StyleApplicator {
|
|||
fn apply_css_style(layout_ctx: &LayoutContext) {
|
||||
let reflow = copy self.reflow;
|
||||
|
||||
do NodeTree.each_child(&self.node) |child| {
|
||||
inheritance_wrapper(layout_ctx, *child, reflow); true
|
||||
for NodeTree.each_child(&self.node) |child| {
|
||||
inheritance_wrapper(layout_ctx, *child, copy reflow)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *jsval, bp: *mut JSB
|
|||
|
||||
pub fn prototype_jsclass(+name: ~str) -> fn(+compartment: bare_compartment) -> JSClass {
|
||||
|+compartment: bare_compartment| {
|
||||
{name: compartment.add_name(name),
|
||||
{name: compartment.add_name(copy name),
|
||||
flags: 0,
|
||||
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||
delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||
|
@ -125,7 +125,7 @@ pub fn prototype_jsclass(+name: ~str) -> fn(+compartment: bare_compartment) -> J
|
|||
pub fn instance_jsclass(+name: ~str, finalize: *u8)
|
||||
-> fn(+compartment: bare_compartment) -> JSClass {
|
||||
|+compartment: bare_compartment| {
|
||||
{name: compartment.add_name(name),
|
||||
{name: compartment.add_name(copy name),
|
||||
flags: JSCLASS_HAS_RESERVED_SLOTS(1),
|
||||
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||
delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||
|
@ -151,19 +151,20 @@ pub fn instance_jsclass(+name: ~str, finalize: *u8)
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: A lot of string copies here
|
||||
pub fn define_empty_prototype(+name: ~str, +proto: Option<~str>, compartment: &bare_compartment)
|
||||
-> js::rust::jsobj {
|
||||
compartment.register_class(utils::prototype_jsclass(name));
|
||||
compartment.register_class(utils::prototype_jsclass(copy name));
|
||||
|
||||
//TODO error checking
|
||||
let obj = result::unwrap(
|
||||
match proto {
|
||||
Some(s) => compartment.new_object_with_proto(name, s,
|
||||
compartment.global_obj.ptr),
|
||||
None => compartment.new_object(name, null(), compartment.global_obj.ptr)
|
||||
match move proto {
|
||||
Some(move s) => compartment.new_object_with_proto(copy name, s,
|
||||
compartment.global_obj.ptr),
|
||||
None => compartment.new_object(copy name, null(), compartment.global_obj.ptr)
|
||||
});
|
||||
|
||||
compartment.define_property(name, RUST_OBJECT_TO_JSVAL(obj.ptr),
|
||||
compartment.define_property(copy name, RUST_OBJECT_TO_JSVAL(obj.ptr),
|
||||
GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||
GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8,
|
||||
JSPROP_ENUMERATE);
|
||||
|
|
|
@ -53,8 +53,8 @@ impl Node {
|
|||
with a generic implementation of rcu::Handle */
|
||||
impl Node : cmp::Eq {
|
||||
pure fn eq(other : &Node) -> bool unsafe {
|
||||
let my_data : @LayoutData = @self.aux(|a| *a);
|
||||
let ot_data : @LayoutData = @other.aux(|a| *a);
|
||||
let my_data : @LayoutData = @self.aux(|a| copy *a);
|
||||
let ot_data : @LayoutData = @other.aux(|a| copy *a);
|
||||
core::box::ptr_eq(my_data, ot_data)
|
||||
}
|
||||
pure fn ne(other : &Node) -> bool unsafe {
|
||||
|
|
|
@ -228,9 +228,11 @@ pub fn parse_html(scope: NodeScope,
|
|||
//Handle CSS style sheets from <link> elements
|
||||
~HTMLLinkElement => {
|
||||
match (elem.get_attr(~"rel"), elem.get_attr(~"href")) {
|
||||
(Some(rel), Some(href)) if rel == ~"stylesheet" => {
|
||||
debug!("found CSS stylesheet: %s", href);
|
||||
css_chan.send(CSSTaskNewFile(make_url(href, Some(copy *url))));
|
||||
(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))));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -298,22 +300,27 @@ pub fn parse_html(scope: NodeScope,
|
|||
encoding_change: |_encname| {
|
||||
debug!("encoding change");
|
||||
},
|
||||
complete_script: |script| unsafe {
|
||||
do scope.read(reinterpret_cast(&script)) |node_contents| {
|
||||
match *node_contents.kind {
|
||||
Element(element) if element.tag_name == ~"script" => {
|
||||
match element.get_attr(~"src") {
|
||||
Some(src) => {
|
||||
debug!("found script: %s", src);
|
||||
let new_url = make_url(src, Some(copy *url));
|
||||
js_chan.send(JSTaskNewFile(new_url));
|
||||
complete_script: |script| {
|
||||
// A little function for holding this lint attr
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn complete_script(scope: &NodeScope, script: hubbub::Node, url: &Url, js_chan: &comm::Chan<JSMessage>) unsafe {
|
||||
do scope.read(reinterpret_cast(&script)) |node_contents| {
|
||||
match *node_contents.kind {
|
||||
Element(element) if element.tag_name == ~"script" => {
|
||||
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));
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
complete_script(scope, script, url, &js_chan);
|
||||
debug!("complete script");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,10 +19,10 @@ pub struct ImageHolder {
|
|||
|
||||
}
|
||||
|
||||
fn ImageHolder(url : &Url, image_cache_task: ImageCacheTask, +cb: fn~()) -> ImageHolder {
|
||||
fn ImageHolder(+url : Url, image_cache_task: ImageCacheTask, +cb: fn~()) -> ImageHolder {
|
||||
debug!("ImageHolder() %?", url.to_str());
|
||||
let holder = ImageHolder {
|
||||
url : Some(copy *url),
|
||||
url : Some(copy url),
|
||||
image : None,
|
||||
cached_size : Size2D(0,0),
|
||||
image_cache_task : image_cache_task,
|
||||
|
@ -34,8 +34,8 @@ fn ImageHolder(url : &Url, image_cache_task: ImageCacheTask, +cb: fn~()) -> Imag
|
|||
// but they are intended to be spread out in time. Ideally prefetch
|
||||
// should be done as early as possible and decode only once we
|
||||
// are sure that the image will be used.
|
||||
image_cache_task.send(image_cache_task::Prefetch(copy *url));
|
||||
image_cache_task.send(image_cache_task::Decode(copy *url));
|
||||
image_cache_task.send(image_cache_task::Prefetch(copy url));
|
||||
image_cache_task.send(image_cache_task::Decode(move url));
|
||||
|
||||
holder
|
||||
}
|
||||
|
@ -73,8 +73,10 @@ impl ImageHolder {
|
|||
// If this is the first time we've called this function, load
|
||||
// the image and store it for the future
|
||||
if self.image.is_none() {
|
||||
assert self.url.is_some();
|
||||
let url = copy self.url.get();
|
||||
let url = match copy self.url {
|
||||
Some(move url) => url,
|
||||
None => fail ~"expected to have a url"
|
||||
};
|
||||
|
||||
let response_port = Port();
|
||||
self.image_cache_task.send(image_cache_task::GetImage(copy url, response_port.chan()));
|
||||
|
|
|
@ -221,7 +221,7 @@ impl LayoutTreeBuilder {
|
|||
// TODO: this could be written as a pattern guard, but it triggers
|
||||
// an ICE (mozilla/rust issue #3601)
|
||||
if d.image.is_some() {
|
||||
let holder = ImageHolder(&d.image.get(),
|
||||
let holder = ImageHolder({copy *d.image.get_ref()},
|
||||
layout_ctx.image_cache,
|
||||
copy layout_ctx.reflow_cb);
|
||||
|
||||
|
@ -254,7 +254,8 @@ impl LayoutTreeBuilder {
|
|||
~Doctype(*) | ~Comment(*) => fail ~"Hey, doctypes and comments shouldn't get here! They are display:none!",
|
||||
~Text(*) => RenderBox_Text,
|
||||
~Element(element) => {
|
||||
match (element.kind, display) {
|
||||
// FIXME: Bad copy
|
||||
match (copy element.kind, display) {
|
||||
(~HTMLImageElement(d), _) if d.image.is_some() => RenderBox_Image,
|
||||
// (_, Specified(_)) => GenericBox,
|
||||
(_, _) => RenderBox_Generic // TODO: replace this with the commented lines
|
||||
|
|
|
@ -140,9 +140,10 @@ impl TextRunScanner {
|
|||
(true, false) => { temp_boxes.push(in_boxes[self.clump_start]); }
|
||||
(true, true) => {
|
||||
let text = in_boxes[self.clump_start].raw_text();
|
||||
let text_len = text.len();
|
||||
// TODO: use actual font for corresponding DOM node to create text run.
|
||||
let run = TextRun(&*ctx.font_cache.get_test_font(), text);
|
||||
let box_guts = TextBoxData(@run, 0, text.len());
|
||||
let run = @TextRun(&*ctx.font_cache.get_test_font(), move text);
|
||||
let box_guts = TextBoxData(run, 0, text_len);
|
||||
debug!("pushing when start=%?,end=%?", self.clump_start, self.clump_end);
|
||||
temp_boxes.push(@TextBox(copy *in_boxes[self.clump_start].d(), box_guts));
|
||||
},
|
||||
|
|
|
@ -86,7 +86,7 @@ impl Layout {
|
|||
match query {
|
||||
ContentBox(node) => {
|
||||
// TODO: extract me to a method when I get sibling arms
|
||||
let response = match node.aux(|a| *a).flow {
|
||||
let response = match node.aux(|a| copy *a).flow {
|
||||
None => Err(()),
|
||||
Some(flow) => {
|
||||
let start_val : Option<Rect<au>> = None;
|
||||
|
@ -146,7 +146,7 @@ impl Layout {
|
|||
node.initialize_style_for_subtree(&layout_ctx, &self.layout_refs);
|
||||
node.recompute_style_for_subtree(&layout_ctx, &styles);
|
||||
/* resolve styles (convert relative values) down the node tree */
|
||||
apply_style(&layout_ctx, node, layout_ctx.reflow_cb);
|
||||
apply_style(&layout_ctx, node, copy layout_ctx.reflow_cb);
|
||||
|
||||
let builder = LayoutTreeBuilder();
|
||||
let layout_root: @FlowContext = match builder.construct_trees(&layout_ctx, node) {
|
||||
|
|
|
@ -126,7 +126,7 @@ impl TextRun {
|
|||
}
|
||||
}
|
||||
|
||||
fn TextRun(font: &Font, text: ~str) -> TextRun {
|
||||
fn TextRun(font: &Font, +text: ~str) -> TextRun {
|
||||
let glyph_store = GlyphStore(text.len());
|
||||
let run = TextRun {
|
||||
text: text,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue