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