diff options
Diffstat (limited to 'src')
45 files changed, 167 insertions, 183 deletions
diff --git a/src/components/gfx/display_list.rs b/src/components/gfx/display_list.rs index 3c220974b9b..ed3af3b1fbc 100644 --- a/src/components/gfx/display_list.rs +++ b/src/components/gfx/display_list.rs @@ -23,7 +23,7 @@ use std::cast::transmute_region; use geom::{Point2D, Rect, Size2D, SideOffsets2D}; use servo_net::image::base::Image; use servo_util::range::Range; -use extra::arc::ARC; +use extra::arc::Arc; /// A list of rendering operations to be performed. pub struct DisplayList<E> { @@ -93,7 +93,7 @@ pub struct TextDisplayItem<E> { /// Renders an image. pub struct ImageDisplayItem<E> { base: BaseDisplayItem<E>, - image: ARC<~Image>, + image: Arc<~Image>, } /// Renders a border. diff --git a/src/components/gfx/font.rs b/src/components/gfx/font.rs index 03f8def38d2..b10b8177760 100644 --- a/src/components/gfx/font.rs +++ b/src/components/gfx/font.rs @@ -10,7 +10,6 @@ use platform::font::{FontHandle, FontTable}; use render_context::RenderContext; use servo_util::range::Range; use std::cast; -use std::result; use std::ptr; use std::str; use std::vec; @@ -18,7 +17,7 @@ use servo_util::cache::{Cache, HashCache}; use text::glyph::{GlyphStore, GlyphIndex}; use text::shaping::ShaperMethods; use text::{Shaper, TextRun}; -use extra::arc::ARC; +use extra::arc::Arc; use azure::{AzFloat, AzScaledFontRef}; use azure::scaled_font::ScaledFont; @@ -240,7 +239,7 @@ pub struct Font { metrics: FontMetrics, backend: BackendType, profiler_chan: ProfilerChan, - shape_cache: HashCache<~str, ARC<GlyphStore>>, + shape_cache: HashCache<~str, Arc<GlyphStore>>, } impl Font { @@ -252,9 +251,9 @@ impl Font { -> Result<@mut Font, ()> { let handle = FontHandleMethods::new_from_buffer(&ctx.handle, buffer, style); let handle: FontHandle = if handle.is_ok() { - result::unwrap(handle) + handle.unwrap() } else { - return Err(handle.get_err()); + return Err(handle.unwrap_err()); }; let metrics = handle.get_metrics(); @@ -394,7 +393,7 @@ impl Font { for run.iter_slices_for_range(range) |glyphs, _offset, slice_range| { for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| { let glyph_advance = glyph.advance_(); - let glyph_offset = glyph.offset().get_or_default(Au::zero_point()); + let glyph_offset = glyph.offset().unwrap_or_default(Au::zero_point()); let azglyph = struct__AzGlyph { mIndex: glyph.index() as uint32_t, @@ -450,13 +449,13 @@ impl Font { RunMetrics::new(advance, self.metrics.ascent, self.metrics.descent) } - pub fn shape_text(@mut self, text: ~str, is_whitespace: bool) -> ARC<GlyphStore> { + pub fn shape_text(@mut self, text: ~str, is_whitespace: bool) -> Arc<GlyphStore> { do profile(time::LayoutShapingCategory, self.profiler_chan.clone()) { let shaper = self.get_shaper(); do self.shape_cache.find_or_create(&text) |txt| { let mut glyphs = GlyphStore::new(text.char_len(), is_whitespace); shaper.shape_text(*txt, &mut glyphs); - ARC(glyphs) + Arc::new(glyphs) } } } diff --git a/src/components/gfx/font_context.rs b/src/components/gfx/font_context.rs index 310539db016..8960b7d248e 100644 --- a/src/components/gfx/font_context.rs +++ b/src/components/gfx/font_context.rs @@ -14,7 +14,6 @@ use platform::font_context::FontContextHandle; use azure::azure_hl::BackendType; use std::hashmap::HashMap; -use std::result; // TODO(Rust #3934): creating lots of new dummy styles is a workaround // for not being able to store symbolic enums in top-level constants. @@ -189,13 +188,13 @@ impl<'self> FontContext { &SelectorPlatformIdentifier(ref identifier) => { let result_handle = self.handle.create_font_from_identifier((*identifier).clone(), desc.style.clone()); - result::chain(result_handle, |handle| { + do result_handle.chain |handle| { Ok(Font::new_from_adopted_handle(self, handle, &desc.style, self.backend, self.profiler_chan.clone())) - }) + } } }; } diff --git a/src/components/gfx/opts.rs b/src/components/gfx/opts.rs index c0bfabbe837..8e201c7a2a7 100644 --- a/src/components/gfx/opts.rs +++ b/src/components/gfx/opts.rs @@ -68,18 +68,18 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts { }; let tile_size: uint = match getopts::opt_maybe_str(&opt_match, "s") { - Some(tile_size_str) => uint::from_str(tile_size_str).get(), + Some(tile_size_str) => uint::from_str(tile_size_str).unwrap(), None => 512, }; let n_render_threads: uint = match getopts::opt_maybe_str(&opt_match, "t") { - Some(n_render_threads_str) => uint::from_str(n_render_threads_str).get(), + Some(n_render_threads_str) => uint::from_str(n_render_threads_str).unwrap(), None => 1, // FIXME: Number of cores. }; // if only flag is present, default to 5 second period let profiler_period = do getopts::opt_default(&opt_match, "p", "5").map |period| { - float::from_str(*period).get() + float::from_str(*period).unwrap() }; let exit_after_load = getopts::opt_present(&opt_match, "x"); diff --git a/src/components/gfx/platform/linux/font.rs b/src/components/gfx/platform/linux/font.rs index 8ae4580fcf3..57a36e6faed 100644 --- a/src/components/gfx/platform/linux/font.rs +++ b/src/components/gfx/platform/linux/font.rs @@ -262,7 +262,7 @@ impl<'self> FontHandle { let mut face: FT_Face = ptr::null(); let face_index = 0 as FT_Long; - do str::as_c_str(file) |file_str| { + do file.as_c_str |file_str| { FT_New_Face(ft_ctx, file_str, face_index, ptr::to_mut_unsafe_ptr(&mut face)); } @@ -289,7 +289,7 @@ impl<'self> FontHandle { let mut face: FT_Face = ptr::null(); let face_index = 0 as FT_Long; - do str::as_c_str(file) |file_str| { + do file.as_c_str |file_str| { FT_New_Face(ft_ctx, file_str, face_index, ptr::to_mut_unsafe_ptr(&mut face)); } diff --git a/src/components/gfx/platform/linux/font_list.rs b/src/components/gfx/platform/linux/font_list.rs index ae53929855c..af92c664f37 100644 --- a/src/components/gfx/platform/linux/font_list.rs +++ b/src/components/gfx/platform/linux/font_list.rs @@ -29,7 +29,6 @@ use std::libc; use std::libc::c_int; use std::ptr; use std::str; -use std::uint; pub struct FontListHandle { fctx: FontContextHandle, @@ -49,7 +48,7 @@ impl FontListHandle { let font = (*fontSet).fonts.offset(i); let family: *FcChar8 = ptr::null(); let mut v: c_int = 0; - do str::as_c_str("family") |FC_FAMILY| { + do "family".as_c_str |FC_FAMILY| { while FcPatternGetString(*font, FC_FAMILY, v, &family) == FcResultMatch { let family_name = str::raw::from_buf(family as *u8); debug!("Creating new FontFamily for family: %s", family_name); @@ -71,8 +70,8 @@ impl FontListHandle { let font_set_array_ptr = ptr::to_unsafe_ptr(&font_set); let pattern = FcPatternCreate(); assert!(pattern.is_not_null()); - do str::as_c_str("family") |FC_FAMILY| { - do str::as_c_str(family.family_name) |family_name| { + do "family".as_c_str |FC_FAMILY| { + do family.family_name.as_c_str |family_name| { let ok = FcPatternAddString(pattern, FC_FAMILY, family_name as *FcChar8); assert!(ok != 0); } @@ -81,10 +80,10 @@ impl FontListHandle { let object_set = FcObjectSetCreate(); assert!(object_set.is_not_null()); - do str::as_c_str("file") |FC_FILE| { + do "file".as_c_str |FC_FILE| { FcObjectSetAdd(object_set, FC_FILE); } - do str::as_c_str("index") |FC_INDEX| { + do "index".as_c_str |FC_INDEX| { FcObjectSetAdd(object_set, FC_INDEX); } @@ -94,7 +93,7 @@ impl FontListHandle { for uint::range(0, (*matches).nfont as uint) |i| { let font = (*matches).fonts.offset(i); - let file = do str::as_c_str("file") |FC_FILE| { + let file = do "file".as_c_str |FC_FILE| { let file: *FcChar8 = ptr::null(); if FcPatternGetString(*font, FC_FILE, 0, &file) == FcResultMatch { str::raw::from_c_str(file as *libc::c_char) @@ -102,7 +101,7 @@ impl FontListHandle { fail!(); } }; - let index = do str::as_c_str("index") |FC_INDEX| { + let index = do "index".as_c_str |FC_INDEX| { let index: libc::c_int = 0; if FcPatternGetInteger(*font, FC_INDEX, 0, &index) == FcResultMatch { index @@ -151,8 +150,8 @@ pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, ( let config = FcConfigGetCurrent(); let wrapper = AutoPattern { pattern: FcPatternCreate() }; let pattern = wrapper.pattern; - let res = do str::as_c_str("family") |FC_FAMILY| { - do str::as_c_str(name) |family| { + let res = do "family".as_c_str |FC_FAMILY| { + do name.as_c_str |family| { FcPatternAddString(pattern, FC_FAMILY, family as *FcChar8) } }; @@ -162,7 +161,7 @@ pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, ( } if style.italic { - let res = do str::as_c_str("slant") |FC_SLANT| { + let res = do "slant".as_c_str |FC_SLANT| { FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC) }; if res != 1 { @@ -171,7 +170,7 @@ pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, ( } } if style.weight.is_bold() { - let res = do str::as_c_str("weight") |FC_WEIGHT| { + let res = do "weight".as_c_str |FC_WEIGHT| { FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD) }; if res != 1 { @@ -194,7 +193,7 @@ pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, ( } let file: *FcChar8 = ptr::null(); - let res = do str::as_c_str("file") |FC_FILE| { + let res = do "file".as_c_str |FC_FILE| { FcPatternGetString(result_pattern, FC_FILE, 0, &file) }; if res != FcResultMatch { diff --git a/src/components/gfx/platform/macos/font_list.rs b/src/components/gfx/platform/macos/font_list.rs index 85e22405745..e47773de5e1 100644 --- a/src/components/gfx/platform/macos/font_list.rs +++ b/src/components/gfx/platform/macos/font_list.rs @@ -16,7 +16,6 @@ use core_text::font_descriptor::CTFontDescriptorRef; use core_text; use std::hashmap::HashMap; -use std::result; pub struct FontListHandle { fctx: FontContextHandle, @@ -49,7 +48,7 @@ impl FontListHandle { for family_collection.get_descriptors().each |descref: &CTFontDescriptorRef| { let desc = CFWrapper::wrap_shared(*descref); let font = core_text::font::new_from_descriptor(&desc, 0.0); - let handle = result::unwrap(FontHandle::new_from_CTFont(&self.fctx, font)); + let handle = FontHandle::new_from_CTFont(&self.fctx, font).unwrap(); debug!("Creating new FontEntry for face: %s", handle.face_name()); let entry = @FontEntry::new(handle); diff --git a/src/components/gfx/render_context.rs b/src/components/gfx/render_context.rs index 89567f1fa3b..d7e2242935e 100644 --- a/src/components/gfx/render_context.rs +++ b/src/components/gfx/render_context.rs @@ -16,7 +16,7 @@ use geom::rect::Rect; use geom::size::Size2D; use geom::side_offsets::SideOffsets2D; use servo_net::image::base::Image; -use extra::arc::ARC; +use extra::arc::Arc; pub struct RenderContext<'self> { canvas: &'self LayerBuffer, @@ -77,7 +77,7 @@ impl<'self> RenderContext<'self> { self.canvas.draw_target.stroke_line(start, end, &pattern, &stroke_opts, &draw_opts); } - pub fn draw_image(&self, bounds: Rect<Au>, image: ARC<~Image>) { + pub fn draw_image(&self, bounds: Rect<Au>, image: Arc<~Image>) { let image = image.get(); let size = Size2D(image.width as i32, image.height as i32); let stride = image.width * 4; diff --git a/src/components/gfx/render_task.rs b/src/components/gfx/render_task.rs index 20f49738ee0..42bed7195e5 100644 --- a/src/components/gfx/render_task.rs +++ b/src/components/gfx/render_task.rs @@ -88,7 +88,7 @@ priv struct RenderTask<C> { /// Permission to send paint messages to the compositor paint_permission: bool, /// Cached copy of last layers rendered - last_paint_msg: Option<(arc::ARC<LayerBufferSet>, Size2D<uint>)>, + last_paint_msg: Option<(arc::Arc<LayerBufferSet>, Size2D<uint>)>, } impl<C: RenderListener + Send> RenderTask<C> { @@ -231,7 +231,7 @@ impl<C: RenderListener + Send> RenderTask<C> { let layer_buffer_set = LayerBufferSet { buffers: new_buffers, }; - let layer_buffer_set = arc::ARC(layer_buffer_set); + let layer_buffer_set = arc::Arc::new(layer_buffer_set); debug!("render_task: returning surface"); if self.paint_permission { diff --git a/src/components/gfx/text/shaping/harfbuzz.rs b/src/components/gfx/text/shaping/harfbuzz.rs index 736328c5995..9dac15cf96b 100644 --- a/src/components/gfx/text/shaping/harfbuzz.rs +++ b/src/components/gfx/text/shaping/harfbuzz.rs @@ -16,7 +16,6 @@ use std::cast::transmute; use std::libc::{c_uint, c_int, c_void, c_char}; use std::ptr; use std::ptr::null; -use std::str; use std::uint; use std::util::ignore; use std::vec; @@ -86,7 +85,7 @@ impl ShapedGlyphData { fn byte_offset_of_glyph(&self, i: uint) -> uint { assert!(i < self.count); - let glyph_info_i = ptr::offset(self.glyph_infos, i); + let glyph_info_i = ptr::offset(self.glyph_infos, i as int); unsafe { (*glyph_info_i).cluster as uint } @@ -101,8 +100,8 @@ impl ShapedGlyphData { assert!(i < self.count); unsafe { - let glyph_info_i = ptr::offset(self.glyph_infos, i); - let pos_info_i = ptr::offset(self.pos_infos, i); + let glyph_info_i = ptr::offset(self.glyph_infos, i as int); + let pos_info_i = ptr::offset(self.pos_infos, i as int); let x_offset = Shaper::fixed_to_float((*pos_info_i).x_offset); let y_offset = Shaper::fixed_to_float((*pos_info_i).y_offset); let x_advance = Shaper::fixed_to_float((*pos_info_i).x_advance); @@ -216,8 +215,8 @@ impl ShaperMethods for Shaper { let hb_buffer: *hb_buffer_t = hb_buffer_create(); hb_buffer_set_direction(hb_buffer, HB_DIRECTION_LTR); - // Using as_buf because it never does a copy - we don't need the trailing null - do str::as_buf(text) |ctext: *u8, _: uint| { + // Using as_imm_buf because it never does a copy - we don't need the trailing null + do text.as_imm_buf |ctext: *u8, _: uint| { hb_buffer_add_utf8(hb_buffer, ctext as *c_char, text.len() as c_int, diff --git a/src/components/gfx/text/text_run.rs b/src/components/gfx/text/text_run.rs index 1bb5464803f..d3ea446fcf7 100644 --- a/src/components/gfx/text/text_run.rs +++ b/src/components/gfx/text/text_run.rs @@ -7,22 +7,22 @@ use geometry::Au; use text::glyph::GlyphStore; use font::{Font, FontDescriptor, RunMetrics}; use servo_util::range::Range; -use extra::arc::ARC; +use extra::arc::Arc; /// A text run. pub struct TextRun { text: ~str, font: @mut Font, underline: bool, - glyphs: ~[ARC<GlyphStore>], + glyphs: ~[Arc<GlyphStore>], } -/// This is a hack until TextRuns are normally sendable, or we instead use ARC<TextRun> everywhere. +/// This is a hack until TextRuns are normally sendable, or we instead use Arc<TextRun> everywhere. pub struct SendableTextRun { text: ~str, font: FontDescriptor, underline: bool, - priv glyphs: ~[ARC<GlyphStore>], + priv glyphs: ~[Arc<GlyphStore>], } impl SendableTextRun { @@ -58,7 +58,7 @@ impl<'self> TextRun { self.font.teardown(); } - pub fn break_and_shape(font: @mut Font, text: &str) -> ~[ARC<GlyphStore>] { + pub fn break_and_shape(font: @mut Font, text: &str) -> ~[Arc<GlyphStore>] { // TODO(Issue #230): do a better job. See Gecko's LineBreaker. let mut glyphs = ~[]; @@ -128,7 +128,7 @@ impl<'self> TextRun { } } - pub fn glyphs(&'self self) -> &'self ~[ARC<GlyphStore>] { &self.glyphs } + pub fn glyphs(&'self self) -> &'self ~[Arc<GlyphStore>] { &self.glyphs } pub fn range_is_trimmable_whitespace(&self, range: &Range) -> bool { for self.iter_slices_for_range(range) |slice_glyphs, _, _| { diff --git a/src/components/main/compositing/compositor_layer.rs b/src/components/main/compositing/compositor_layer.rs index 083dc5312c5..61e2b0206a1 100644 --- a/src/components/main/compositing/compositor_layer.rs +++ b/src/components/main/compositing/compositor_layer.rs @@ -313,7 +313,7 @@ impl CompositorLayer { texture_layer.manager = @buffer.draw_target.clone() as @TextureManager; // Move on to the next sibling. - do current_layer_child.get().with_common |common| { + do current_layer_child.unwrap().with_common |common| { common.next_sibling } } diff --git a/src/components/main/compositing/mod.rs b/src/components/main/compositing/mod.rs index b8f4c22ae5d..901354bc011 100644 --- a/src/components/main/compositing/mod.rs +++ b/src/components/main/compositing/mod.rs @@ -80,7 +80,7 @@ impl RenderListener for CompositorChan { port.recv() } - fn paint(&self, id: PipelineId, layer_buffer_set: arc::ARC<LayerBufferSet>) { + fn paint(&self, id: PipelineId, layer_buffer_set: arc::Arc<LayerBufferSet>) { self.chan.send(Paint(id, layer_buffer_set)) } @@ -136,7 +136,7 @@ pub enum Msg { DeleteLayer(PipelineId), /// Requests that the compositor paint the given layer buffer set for the given page size. - Paint(PipelineId, arc::ARC<LayerBufferSet>), + Paint(PipelineId, arc::Arc<LayerBufferSet>), /// Alerts the compositor to the current status of page loading. ChangeReadyState(ReadyState), /// Alerts the compositor to the current status of rendering. diff --git a/src/components/main/constellation.rs b/src/components/main/constellation.rs index af036a5f0aa..91ab2317c4f 100644 --- a/src/components/main/constellation.rs +++ b/src/components/main/constellation.rs @@ -4,8 +4,6 @@ use compositing::{CompositorChan, SetIds}; -use extra::net::url; - use std::cell::Cell; use std::comm; use std::comm::Port; @@ -169,17 +167,17 @@ impl NavigationContext { * when it is known that there exists either a previous page or a next page. */ pub fn back(&mut self) -> @mut FrameTree { - self.next.push(self.current.swap_unwrap()); + self.next.push(self.current.take_unwrap()); self.current = Some(self.previous.pop()); debug!("previous: %? next: %? current: %?", self.previous, self.next, *self.current.get_ref()); - self.current.get() + self.current.unwrap() } pub fn forward(&mut self) -> @mut FrameTree { - self.previous.push(self.current.swap_unwrap()); + self.previous.push(self.current.take_unwrap()); self.current = Some(self.next.pop()); debug!("previous: %? next: %? current: %?", self.previous, self.next, *self.current.get_ref()); - self.current.get() + self.current.unwrap() } /// Loads a new set of page frames, returning all evicted frame trees @@ -187,7 +185,7 @@ impl NavigationContext { debug!("navigating to %?", frame_tree); let evicted = replace(&mut self.next, ~[]); if self.current.is_some() { - self.previous.push(self.current.swap_unwrap()); + self.previous.push(self.current.take_unwrap()); } self.current = Some(frame_tree); evicted @@ -405,7 +403,7 @@ impl Constellation { // If there is already a pending page (self.pending_frames), it will not be overridden; // However, if the id is not encompassed by another change, it will be. LoadUrlMsg(source_id, url, size_future) => { - debug!("received message to load %s", url::to_str(&url)); + debug!("received message to load %s", url.to_str()); // Make sure no pending page would be overridden. let source_frame = self.current_frame().get_ref().find_mut(source_id).expect( "Constellation: received a LoadUrlMsg from a pipeline_id associated @@ -530,13 +528,13 @@ impl Constellation { // Create the next frame tree that will be given to the compositor let next_frame_tree = match to_add.parent { None => to_add, // to_add is the root - Some(_parent) => @mut (*self.current_frame().get()).clone(), + Some(_parent) => @mut (*self.current_frame().unwrap()).clone(), }; // If there are frames to revoke permission from, do so now. match frame_change.before { Some(revoke_id) => { - let current_frame = self.current_frame().get(); + let current_frame = self.current_frame().unwrap(); let to_revoke = current_frame.find_mut(revoke_id).expect( "Constellation: pending frame change refers to an old diff --git a/src/components/main/css/node_util.rs b/src/components/main/css/node_util.rs index a63ee695af5..721b8ca9132 100644 --- a/src/components/main/css/node_util.rs +++ b/src/components/main/css/node_util.rs @@ -65,7 +65,7 @@ impl<'self> NodeUtil<'self> for AbstractNode<LayoutView> { if !self.has_layout_data() { return default; } - self.layout_data().restyle_damage.get_or_default(default) + self.layout_data().restyle_damage.unwrap_or_default(default) } /// Set the restyle damage field. diff --git a/src/components/main/css/select.rs b/src/components/main/css/select.rs index b776ade5978..d106c7bc6e9 100644 --- a/src/components/main/css/select.rs +++ b/src/components/main/css/select.rs @@ -2,10 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use extra::net::url::Url; -use url_from_str = extra::net::url::from_str; +use extra::url::Url; use std::cell::Cell; -use std::result; +use std::FromStr; use newcss::stylesheet::Stylesheet; use newcss::select::SelectCtx; use newcss::types::OriginUA; @@ -29,7 +28,7 @@ fn servo_default_style() -> Stylesheet { } fn default_url(name: &str) -> Url { - result::unwrap(url_from_str(fmt!("http://%s", name))) + FromStr::from_str(fmt!("http://%s", name)).unwrap() } fn style_stream(style: &str) -> DataStream { diff --git a/src/components/main/layout/box.rs b/src/components/main/layout/box.rs index 38f422a1dff..658b52726c8 100644 --- a/src/components/main/layout/box.rs +++ b/src/components/main/layout/box.rs @@ -38,7 +38,7 @@ use script::dom::node::{AbstractNode, LayoutView}; use servo_net::image::holder::ImageHolder; use servo_net::local_image_cache::LocalImageCache; use servo_util::range::*; -use extra::net::url::Url; +use extra::url::Url; /// Render boxes (`struct RenderBox`) are the leaves of the layout tree. They cannot position /// themselves. In general, render boxes do not have a simple correspondence with CSS boxes as in @@ -433,7 +433,7 @@ impl RenderBox { ImageRenderBoxClass(image_box) => { // TODO: Consult the CSS `width` property as well as margins and borders. // TODO: If the image isn't available, consult `width`. - Au::from_px(image_box.image.get_size().get_or_default(Size2D(0, 0)).width) + Au::from_px(image_box.image.get_size().unwrap_or_default(Size2D(0, 0)).width) } TextRenderBoxClass(text_box) => { @@ -454,7 +454,7 @@ impl RenderBox { GenericRenderBoxClass(*) => Au(0), ImageRenderBoxClass(image_box) => { - Au::from_px(image_box.image.get_size().get_or_default(Size2D(0, 0)).width) + Au::from_px(image_box.image.get_size().unwrap_or_default(Size2D(0, 0)).width) } TextRenderBoxClass(text_box) => { diff --git a/src/components/main/layout/box_builder.rs b/src/components/main/layout/box_builder.rs index cd11e948ed0..5ea78c8a0fe 100644 --- a/src/components/main/layout/box_builder.rs +++ b/src/components/main/layout/box_builder.rs @@ -403,22 +403,22 @@ impl LayoutTreeBuilder { // Floats (CSSDisplayBlock, BlockFlow(_), _) | (CSSDisplayBlock, FloatFlow(_), _) if !is_float.is_none() => { - self.create_child_generator(node, parent_generator, Flow_Float(is_float.get())) + self.create_child_generator(node, parent_generator, Flow_Float(is_float.unwrap())) } // If we're placing a float after an inline, append the float to the inline flow, // then continue building from the inline flow in case there are more inlines // afterward. (CSSDisplayBlock, _, Some(InlineFlow(_))) if !is_float.is_none() => { let float_generator = self.create_child_generator(node, - sibling_generator.get(), - Flow_Float(is_float.get())); - return Some((float_generator, sibling_generator.get())); + sibling_generator.unwrap(), + Flow_Float(is_float.unwrap())); + return Some((float_generator, sibling_generator.unwrap())); } // This is a catch-all case for when: // a) sibling_flow is None // b) sibling_flow is a BlockFlow (CSSDisplayBlock, InlineFlow(_), _) if !is_float.is_none() => { - self.create_child_generator(node, parent_generator, Flow_Float(is_float.get())) + self.create_child_generator(node, parent_generator, Flow_Float(is_float.unwrap())) } (CSSDisplayBlock, BlockFlow(info), _) => match (info.is_root, node.parent_node()) { diff --git a/src/components/main/layout/float_context.rs b/src/components/main/layout/float_context.rs index 60bb9595615..c24277465cc 100644 --- a/src/components/main/layout/float_context.rs +++ b/src/components/main/layout/float_context.rs @@ -300,7 +300,7 @@ impl FloatContextBase{ f_data.bounds.origin.x + f_data.bounds.size.width > left && f_data.bounds.origin.x < left + width { let new_y = f_data.bounds.origin.y; - max_height = Some(min(max_height.get_or_default(new_y), new_y)); + max_height = Some(min(max_height.unwrap_or_default(new_y), new_y)); } } } @@ -340,7 +340,7 @@ impl FloatContextBase{ let height = self.max_height_for_bounds(rect.origin.x, rect.origin.y, rect.size.width); - let height = height.get_or_default(Au(max_value)); + let height = height.unwrap_or_default(Au(max_value)); return match info.f_type { FloatLeft => Rect(Point2D(rect.origin.x, float_y), Size2D(rect.size.width, height)), diff --git a/src/components/main/layout/inline.rs b/src/components/main/layout/inline.rs index 3886695c4d3..3a4f8122dfe 100644 --- a/src/components/main/layout/inline.rs +++ b/src/components/main/layout/inline.rs @@ -22,7 +22,8 @@ use newcss::units::{Em, Px, Pt}; use newcss::values::{CSSLineHeightNormal, CSSLineHeightNumber, CSSLineHeightLength, CSSLineHeightPercentage}; use servo_util::range::Range; use servo_util::tree::{TreeNodeRef, TreeUtils}; -use extra::deque::Deque; +use extra::container::Deque; +use extra::ringbuf::RingBuf; /* Lineboxes are represented as offsets into the child list, rather than @@ -62,7 +63,7 @@ struct LineboxScanner { flow: FlowContext, floats: FloatContext, new_boxes: ~[RenderBox], - work_list: @mut Deque<RenderBox>, + work_list: @mut RingBuf<RenderBox>, pending_line: LineBox, lines: ~[LineBox], cur_y: Au, @@ -76,7 +77,7 @@ impl LineboxScanner { flow: inline, floats: float_ctx, new_boxes: ~[], - work_list: @mut Deque::new(), + work_list: @mut RingBuf::new(), pending_line: LineBox { range: Range::empty(), bounds: Rect(Point2D(Au(0), Au(0)), Size2D(Au(0), Au(0))), @@ -122,7 +123,7 @@ impl LineboxScanner { debug!("LineboxScanner: Working with box from box list: b%d", box.id()); box } else { - let box = self.work_list.pop_front(); + let box = self.work_list.pop_front().unwrap(); debug!("LineboxScanner: Working with box from work list: b%d", box.id()); box }; @@ -176,7 +177,7 @@ impl LineboxScanner { match box { ImageRenderBoxClass(image_box) => { let size = image_box.image.get_size(); - let height = Au::from_px(size.get_or_default(Size2D(0, 0)).height); + let height = Au::from_px(size.unwrap_or_default(Size2D(0, 0)).height); image_box.base.position.size.height = height; debug!("box_height: found image height: %?", height); height @@ -360,11 +361,11 @@ impl LineboxScanner { self.pending_line.green_zone = next_green_zone; assert!(!line_is_empty, "Non-terminating line breaking"); - self.work_list.add_front(in_box); + self.work_list.push_front(in_box); return true; } else { debug!("LineboxScanner: case=adding box collides vertically with floats: breaking line"); - self.work_list.add_front(in_box); + self.work_list.push_front(in_box); return false; } } @@ -407,7 +408,7 @@ impl LineboxScanner { match (left, right) { (Some(left_box), Some(right_box)) => { self.push_box_to_line(left_box); - self.work_list.add_front(right_box); + self.work_list.push_front(right_box); } (Some(left_box), None) => self.push_box_to_line(left_box), (None, Some(right_box)) => self.push_box_to_line(right_box), @@ -423,7 +424,7 @@ impl LineboxScanner { match (left, right) { (Some(left_box), Some(right_box)) => { self.push_box_to_line(left_box); - self.work_list.add_front(right_box); + self.work_list.push_front(right_box); } (Some(left_box), None) => { self.push_box_to_line(left_box); @@ -438,7 +439,7 @@ impl LineboxScanner { return true; } else { debug!("LineboxScanner: case=split box didn't fit, not appending and deferring original box."); - self.work_list.add_front(in_box); + self.work_list.push_front(in_box); return false; } } @@ -553,7 +554,7 @@ impl InlineFlowData { match box { ImageRenderBoxClass(image_box) => { let size = image_box.image.get_size(); - let width = Au::from_px(size.get_or_default(Size2D(0, 0)).width); + let width = Au::from_px(size.unwrap_or_default(Size2D(0, 0)).width); image_box.base.position.size.width = width; } TextRenderBoxClass(_) => { @@ -671,7 +672,7 @@ impl InlineFlowData { match cur_box { ImageRenderBoxClass(image_box) => { let size = image_box.image.get_size(); - let height = Au::from_px(size.get_or_default(Size2D(0, 0)).height); + let height = Au::from_px(size.unwrap_or_default(Size2D(0, 0)).height); image_box.base.position.size.height = height; image_box.base.position.translate(&Point2D(Au(0), -height)) diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs index 48c9b347e71..73f9e5c9556 100644 --- a/src/components/main/layout/layout_task.rs +++ b/src/components/main/layout/layout_task.rs @@ -44,7 +44,7 @@ use servo_net::local_image_cache::LocalImageCache; use servo_util::tree::{TreeNodeRef, TreeUtils}; use servo_util::time::{ProfilerChan, profile}; use servo_util::time; -use extra::net::url::Url; +use extra::url::Url; struct LayoutTask { id: PipelineId, diff --git a/src/components/main/layout/text.rs b/src/components/main/layout/text.rs index 525e6239320..d0eb65937d6 100644 --- a/src/components/main/layout/text.rs +++ b/src/components/main/layout/text.rs @@ -241,7 +241,7 @@ impl TextRunScanner { } do in_boxes[i].with_base |base| { - let new_box = @mut adapt_textbox_with_range(*base, run.get(), range); + let new_box = @mut adapt_textbox_with_range(*base, run.unwrap(), range); out_boxes.push(TextRenderBoxClass(new_box)); } } diff --git a/src/components/main/pipeline.rs b/src/components/main/pipeline.rs index ef33125efeb..ab12a1f73e0 100644 --- a/src/components/main/pipeline.rs +++ b/src/components/main/pipeline.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use extra::net::url::Url; +use extra::url::Url; use compositing::CompositorChan; use gfx::render_task::{RenderChan, RenderTask}; use gfx::render_task::{PaintPermissionGranted, PaintPermissionRevoked}; diff --git a/src/components/msg/compositor_msg.rs b/src/components/msg/compositor_msg.rs index 80f0c0703d3..410da56f6e0 100644 --- a/src/components/msg/compositor_msg.rs +++ b/src/components/msg/compositor_msg.rs @@ -61,7 +61,7 @@ pub trait RenderListener { fn new_layer(&self, PipelineId, Size2D<uint>); fn resize_layer(&self, PipelineId, Size2D<uint>); fn delete_layer(&self, PipelineId); - fn paint(&self, id: PipelineId, layer_buffer_set: arc::ARC<LayerBufferSet>); + fn paint(&self, id: PipelineId, layer_buffer_set: arc::Arc<LayerBufferSet>); fn set_render_state(&self, render_state: RenderState); } diff --git a/src/components/msg/constellation_msg.rs b/src/components/msg/constellation_msg.rs index 419aadf1ae3..af0a01184a3 100644 --- a/src/components/msg/constellation_msg.rs +++ b/src/components/msg/constellation_msg.rs @@ -6,7 +6,7 @@ /// coupling between these two components use std::comm::{Chan, SharedChan}; -use extra::net::url::Url; +use extra::url::Url; use extra::future::Future; use geom::size::Size2D; diff --git a/src/components/net/image/holder.rs b/src/components/net/image/holder.rs index bf56b6413e3..096c07b2f19 100644 --- a/src/components/net/image/holder.rs +++ b/src/components/net/image/holder.rs @@ -8,18 +8,18 @@ use local_image_cache::LocalImageCache; use std::util::replace; use geom::size::Size2D; -use extra::net::url::Url; -use extra::arc::ARC; +use extra::url::Url; +use extra::arc::Arc; // FIXME: Nasty coupling here This will be a problem if we want to factor out image handling from // the network stack. This should probably be factored out into an interface and use dependency // injection. /// A struct to store image data. The image will be loaded once the first time it is requested, -/// and an ARC will be stored. Clones of this ARC are given out on demand. +/// and an Arc will be stored. Clones of this Arc are given out on demand. pub struct ImageHolder { url: Url, - image: Option<ARC<~Image>>, + image: Option<Arc<~Image>>, cached_size: Size2D<int>, local_image_cache: @mut LocalImageCache, } @@ -65,7 +65,7 @@ impl ImageHolder { } } - pub fn get_image(&mut self) -> Option<ARC<~Image>> { + pub fn get_image(&mut self) -> Option<Arc<~Image>> { debug!("get_image() %?", self.url); // If this is the first time we've called this function, load diff --git a/src/components/net/image_cache_task.rs b/src/components/net/image_cache_task.rs index f81e3fb960d..558f31de200 100644 --- a/src/components/net/image_cache_task.rs +++ b/src/components/net/image_cache_task.rs @@ -13,8 +13,8 @@ use std::task::spawn; use std::to_str::ToStr; use std::util::replace; use std::result; -use extra::arc::ARC; -use extra::net::url::Url; +use extra::arc::Arc; +use extra::url::Url; pub enum Msg { /// Tell the cache that we may need a particular image soon. Must be posted @@ -29,7 +29,7 @@ pub enum Msg { Decode(Url), /// Used by the decoder tasks to post decoded images back to the cache - priv StoreImage(Url, Option<ARC<~Image>>), + priv StoreImage(Url, Option<Arc<~Image>>), /// Request an Image object for a URL. If the image is not is not immediately /// available then ImageNotReady is returned. @@ -46,7 +46,7 @@ pub enum Msg { } pub enum ImageResponseMsg { - ImageReady(ARC<~Image>), + ImageReady(Arc<~Image>), ImageNotReady, ImageFailed } @@ -163,7 +163,7 @@ enum ImageState { Prefetching(AfterPrefetch), Prefetched(@Cell<~[u8]>), Decoding, - Decoded(@ARC<~Image>), + Decoded(@Arc<~Image>), Failed } @@ -257,7 +257,7 @@ impl ImageCache { let image = load_image_data(url.clone(), resource_task.clone()); let result = if image.is_ok() { - Ok(Cell::new(result::unwrap(image))) + Ok(Cell::new(image.unwrap())) } else { Err(()) }; @@ -329,7 +329,7 @@ impl ImageCache { debug!("image_cache_task: started image decode for %s", url.to_str()); let image = decode(data); let image = if image.is_some() { - Some(ARC(~image.unwrap())) + Some(Arc::new(~image.unwrap())) } else { None }; @@ -346,7 +346,7 @@ 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(url.clone()) { Decoding => { diff --git a/src/components/net/local_image_cache.rs b/src/components/net/local_image_cache.rs index 5555c35aa5f..2c0685bf326 100644 --- a/src/components/net/local_image_cache.rs +++ b/src/components/net/local_image_cache.rs @@ -15,7 +15,7 @@ use std::comm; use std::comm::Port; use std::task; use servo_util::url::{UrlMap, url_map}; -use extra::net::url::Url; +use extra::url::Url; pub fn LocalImageCache(image_cache_task: ImageCacheTask) -> LocalImageCache { LocalImageCache { @@ -109,7 +109,7 @@ impl LocalImageCache { // on the image to load and triggering layout let image_cache_task = self.image_cache_task.clone(); assert!(self.on_image_available.is_some()); - let on_image_available = self.on_image_available.get()(); + let on_image_available = self.on_image_available.unwrap()(); let url = (*url).clone(); do task::spawn { let (response_port, response_chan) = comm::stream(); diff --git a/src/components/net/resource_task.rs b/src/components/net/resource_task.rs index 0b74e614627..d941bbb8132 100644 --- a/src/components/net/resource_task.rs +++ b/src/components/net/resource_task.rs @@ -9,7 +9,7 @@ use http_loader; use std::cell::Cell; use std::comm::{Chan, Port, SharedChan}; -use extra::net::url::{Url, to_str}; +use extra::url::Url; use util::spawn_listener; pub enum ControlMsg { @@ -94,7 +94,7 @@ impl ResourceManager { match self.get_loader_factory(&url) { Some(loader_factory) => { - debug!("resource_task: loading url: %s", to_str(&url)); + debug!("resource_task: loading url: %s", url.to_str()); loader_factory(url, progress_chan); } None => { diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index 140a712b950..8a1c647b6e5 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -1044,7 +1044,7 @@ for (uint32_t i = 0; i < length; ++i) { # "if (!ConvertJSValueToString(cx, ${val}, ${valPtr}, %s, %s, %s)) {\n" # " return false;\n" # "}" % (nullBehavior, undefinedBehavior, varName)) - strval = "str(strval.get())" + strval = "str(strval.unwrap())" if isOptional: strval = "Some(%s)" % strval conversionCode = ( @@ -1114,7 +1114,7 @@ for (uint32_t i = 0; i < length; ++i) { " if result.is_err() {\n" "%(handleInvalidEnumValueCode)s" " }\n" - " let index = result.get();\n" + " let index = result.unwrap();\n" " ${declName} = cast::transmute(index); //XXXjdm need some range checks up in here\n" "}" % { "enumtype" : enum, "values" : enum + "Values::strings", @@ -1511,7 +1511,7 @@ for (uint32_t i = 0; i < length; ++i) { wrappingCode = ("if %s.is_none() {\n" % (result) + CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" + "}\n" + - "let mut %s = %s.get();\n" % (result, result)) + "let mut %s = %s.unwrap();\n" % (result, result)) else: wrappingCode = "" if (not descriptor.interface.isExternal() and @@ -2746,10 +2746,10 @@ class CGGetPerInterfaceObject(CGAbstractMethod): }*/ /* Check to see whether the interface objects are already installed */ let protoOrIfaceArray: *mut *JSObject = cast::transmute(GetProtoOrIfaceArray(aGlobal)); - let cachedObject: *JSObject = *protoOrIfaceArray.offset(%s as uint); + let cachedObject: *JSObject = *protoOrIfaceArray.offset(%s as int); if cachedObject.is_null() { let tmp: *JSObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver); - *protoOrIfaceArray.offset(%s as uint) = tmp; + *protoOrIfaceArray.offset(%s as int) = tmp; tmp } else { cachedObject @@ -3623,7 +3623,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): templateValues = {'jsvalRef': '(*desc).value', 'jsvalPtr': 'ptr::to_mut_unsafe_ptr(&mut (*desc).value)', 'obj': 'proxy', 'successCode': fillDescriptor} get = ("if index.is_some() {\n" + - " let index = index.get();\n" + + " let index = index.unwrap();\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define() + "\n" + "}\n") % (self.descriptor.concreteType) @@ -3632,7 +3632,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): setOrIndexedGet += "if set != 0 {\n" if indexedSetter: setOrIndexedGet += (" if index.is_some() {\n" + - " let index = index.get();\n") + " let index = index.unwrap();\n") if not 'IndexedCreator' in self.descriptor.operations: # FIXME need to check that this is a 'supported property index' assert False @@ -3677,7 +3677,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): " if strval.is_err() {\n" + " return 0;\n" + " }\n" + - " let name = str(strval.get());\n" + + " let name = str(strval.unwrap());\n" + "\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" + @@ -3721,7 +3721,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): raise TypeError("Can't handle creator that's different from the setter") set += ("let index = GetArrayIndexFromId(cx, id);\n" + "if index.is_some() {\n" + - " let index = index.get();\n" + + " let index = index.unwrap();\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() + " return 1;\n" + @@ -3746,7 +3746,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): " if strval.is_err() {\n" + " return 0;\n" + " }\n" + - " let name = str(strval.get());\n" + + " let name = str(strval.unwrap());\n" + "\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedSetter(self.descriptor)).define() + "\n" + @@ -3762,7 +3762,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod): " if strval.is_err() {\n" + " return 0;\n" + " }\n" + - " let name = str(strval.get());\n" + + " let name = str(strval.unwrap());\n" + " let this: %%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + " if (found) {\n" @@ -3787,7 +3787,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): if indexedGetter: indexed = ("let index = GetArrayIndexFromId(cx, id);\n" + "if index.is_some() {\n" + - " let index = index.get();\n" + + " let index = index.unwrap();\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" + " *bp = found as JSBool;\n" + @@ -3808,7 +3808,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): " if strval.is_err() {\n" + " return 0;\n" + " }\n" + - " let name = str(strval.get());\n" + + " let name = str(strval.unwrap());\n" + "\n" + " let this: *%s = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" + @@ -3861,7 +3861,7 @@ if expando.is_not_null() { if indexedGetter: getIndexedOrExpando = ("let index = GetArrayIndexFromId(cx, id);\n" + "if index.is_some() {\n" + - " let index = index.get();\n" + + " let index = index.unwrap();\n" + " let this = UnwrapProxy(proxy);\n" + CGIndenter(CGProxyIndexedGetter(self.descriptor, templateValues)).define()) getIndexedOrExpando += """ @@ -3935,7 +3935,7 @@ class CGDOMJSProxyHandler_obj_toString(CGAbstractExternMethod): JSString* jsresult; return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;""" - return """ do str::as_c_str("%s") |s| { + return """ do "%s".as_c_str |s| { _obj_toString(cx, s) }""" % self.descriptor.name @@ -4461,9 +4461,9 @@ class CGDictionary(CGThing): # NOTE: jsids are per-runtime, so don't use them in workers if True or self.workers: #XXXjdm hack until 'static mut' exists for global jsids propName = member.identifier.name - propCheck = ('str::as_c_str("%s", |s| { JS_HasProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&found)) })' % + propCheck = ('"%s".as_c_str(|s| { JS_HasProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&found)) })' % propName) - propGet = ('str::as_c_str("%s", |s| { JS_GetProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&temp)) })' % + propGet = ('"%s".as_c_str(|s| { JS_GetProperty(cx, RUST_JSVAL_TO_OBJECT(val), s, ptr::to_unsafe_ptr(&temp)) })' % propName) else: propId = self.makeIdName(member.identifier.name); diff --git a/src/components/script/dom/bindings/element.rs b/src/components/script/dom/bindings/element.rs index e9336e3da2a..5a3075efacc 100644 --- a/src/components/script/dom/bindings/element.rs +++ b/src/components/script/dom/bindings/element.rs @@ -21,8 +21,6 @@ use std::libc::c_uint; use std::comm; use std::ptr; use std::ptr::null; -use std::result; -use std::str; use js::glue::*; use js::jsapi::*; use js::jsapi::{JSContext, JSVal, JSObject, JSBool, JSFreeOp, JSPropertySpec}; @@ -49,14 +47,14 @@ pub extern fn trace(tracer: *mut JSTracer, obj: *JSObject) { return; } error!("tracing %s", name); - let mut node = node.get(); + let mut node = node.unwrap(); let cache = node.get_wrappercache(); let wrapper = cache.get_wrapper(); assert!(wrapper.is_not_null()); unsafe { (*tracer).debugPrinter = ptr::null(); (*tracer).debugPrintIndex = -1; - do str::as_c_str(name) |name| { + do name.as_c_str |name| { (*tracer).debugPrintArg = name as *libc::c_void; JS_CallTracer(cast::transmute(tracer), wrapper, JSTRACE_OBJECT as u32); } @@ -194,14 +192,14 @@ extern fn setAttribute(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool { if strval.is_err() { return 0; } - arg0 = str(strval.get()); + arg0 = str(strval.unwrap()); let arg1: DOMString; let strval = jsval_to_str(cx, (*argv.offset(1))); if strval.is_err() { return 0; } - arg1 = str(strval.get()); + arg1 = str(strval.unwrap()); do node.as_mut_element |elem| { elem.set_attr(&arg0, &arg1); @@ -293,9 +291,9 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj { //XXXjdm the parent should probably be the node parent instead of the global //TODO error checking let compartment = utils::get_compartment(cx); - let obj = result::unwrap(compartment.new_object_with_proto(~"GenericElementInstance", - proto, - compartment.global_obj.ptr)); + let obj = compartment.new_object_with_proto(~"GenericElementInstance", + proto, + compartment.global_obj.ptr).unwrap(); let cache = node.get_wrappercache(); assert!(cache.get_wrapper().is_null()); diff --git a/src/components/script/dom/bindings/text.rs b/src/components/script/dom/bindings/text.rs index 2ec4a6a69df..efa8cc90206 100644 --- a/src/components/script/dom/bindings/text.rs +++ b/src/components/script/dom/bindings/text.rs @@ -16,7 +16,6 @@ use js::rust::{Compartment, jsobj}; use std::cast; use std::libc; -use std::result; extern fn finalize_text(_fop: *JSFreeOp, obj: *JSObject) { debug!("text finalize: %?!", obj as uint); @@ -79,9 +78,9 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj { //XXXjdm the parent should probably be the node parent instead of the global //TODO error checking let compartment = utils::get_compartment(cx); - let obj = result::unwrap(compartment.new_object_with_proto(instance, - proto, - compartment.global_obj.ptr)); + let obj = compartment.new_object_with_proto(instance, + proto, + compartment.global_obj.ptr).unwrap(); let cache = node.get_wrappercache(); assert!(cache.get_wrapper().is_null()); diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs index c30eea5f1db..7db5a27a988 100644 --- a/src/components/script/dom/bindings/utils.rs +++ b/src/components/script/dom/bindings/utils.rs @@ -13,7 +13,6 @@ use std::hashmap::HashMap; use std::libc; use std::ptr; use std::ptr::{null, to_unsafe_ptr}; -use std::result; use std::str; use std::uint; use std::unstable::intrinsics; @@ -85,7 +84,7 @@ extern fn InterfaceObjectToString(cx: *JSContext, _argc: uint, vp: *mut JSVal) - return 0; } - let name = jsval_to_str(cx, *v).get(); + let name = jsval_to_str(cx, *v).unwrap(); let retval = str(~"function " + name + "() {\n [native code]\n}"); *vp = domstring_to_jsval(cx, &retval); return 1; @@ -216,10 +215,10 @@ pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal { JSVAL_NULL } &str(ref s) => { - str::as_buf(*s, |buf, len| { + do s.as_imm_buf |buf, len| { let cbuf = cast::transmute(buf); RUST_STRING_TO_JSVAL(JS_NewStringCopyN(cx, cbuf, len as libc::size_t)) - }) + } } } } @@ -322,13 +321,13 @@ pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut compartment.register_class(prototype_jsclass(name.to_owned())); //TODO error checking - let obj = result::unwrap( + let obj = ( match proto { Some(s) => compartment.new_object_with_proto(name.to_owned(), s, compartment.global_obj.ptr), None => compartment.new_object(name.to_owned(), null(), compartment.global_obj.ptr) - }); + }).unwrap(); unsafe { compartment.define_property(name.to_owned(), RUST_OBJECT_TO_JSVAL(obj.ptr), @@ -456,7 +455,7 @@ pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSO let mut interface = ptr::null(); if constructorClass.is_not_null() || constructor.is_not_null() { - interface = do str::as_c_str(name) |s| { + interface = do name.as_c_str |s| { CreateInterfaceObject(cx, global, receiver, constructorClass, constructor, ctorNargs, proto, staticMethods, constants, s) @@ -508,7 +507,7 @@ fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject, } if constructorClass.is_not_null() { - let toString = do str::as_c_str("toString") |s| { + let toString = do "toString".as_c_str |s| { DefineFunctionWithReserved(cx, constructor, s, InterfaceObjectToString, 0, 0) diff --git a/src/components/script/dom/clientrect.rs b/src/components/script/dom/clientrect.rs index 5c1de65851a..a0ad4a96dc1 100644 --- a/src/components/script/dom/clientrect.rs +++ b/src/components/script/dom/clientrect.rs @@ -10,7 +10,6 @@ use js::jsapi::{JSObject, JSContext, JSVal}; use js::glue::RUST_OBJECT_TO_JSVAL; use std::cast; -use std::f32; pub struct ClientRect { wrapper: WrapperCache, @@ -54,11 +53,11 @@ impl ClientRect { } pub fn Width(&self) -> f32 { - f32::abs(self.right - self.left) + (self.right - self.left).abs() } pub fn Height(&self) -> f32 { - f32::abs(self.bottom - self.top) + (self.bottom - self.top).abs() } } diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index 4d775577367..a050cd240ea 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -47,7 +47,7 @@ use js::jsapi::{JSContext, JSObject}; use std::cell::Cell; use std::comm; use std::str::eq_slice; -use extra::net::url; +use std::FromStr; pub struct Element { parent: Node<ScriptView>, @@ -279,7 +279,7 @@ impl<'self> Element { if "style" == name { self.style_attribute = Some( Stylesheet::from_attribute( - url::from_str("http://www.example.com/").unwrap(), + FromStr::from_str("http://www.example.com/").unwrap(), value.get_ref())); } @@ -290,8 +290,8 @@ impl<'self> Element { } fn get_scope_and_cx(&self) -> (*JSObject, *JSContext) { - let doc = self.parent.owner_doc.get(); - let win = doc.with_base(|doc| doc.window.get()); + let doc = self.parent.owner_doc.unwrap(); + let win = doc.with_base(|doc| doc.window.unwrap()); let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr}; let cache = win.get_wrappercache(); let scope = cache.get_wrapper(); @@ -419,7 +419,7 @@ impl Element { debug!("no document"); None } - }.get(); + }.unwrap(); ClientRectList::new(rects, cx, scope) } diff --git a/src/components/script/dom/formdata.rs b/src/components/script/dom/formdata.rs index e5e027ed4f1..873b539fdc3 100644 --- a/src/components/script/dom/formdata.rs +++ b/src/components/script/dom/formdata.rs @@ -39,7 +39,7 @@ impl FormData { pub fn Append(&mut self, name: &DOMString, value: @mut Blob, filename: Option<DOMString>) { let blob = BlobData { blob: value, - name: filename.get_or_default(str(~"default")) + name: filename.unwrap_or_default(str(~"default")) }; self.data.insert(name.to_str(), blob); } diff --git a/src/components/script/dom/htmliframeelement.rs b/src/components/script/dom/htmliframeelement.rs index ee71c2786ff..98217737a27 100644 --- a/src/components/script/dom/htmliframeelement.rs +++ b/src/components/script/dom/htmliframeelement.rs @@ -11,7 +11,7 @@ use geom::size::Size2D; use servo_msg::constellation_msg::SubpageId; use std::comm::ChanOne; -use extra::net::url::Url; +use extra::url::Url; pub struct HTMLIFrameElement { parent: HTMLElement, diff --git a/src/components/script/dom/htmlimageelement.rs b/src/components/script/dom/htmlimageelement.rs index b803625ebde..f345d59a8b8 100644 --- a/src/components/script/dom/htmlimageelement.rs +++ b/src/components/script/dom/htmlimageelement.rs @@ -4,7 +4,7 @@ use dom::bindings::utils::{DOMString, null_string, ErrorResult}; use dom::htmlelement::HTMLElement; -use extra::net::url::Url; +use extra::url::Url; pub struct HTMLImageElement { parent: HTMLElement, diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index 236df0f3732..bee3dac63d7 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -250,7 +250,7 @@ impl<'self, View> AbstractNode<View> { /// allowed to call this. This is wildly unsafe and is therefore marked as such. pub unsafe fn unsafe_layout_data<T>(self) -> @mut T { do self.with_base |base| { - transmute(base.layout_data.get()) + transmute(base.layout_data.unwrap()) } } /// Returns true if this node has layout data and false otherwise. diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs index 3f8339f913d..b6f028f2081 100644 --- a/src/components/script/dom/window.rs +++ b/src/components/script/dom/window.rs @@ -19,7 +19,6 @@ use js::{JSVAL_NULL, JSPROP_ENUMERATE}; use std::cast; use std::comm; use std::comm::Chan; -use std::int; use std::io; use std::ptr; use js::jsapi::JSVal; @@ -68,7 +67,7 @@ impl Window { pub fn Document(&self) -> AbstractDocument { unsafe { - (*self.page).frame.get().document + (*self.page).frame.unwrap().document } } diff --git a/src/components/script/html/cssparse.rs b/src/components/script/html/cssparse.rs index 0a04daf15ae..6d9d0d18a5a 100644 --- a/src/components/script/html/cssparse.rs +++ b/src/components/script/html/cssparse.rs @@ -11,7 +11,7 @@ use std::task; use newcss::stylesheet::Stylesheet; use newcss::util::DataStream; use servo_net::resource_task::{ResourceTask, ProgressMsg, Load, Payload, Done}; -use extra::net::url::Url; +use extra::url::Url; /// Where a style sheet comes from. pub enum StylesheetProvenance { diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index 79403b643c2..2409d4c0a6a 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -56,8 +56,8 @@ use std::cell::Cell; use std::comm; use std::comm::{Chan, Port, SharedChan}; use std::str::eq_slice; -use std::result; use std::task; +use std::from_str::FromStr; use hubbub::hubbub; use servo_msg::constellation_msg::SubpageId; use servo_net::image_cache_task::ImageCacheTask; @@ -65,8 +65,7 @@ use servo_net::image_cache_task; use servo_net::resource_task::{Done, Load, Payload, ResourceTask}; use servo_util::tree::TreeUtils; use servo_util::url::make_url; -use extra::net::url::Url; -use extra::net::url; +use extra::url::Url; use extra::future::{Future, from_port}; use geom::size::Size2D; @@ -498,7 +497,7 @@ pub fn parse_html(cx: *JSContext, // We've reached the end of a <style> so we can submit all the text to the parser. unsafe { let style: AbstractNode<ScriptView> = NodeWrapping::from_hubbub_node(style); - let url = url::from_str("http://example.com/"); // FIXME + let url = FromStr::from_str("http://example.com/"); // FIXME let url_cell = Cell::new(url); let mut data = ~[]; @@ -511,7 +510,7 @@ pub fn parse_html(cx: *JSContext, } debug!("data = %?", data); - let provenance = InlineProvenance(result::unwrap(url_cell.take()), data.concat()); + let provenance = InlineProvenance(url_cell.take().unwrap(), data.concat()); css_chan3.send(CSSTaskNewFile(provenance)); } }, diff --git a/src/components/script/layout_interface.rs b/src/components/script/layout_interface.rs index 9c9f27328c6..c7c7634f80b 100644 --- a/src/components/script/layout_interface.rs +++ b/src/components/script/layout_interface.rs @@ -14,7 +14,7 @@ use geom::size::Size2D; use geom::point::Point2D; use gfx::geometry::Au; use newcss::stylesheet::Stylesheet; -use extra::net::url::Url; +use extra::url::Url; /// Asynchronous messages that script can send to layout. /// diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index 4d6b5f2bda2..ac546f5cce6 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -29,7 +29,7 @@ use newcss::stylesheet::Stylesheet; use std::cell::Cell; use std::comm; -use std::comm::{Port, SharedChan, Select2}; +use std::comm::{Port, SharedChan}; use std::io::read_whole_file; use std::ptr::null; use std::task::{SingleThreaded, task}; @@ -50,8 +50,7 @@ use servo_net::image_cache_task::ImageCacheTask; use servo_net::resource_task::ResourceTask; use servo_util::tree::TreeNodeRef; use servo_util::url::make_url; -use extra::net::url::Url; -use extra::net::url; +use extra::url::Url; use extra::future::{from_value, Future}; /// Messages used to control the script task. @@ -485,14 +484,14 @@ impl ScriptTask { /// Handles a request to execute a script. fn handle_execute_msg(&mut self, id: PipelineId, url: Url) { - debug!("script: Received url `%s` to execute", url::to_str(&url)); + debug!("script: Received url `%s` to execute", url.to_str()); let page_tree = self.page_tree.find(id).expect("ScriptTask: received fire timer msg for a pipeline ID not associated with this script task. This is a bug."); let js_info = page_tree.page.js_info.get_ref(); match read_whole_file(&Path(url.path)) { - Err(msg) => println(fmt!("Error opening %s: %s", url::to_str(&url), msg)), + Err(msg) => println(fmt!("Error opening %s: %s", url.to_str(), msg)), Ok(bytes) => { js_info.js_compartment.define_functions(debug_fns); @@ -558,7 +557,7 @@ impl ScriptTask { fn handle_exit_msg(&mut self) { for self.page_tree.iter().advance |page| { page.join_layout(); - do page.frame.get().document.with_mut_base |doc| { + do page.frame.unwrap().document.with_mut_base |doc| { doc.teardown(); } page.layout_chan.send(layout_interface::ExitMsg); @@ -661,7 +660,7 @@ impl ScriptTask { // Receive the JavaScript scripts. assert!(js_scripts.is_some()); - let js_scripts = js_scripts.swap_unwrap(); + let js_scripts = js_scripts.take_unwrap(); debug!("js_scripts: %?", js_scripts); // Perform the initial reflow. diff --git a/src/components/util/url.rs b/src/components/util/url.rs index 4d08386511d..0f0ff19331d 100644 --- a/src/components/util/url.rs +++ b/src/components/util/url.rs @@ -2,11 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use extra::net::url; -use extra::net::url::Url; +use extra::url; +use extra::url::Url; use std::hashmap::HashMap; use std::os; -use std::result; /** Create a URL object from a string. Does various helpful browsery things like @@ -19,7 +18,7 @@ Create a URL object from a string. Does various helpful browsery things like */ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url { let schm = url::get_scheme(str_url); - let str_url = if result::is_err(&schm) { + let str_url = if schm.is_err() { if current_url.is_none() { // Assume we've been given a file path. If it's absolute just return // it, otherwise make it absolute with the cwd. @@ -29,7 +28,7 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url { ~"file://" + os::getcwd().push(str_url).to_str() } } else { - let current_url = current_url.get(); + let current_url = current_url.unwrap(); debug!("make_url: current_url: %?", current_url); if str_url.starts_with("//") { current_url.scheme + ":" + str_url @@ -56,7 +55,7 @@ pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url { }; // FIXME: Need to handle errors - url::from_str(str_url).get() + url::from_str(str_url).unwrap() } mod make_url_tests { |