Trait changes, and eliminate 'copy'

This commit is contained in:
Keegan McAllister 2013-08-09 13:41:10 -07:00
parent 907d9f23cf
commit ffe60ea027
30 changed files with 111 additions and 100 deletions

View file

@ -183,7 +183,7 @@ impl FontGroup {
pub fn new(families: @str, style: &UsedFontStyle, fonts: ~[@mut Font]) -> FontGroup { pub fn new(families: @str, style: &UsedFontStyle, fonts: ~[@mut Font]) -> FontGroup {
FontGroup { FontGroup {
families: families, families: families,
style: copy *style, style: (*style).clone(),
fonts: fonts, fonts: fonts,
} }
} }
@ -264,7 +264,7 @@ impl Font {
handle: handle, handle: handle,
azure_font: None, azure_font: None,
shaper: None, shaper: None,
style: copy *style, style: (*style).clone(),
metrics: metrics, metrics: metrics,
backend: backend, backend: backend,
profiler_chan: profiler_chan, profiler_chan: profiler_chan,
@ -281,7 +281,7 @@ impl Font {
handle: handle, handle: handle,
azure_font: None, azure_font: None,
shaper: None, shaper: None,
style: copy *style, style: (*style).clone(),
metrics: metrics, metrics: metrics,
backend: backend, backend: backend,
profiler_chan: profiler_chan, profiler_chan: profiler_chan,
@ -387,7 +387,7 @@ impl Font {
fields: 0x0200 as uint16_t fields: 0x0200 as uint16_t
}; };
let mut origin = copy baseline_origin; let mut origin = baseline_origin.clone();
let mut azglyphs = ~[]; let mut azglyphs = ~[];
azglyphs.reserve(range.length()); azglyphs.reserve(range.length());
@ -462,7 +462,7 @@ impl Font {
} }
pub fn get_descriptor(&self) -> FontDescriptor { pub fn get_descriptor(&self) -> FontDescriptor {
FontDescriptor::new(copy self.style, SelectorPlatformIdentifier(self.handle.face_identifier())) FontDescriptor::new(self.style.clone(), SelectorPlatformIdentifier(self.handle.face_identifier()))
} }
pub fn glyph_index(&self, codepoint: char) -> Option<GlyphIndex> { pub fn glyph_index(&self, codepoint: char) -> Option<GlyphIndex> {

View file

@ -117,7 +117,7 @@ impl<'self> FontContext {
debug!("(transform family) searching for `%s`", family); debug!("(transform family) searching for `%s`", family);
match self.generic_fonts.find(&family) { match self.generic_fonts.find(&family) {
None => family, None => family,
Some(mapped_family) => copy *mapped_family Some(mapped_family) => (*mapped_family).clone()
} }
} }
@ -142,7 +142,7 @@ impl<'self> FontContext {
let font_id = let font_id =
SelectorPlatformIdentifier(font_entry.handle.face_identifier()); SelectorPlatformIdentifier(font_entry.handle.face_identifier());
let font_desc = FontDescriptor::new(copy *style, font_id); let font_desc = FontDescriptor::new((*style).clone(), font_id);
let instance = self.get_font_by_descriptor(&font_desc); let instance = self.get_font_by_descriptor(&font_desc);
@ -164,7 +164,7 @@ impl<'self> FontContext {
for result.iter().advance |font_entry| { for result.iter().advance |font_entry| {
let font_id = let font_id =
SelectorPlatformIdentifier(font_entry.handle.face_identifier()); SelectorPlatformIdentifier(font_entry.handle.face_identifier());
let font_desc = FontDescriptor::new(copy *style, font_id); let font_desc = FontDescriptor::new((*style).clone(), font_id);
let instance = self.get_font_by_descriptor(&font_desc); let instance = self.get_font_by_descriptor(&font_desc);
@ -176,7 +176,7 @@ impl<'self> FontContext {
assert!(fonts.len() > 0); assert!(fonts.len() > 0);
// TODO(Issue #179): Split FontStyle into specified and used styles // TODO(Issue #179): Split FontStyle into specified and used styles
let used_style = copy *style; let used_style = (*style).clone();
debug!("(create font group) --- finished ---"); debug!("(create font group) --- finished ---");
@ -187,8 +187,8 @@ impl<'self> FontContext {
return match &desc.selector { return match &desc.selector {
// TODO(Issue #174): implement by-platform-name font selectors. // TODO(Issue #174): implement by-platform-name font selectors.
&SelectorPlatformIdentifier(ref identifier) => { &SelectorPlatformIdentifier(ref identifier) => {
let result_handle = self.handle.create_font_from_identifier(copy *identifier, let result_handle = self.handle.create_font_from_identifier((*identifier).clone(),
copy desc.style); desc.style.clone());
result::chain(result_handle, |handle| { result::chain(result_handle, |handle| {
Ok(Font::new_from_adopted_handle(self, Ok(Font::new_from_adopted_handle(self,
handle, handle,

View file

@ -39,13 +39,13 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
let opt_match = match getopts::getopts(args, opts) { let opt_match = match getopts::getopts(args, opts) {
result::Ok(m) => m, result::Ok(m) => m,
result::Err(f) => fail!(getopts::fail_str(copy f)), result::Err(f) => fail!(getopts::fail_str(f.clone())),
}; };
let urls = if opt_match.free.is_empty() { let urls = if opt_match.free.is_empty() {
fail!(~"servo asks that you provide 1 or more URLs") fail!(~"servo asks that you provide 1 or more URLs")
} else { } else {
copy opt_match.free opt_match.free.clone()
}; };
let render_backend = match getopts::opt_maybe_str(&opt_match, "r") { let render_backend = match getopts::opt_maybe_str(&opt_match, "r") {

View file

@ -173,7 +173,7 @@ impl FontHandleMethods for FontHandle {
FontHandleMethods::new_from_buffer(fctx, buf.clone(), style) FontHandleMethods::new_from_buffer(fctx, buf.clone(), style)
} }
FontSourceFile(ref file) => { FontSourceFile(ref file) => {
FontHandle::new_from_file(fctx, copy *file, style) FontHandle::new_from_file(fctx, (*file).clone(), style)
} }
} }
} }

View file

@ -39,6 +39,7 @@ pub enum Msg {
} }
/// A request from the compositor to the renderer for tiles that need to be (re)displayed. /// A request from the compositor to the renderer for tiles that need to be (re)displayed.
#[deriving(Clone)]
pub struct BufferRequest { pub struct BufferRequest {
// The rect in pixels that will be drawn to the screen // The rect in pixels that will be drawn to the screen
screen_rect: Rect<uint>, screen_rect: Rect<uint>,
@ -112,7 +113,7 @@ impl<C: RenderListener + Send> RenderTask<C> {
id: id, id: id,
port: port.take(), port: port.take(),
compositor: compositor, compositor: compositor,
font_ctx: @mut FontContext::new(copy opts.render_backend, font_ctx: @mut FontContext::new(opts.render_backend.clone(),
false, false,
profiler_chan.clone()), profiler_chan.clone()),
opts: opts, opts: opts,

View file

@ -28,7 +28,7 @@ pub struct ImageSurface {
impl ImageSurface { impl ImageSurface {
pub fn new(size: Size2D<int>, format: format) -> ImageSurface { pub fn new(size: Size2D<int>, format: format) -> ImageSurface {
ImageSurface { ImageSurface {
size: copy size, size: size.clone(),
format: format, format: format,
buffer: vec::from_elem((size.area() as uint) * format.bpp(), 0u8) buffer: vec::from_elem((size.area() as uint) * format.bpp(), 0u8)
} }

View file

@ -25,6 +25,7 @@ use extra::sort;
/// In the uncommon case (multiple glyphs per unicode character, large glyph index/advance, or /// In the uncommon case (multiple glyphs per unicode character, large glyph index/advance, or
/// glyph offsets), we pack the glyph count into GlyphEntry, and store the other glyph information /// glyph offsets), we pack the glyph count into GlyphEntry, and store the other glyph information
/// in DetailedGlyphStore. /// in DetailedGlyphStore.
#[deriving(Clone)]
struct GlyphEntry { struct GlyphEntry {
value: u32 value: u32
} }
@ -256,6 +257,7 @@ impl GlyphEntry {
// Stores data for a detailed glyph, in the case that several glyphs // Stores data for a detailed glyph, in the case that several glyphs
// correspond to one character, or the glyph's data couldn't be packed. // correspond to one character, or the glyph's data couldn't be packed.
#[deriving(Clone)]
struct DetailedGlyph { struct DetailedGlyph {
index: GlyphIndex, index: GlyphIndex,
// glyph's advance, in the text's direction (RTL or RTL) // glyph's advance, in the text's direction (RTL or RTL)
@ -274,7 +276,7 @@ impl DetailedGlyph {
} }
} }
#[deriving(Eq)] #[deriving(Eq, Clone)]
struct DetailedGlyphRecord { struct DetailedGlyphRecord {
// source string offset/GlyphEntry offset in the TextRun // source string offset/GlyphEntry offset in the TextRun
entry_offset: uint, entry_offset: uint,

View file

@ -398,7 +398,7 @@ impl Shaper {
// cspan: [-] // cspan: [-]
// covsp: [---------------] // covsp: [---------------]
let mut covered_byte_span = copy char_byte_span; let mut covered_byte_span = char_byte_span.clone();
// extend, clipping at end of text range. // extend, clipping at end of text range.
while covered_byte_span.end() < byte_max while covered_byte_span.end() < byte_max
&& byteToGlyph[covered_byte_span.end()] == NO_GLYPH { && byteToGlyph[covered_byte_span.end()] == NO_GLYPH {

View file

@ -33,7 +33,7 @@ impl SendableTextRun {
}; };
TextRun { TextRun {
text: copy self.text, text: self.text.clone(),
font: font, font: font,
underline: self.underline, underline: self.underline,
glyphs: self.glyphs.clone(), glyphs: self.glyphs.clone(),
@ -115,7 +115,7 @@ impl<'self> TextRun {
pub fn serialize(&self) -> SendableTextRun { pub fn serialize(&self) -> SendableTextRun {
SendableTextRun { SendableTextRun {
text: copy self.text, text: self.text.clone(),
font: self.font.get_descriptor(), font: self.font.get_descriptor(),
underline: self.underline, underline: self.underline,
glyphs: self.glyphs.clone(), glyphs: self.glyphs.clone(),

View file

@ -227,7 +227,7 @@ impl Constellation {
profiler_chan: ProfilerChan) profiler_chan: ProfilerChan)
-> ConstellationChan { -> ConstellationChan {
let opts = Cell::new(copy *opts); let opts = Cell::new((*opts).clone());
let (constellation_port, constellation_chan) = special_stream!(ConstellationChan); let (constellation_port, constellation_chan) = special_stream!(ConstellationChan);
let constellation_port = Cell::new(constellation_port); let constellation_port = Cell::new(constellation_port);
@ -304,7 +304,7 @@ impl Constellation {
self.image_cache_task.clone(), self.image_cache_task.clone(),
self.resource_task.clone(), self.resource_task.clone(),
self.profiler_chan.clone(), self.profiler_chan.clone(),
copy self.opts, self.opts.clone(),
{ {
let size = self.compositor_chan.get_size(); let size = self.compositor_chan.get_size();
from_value(Size2D(size.width as uint, size.height as uint)) from_value(Size2D(size.width as uint, size.height as uint))
@ -370,7 +370,7 @@ impl Constellation {
self.compositor_chan.clone(), self.compositor_chan.clone(),
self.image_cache_task.clone(), self.image_cache_task.clone(),
self.profiler_chan.clone(), self.profiler_chan.clone(),
copy self.opts, self.opts.clone(),
source_pipeline, source_pipeline,
size_future) size_future)
} else { } else {
@ -382,7 +382,7 @@ impl Constellation {
self.image_cache_task.clone(), self.image_cache_task.clone(),
self.resource_task.clone(), self.resource_task.clone(),
self.profiler_chan.clone(), self.profiler_chan.clone(),
copy self.opts, self.opts.clone(),
size_future) size_future)
}; };
@ -438,7 +438,7 @@ impl Constellation {
self.image_cache_task.clone(), self.image_cache_task.clone(),
self.resource_task.clone(), self.resource_task.clone(),
self.profiler_chan.clone(), self.profiler_chan.clone(),
copy self.opts, self.opts.clone(),
size_future); size_future);
if url.path.ends_with(".js") { if url.path.ends_with(".js") {

View file

@ -782,7 +782,7 @@ impl RenderBox {
// FIXME: Too much allocation here. // FIXME: Too much allocation here.
let font_families = do my_style.font_family().map |family| { let font_families = do my_style.font_family().map |family| {
match *family { match *family {
CSSFontFamilyFamilyName(ref family_str) => copy *family_str, CSSFontFamilyFamilyName(ref family_str) => (*family_str).clone(),
CSSFontFamilyGenericFamily(Serif) => ~"serif", CSSFontFamilyGenericFamily(Serif) => ~"serif",
CSSFontFamilyGenericFamily(SansSerif) => ~"sans-serif", CSSFontFamilyGenericFamily(SansSerif) => ~"sans-serif",
CSSFontFamilyGenericFamily(Cursive) => ~"cursive", CSSFontFamilyGenericFamily(Cursive) => ~"cursive",

View file

@ -269,7 +269,7 @@ impl BoxGenerator {
do node.with_imm_image_element |image_element| { do node.with_imm_image_element |image_element| {
if image_element.image.is_some() { if image_element.image.is_some() {
// FIXME(pcwalton): Don't copy URLs. // FIXME(pcwalton): Don't copy URLs.
let url = copy *image_element.image.get_ref(); let url = (*image_element.image.get_ref()).clone();
ImageRenderBoxClass(@mut ImageRenderBox::new(base, url, layout_ctx.image_cache)) ImageRenderBoxClass(@mut ImageRenderBox::new(base, url, layout_ctx.image_cache))
} else { } else {
info!("Tried to make image box, but couldn't find image. Made generic box \ info!("Tried to make image box, but couldn't find image. Made generic box \

View file

@ -10,6 +10,7 @@ use std::util::replace;
use std::vec; use std::vec;
use std::i32::max_value; use std::i32::max_value;
#[deriving(Clone)]
pub enum FloatType{ pub enum FloatType{
FloatLeft, FloatLeft,
FloatRight FloatRight
@ -28,6 +29,7 @@ struct FloatContextBase{
offset: Point2D<Au> offset: Point2D<Au>
} }
#[deriving(Clone)]
struct FloatData{ struct FloatData{
bounds: Rect<Au>, bounds: Rect<Au>,
f_type: FloatType f_type: FloatType

View file

@ -181,7 +181,7 @@ impl LayoutTask {
}; };
// FIXME: Bad copy! // FIXME: Bad copy!
let doc_url = copy data.url; let doc_url = data.url.clone();
let script_chan = data.script_chan.clone(); let script_chan = data.script_chan.clone();
debug!("layout: received layout request for: %s", doc_url.to_str()); debug!("layout: received layout request for: %s", doc_url.to_str());

View file

@ -50,7 +50,7 @@ pub trait UnscannedMethods {
impl UnscannedMethods for RenderBox { impl UnscannedMethods for RenderBox {
fn raw_text(&self) -> ~str { fn raw_text(&self) -> ~str {
match *self { match *self {
UnscannedTextRenderBoxClass(text_box) => copy text_box.text, UnscannedTextRenderBoxClass(text_box) => text_box.text.clone(),
_ => fail!(~"unsupported operation: box.raw_text() on non-unscanned text box."), _ => fail!(~"unsupported operation: box.raw_text() on non-unscanned text box."),
} }
} }

View file

@ -13,7 +13,7 @@ pub struct NodeRange {
impl NodeRange { impl NodeRange {
pub fn new(node: AbstractNode<LayoutView>, range: &Range) -> NodeRange { pub fn new(node: AbstractNode<LayoutView>, range: &Range) -> NodeRange {
NodeRange { node: node, range: copy *range } NodeRange { node: node, range: (*range).clone() }
} }
} }

View file

@ -52,7 +52,7 @@ impl Pipeline {
RenderTask::create(id, RenderTask::create(id,
render_port, render_port,
compositor_chan.clone(), compositor_chan.clone(),
copy opts, opts.clone(),
profiler_chan.clone()); profiler_chan.clone());
LayoutTask::create(id, LayoutTask::create(id,
@ -61,7 +61,7 @@ impl Pipeline {
script_pipeline.script_chan.clone(), script_pipeline.script_chan.clone(),
render_chan.clone(), render_chan.clone(),
image_cache_task.clone(), image_cache_task.clone(),
copy opts, opts.clone(),
profiler_chan); profiler_chan);
let new_layout_info = NewLayoutInfo { let new_layout_info = NewLayoutInfo {
@ -109,7 +109,7 @@ impl Pipeline {
RenderTask::create(id, RenderTask::create(id,
render_port, render_port,
compositor_chan.clone(), compositor_chan.clone(),
copy opts, opts.clone(),
profiler_chan.clone()); profiler_chan.clone());
LayoutTask::create(id, LayoutTask::create(id,
@ -118,7 +118,7 @@ impl Pipeline {
script_chan.clone(), script_chan.clone(),
render_chan.clone(), render_chan.clone(),
image_cache_task, image_cache_task,
copy opts, opts.clone(),
profiler_chan); profiler_chan);
Pipeline::new(id, Pipeline::new(id,
subpage_id, subpage_id,

View file

@ -157,6 +157,7 @@ struct ImageCache {
need_exit: Option<Chan<()>>, need_exit: Option<Chan<()>>,
} }
#[deriving(Clone)]
enum ImageState { enum ImageState {
Init, Init,
Prefetching(AfterPrefetch), Prefetching(AfterPrefetch),
@ -166,6 +167,7 @@ enum ImageState {
Failed Failed
} }
#[deriving(Clone)]
enum AfterPrefetch { enum AfterPrefetch {
DoDecode, DoDecode,
DoNotDecode DoNotDecode
@ -242,25 +244,25 @@ impl ImageCache {
} }
priv fn prefetch(&self, url: Url) { priv fn prefetch(&self, url: Url) {
match self.get_state(copy url) { match self.get_state(url.clone()) {
Init => { Init => {
let to_cache = self.chan.clone(); let to_cache = self.chan.clone();
let resource_task = self.resource_task.clone(); let resource_task = self.resource_task.clone();
let url_cell = Cell::new(copy url); let url_cell = Cell::new(url.clone());
do spawn { do spawn {
let url = url_cell.take(); let url = url_cell.take();
debug!("image_cache_task: started fetch for %s", url.to_str()); debug!("image_cache_task: started fetch for %s", url.to_str());
let image = load_image_data(copy url, resource_task.clone()); let image = load_image_data(url.clone(), resource_task.clone());
let result = if image.is_ok() { let result = if image.is_ok() {
Ok(Cell::new(result::unwrap(image))) Ok(Cell::new(result::unwrap(image)))
} else { } else {
Err(()) Err(())
}; };
to_cache.send(StorePrefetchedImageData(copy url, result)); to_cache.send(StorePrefetchedImageData(url.clone(), result));
debug!("image_cache_task: ended fetch for %s", (copy url).to_str()); debug!("image_cache_task: ended fetch for %s", (url.clone()).to_str());
} }
self.set_state(url, Prefetching(DoNotDecode)); self.set_state(url, Prefetching(DoNotDecode));
@ -273,19 +275,19 @@ impl ImageCache {
} }
priv fn store_prefetched_image_data(&self, url: Url, data: Result<Cell<~[u8]>, ()>) { priv fn store_prefetched_image_data(&self, url: Url, data: Result<Cell<~[u8]>, ()>) {
match self.get_state(copy url) { match self.get_state(url.clone()) {
Prefetching(next_step) => { Prefetching(next_step) => {
match data { match data {
Ok(data_cell) => { Ok(data_cell) => {
let data = data_cell.take(); let data = data_cell.take();
self.set_state(copy url, Prefetched(@Cell::new(data))); self.set_state(url.clone(), Prefetched(@Cell::new(data)));
match next_step { match next_step {
DoDecode => self.decode(url), DoDecode => self.decode(url),
_ => () _ => ()
} }
} }
Err(*) => { Err(*) => {
self.set_state(copy url, Failed); self.set_state(url.clone(), Failed);
self.purge_waiters(url, || ImageFailed); self.purge_waiters(url, || ImageFailed);
} }
} }
@ -302,7 +304,7 @@ impl ImageCache {
} }
priv fn decode(&self, url: Url) { priv fn decode(&self, url: Url) {
match self.get_state(copy url) { match self.get_state(url.clone()) {
Init => fail!(~"decoding image before prefetch"), Init => fail!(~"decoding image before prefetch"),
Prefetching(DoNotDecode) => { Prefetching(DoNotDecode) => {
@ -319,7 +321,7 @@ impl ImageCache {
let data = data_cell.take(); let data = data_cell.take();
let to_cache = self.chan.clone(); let to_cache = self.chan.clone();
let url_cell = Cell::new(copy url); let url_cell = Cell::new(url.clone());
let decode = (self.decoder_factory)(); let decode = (self.decoder_factory)();
do spawn { do spawn {
@ -331,7 +333,7 @@ impl ImageCache {
} else { } else {
None None
}; };
to_cache.send(StoreImage(copy url, image)); to_cache.send(StoreImage(url.clone(), image));
debug!("image_cache_task: ended image decode for %s", url.to_str()); debug!("image_cache_task: ended image decode for %s", url.to_str());
} }
@ -346,15 +348,15 @@ impl ImageCache {
priv fn store_image(&self, url: Url, image: Option<ARC<~Image>>) { priv fn store_image(&self, url: Url, image: Option<ARC<~Image>>) {
match self.get_state(copy url) { match self.get_state(url.clone()) {
Decoding => { Decoding => {
match image { match image {
Some(image) => { Some(image) => {
self.set_state(copy url, Decoded(@image.clone())); self.set_state(url.clone(), Decoded(@image.clone()));
self.purge_waiters(url, || ImageReady(image.clone()) ); self.purge_waiters(url, || ImageReady(image.clone()) );
} }
None => { None => {
self.set_state(copy url, Failed); self.set_state(url.clone(), Failed);
self.purge_waiters(url, || ImageFailed ); self.purge_waiters(url, || ImageFailed );
} }
} }
@ -383,7 +385,7 @@ impl ImageCache {
} }
priv fn get_image(&self, url: Url, response: Chan<ImageResponseMsg>) { priv fn get_image(&self, url: Url, response: Chan<ImageResponseMsg>) {
match self.get_state(copy url) { match self.get_state(url.clone()) {
Init => fail!(~"request for image before prefetch"), Init => fail!(~"request for image before prefetch"),
Prefetching(DoDecode) => response.send(ImageNotReady), Prefetching(DoDecode) => response.send(ImageNotReady),
Prefetching(DoNotDecode) | Prefetched(*) => fail!(~"request for image before decode"), Prefetching(DoNotDecode) | Prefetched(*) => fail!(~"request for image before decode"),
@ -394,7 +396,7 @@ impl ImageCache {
} }
priv fn wait_for_image(&self, url: Url, response: Chan<ImageResponseMsg>) { priv fn wait_for_image(&self, url: Url, response: Chan<ImageResponseMsg>) {
match self.get_state(copy url) { match self.get_state(url.clone()) {
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"),
@ -540,7 +542,7 @@ fn should_fail_if_requesting_image_before_requesting_decode() {
let image_cache_task = ImageCacheTask(mock_resource_task); let image_cache_task = ImageCacheTask(mock_resource_task);
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
// no decode message // no decode message
let (chan, _port) = stream(); let (chan, _port) = stream();
@ -563,7 +565,7 @@ fn should_not_request_url_from_resource_task_on_multiple_prefetches() {
let image_cache_task = ImageCacheTask(mock_resource_task); let image_cache_task = ImageCacheTask(mock_resource_task);
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Prefetch(url)); image_cache_task.send(Prefetch(url));
url_requested.recv(); url_requested.recv();
image_cache_task.exit(); image_cache_task.exit();
@ -586,8 +588,8 @@ fn should_return_image_not_ready_if_data_has_not_arrived() {
let image_cache_task = ImageCacheTask(mock_resource_task); let image_cache_task = ImageCacheTask(mock_resource_task);
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(url, response_chan)); image_cache_task.send(GetImage(url, response_chan));
assert!(response_port.recv() == ImageNotReady); assert!(response_port.recv() == ImageNotReady);
@ -616,8 +618,8 @@ fn should_return_decoded_image_data_if_data_has_arrived() {
} }
})); }));
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
// Wait until our mock resource task has sent the image to the image cache // Wait until our mock resource task has sent the image to the image cache
wait_for_image_chan.recv(); wait_for_image_chan.recv();
@ -653,15 +655,15 @@ fn should_return_decoded_image_data_for_multiple_requests() {
} }
})); }));
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
// Wait until our mock resource task has sent the image to the image cache // Wait until our mock resource task has sent the image to the image cache
wait_for_image.recv(); wait_for_image.recv();
for iter::repeat(2) { for iter::repeat(2) {
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(copy url, response_chan)); image_cache_task.send(GetImage(url.clone(), response_chan));
match response_port.recv() { match response_port.recv() {
ImageReady(_) => (), ImageReady(_) => (),
_ => fail _ => fail
@ -699,12 +701,12 @@ fn should_not_request_image_from_resource_task_if_image_is_already_available() {
let image_cache_task = ImageCacheTask(mock_resource_task); let image_cache_task = ImageCacheTask(mock_resource_task);
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
// Wait until our mock resource task has sent the image to the image cache // Wait until our mock resource task has sent the image to the image cache
image_bin_sent.recv(); image_bin_sent.recv();
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.exit(); image_cache_task.exit();
mock_resource_task.send(resource_task::Exit); mock_resource_task.send(resource_task::Exit);
@ -743,14 +745,14 @@ fn should_not_request_image_from_resource_task_if_image_fetch_already_failed() {
let image_cache_task = ImageCacheTask(mock_resource_task); let image_cache_task = ImageCacheTask(mock_resource_task);
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
// Wait until our mock resource task has sent the image to the image cache // Wait until our mock resource task has sent the image to the image cache
image_bin_sent.recv(); image_bin_sent.recv();
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
image_cache_task.exit(); image_cache_task.exit();
mock_resource_task.send(resource_task::Exit); mock_resource_task.send(resource_task::Exit);
@ -783,8 +785,8 @@ fn should_return_failed_if_image_bin_cannot_be_fetched() {
} }
})); }));
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
// Wait until our mock resource task has sent the image to the image cache // Wait until our mock resource task has sent the image to the image cache
wait_for_prefetech.recv(); wait_for_prefetech.recv();
@ -821,14 +823,14 @@ fn should_return_failed_for_multiple_get_image_requests_if_image_bin_cannot_be_f
} }
})); }));
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
// Wait until our mock resource task has sent the image to the image cache // Wait until our mock resource task has sent the image to the image cache
wait_for_prefetech.recv(); wait_for_prefetech.recv();
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(copy url, response_chan)); image_cache_task.send(GetImage(url.clone(), response_chan));
match response_port.recv() { match response_port.recv() {
ImageFailed => (), ImageFailed => (),
_ => fail _ => fail
@ -878,8 +880,8 @@ fn should_return_not_ready_if_image_is_still_decoding() {
} }
})); }));
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
// Wait until our mock resource task has sent the image to the image cache // Wait until our mock resource task has sent the image to the image cache
wait_for_prefetech.recv(); wait_for_prefetech.recv();
@ -921,8 +923,8 @@ fn should_return_failed_if_image_decode_fails() {
} }
})); }));
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
// Wait until our mock resource task has sent the image to the image cache // Wait until our mock resource task has sent the image to the image cache
wait_for_decode.recv(); wait_for_decode.recv();
@ -960,8 +962,8 @@ fn should_return_image_on_wait_if_image_is_already_loaded() {
} }
})); }));
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
// Wait until our mock resource task has sent the image to the image cache // Wait until our mock resource task has sent the image to the image cache
wait_for_decode.recv(); wait_for_decode.recv();
@ -990,8 +992,8 @@ fn should_return_image_on_wait_if_image_is_not_yet_loaded() {
let image_cache_task = ImageCacheTask(mock_resource_task); let image_cache_task = ImageCacheTask(mock_resource_task);
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(WaitForImage(url, response_chan)); image_cache_task.send(WaitForImage(url, response_chan));
@ -1020,8 +1022,8 @@ fn should_return_image_failed_on_wait_if_image_fails_to_load() {
let image_cache_task = ImageCacheTask(mock_resource_task); let image_cache_task = ImageCacheTask(mock_resource_task);
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(WaitForImage(url, response_chan)); image_cache_task.send(WaitForImage(url, response_chan));
@ -1047,8 +1049,8 @@ fn sync_cache_should_wait_for_images() {
let image_cache_task = SyncImageCacheTask(mock_resource_task); let image_cache_task = SyncImageCacheTask(mock_resource_task);
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(url.clone()));
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(url, response_chan)); image_cache_task.send(GetImage(url, response_chan));

View file

@ -51,7 +51,7 @@ impl LocalImageCache {
pub fn prefetch(&self, url: &Url) { pub fn prefetch(&self, url: &Url) {
let state = self.get_state(url); let state = self.get_state(url);
if !state.prefetched { if !state.prefetched {
self.image_cache_task.send(Prefetch(copy *url)); self.image_cache_task.send(Prefetch((*url).clone()));
state.prefetched = true; state.prefetched = true;
} }
} }
@ -59,7 +59,7 @@ impl LocalImageCache {
pub fn decode(&self, url: &Url) { pub fn decode(&self, url: &Url) {
let state = self.get_state(url); let state = self.get_state(url);
if !state.decoded { if !state.decoded {
self.image_cache_task.send(Decode(copy *url)); self.image_cache_task.send(Decode((*url).clone()));
state.decoded = true; state.decoded = true;
} }
} }
@ -97,7 +97,7 @@ impl LocalImageCache {
} }
let (response_port, response_chan) = comm::stream(); let (response_port, response_chan) = comm::stream();
self.image_cache_task.send(GetImage(copy *url, response_chan)); self.image_cache_task.send(GetImage((*url).clone(), response_chan));
let response = response_port.recv(); let response = response_port.recv();
match response { match response {
@ -110,10 +110,10 @@ impl LocalImageCache {
let image_cache_task = self.image_cache_task.clone(); let image_cache_task = self.image_cache_task.clone();
assert!(self.on_image_available.is_some()); assert!(self.on_image_available.is_some());
let on_image_available = self.on_image_available.get()(); let on_image_available = self.on_image_available.get()();
let url = copy *url; let url = (*url).clone();
do task::spawn { do task::spawn {
let (response_port, response_chan) = comm::stream(); let (response_port, response_chan) = comm::stream();
image_cache_task.send(WaitForImage(copy url, response_chan)); image_cache_task.send(WaitForImage(url.clone(), response_chan));
on_image_available(response_port.recv()); on_image_available(response_port.recv());
} }
} }

View file

@ -142,7 +142,7 @@ fn test_bad_scheme() {
fn should_delegate_to_scheme_loader() { fn should_delegate_to_scheme_loader() {
let payload = ~[1, 2, 3]; let payload = ~[1, 2, 3];
let loader_factory = |_url: Url, progress_chan: Chan<ProgressMsg>| { let loader_factory = |_url: Url, progress_chan: Chan<ProgressMsg>| {
progress_chan.send(Payload(copy payload)); progress_chan.send(Payload(payload.clone()));
progress_chan.send(Done(Ok(()))); progress_chan.send(Done(Ok(())));
}; };
let loader_factories = ~[(~"snicklefritz", loader_factory)]; let loader_factories = ~[(~"snicklefritz", loader_factory)];

View file

@ -273,7 +273,7 @@ extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
let node = unwrap(obj); let node = unwrap(obj);
do node.with_imm_element |elem| { do node.with_imm_element |elem| {
let s = str(copy elem.tag_name); let s = str(elem.tag_name.clone());
*vp = domstring_to_jsval(cx, &s); *vp = domstring_to_jsval(cx, &s);
} }
} }

View file

@ -392,6 +392,7 @@ pub struct JSNativeHolder {
propertyHooks: *NativePropertyHooks propertyHooks: *NativePropertyHooks
} }
#[deriving(Clone)]
pub enum ConstantVal { pub enum ConstantVal {
IntVal(i32), IntVal(i32),
UintVal(u32), UintVal(u32),
@ -401,6 +402,7 @@ pub enum ConstantVal {
VoidVal VoidVal
} }
#[deriving(Clone)]
pub struct ConstantSpec { pub struct ConstantSpec {
name: *libc::c_char, name: *libc::c_char,
value: ConstantVal value: ConstantVal
@ -853,6 +855,7 @@ impl DerivedWrapper for AbstractNode<ScriptView> {
} }
} }
#[deriving(ToStr)]
pub enum Error { pub enum Error {
FailureUnknown FailureUnknown
} }

View file

@ -23,7 +23,7 @@ impl CharacterData {
} }
pub fn Data(&self) -> DOMString { pub fn Data(&self) -> DOMString {
copy self.data self.data.clone()
} }
pub fn SetData(&mut self, arg: &DOMString, _rv: &mut ErrorResult) { pub fn SetData(&mut self, arg: &DOMString, _rv: &mut ErrorResult) {

View file

@ -55,7 +55,7 @@ impl Event {
} }
pub fn Type(&self) -> DOMString { pub fn Type(&self) -> DOMString {
copy self.type_ self.type_.clone()
} }
pub fn GetTarget(&self) -> Option<@mut EventTarget> { pub fn GetTarget(&self) -> Option<@mut EventTarget> {

View file

@ -28,8 +28,8 @@ pub fn spawn_css_parser(provenance: StylesheetProvenance,
do task::spawn { do task::spawn {
let url = do provenance_cell.with_ref |p| { let url = do provenance_cell.with_ref |p| {
match *p { match *p {
UrlProvenance(ref the_url) => copy *the_url, UrlProvenance(ref the_url) => (*the_url).clone(),
InlineProvenance(ref the_url, _) => copy *the_url InlineProvenance(ref the_url, _) => (*the_url).clone()
} }
}; };

View file

@ -185,7 +185,7 @@ fn js_script_listener(to_parent: SharedChan<HtmlDiscoveryMessage>,
do task::spawn { do task::spawn {
let (input_port, input_chan) = comm::stream(); let (input_port, input_chan) = comm::stream();
// TODO: change copy to move once we can move into closures // TODO: change copy to move once we can move into closures
resource_task.send(Load(copy url, input_chan)); resource_task.send(Load(url.clone(), input_chan));
let mut buf = ~[]; let mut buf = ~[];
loop { loop {
@ -403,7 +403,7 @@ pub fn parse_html(cx: *JSContext,
None => {} None => {}
Some(src) => { Some(src) => {
let img_url = make_url(src, Some(url2.clone())); let img_url = make_url(src, Some(url2.clone()));
image_element.image = Some(copy img_url); image_element.image = Some(img_url.clone());
// 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> // TODO (Issue #84): don't prefetch if we are within a <noscript>
// tag. // tag.

View file

@ -266,7 +266,7 @@ impl Page {
// Send new document and relevant styles to layout. // Send new document and relevant styles to layout.
let reflow = ~Reflow { let reflow = ~Reflow {
document_root: do frame.document.with_base |doc| { doc.root }, document_root: do frame.document.with_base |doc| { doc.root },
url: copy self.url.get_ref().first(), url: self.url.get_ref().first().clone(),
goal: goal, goal: goal,
window_size: self.window_size.get(), window_size: self.window_size.get(),
script_chan: script_chan, script_chan: script_chan,
@ -498,7 +498,7 @@ impl ScriptTask {
js_info.js_compartment.define_functions(debug_fns); js_info.js_compartment.define_functions(debug_fns);
js_info.js_context.evaluate_script(js_info.js_compartment.global_obj, js_info.js_context.evaluate_script(js_info.js_compartment.global_obj,
bytes, bytes,
copy url.path, url.path.clone(),
1); 1);
} }
} }

View file

@ -15,6 +15,7 @@ enum RangeRelation {
EntirelyAfter EntirelyAfter
} }
#[deriving(Clone)]
pub struct Range { pub struct Range {
priv off: uint, priv off: uint,
priv len: uint priv len: uint

View file

@ -26,7 +26,7 @@ impl ProfilerChan {
} }
} }
#[deriving(Eq)] #[deriving(Eq, Clone)]
pub enum ProfilerCategory { pub enum ProfilerCategory {
CompositingCategory, CompositingCategory,
LayoutQueryCategory, LayoutQueryCategory,

View file

@ -44,7 +44,7 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
path.push(p.to_str()); path.push(p.to_str());
} }
let path = path.init(); let path = path.init();
let mut path = path.iter().transform(|x| copy *x).collect::<~[~str]>(); let mut path = path.iter().transform(|x| (*x).clone()).collect::<~[~str]>();
path.push(str_url); path.push(str_url);
let path = path.connect("/"); let path = path.connect("/");
@ -118,6 +118,6 @@ mod make_url_tests {
pub type UrlMap<T> = @mut HashMap<Url, T>; pub type UrlMap<T> = @mut HashMap<Url, T>;
pub fn url_map<T: Copy>() -> UrlMap<T> { pub fn url_map<T: Clone + 'static>() -> UrlMap<T> {
@mut HashMap::new() @mut HashMap::new()
} }