From 164520ef3c6b5f4b3c6627bccff2fdb6c345995b Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Wed, 13 Mar 2013 10:47:43 -0400 Subject: [PATCH] De-mut field, de-DVec, de-assert. --- Makefile.in | 1 + mk/sub.mk | 1 + src/rust-azure | 2 +- src/rust-cairo | 2 +- src/rust-css | 2 +- src/rust-fontconfig | 2 +- src/rust-freetype | 2 +- src/rust-geom | 2 +- src/rust-glut | 2 +- src/rust-harfbuzz | 2 +- src/rust-http-client | 2 +- src/rust-hubbub | 2 +- src/rust-layers | 2 +- src/rust-mozjs | 2 +- src/rust-netsurfcss | 2 +- src/rust-stb-image | 2 +- src/rust-wapcaplet | 2 +- src/rust-xlib | 2 +- src/servo-gfx/display_list.rs | 1 - src/servo-gfx/font.rs | 18 ++-- src/servo-gfx/font_context.rs | 7 +- src/servo-gfx/font_list.rs | 2 +- src/servo-gfx/fontconfig/font_list.rs | 7 +- src/servo-gfx/freetype_impl/font.rs | 14 +-- src/servo-gfx/freetype_impl/font_context.rs | 6 +- src/servo-gfx/image/base.rs | 4 +- src/servo-gfx/image/encode/tga.rs | 2 +- src/servo-gfx/quartz/font.rs | 2 +- src/servo-gfx/render_context.rs | 1 - src/servo-gfx/render_layers.rs | 10 +- src/servo-gfx/resource/file_loader.rs | 2 +- src/servo-gfx/resource/http_loader.rs | 2 +- src/servo-gfx/resource/image_cache_task.rs | 14 +-- src/servo-gfx/resource/local_image_cache.rs | 2 +- src/servo-gfx/resource/resource_task.rs | 6 +- src/servo-gfx/text/glyph.rs | 73 +++++++------- src/servo-gfx/text/harfbuzz/shaper.rs | 36 +++---- src/servo-gfx/text/text_run.rs | 4 +- src/servo-gfx/text/util.rs | 16 +-- src/servo-gfx/util/cache.rs | 8 +- src/servo-gfx/util/time.rs | 2 +- src/servo-gfx/util/url.rs | 28 +++--- src/servo-gfx/util/vec.rs | 4 +- src/servo/content/content_task.rs | 6 +- src/servo/css/node_style.rs | 2 +- src/servo/css/node_void_ptr.rs | 2 +- src/servo/dom/bindings/document.rs | 4 +- src/servo/dom/bindings/utils.rs | 10 +- src/servo/dom/bindings/window.rs | 5 +- src/servo/dom/node.rs | 10 +- src/servo/dom/window.rs | 23 +++-- src/servo/engine.rs | 4 +- src/servo/layout/aux.rs | 5 +- src/servo/layout/block.rs | 16 +-- src/servo/layout/box.rs | 9 +- src/servo/layout/box_builder.rs | 37 ++++--- src/servo/layout/display_list_builder.rs | 1 - src/servo/layout/flow.rs | 9 +- src/servo/layout/inline.rs | 106 ++++++++++---------- src/servo/layout/layout_task.rs | 11 +- src/servo/layout/root.rs | 8 +- src/servo/layout/text.rs | 6 +- src/servo/layout/traverse.rs | 10 +- src/servo/platform/osmain.rs | 25 ++--- src/servo/platform/resize_rate_limiter.rs | 4 +- src/servo/servo.rc | 2 +- src/servo/util/tree.rs | 34 +++---- src/sharegl | 2 +- 68 files changed, 330 insertions(+), 326 deletions(-) diff --git a/Makefile.in b/Makefile.in index 8d4f063b465..fd5f105fc41 100644 --- a/Makefile.in +++ b/Makefile.in @@ -153,6 +153,7 @@ DONE_servo_gfx = $(B)src/servo-gfx/libservogfx.dummy DEPS_servo_gfx = $(CRATE_servo_gfx) $(SRC_servo_gfx) $(DONE_SUBMODULES) RFLAGS_servo = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/servo-gfx + SRC_servo = $(call rwildcard,$(S)src/servo/,*.rs) CRATE_servo = $(S)src/servo/servo.rc diff --git a/mk/sub.mk b/mk/sub.mk index a2200bfbfb0..bfb02360686 100644 --- a/mk/sub.mk +++ b/mk/sub.mk @@ -55,6 +55,7 @@ DEPS_rust-layers += \ rust-geom \ rust-glut \ rust-opengles \ + skia \ $(NULL) DEPS_sharegl += \ diff --git a/src/rust-azure b/src/rust-azure index 433fcc2d686..a016a795bb9 160000 --- a/src/rust-azure +++ b/src/rust-azure @@ -1 +1 @@ -Subproject commit 433fcc2d6862bea202ad2e3acfd1fe4041064edc +Subproject commit a016a795bb9a021c06a665563c4aaf793b0b97ca diff --git a/src/rust-cairo b/src/rust-cairo index a0257b8d6d8..252672fd902 160000 --- a/src/rust-cairo +++ b/src/rust-cairo @@ -1 +1 @@ -Subproject commit a0257b8d6d81ead5aeb018e48b37c456177cd92e +Subproject commit 252672fd902723cca59423a135c829a70a0b3f0b diff --git a/src/rust-css b/src/rust-css index 6eba2da0919..9f406c72c22 160000 --- a/src/rust-css +++ b/src/rust-css @@ -1 +1 @@ -Subproject commit 6eba2da0919e6d47458d8d4e002aaa7a17a66f77 +Subproject commit 9f406c72c22fb68691d8d137df679a7d047ec135 diff --git a/src/rust-fontconfig b/src/rust-fontconfig index 1d966254065..260f7062a4c 160000 --- a/src/rust-fontconfig +++ b/src/rust-fontconfig @@ -1 +1 @@ -Subproject commit 1d966254065c59d0c108f3207c4646184fc85635 +Subproject commit 260f7062a4cae7e3575a3cf97d1119bc076ab221 diff --git a/src/rust-freetype b/src/rust-freetype index e185c9ad59e..b414d3bf445 160000 --- a/src/rust-freetype +++ b/src/rust-freetype @@ -1 +1 @@ -Subproject commit e185c9ad59eb42250db8a1c5d1d1e078265d933d +Subproject commit b414d3bf445ac63860a9cf44532280228f001a2b diff --git a/src/rust-geom b/src/rust-geom index f382fa4ca9b..cdc1b0b8d17 160000 --- a/src/rust-geom +++ b/src/rust-geom @@ -1 +1 @@ -Subproject commit f382fa4ca9bd2b13805156b821d1a8242f9873a1 +Subproject commit cdc1b0b8d173be4e1c79961742a367dac39d7d86 diff --git a/src/rust-glut b/src/rust-glut index 84684665c67..337bc5cb49b 160000 --- a/src/rust-glut +++ b/src/rust-glut @@ -1 +1 @@ -Subproject commit 84684665c678d35057296cdfdfaa4389a23d1d9b +Subproject commit 337bc5cb49b2a518527d62cd9af08e169f4f6456 diff --git a/src/rust-harfbuzz b/src/rust-harfbuzz index 6a58ecc9628..e416f03f489 160000 --- a/src/rust-harfbuzz +++ b/src/rust-harfbuzz @@ -1 +1 @@ -Subproject commit 6a58ecc96287aa1c051c0aacba3d3b6857b4dd0d +Subproject commit e416f03f4898825bc8f24cfd890004a130e2457b diff --git a/src/rust-http-client b/src/rust-http-client index 5d00c01fb47..886cf481cbf 160000 --- a/src/rust-http-client +++ b/src/rust-http-client @@ -1 +1 @@ -Subproject commit 5d00c01fb4798722b5e5a27f55fccc726068ad08 +Subproject commit 886cf481cbf9c9eedfbab0344e5f887c11220497 diff --git a/src/rust-hubbub b/src/rust-hubbub index 4714bc7a8f7..8e04c939c72 160000 --- a/src/rust-hubbub +++ b/src/rust-hubbub @@ -1 +1 @@ -Subproject commit 4714bc7a8f7a3d4168b297c4568b38acd5b7a8c9 +Subproject commit 8e04c939c72083fa311ea709f5aafeaccd83975d diff --git a/src/rust-layers b/src/rust-layers index 9bf7ae289c9..276a57d204f 160000 --- a/src/rust-layers +++ b/src/rust-layers @@ -1 +1 @@ -Subproject commit 9bf7ae289c9fdbc82d0a8f45a54f18e281fc6875 +Subproject commit 276a57d204f2d0ae74bda4ed76e63b830ca6332b diff --git a/src/rust-mozjs b/src/rust-mozjs index f796ad48dae..62558783027 160000 --- a/src/rust-mozjs +++ b/src/rust-mozjs @@ -1 +1 @@ -Subproject commit f796ad48dae00987ab6bc0c64031ecb8358a9c08 +Subproject commit 62558783027d1aaccb4e689d3ff5aed057a1f5f5 diff --git a/src/rust-netsurfcss b/src/rust-netsurfcss index ea93796f5c0..9b6d463d904 160000 --- a/src/rust-netsurfcss +++ b/src/rust-netsurfcss @@ -1 +1 @@ -Subproject commit ea93796f5c0675d50fa1e92bfd76709a601fe9fe +Subproject commit 9b6d463d9045a90e6e3f31e35806af87e46e3852 diff --git a/src/rust-stb-image b/src/rust-stb-image index 485845b44db..06b790f2268 160000 --- a/src/rust-stb-image +++ b/src/rust-stb-image @@ -1 +1 @@ -Subproject commit 485845b44db19558c8c911a4a4a864144a85f72b +Subproject commit 06b790f226819e30c59b35523407bc671fe4d2ca diff --git a/src/rust-wapcaplet b/src/rust-wapcaplet index 6cec2ef974c..ce75a426858 160000 --- a/src/rust-wapcaplet +++ b/src/rust-wapcaplet @@ -1 +1 @@ -Subproject commit 6cec2ef974c10669d127d19509ae595ce2b76135 +Subproject commit ce75a42685824a4c3c63a638a2c76762b7fac813 diff --git a/src/rust-xlib b/src/rust-xlib index 0adab98b6bc..c8328148ec5 160000 --- a/src/rust-xlib +++ b/src/rust-xlib @@ -1 +1 @@ -Subproject commit 0adab98b6bc352fa689320ce8cd14ca6d92a88d3 +Subproject commit c8328148ec5d1ec4fb8a496a41e34badf53e7f88 diff --git a/src/servo-gfx/display_list.rs b/src/servo-gfx/display_list.rs index 8bdea3b5033..7d219ba3108 100644 --- a/src/servo-gfx/display_list.rs +++ b/src/servo-gfx/display_list.rs @@ -6,7 +6,6 @@ use text::SendableTextRun; use util::range::Range; use azure::azure_hl::DrawTarget; -use core::dvec::DVec; use clone_arc = std::arc::clone; use geom::Rect; use geom::Point2D; diff --git a/src/servo-gfx/font.rs b/src/servo-gfx/font.rs index 9470ecd1964..b33140a2e16 100644 --- a/src/servo-gfx/font.rs +++ b/src/servo-gfx/font.rs @@ -11,7 +11,6 @@ use azure::{AzFloat, AzScaledFontRef, struct__AzDrawOptions, struct__AzGlyph}; use azure::{struct__AzGlyphBuffer, struct__AzPoint}; use azure::scaled_font::ScaledFont; use azure::azure_hl::{BackendType, ColorPattern}; -use core::dvec::DVec; use geom::{Point2D, Rect, Size2D}; #[cfg(target_os = "macos")] @@ -212,7 +211,7 @@ pub impl FontGroup { } fn create_textrun(&self, text: ~str) -> TextRun { - assert self.fonts.len() > 0; + fail_unless!(self.fonts.len() > 0); // TODO(Issue #177): Actually fall back through the FontGroup when a font is unsuitable. return TextRun::new(self.fonts[0], text); @@ -366,7 +365,7 @@ pub impl Font { let azfontref = self.get_azure_font(); let pattern = ColorPattern(color); let azure_pattern = pattern.azure_color_pattern; - assert azure_pattern.is_not_null(); + fail_unless!(azure_pattern.is_not_null()); let options = struct__AzDrawOptions { mAlpha: 1f as AzFloat, @@ -374,8 +373,8 @@ pub impl Font { }; let mut origin = copy baseline_origin; - let azglyphs = DVec(); - azglyphs.reserve(range.length()); + let mut azglyphs = ~[]; + vec::reserve(&mut azglyphs, range.length()); for run.glyphs.iter_glyphs_for_char_range(range) |_i, glyph| { let glyph_advance = glyph.advance(); @@ -395,10 +394,9 @@ pub impl Font { let azglyph_buf_len = azglyphs.len(); if azglyph_buf_len == 0 { return; } // Otherwise the Quartz backend will assert. - let azglyph_buf = dvec::unwrap(azglyphs); let glyphbuf = unsafe { struct__AzGlyphBuffer { - mGlyphs: vec::raw::to_ptr(azglyph_buf), + mGlyphs: vec::raw::to_ptr(azglyphs), mNumGlyphs: azglyph_buf_len as uint32_t } }; @@ -474,7 +472,7 @@ fn should_get_glyph_indexes() { let matcher = @FontMatcher(fctx); let font = matcher.get_test_font(); let glyph_idx = font.glyph_index('w'); - assert glyph_idx == Some(40u as GlyphIndex); + fail_unless!(glyph_idx == Some(40u as GlyphIndex)); } fn should_get_glyph_advance() { @@ -485,7 +483,7 @@ fn should_get_glyph_advance() { let matcher = @FontMatcher(fctx); let font = matcher.get_test_font(); let x = font.glyph_h_advance(40u as GlyphIndex); - assert x == 15f || x == 16f; + fail_unless!(x == 15f || x == 16f); } // Testing thread safety @@ -503,7 +501,7 @@ fn should_get_glyph_advance_stress() { let matcher = @FontMatcher(fctx); let _font = matcher.get_test_font(); let x = font.glyph_h_advance(40u as GlyphIndex); - assert x == 15f || x == 16f; + fail_unless!(x == 15f || x == 16f); chan.send(()); } } diff --git a/src/servo-gfx/font_context.rs b/src/servo-gfx/font_context.rs index 532124e0205..0a78bad5d6c 100644 --- a/src/servo-gfx/font_context.rs +++ b/src/servo-gfx/font_context.rs @@ -6,7 +6,6 @@ use util::cache::Cache; use util::cache::MonoCache; use azure::azure_hl::BackendType; -use core::dvec::DVec; use core::hashmap::linear::LinearMap; use core::hashmap::linear; @@ -131,7 +130,7 @@ pub impl FontContext { // TODO:(Issue #196): cache font groups on the font context. priv fn create_font_group(&mut self, style: &SpecifiedFontStyle) -> @FontGroup { - let fonts = DVec(); + let mut fonts = ~[]; debug!("(create font group) --- starting ---"); @@ -169,13 +168,13 @@ pub impl FontContext { Err(()) => {} } } - assert fonts.len() > 0; + fail_unless!(fonts.len() > 0); // TODO(Issue #179): Split FontStyle into specified and used styles let used_style = copy *style; debug!("(create font group) --- finished ---"); - @FontGroup::new(style.families.to_managed(), &used_style, dvec::unwrap(fonts)) + @FontGroup::new(style.families.to_managed(), &used_style, fonts) } priv fn create_font_instance(&self, desc: &FontDescriptor) -> Result<@mut Font, ()> { diff --git a/src/servo-gfx/font_list.rs b/src/servo-gfx/font_list.rs index 4359684cffe..b1a5371d7bc 100644 --- a/src/servo-gfx/font_list.rs +++ b/src/servo-gfx/font_list.rs @@ -110,7 +110,7 @@ pub impl FontFamily { priv fn load_family_variations(@mut self, list: &native::FontListHandle) { if self.entries.len() > 0 { return; } list.load_variations_for_family(self); - assert self.entries.len() > 0; + fail_unless!(self.entries.len() > 0); } fn find_font_for_style(@mut self, list: &native::FontListHandle, style: &SpecifiedFontStyle) -> Option<@FontEntry> { diff --git a/src/servo-gfx/fontconfig/font_list.rs b/src/servo-gfx/fontconfig/font_list.rs index c148e41e5d7..de302755bbb 100644 --- a/src/servo-gfx/fontconfig/font_list.rs +++ b/src/servo-gfx/fontconfig/font_list.rs @@ -19,7 +19,6 @@ use self::fontconfig::fontconfig::bindgen::{ FcPatternGetInteger }; -use core::dvec::DVec; use core::hashmap::linear; use core::libc::c_int; use core::ptr::Ptr; @@ -66,13 +65,13 @@ pub impl FontconfigFontListHandle { do str::as_c_str("family") |FC_FAMILY| { do str::as_c_str(family.family_name) |family_name| { let pattern = FcPatternCreate(); - assert pattern.is_not_null(); + fail_unless!(pattern.is_not_null()); let family_name = family_name as *FcChar8; let ok = FcPatternAddString(pattern, FC_FAMILY, family_name); - assert ok != 0; + fail_unless!(ok != 0); let object_set = FcObjectSetCreate(); - assert object_set.is_not_null(); + fail_unless!(object_set.is_not_null()); str::as_c_str("file", |FC_FILE| FcObjectSetAdd(object_set, FC_FILE) ); str::as_c_str("index", |FC_INDEX| FcObjectSetAdd(object_set, FC_INDEX) ); diff --git a/src/servo-gfx/freetype_impl/font.rs b/src/servo-gfx/freetype_impl/font.rs index 9fe75211c0e..778758476d2 100644 --- a/src/servo-gfx/freetype_impl/font.rs +++ b/src/servo-gfx/freetype_impl/font.rs @@ -88,9 +88,11 @@ pub struct FreeTypeFontHandle { // if the font is created using FT_Memory_Face. source: FontSource, face: FT_Face, +} - drop { - assert self.face.is_not_null(); +impl Drop for FreeTypeFontHandle { + fn finalize(&self) { + fail_unless!(self.face.is_not_null()); if !FT_Done_Face(self.face).succeeded() { fail!(~"FT_Done_Face failed"); } @@ -243,7 +245,7 @@ impl FontHandleMethods for FreeTypeFontHandle { pub fn glyph_index(&self, codepoint: char) -> Option { - assert self.face.is_not_null(); + fail_unless!(self.face.is_not_null()); let idx = FT_Get_Char_Index(self.face, codepoint as FT_ULong); return if idx != 0 as FT_UInt { Some(idx as GlyphIndex) @@ -255,13 +257,13 @@ impl FontHandleMethods for FreeTypeFontHandle { pub fn glyph_h_advance(&self, glyph: GlyphIndex) -> Option { - assert self.face.is_not_null(); + fail_unless!(self.face.is_not_null()); let res = FT_Load_Glyph(self.face, glyph as FT_UInt, 0); if res.succeeded() { unsafe { let void_glyph = (*self.face).glyph; let slot: FT_GlyphSlot = cast::transmute(void_glyph); - assert slot.is_not_null(); + fail_unless!(slot.is_not_null()); debug!("metrics: %?", (*slot).metrics); let advance = (*slot).metrics.horiAdvance; debug!("h_advance for %? is %?", glyph, advance); @@ -322,7 +324,7 @@ pub impl FreeTypeFontHandle { let x_scale = (metrics.x_ppem as float) / em_size as float; // If this isn't true then we're scaling one of the axes wrong - assert metrics.x_ppem == metrics.y_ppem; + fail_unless!(metrics.x_ppem == metrics.y_ppem); return geometry::from_frac_px(value * x_scale); } diff --git a/src/servo-gfx/freetype_impl/font_context.rs b/src/servo-gfx/freetype_impl/font_context.rs index 38740dc2be1..27617cdb4cf 100644 --- a/src/servo-gfx/freetype_impl/font_context.rs +++ b/src/servo-gfx/freetype_impl/font_context.rs @@ -21,9 +21,11 @@ use freetype_impl::font::FreeTypeFontHandle; struct FreeTypeLibraryHandle { ctx: FT_Library, +} - drop { - assert self.ctx.is_not_null(); +impl Drop for FreeTypeLibraryHandle { + fn finalize(&self) { + fail_unless!(self.ctx.is_not_null()); FT_Done_FreeType(self.ctx); } } diff --git a/src/servo-gfx/image/base.rs b/src/servo-gfx/image/base.rs index 84148b7d766..c0e8b9bcc55 100644 --- a/src/servo-gfx/image/base.rs +++ b/src/servo-gfx/image/base.rs @@ -22,7 +22,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option { match stb_image::load_from_memory_with_depth(buffer, FORCE_DEPTH, true) { stb_image::ImageU8(image) => { - assert image.depth == 4; + fail_unless!(image.depth == 4); // Do color space conversion :( let data = do vec::from_fn(image.width * image.height * 4) |i| { let color = i % 4; @@ -36,7 +36,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option { } }; - assert image.data.len() == data.len(); + fail_unless!(image.data.len() == data.len()); Some(Image(image.width, image.height, image.depth, data)) } diff --git a/src/servo-gfx/image/encode/tga.rs b/src/servo-gfx/image/encode/tga.rs index ff86513685b..17c13854cca 100644 --- a/src/servo-gfx/image/encode/tga.rs +++ b/src/servo-gfx/image/encode/tga.rs @@ -2,7 +2,7 @@ use core::io::WriterUtil; use surface; fn encode(writer: io::Writer, surface: &surface::ImageSurface) { - assert surface.format == surface::fo_rgba_8888; + fail_unless!(surface.format == surface::fo_rgba_8888); writer.write_u8(0u8); // identsize writer.write_u8(0u8); // colourmaptype diff --git a/src/servo-gfx/quartz/font.rs b/src/servo-gfx/quartz/font.rs index d53276ad36e..f54e2576d14 100644 --- a/src/servo-gfx/quartz/font.rs +++ b/src/servo-gfx/quartz/font.rs @@ -141,7 +141,7 @@ impl FontHandleMethods for QuartzFontHandle { return None; } - assert glyphs[0] != 0; // FIXME: error handling + fail_unless!(glyphs[0] != 0); // FIXME: error handling return Some(glyphs[0] as GlyphIndex); } diff --git a/src/servo-gfx/render_context.rs b/src/servo-gfx/render_context.rs index 94438cc5404..37e3b927760 100644 --- a/src/servo-gfx/render_context.rs +++ b/src/servo-gfx/render_context.rs @@ -8,7 +8,6 @@ use text::TextRun; use azure::azure_hl::{AsAzureRect, B8G8R8A8, Color, ColorPattern, DrawOptions}; use azure::azure_hl::{DrawSurfaceOptions, DrawTarget, Linear, StrokeOptions}; use azure::{AzDrawOptions, AzFloat}; -use core::dvec::DVec; use core::libc::types::common::c99::uint16_t; use core::ptr::to_unsafe_ptr; use geom::point::Point2D; diff --git a/src/servo-gfx/render_layers.rs b/src/servo-gfx/render_layers.rs index 99b4a6ed60c..f05e04877e4 100644 --- a/src/servo-gfx/render_layers.rs +++ b/src/servo-gfx/render_layers.rs @@ -36,7 +36,7 @@ pub fn render_layers(layer_ref: *RenderLayer, let mut _buffers = match buffer_set { LayerBufferSet { buffers: b } => b }; // FIXME: Try not to create a new array here. - let new_buffer_ports = dvec::DVec(); + let mut new_buffer_ports = ~[]; // Divide up the layer into tiles. do time::time("rendering: preparing buffers") { @@ -56,8 +56,8 @@ pub fn render_layers(layer_ref: *RenderLayer, if stride % 32 != 0 { stride = (stride & !(32 - 1)) + 32; } - assert stride % 32 == 0; - assert stride >= width; + fail_unless!(stride % 32 == 0); + fail_unless!(stride >= width); debug!("tile stride %u", stride); @@ -125,13 +125,13 @@ pub fn render_layers(layer_ref: *RenderLayer, } } - let new_buffers = dvec::DVec(); + let mut new_buffers = ~[]; do time::time("rendering: waiting on subtasks") { for new_buffer_ports.each |new_buffer_port| { new_buffers.push(new_buffer_port.recv()); } } - return LayerBufferSet { buffers: dvec::unwrap(new_buffers) }; + return LayerBufferSet { buffers: new_buffers }; } diff --git a/src/servo-gfx/resource/file_loader.rs b/src/servo-gfx/resource/file_loader.rs index 72a4dc1aaa2..60476f87fa0 100644 --- a/src/servo-gfx/resource/file_loader.rs +++ b/src/servo-gfx/resource/file_loader.rs @@ -8,7 +8,7 @@ const READ_SIZE: uint = 1024; pub fn factory() -> LoaderTask { let f: LoaderTask = |url, progress_chan| { - assert url.scheme == ~"file"; + fail_unless!(url.scheme == ~"file"); do spawn { // FIXME: Resolve bug prevents us from moving the path out of the URL. match file_reader(&Path(url.path)) { diff --git a/src/servo-gfx/resource/http_loader.rs b/src/servo-gfx/resource/http_loader.rs index 9c73a5816b6..31c85e21e96 100644 --- a/src/servo-gfx/resource/http_loader.rs +++ b/src/servo-gfx/resource/http_loader.rs @@ -8,7 +8,7 @@ use http_client::{uv_http_request}; pub fn factory() -> LoaderTask { let f: LoaderTask = |url, progress_chan| { - assert url.scheme == ~"http"; + fail_unless!(url.scheme == ~"http"); let progress_chan = SharedChan(progress_chan); do spawn { diff --git a/src/servo-gfx/resource/image_cache_task.rs b/src/servo-gfx/resource/image_cache_task.rs index eaab065da9e..c9c54e74c03 100644 --- a/src/servo-gfx/resource/image_cache_task.rs +++ b/src/servo-gfx/resource/image_cache_task.rs @@ -199,7 +199,7 @@ impl ImageCache { } OnMsg(handler) => msg_handlers.push(handler), Exit(response) => { - assert self.need_exit.is_none(); + fail_unless!(self.need_exit.is_none()); self.need_exit = Some(response); } } @@ -317,7 +317,7 @@ impl ImageCache { } Prefetched(data_cell) => { - assert !data_cell.is_empty(); + fail_unless!(!data_cell.is_empty()); let data = data_cell.take(); let to_cache = self.chan.clone(); @@ -373,7 +373,7 @@ impl ImageCache { } - priv fn purge_waiters(&self, url: Url, f: fn() -> ImageResponseMsg) { + priv fn purge_waiters(&self, url: Url, f: &fn() -> ImageResponseMsg) { match self.wait_map.find(&url) { Some(waiters) => { let waiters = &mut *waiters; @@ -598,7 +598,7 @@ fn should_not_request_url_from_resource_task_on_multiple_prefetches() { url_requested.recv(); image_cache_task.exit(); mock_resource_task.send(resource_task::Exit); - assert !url_requested.peek() + fail_unless!(!url_requested.peek()) } #[test] @@ -621,7 +621,7 @@ fn should_return_image_not_ready_if_data_has_not_arrived() { image_cache_task.send(Decode(copy url)); let (response_chan, response_port) = stream(); image_cache_task.send(GetImage(url, response_chan)); - assert response_port.recv() == ImageNotReady; + fail_unless!(response_port.recv() == ImageNotReady); wait_chan.send(()); image_cache_task.exit(); mock_resource_task.send(resource_task::Exit); @@ -747,7 +747,7 @@ fn should_not_request_image_from_resource_task_if_image_is_already_available() { // Our resource task should not have received another request for the image // because it's already cached - assert !image_bin_sent.peek(); + fail_unless!(!image_bin_sent.peek()); } #[test] @@ -794,7 +794,7 @@ fn should_not_request_image_from_resource_task_if_image_fetch_already_failed() { // Our resource task should not have received another request for the image // because it's already cached - assert !image_bin_sent.peek(); + fail_unless!(!image_bin_sent.peek()); } #[test] diff --git a/src/servo-gfx/resource/local_image_cache.rs b/src/servo-gfx/resource/local_image_cache.rs index aeb4098d30a..0b3468510f8 100644 --- a/src/servo-gfx/resource/local_image_cache.rs +++ b/src/servo-gfx/resource/local_image_cache.rs @@ -107,7 +107,7 @@ pub impl LocalImageCache { // the compositor should be resonsible for waiting // on the image to load and triggering layout let image_cache_task = self.image_cache_task.clone(); - assert self.on_image_available.is_some(); + fail_unless!(self.on_image_available.is_some()); let on_image_available = self.on_image_available.get()(); let url = copy *url; do task::spawn { diff --git a/src/servo-gfx/resource/resource_task.rs b/src/servo-gfx/resource/resource_task.rs index f0b38559293..7786ae8cabd 100644 --- a/src/servo-gfx/resource/resource_task.rs +++ b/src/servo-gfx/resource/resource_task.rs @@ -130,7 +130,7 @@ fn test_bad_scheme() { let progress = Port(); resource_task.send(Load(url::from_str(~"bogus://whatever").get(), progress.chan())); match progress.recv() { - Done(result) => { assert result.is_err() } + Done(result) => { fail_unless!(result.is_err()) } _ => fail } resource_task.send(Exit); @@ -148,7 +148,7 @@ fn should_delegate_to_scheme_loader() { let resource_task = create_resource_task_with_loaders(loader_factories); let progress = Port(); resource_task.send(Load(url::from_str(~"snicklefritz://heya").get(), progress.chan())); - assert progress.recv() == Payload(payload); - assert progress.recv() == Done(Ok(())); + fail_unless!(progress.recv() == Payload(payload)); + fail_unless!(progress.recv() == Done(Ok(()))); resource_task.send(Exit); } diff --git a/src/servo-gfx/text/glyph.rs b/src/servo-gfx/text/glyph.rs index 6dbccac3b70..c5f0e0137f4 100644 --- a/src/servo-gfx/text/glyph.rs +++ b/src/servo-gfx/text/glyph.rs @@ -5,7 +5,6 @@ use servo_gfx_util::vec::*; use geometry; use core; use core::cmp::{Ord, Eq}; -use core::dvec::DVec; use core::num::NumCast; use core::u16; use geom::point::Point2D; @@ -110,8 +109,8 @@ pure fn InitialGlyphEntry() -> GlyphEntry { // Creates a GlyphEntry for the common case pure fn SimpleGlyphEntry(index: GlyphIndex, advance: Au) -> GlyphEntry { - assert is_simple_glyph_id(index); - assert is_simple_advance(advance); + fail_unless!(is_simple_glyph_id(index)); + fail_unless!(is_simple_advance(advance)); let index_mask = index as u32; let advance_mask = (*advance as u32) << GLYPH_ADVANCE_SHIFT; @@ -124,7 +123,7 @@ pure fn SimpleGlyphEntry(index: GlyphIndex, advance: Au) -> GlyphEntry { // Create a GlyphEntry for uncommon case; should be accompanied by // initialization of the actual DetailedGlyph data in DetailedGlyphStore pure fn ComplexGlyphEntry(startsCluster: bool, startsLigature: bool, glyphCount: uint) -> GlyphEntry { - assert glyphCount <= u16::max_value as uint; + fail_unless!(glyphCount <= u16::max_value as uint); debug!("Creating complex glyph entry: startsCluster=%?, startsLigature=%?, glyphCount=%?", startsCluster, startsLigature, glyphCount); @@ -147,7 +146,7 @@ pure fn ComplexGlyphEntry(startsCluster: bool, startsLigature: bool, glyphCount: // Create a GlyphEntry for the case where glyphs couldn't be found // for the specified character. pure fn MissingGlyphsEntry(glyphCount: uint) -> GlyphEntry { - assert glyphCount <= u16::max_value as uint; + fail_unless!(glyphCount <= u16::max_value as uint); GlyphEntry { value: (glyphCount as u32) << GLYPH_COUNT_SHIFT @@ -160,17 +159,17 @@ impl GlyphEntry { // getter methods #[inline(always)] pure fn advance(&self) -> Au { - //assert self.is_simple(); + //fail_unless!(self.is_simple()); NumCast::from((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) } pure fn index(&self) -> GlyphIndex { - //assert self.is_simple(); + //fail_unless!(self.is_simple()); self.value & GLYPH_ID_MASK } pure fn offset(&self) -> Point2D { - //assert self.is_simple(); + //fail_unless!(self.is_simple()); Point2D(Au(0), Au(0)) } @@ -209,13 +208,13 @@ impl GlyphEntry { #[inline(always)] pure fn set_char_is_tab(&self) -> GlyphEntry { - assert !self.is_simple(); + fail_unless!(!self.is_simple()); GlyphEntry(self.value | FLAG_CHAR_IS_TAB) } #[inline(always)] pure fn set_char_is_newline(&self) -> GlyphEntry { - assert !self.is_simple(); + fail_unless!(!self.is_simple()); GlyphEntry(self.value | FLAG_CHAR_IS_NEWLINE) } @@ -228,7 +227,7 @@ impl GlyphEntry { // helper methods /*priv*/ pure fn glyph_count(&self) -> u16 { - assert !self.is_simple(); + fail_unless!(!self.is_simple()); ((self.value & GLYPH_COUNT_MASK) >> GLYPH_COUNT_SHIFT) as u16 } @@ -343,8 +342,8 @@ impl DetailedGlyphStore { return vec::slice(self.detail_buffer, 0, 0); } - assert (count as uint) <= self.detail_buffer.len(); - assert self.lookup_is_sorted; + fail_unless!((count as uint) <= self.detail_buffer.len()); + fail_unless!(self.lookup_is_sorted); let key = DetailedGlyphRecord { entry_offset: entry_offset, @@ -356,7 +355,7 @@ impl DetailedGlyphStore { match records.binary_search_index(&key) { None => fail!(~"Invalid index not found in detailed glyph lookup table!"), Some(i) => { - assert i + (count as uint) <= self.detail_buffer.len(); + fail_unless!(i + (count as uint) <= self.detail_buffer.len()); // return a slice into the buffer vec::slice(self.detail_buffer, i, i + count as uint) } @@ -367,8 +366,8 @@ impl DetailedGlyphStore { entry_offset: uint, detail_offset: u16) -> &self/DetailedGlyph { - assert (detail_offset as uint) <= self.detail_buffer.len(); - assert self.lookup_is_sorted; + fail_unless!((detail_offset as uint) <= self.detail_buffer.len()); + fail_unless!(self.lookup_is_sorted); let key = DetailedGlyphRecord { entry_offset: entry_offset, @@ -380,7 +379,7 @@ impl DetailedGlyphStore { match records.binary_search_index(&key) { None => fail!(~"Invalid index not found in detailed glyph lookup table!"), Some(i) => { - assert i + (detail_offset as uint) < self.detail_buffer.len(); + fail_unless!(i + (detail_offset as uint) < self.detail_buffer.len()); &self.detail_buffer[i+(detail_offset as uint)] } } @@ -498,7 +497,7 @@ pub impl GlyphStore { // Initializes the glyph store, but doesn't actually shape anything. // Use the set_glyph, set_glyphs() methods to store glyph data. static fn new(length: uint) -> GlyphStore { - assert length > 0; + fail_unless!(length > 0); GlyphStore { entry_buffer: vec::from_elem(length, InitialGlyphEntry()), @@ -519,8 +518,8 @@ pub impl GlyphStore { && data.cluster_start // others are stored in detail buffer } - assert data.ligature_start; // can't compress ligature continuation glyphs. - assert i < self.entry_buffer.len(); + fail_unless!(data.ligature_start); // can't compress ligature continuation glyphs. + fail_unless!(i < self.entry_buffer.len()); let entry = match (data.is_missing, glyph_is_compressible(data)) { (true, _) => MissingGlyphsEntry(1), @@ -536,8 +535,8 @@ pub impl GlyphStore { } fn add_glyphs_for_char_index(&mut self, i: uint, data_for_glyphs: &[GlyphData]) { - assert i < self.entry_buffer.len(); - assert data_for_glyphs.len() > 0; + fail_unless!(i < self.entry_buffer.len()); + fail_unless!(data_for_glyphs.len() > 0); let glyph_count = data_for_glyphs.len(); @@ -565,7 +564,7 @@ pub impl GlyphStore { // used when a character index has no associated glyph---for example, a ligature continuation. fn add_nonglyph_for_char_index(&mut self, i: uint, cluster_start: bool, ligature_start: bool) { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); let entry = ComplexGlyphEntry(cluster_start, ligature_start, 0); debug!("adding spacer for chracter without associated glyph[idx=%u]", i); @@ -573,8 +572,8 @@ pub impl GlyphStore { self.entry_buffer[i] = entry; } - pure fn iter_glyphs_for_char_index(&self, i: uint, cb: &fn(uint, GlyphInfo/&) -> bool) -> bool { - assert i < self.entry_buffer.len(); + pure fn iter_glyphs_for_char_index(&self, i: uint, cb: &fn(uint, GlyphInfo/&self) -> bool) -> bool { + fail_unless!(i < self.entry_buffer.len()); let entry = &self.entry_buffer[i]; match entry.is_simple() { @@ -594,7 +593,7 @@ pub impl GlyphStore { return true; } - pure fn iter_glyphs_for_char_range(&self, range: &const Range, cb: &fn(uint, GlyphInfo/&) -> bool) { + pure fn iter_glyphs_for_char_range(&self, range: &const Range, cb: &fn(uint, GlyphInfo/&self) -> bool) { if range.begin() >= self.entry_buffer.len() { error!("iter_glyphs_for_range: range.begin beyond length!"); return; @@ -609,7 +608,7 @@ pub impl GlyphStore { } } - pure fn iter_all_glyphs(&self, cb: &fn(uint, GlyphInfo/&) -> bool) { + pure fn iter_all_glyphs(&self, cb: &fn(uint, GlyphInfo/&self) -> bool) { for uint::range(0, self.entry_buffer.len()) |i| { if !self.iter_glyphs_for_char_index(i, cb) { break; } } @@ -617,56 +616,56 @@ pub impl GlyphStore { // getter methods pure fn char_is_space(&self, i: uint) -> bool { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); self.entry_buffer[i].char_is_space() } pure fn char_is_tab(&self, i: uint) -> bool { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); self.entry_buffer[i].char_is_tab() } pure fn char_is_newline(&self, i: uint) -> bool { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); self.entry_buffer[i].char_is_newline() } pure fn is_ligature_start(&self, i: uint) -> bool { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); self.entry_buffer[i].is_ligature_start() } pure fn is_cluster_start(&self, i: uint) -> bool { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); self.entry_buffer[i].is_cluster_start() } pure fn can_break_before(&self, i: uint) -> BreakType { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); self.entry_buffer[i].can_break_before() } // setter methods fn set_char_is_space(&mut self, i: uint) { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); let entry = self.entry_buffer[i]; self.entry_buffer[i] = entry.set_char_is_space(); } fn set_char_is_tab(&mut self, i: uint) { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); let entry = self.entry_buffer[i]; self.entry_buffer[i] = entry.set_char_is_tab(); } fn set_char_is_newline(&mut self, i: uint) { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); let entry = self.entry_buffer[i]; self.entry_buffer[i] = entry.set_char_is_newline(); } fn set_can_break_before(&mut self, i: uint, t: BreakType) { - assert i < self.entry_buffer.len(); + fail_unless!(i < self.entry_buffer.len()); let entry = self.entry_buffer[i]; self.entry_buffer[i] = entry.set_can_break_before(t); } diff --git a/src/servo-gfx/text/harfbuzz/shaper.rs b/src/servo-gfx/text/harfbuzz/shaper.rs index 33a4e87c4ec..599cb98ff57 100644 --- a/src/servo-gfx/text/harfbuzz/shaper.rs +++ b/src/servo-gfx/text/harfbuzz/shaper.rs @@ -82,11 +82,11 @@ pub impl ShapedGlyphData { let glyph_count = 0 as c_uint; let glyph_infos = hb_buffer_get_glyph_infos(buffer, ptr::to_unsafe_ptr(&glyph_count)); let glyph_count = glyph_count as uint; - assert glyph_infos.is_not_null(); + fail_unless!(glyph_infos.is_not_null()); let pos_count = 0 as c_uint; let pos_infos = hb_buffer_get_glyph_positions(buffer, ptr::to_unsafe_ptr(&pos_count)); - assert pos_infos.is_not_null(); - assert glyph_count == pos_count as uint; + fail_unless!(pos_infos.is_not_null()); + fail_unless!(glyph_count == pos_count as uint); ShapedGlyphData { count: glyph_count, @@ -98,7 +98,7 @@ pub impl ShapedGlyphData { #[inline(always)] priv pure fn byte_offset_of_glyph(&const self, i: uint) -> uint { - assert i < self.count; + fail_unless!(i < self.count); let glyph_info_i = ptr::offset(self.glyph_infos, i); unsafe { @@ -110,7 +110,7 @@ pub impl ShapedGlyphData { // Returns shaped glyph data for one glyph, and updates the y-position of the pen. fn get_entry_for_glyph(&self, i: uint, y_pos: &mut Au) -> ShapedGlyphEntry { - assert i < self.count; + fail_unless!(i < self.count); let glyph_info_i = ptr::offset(self.glyph_infos, i); let pos_info_i = ptr::offset(self.pos_infos, i); @@ -146,15 +146,17 @@ pub struct HarfbuzzShaper { priv hb_face: *hb_face_t, priv hb_font: *hb_font_t, priv hb_funcs: *hb_font_funcs_t, +} - drop { - assert self.hb_face.is_not_null(); +impl Drop for HarfbuzzShaper { + fn finalize(&self) { + fail_unless!(self.hb_face.is_not_null()); hb_face_destroy(self.hb_face); - assert self.hb_font.is_not_null(); + fail_unless!(self.hb_font.is_not_null()); hb_font_destroy(self.hb_font); - assert self.hb_funcs.is_not_null(); + fail_unless!(self.hb_funcs.is_not_null()); hb_font_funcs_destroy(self.hb_funcs); } } @@ -237,7 +239,7 @@ pub impl HarfbuzzShaper { // so, we must be careful to increment this when saving glyph entries. let mut char_idx = 0; - assert glyph_count <= char_max; + fail_unless!(glyph_count <= char_max); debug!("Shaped text[char count=%u], got back %u glyph info records.", char_max, glyph_count); if char_max != glyph_count { @@ -268,7 +270,7 @@ pub impl HarfbuzzShaper { // loc refers to a *byte* offset within the utf8 string. let loc = glyph_data.byte_offset_of_glyph(i); if loc < byte_max { - assert byteToGlyph[loc] != CONTINUATION_BYTE; + fail_unless!(byteToGlyph[loc] != CONTINUATION_BYTE); byteToGlyph[loc] = i as i32; } else { debug!("ERROR: tried to set out of range byteToGlyph: idx=%u, glyph idx=%u", loc, i); } @@ -358,9 +360,9 @@ pub impl HarfbuzzShaper { } // character/glyph clump must contain characters. - assert char_byte_span.length() > 0; + fail_unless!(char_byte_span.length() > 0); // character/glyph clump must contain glyphs. - assert glyph_span.length() > 0; + fail_unless!(glyph_span.length() > 0); // now char_span is a ligature clump, formed by the glyphs in glyph_span. // we need to find the chars that correspond to actual glyphs (char_extended_span), @@ -451,7 +453,7 @@ extern fn glyph_func(_font: *hb_font_t, glyph: *mut hb_codepoint_t, _user_data: *c_void) -> hb_bool_t { let font: *Font = font_data as *Font; - assert font.is_not_null(); + fail_unless!(font.is_not_null()); unsafe { return match (*font).glyph_index(unicode as char) { Some(g) => { *glyph = g as hb_codepoint_t; true }, @@ -465,7 +467,7 @@ extern fn glyph_h_advance_func(_font: *hb_font_t, glyph: hb_codepoint_t, _user_data: *c_void) -> hb_position_t { let font: *Font = font_data as *Font; - assert font.is_not_null(); + fail_unless!(font.is_not_null()); unsafe { let advance = (*font).glyph_h_advance(glyph as GlyphIndex); @@ -477,7 +479,7 @@ extern fn glyph_h_advance_func(_font: *hb_font_t, extern fn get_font_table_func(_face: *hb_face_t, tag: hb_tag_t, user_data: *c_void) -> *hb_blob_t { unsafe { let font: *Font = user_data as *Font; - assert font.is_not_null(); + fail_unless!(font.is_not_null()); // TODO(Issue #197): reuse font table data, which will change the unsound trickery here. match (*font).get_table_for_tag(tag as FontTableTag) { @@ -493,7 +495,7 @@ extern fn get_font_table_func(_face: *hb_face_t, tag: hb_tag_t, user_data: *c_vo cast::transmute(skinny_font_table_ptr), // private context for below. destroy_blob_func); // HarfBuzz calls this when blob not needed. }); - assert blob.is_not_null(); + fail_unless!(blob.is_not_null()); return blob; } } diff --git a/src/servo-gfx/text/text_run.rs b/src/servo-gfx/text/text_run.rs index d1c57bc2f66..2f8993285d9 100644 --- a/src/servo-gfx/text/text_run.rs +++ b/src/servo-gfx/text/text_run.rs @@ -130,7 +130,7 @@ pub impl TextRun { return max_piece_width; } - fn iter_natural_lines_for_range(&self, range: &const Range, f: fn(&const Range) -> bool) { + fn iter_natural_lines_for_range(&self, range: &const Range, f: &fn(&const Range) -> bool) { let mut clump = Range::new(range.begin(), 0); let mut in_clump = false; @@ -155,7 +155,7 @@ pub impl TextRun { } } - fn iter_indivisible_pieces_for_range(&self, range: &const Range, f: fn(&const Range) -> bool) { + fn iter_indivisible_pieces_for_range(&self, range: &const Range, f: &fn(&const Range) -> bool) { let mut clump = Range::new(range.begin(), 0); loop { diff --git a/src/servo-gfx/text/util.rs b/src/servo-gfx/text/util.rs index 0692f36144c..b137ace8225 100644 --- a/src/servo-gfx/text/util.rs +++ b/src/servo-gfx/text/util.rs @@ -123,7 +123,7 @@ pub fn true_type_tag(a: char, b: char, c: char, d: char) -> u32 { #[test] fn test_true_type_tag() { - assert true_type_tag('c', 'm', 'a', 'p') == 0x_63_6D_61_70_u32; + fail_unless!(true_type_tag('c', 'm', 'a', 'p') == 0x_63_6D_61_70_u32); } #[test] @@ -139,7 +139,7 @@ fn test_transform_compress_none() { let mode = CompressNone; for uint::range(0, test_strs.len()) |i| { - assert transform_text(test_strs[i], mode) == test_strs[i]; + fail_unless!(transform_text(test_strs[i], mode) == test_strs[i]); } } @@ -162,11 +162,11 @@ fn test_transform_discard_newline() { ~"foo bar baz", ~"foobarbaz"]; - assert test_strs.len() == oracle_strs.len(); + fail_unless!(test_strs.len() == oracle_strs.len()); let mode = DiscardNewline; for uint::range(0, test_strs.len()) |i| { - assert transform_text(test_strs[i], mode) == oracle_strs[i]; + fail_unless!(transform_text(test_strs[i], mode) == oracle_strs[i]); } } @@ -188,11 +188,11 @@ fn test_transform_compress_whitespace() { ~"foo bar baz", ~"foobarbaz\n\n"]; - assert test_strs.len() == oracle_strs.len(); + fail_unless!(test_strs.len() == oracle_strs.len()); let mode = CompressWhitespace; for uint::range(0, test_strs.len()) |i| { - assert transform_text(test_strs[i], mode) == oracle_strs[i]; + fail_unless!(transform_text(test_strs[i], mode) == oracle_strs[i]); } } @@ -214,10 +214,10 @@ fn test_transform_compress_whitespace_newline() { ~"foo bar baz", ~"foobarbaz "]; - assert test_strs.len() == oracle_strs.len(); + fail_unless!(test_strs.len() == oracle_strs.len()); let mode = CompressWhitespaceNewline; for uint::range(0, test_strs.len()) |i| { - assert transform_text(test_strs[i], mode) == oracle_strs[i]; + fail_unless!(transform_text(test_strs[i], mode) == oracle_strs[i]); } } diff --git a/src/servo-gfx/util/cache.rs b/src/servo-gfx/util/cache.rs index 6aa019b84b2..6ae23b66426 100644 --- a/src/servo-gfx/util/cache.rs +++ b/src/servo-gfx/util/cache.rs @@ -51,9 +51,9 @@ fn test_monocache() { let two = @"two"; cache.insert(&1, one); - assert cache.find(&1).is_some(); - assert cache.find(&2).is_none(); + fail_unless!(cache.find(&1).is_some()); + fail_unless!(cache.find(&2).is_none()); cache.find_or_create(&2, |_v| { two }); - assert cache.find(&2).is_some(); - assert cache.find(&1).is_none(); + fail_unless!(cache.find(&2).is_some()); + fail_unless!(cache.find(&1).is_none()); } diff --git a/src/servo-gfx/util/time.rs b/src/servo-gfx/util/time.rs index c2cd58f2d1a..1b440aa7cdd 100644 --- a/src/servo-gfx/util/time.rs +++ b/src/servo-gfx/util/time.rs @@ -1,7 +1,7 @@ // Timing functions. use std::time::precise_time_ns; -pub fn time(msg: &str, callback: fn() -> T) -> T{ +pub fn time(msg: &str, callback: &fn() -> T) -> T{ let start_time = precise_time_ns(); let val = callback(); let end_time = precise_time_ns(); diff --git a/src/servo-gfx/util/url.rs b/src/servo-gfx/util/url.rs index 34ca8b6ef82..803e4a26954 100644 --- a/src/servo-gfx/util/url.rs +++ b/src/servo-gfx/util/url.rs @@ -48,8 +48,8 @@ mod make_url_tests { let file = ~"local.html"; let url = make_url(file, None); debug!("url: %?", url); - assert url.scheme == ~"file"; - assert url.path.contains(os::getcwd().to_str()); + fail_unless!(url.scheme == ~"file"); + fail_unless!(url.path.contains(os::getcwd().to_str())); } #[test] @@ -58,9 +58,9 @@ mod make_url_tests { let old_url = make_url(old_str, None); let new_str = ~"index.html"; let new_url = make_url(new_str, Some(old_url)); - assert new_url.scheme == ~"http"; - assert new_url.host == ~"example.com"; - assert new_url.path == ~"/index.html"; + fail_unless!(new_url.scheme == ~"http"); + fail_unless!(new_url.host == ~"example.com"); + fail_unless!(new_url.path == ~"/index.html"); } #[test] @@ -69,9 +69,9 @@ mod make_url_tests { let old_url = make_url(old_str, None); let new_str = ~"index.html"; let new_url = make_url(new_str, Some(old_url)); - assert new_url.scheme == ~"http"; - assert new_url.host == ~"example.com"; - assert new_url.path == ~"/index.html"; + fail_unless!(new_url.scheme == ~"http"); + fail_unless!(new_url.host == ~"example.com"); + fail_unless!(new_url.path == ~"/index.html"); } #[test] @@ -80,9 +80,9 @@ mod make_url_tests { let old_url = make_url(old_str, None); let new_str = ~"crumpet.html"; let new_url = make_url(new_str, Some(old_url)); - assert new_url.scheme == ~"http"; - assert new_url.host == ~"example.com"; - assert new_url.path == ~"/crumpet.html"; + fail_unless!(new_url.scheme == ~"http"); + fail_unless!(new_url.host == ~"example.com"); + fail_unless!(new_url.path == ~"/crumpet.html"); } #[test] @@ -91,9 +91,9 @@ mod make_url_tests { let old_url = make_url(old_str, None); let new_str = ~"crumpet.html"; let new_url = make_url(new_str, Some(old_url)); - assert new_url.scheme == ~"http"; - assert new_url.host == ~"example.com"; - assert new_url.path == ~"/snarf/crumpet.html"; + fail_unless!(new_url.scheme == ~"http"); + fail_unless!(new_url.host == ~"example.com"); + fail_unless!(new_url.path == ~"/snarf/crumpet.html"); } } diff --git a/src/servo-gfx/util/vec.rs b/src/servo-gfx/util/vec.rs index 99c90cf7778..c12d0732b11 100644 --- a/src/servo-gfx/util/vec.rs +++ b/src/servo-gfx/util/vec.rs @@ -41,7 +41,7 @@ impl<'self, T: Ord + Eq> BinarySearchMethods for &'self [T] { fn test_find_all_elems(arr: &[T]) { let mut i = 0; while i < arr.len() { - assert test_match(&arr[i], arr.binary_search(&arr[i])); + fail_unless!(test_match(&arr[i], arr.binary_search(&arr[i]))); i += 1; } } @@ -51,7 +51,7 @@ fn test_miss_all_elems(arr: &[T], misses: &[T]) { while i < misses.len() { let res = arr.binary_search(&misses[i]); debug!("%? == %? ?", misses[i], res); - assert !test_match(&misses[i], arr.binary_search(&misses[i])); + fail_unless!(!test_match(&misses[i], arr.binary_search(&misses[i]))); i += 1; } } diff --git a/src/servo/content/content_task.rs b/src/servo/content/content_task.rs index 8d5ebebbeae..9d908867231 100644 --- a/src/servo/content/content_task.rs +++ b/src/servo/content/content_task.rs @@ -235,7 +235,7 @@ pub impl Content { Timer(timerData) => { let compartment = option::expect(self.compartment, ~"TODO error checking"); let thisValue = if timerData.args.len() > 0 { - RUST_JSVAL_TO_OBJECT(unsafe { timerData.args.shift() }) + RUST_JSVAL_TO_OBJECT(timerData.args[0]) } else { compartment.global_obj.ptr }; @@ -347,7 +347,7 @@ pub impl Content { // Nothing to do. } Some(document) => { - assert self.doc_url.is_some(); + fail_unless!(self.doc_url.is_some()); self.relayout(document, &(copy self.doc_url).get()); } } @@ -362,7 +362,7 @@ pub impl Content { // Nothing to do. } Some(document) => { - assert self.doc_url.is_some(); + fail_unless!(self.doc_url.is_some()); self.relayout(document, &(copy self.doc_url).get()); } } diff --git a/src/servo/css/node_style.rs b/src/servo/css/node_style.rs index c62d141ac8f..35a7a6fb8fb 100644 --- a/src/servo/css/node_style.rs +++ b/src/servo/css/node_style.rs @@ -11,7 +11,7 @@ pub trait StyledNode { impl StyledNode for AbstractNode { fn style(&self) -> CompleteStyle/&self { - assert self.is_element(); // Only elements can have styles + fail_unless!(self.is_element()); // Only elements can have styles let results = self.get_css_select_results(); results.computed_style() } diff --git a/src/servo/css/node_void_ptr.rs b/src/servo/css/node_void_ptr.rs index f436164b0ac..60343b9c0d9 100644 --- a/src/servo/css/node_void_ptr.rs +++ b/src/servo/css/node_void_ptr.rs @@ -10,7 +10,7 @@ use css::node_void_ptr::netsurfcss::util::VoidPtrLike; impl VoidPtrLike for AbstractNode { static fn from_void_ptr(node: *libc::c_void) -> AbstractNode { - assert node.is_not_null(); + fail_unless!(node.is_not_null()); unsafe { cast::transmute(node) } diff --git a/src/servo/dom/bindings/document.rs b/src/servo/dom/bindings/document.rs index 1153258e72c..5903934a751 100644 --- a/src/servo/dom/bindings/document.rs +++ b/src/servo/dom/bindings/document.rs @@ -22,7 +22,7 @@ enum DOMException { INVALID_CHARACTER_ERR } -enum Element = int; +struct Element(int); /*extern fn getElementById(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool { //XXX check if actually document object @@ -108,7 +108,7 @@ pub fn init(compartment: @mut Compartment, doc: @Document) { setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}]; vec::push(&mut compartment.global_props, attrs); vec::as_imm_buf(*attrs, |specs, _len| { - assert JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs) == 1; + fail_unless!(JS_DefineProperties(compartment.cx.ptr, obj.ptr, specs) == 1); }); compartment.register_class(utils::instance_jsclass(~"DocumentInstance", finalize)); diff --git a/src/servo/dom/bindings/utils.rs b/src/servo/dom/bindings/utils.rs index 6405262a633..44b0094584c 100644 --- a/src/servo/dom/bindings/utils.rs +++ b/src/servo/dom/bindings/utils.rs @@ -19,7 +19,13 @@ pub enum DOMString { null_string } -pub type rust_box = {rc: uint, td: *sys::TypeDesc, next: *(), prev: *(), payload: T}; +pub struct rust_box { + rc: uint, + td: *sys::TypeDesc, + next: *(), + prev: *(), + payload: T +} pub unsafe fn squirrel_away(x: @T) -> *rust_box { let y: *rust_box = cast::reinterpret_cast(&x); @@ -77,7 +83,7 @@ pub fn get_compartment(cx: *JSContext) -> @mut Compartment { let compartment = option::expect((*content).compartment, ~"Should always have compartment when \ executing JS code"); - assert cx == compartment.cx.ptr; + fail_unless!(cx == compartment.cx.ptr); compartment } } diff --git a/src/servo/dom/bindings/window.rs b/src/servo/dom/bindings/window.rs index 7006c261c03..1ef457d8644 100644 --- a/src/servo/dom/bindings/window.rs +++ b/src/servo/dom/bindings/window.rs @@ -6,7 +6,6 @@ use dom::node::Node; use dom::window::{Window, TimerMessage_Fire}; use super::utils; -use core::dvec::DVec; use core::libc::c_uint; use core::ptr::null; use core::ptr; @@ -28,7 +27,7 @@ use js::{JS_THIS_OBJECT, JS_SET_RVAL}; extern fn alert(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool { unsafe { let argv = JS_ARGV(cx, vp); - assert (argc == 1); + fail_unless!(argc == 1); // Abstract this pattern and use it in debug, too? let jsstr = JS_ValueToString(cx, *ptr::offset(argv, 0)); @@ -42,7 +41,7 @@ extern fn alert(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool { extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool { unsafe { let argv = JS_ARGV(cx, vp); - assert (argc >= 2); + fail_unless!(argc >= 2); //TODO: don't crash when passed a non-integer value for the timeout diff --git a/src/servo/dom/node.rs b/src/servo/dom/node.rs index f19daba5e5e..244b8dedb37 100644 --- a/src/servo/dom/node.rs +++ b/src/servo/dom/node.rs @@ -165,13 +165,13 @@ pub impl AbstractNode { // Invariant: `child` is disconnected from the document. fn append_child(self, child: AbstractNode) { - assert self != child; + fail_unless!(self != child); do self.with_mut_node |parent_n| { do child.with_mut_node |child_n| { - assert child_n.parent_node.is_none(); - assert child_n.prev_sibling.is_none(); - assert child_n.next_sibling.is_none(); + fail_unless!(child_n.parent_node.is_none()); + fail_unless!(child_n.prev_sibling.is_none()); + fail_unless!(child_n.next_sibling.is_none()); child_n.parent_node = Some(self); @@ -179,7 +179,7 @@ pub impl AbstractNode { None => parent_n.first_child = Some(child), Some(last_child) => { do last_child.with_mut_node |last_child_n| { - assert last_child_n.next_sibling.is_none(); + fail_unless!(last_child_n.next_sibling.is_none()); last_child_n.next_sibling = Some(child); } } diff --git a/src/servo/dom/window.rs b/src/servo/dom/window.rs index 83812b442aa..a998290083b 100644 --- a/src/servo/dom/window.rs +++ b/src/servo/dom/window.rs @@ -3,7 +3,6 @@ use js::jsapi::JSVal; use util::task::spawn_listener; use core::comm::{Port, Chan}; -use core::dvec::DVec; use std::timer; use std::uv_global_loop; @@ -15,8 +14,10 @@ pub enum TimerControlMsg { pub struct Window { timer_chan: Chan, +} - drop { +impl Drop for Window { + fn finalize(&self) { self.timer_chan.send(TimerMessage_Close); } } @@ -26,35 +27,35 @@ pub struct Window { // to the function when calling it) pub struct TimerData { funval: JSVal, - args: DVec, + args: ~[JSVal], } pub fn TimerData(argc: libc::c_uint, argv: *JSVal) -> TimerData { unsafe { - let data = TimerData { - funval : *argv, - args : DVec(), - }; + let mut args = ~[]; let mut i = 2; while i < argc as uint { - data.args.push(*ptr::offset(argv, i)); + args.push(*ptr::offset(argv, i)); i += 1; }; - data + TimerData { + funval : *argv, + args : args, + } } } // FIXME: delayed_send shouldn't require Copy #[allow(non_implicitly_copyable_typarams)] pub impl Window { - fn alert(s: &str) { + fn alert(&self, s: &str) { // Right now, just print to the console io::println(fmt!("ALERT: %s", s)); } - fn close() { + fn close(&self) { self.timer_chan.send(TimerMessage_TriggerExit); } diff --git a/src/servo/engine.rs b/src/servo/engine.rs index f017072341e..e195c3b2f56 100644 --- a/src/servo/engine.rs +++ b/src/servo/engine.rs @@ -66,13 +66,13 @@ pub fn Engine(compositor: C, } impl Engine { - fn run() { + fn run(&self) { while self.handle_request(self.request_port.recv()) { // Go on... } } - fn handle_request(request: Msg) -> bool { + fn handle_request(&self, request: Msg) -> bool { match request { LoadURLMsg(url) => { if url.path.ends_with(".js") { diff --git a/src/servo/layout/aux.rs b/src/servo/layout/aux.rs index d5dbe389f34..2893a888064 100644 --- a/src/servo/layout/aux.rs +++ b/src/servo/layout/aux.rs @@ -3,11 +3,10 @@ Code for managing the DOM aux pointer */ use dom::node::{AbstractNode, LayoutData}; -use core::dvec::DVec; pub trait LayoutAuxMethods { fn initialize_layout_data(self) -> Option<@mut LayoutData>; - fn initialize_style_for_subtree(self, refs: &DVec<@mut LayoutData>); + fn initialize_style_for_subtree(self, refs: &mut ~[@mut LayoutData]); } impl LayoutAuxMethods for AbstractNode { @@ -25,7 +24,7 @@ impl LayoutAuxMethods for AbstractNode { /// Initializes layout data and styles for a Node tree, if any nodes do not have /// this data already. Append created layout data to the task's GC roots. - fn initialize_style_for_subtree(self, refs: &DVec<@mut LayoutData>) { + fn initialize_style_for_subtree(self, refs: &mut ~[@mut LayoutData]) { let _ = for self.traverse_preorder |n| { match n.initialize_layout_data() { Some(r) => refs.push(r), diff --git a/src/servo/layout/block.rs b/src/servo/layout/block.rs index 7b886a0eb16..24d8657dd93 100644 --- a/src/servo/layout/block.rs +++ b/src/servo/layout/block.rs @@ -28,7 +28,7 @@ pub fn BlockFlowData() -> BlockFlowData { pub trait BlockLayout { pure fn starts_block_flow() -> bool; - pure fn with_block_box(@mut self, fn(box: &@mut RenderBox) -> ()) -> (); + pure fn with_block_box(@mut self, &fn(box: &@mut RenderBox) -> ()) -> (); fn bubble_widths_block(@mut self, ctx: &LayoutContext); fn assign_widths_block(@mut self, ctx: &LayoutContext); @@ -50,7 +50,7 @@ impl BlockLayout for FlowContext { /* Get the current flow's corresponding block box, if it exists, and do something with it. This works on both BlockFlow and RootFlow, since they are mostly the same. */ - pure fn with_block_box(@mut self, cb: fn(box: &@mut RenderBox) -> ()) -> () { + pure fn with_block_box(@mut self, cb: &fn(box: &@mut RenderBox) -> ()) -> () { match *self { BlockFlow(*) => { let box = self.block().box; @@ -74,14 +74,14 @@ impl BlockLayout for FlowContext { /* TODO: absolute contexts */ /* TODO: inline-blocks */ fn bubble_widths_block(@mut self, ctx: &LayoutContext) { - assert self.starts_block_flow(); + fail_unless!(self.starts_block_flow()); let mut min_width = Au(0); let mut pref_width = Au(0); /* find max width from child block contexts */ for FlowTree.each_child(self) |child_ctx| { - assert child_ctx.starts_block_flow() || child_ctx.starts_inline_flow(); + fail_unless!(child_ctx.starts_block_flow() || child_ctx.starts_inline_flow()); min_width = au::max(min_width, child_ctx.d().min_width); pref_width = au::max(pref_width, child_ctx.d().pref_width); @@ -106,7 +106,7 @@ impl BlockLayout for FlowContext { all child (block) contexts. */ fn assign_widths_block(@mut self, _ctx: &LayoutContext) { - assert self.starts_block_flow(); + fail_unless!(self.starts_block_flow()); let mut remaining_width = self.d().position.size.width; let mut _right_used = Au(0); @@ -121,14 +121,14 @@ impl BlockLayout for FlowContext { } for FlowTree.each_child(self) |child_ctx| { - assert child_ctx.starts_block_flow() || child_ctx.starts_inline_flow(); + fail_unless!(child_ctx.starts_block_flow() || child_ctx.starts_inline_flow()); child_ctx.d().position.origin.x = left_used; child_ctx.d().position.size.width = remaining_width; } } fn assign_height_block(@mut self, _ctx: &LayoutContext) { - assert self.starts_block_flow(); + fail_unless!(self.starts_block_flow()); let mut cur_y = Au(0); @@ -152,7 +152,7 @@ impl BlockLayout for FlowContext { fn build_display_list_block(@mut self, builder: &DisplayListBuilder, dirty: &Rect, offset: &Point2D, list: &Mut) { - assert self.starts_block_flow(); + fail_unless!(self.starts_block_flow()); // add box that starts block context do self.with_block_box |box| { diff --git a/src/servo/layout/box.rs b/src/servo/layout/box.rs index 7c6cafe511a..385ab580077 100644 --- a/src/servo/layout/box.rs +++ b/src/servo/layout/box.rs @@ -18,7 +18,6 @@ use newcss::values::{CSSFontSizeLength, CSSFontStyleItalic, CSSFontStyleNormal}; use newcss::values::{CSSFontStyleOblique, CSSTextAlign, Specified}; use util::tree::ReadMethods; -use core::dvec::DVec; use core::managed; use core::mutable::Mut; use core::rand; @@ -133,7 +132,7 @@ impl RenderBox { } } - pure fn is_replaced() -> bool { + pure fn is_replaced(self) -> bool { match self { ImageBox(*) => true, // TODO: form elements, etc _ => false @@ -155,7 +154,7 @@ impl RenderBox { } fn can_merge_with_box(@mut self, other: @mut RenderBox) -> bool { - assert !managed::mut_ptr_eq(self, other); + fail_unless!(!managed::mut_ptr_eq(self, other)); match (self, other) { (@UnscannedTextBox(*), @UnscannedTextBox(*)) => { @@ -292,7 +291,7 @@ impl RenderBox { /* Returns the amount of left, right "fringe" used by this box. This should be based on margin, border, padding, width. */ - fn get_used_width() -> (Au, Au) { + fn get_used_width(&self) -> (Au, Au) { // TODO: this should actually do some computation! // See CSS 2.1, Section 10.3, 10.4. @@ -301,7 +300,7 @@ impl RenderBox { /* Returns the amount of left, right "fringe" used by this box. This should be based on margin, border, padding, width. */ - fn get_used_height() -> (Au, Au) { + fn get_used_height(&self) -> (Au, Au) { // TODO: this should actually do some computation! // See CSS 2.1, Section 10.5, 10.6. diff --git a/src/servo/layout/box_builder.rs b/src/servo/layout/box_builder.rs index 5f0fa9c9469..b28a61174c1 100644 --- a/src/servo/layout/box_builder.rs +++ b/src/servo/layout/box_builder.rs @@ -13,7 +13,6 @@ use layout::inline::{InlineFlowData, InlineLayout}; use layout::root::RootFlowData; use util::tree; -use core::dvec::DVec; use gfx::image::holder::ImageHolder; use gfx::util::range::Range; use newcss::values::{CSSDisplay, CSSDisplayBlock, CSSDisplayInline, CSSDisplayInlineBlock}; @@ -39,7 +38,7 @@ pub impl LayoutTreeBuilder { // mapping between DOM nodes and boxes. struct BoxGenerator { flow: @mut FlowContext, - range_stack: DVec, + range_stack: ~[uint], } enum InlineSpacerSide { @@ -84,24 +83,25 @@ impl BoxGenerator { unsafe { debug!("Creating box generator for flow: %s", flow.debug_str()); } BoxGenerator { flow: flow, - range_stack: DVec() + range_stack: ~[] } } /* Whether "spacer" boxes are needed to stand in for this DOM node */ - pure fn inline_spacers_needed_for_node(_: AbstractNode) -> bool { + pure fn inline_spacers_needed_for_node(&self, _: AbstractNode) -> bool { return false; } // TODO: implement this, generating spacer - fn make_inline_spacer_for_node_side(_: &LayoutContext, + fn make_inline_spacer_for_node_side(&self, + _: &LayoutContext, _: AbstractNode, _: InlineSpacerSide) -> Option<@mut RenderBox> { None } - pub fn push_node(&mut self, ctx: &LayoutContext, builder: &mut LayoutTreeBuilder, node: AbstractNode) { + pub fn push_node(@mut self, ctx: &LayoutContext, builder: &mut LayoutTreeBuilder, node: AbstractNode) { debug!("BoxGenerator[f%d]: pushing node: %s", self.flow.d().id, node.debug_str()); // first, determine the box type, based on node characteristics @@ -141,8 +141,10 @@ impl BoxGenerator { debug!("BoxGenerator[f%d]: attaching box[b%d] to block flow (node: %s)", self.flow.d().id, new_box.d().id, node.debug_str()); - assert self.flow.block().box.is_none(); - self.flow.block().box = Some(new_box); + fail_unless!(self.flow.block().box.is_none()); + //XXXjdm We segfault when returning without this temporary. + let block = self.flow.block(); + block.box = Some(new_box); }, @RootFlow(*) => { debug!("BoxGenerator[f%d]: point c", self.flow.d().id); @@ -151,8 +153,10 @@ impl BoxGenerator { debug!("BoxGenerator[f%d]: attaching box[b%d] to root flow (node: %s)", self.flow.d().id, new_box.d().id, node.debug_str()); - assert self.flow.root().box.is_none(); - self.flow.root().box = Some(new_box); + fail_unless!(self.flow.root().box.is_none()); + //XXXjdm We segfault when returning without this temporary. + let root = self.flow.root(); + root.box = Some(new_box); }, _ => { warn!("push_node() not implemented for flow f%d", self.flow.d().id) } } @@ -173,14 +177,14 @@ impl BoxGenerator { } let mut node_range: Range = Range::new(self.range_stack.pop(), 0); node_range.extend_to(self.flow.inline().boxes.len()); - assert node_range.length() > 0; + fail_unless!(node_range.length() > 0); debug!("BoxGenerator: adding element range=%?", node_range); let elems = &mut self.flow.inline().elems; elems.add_mapping(node, &const node_range); }, @BlockFlow(*) | @RootFlow(*) => { - assert self.range_stack.len() == 0; + fail_unless!(self.range_stack.len() == 0); }, _ => { warn!("pop_node() not implemented for flow %?", self.flow.d().id) } } @@ -201,18 +205,19 @@ impl BuilderContext { } } - fn clone() -> BuilderContext { + fn clone(self) -> BuilderContext { debug!("BuilderContext: cloning context"); copy self } - priv fn attach_child_flow(child: @mut FlowContext) { + priv fn attach_child_flow(&self, child: @mut FlowContext) { debug!("BuilderContext: Adding child flow f%? of f%?", self.default_collector.flow.d().id, child.d().id); tree::add_child(&FlowTree, self.default_collector.flow, child); } - priv fn create_child_flow_of_type(flow_type: FlowContextType, + priv fn create_child_flow_of_type(&self, + flow_type: FlowContextType, builder: &mut LayoutTreeBuilder) -> BuilderContext { let new_flow = builder.make_flow(flow_type); self.attach_child_flow(new_flow); @@ -316,7 +321,7 @@ pub impl LayoutTreeBuilder { let flow = &mut this_ctx.default_collector.flow; for tree::each_child(&FlowTree, flow) |child_flow: &@mut FlowContext| { for (copy child_flow.d().node).each |node| { - assert node.has_layout_data(); + fail_unless!(node.has_layout_data()); node.layout_data().flow = Some(*child_flow); } } diff --git a/src/servo/layout/display_list_builder.rs b/src/servo/layout/display_list_builder.rs index 8014e848221..995271e2432 100644 --- a/src/servo/layout/display_list_builder.rs +++ b/src/servo/layout/display_list_builder.rs @@ -10,7 +10,6 @@ use newcss::values::Specified; use newcss::values::{CSSBackgroundColorColor, CSSBackgroundColorTransparent}; use util::tree; -use core::dvec::DVec; use core::either::{Left, Right}; use core::mutable::Mut; use core::vec::push; diff --git a/src/servo/layout/flow.rs b/src/servo/layout/flow.rs index 6797789a05e..318040f5770 100644 --- a/src/servo/layout/flow.rs +++ b/src/servo/layout/flow.rs @@ -9,7 +9,6 @@ use layout::inline::{InlineFlowData, InlineLayout, NodeRange}; use layout::root::{RootFlowData, RootLayout}; use util::tree; use core::mutable::Mut; -use core::dvec::DVec; use geom::rect::Rect; use geom::point::Point2D; use gfx::display_list::DisplayList; @@ -213,20 +212,20 @@ pub impl FlowContext { pub enum FlowTree { FlowTree } impl FlowTree { - fn each_child(ctx: @mut FlowContext, f: fn(box: @mut FlowContext) -> bool) { + fn each_child(ctx: @mut FlowContext, f: &fn(box: @mut FlowContext) -> bool) { tree::each_child(&self, &ctx, |box| f(*box) ) } } impl tree::ReadMethods<@mut FlowContext> for FlowTree { - fn with_tree_fields(box: &@mut FlowContext, f: fn(&mut tree::Tree<@mut FlowContext>) -> R) -> R { + fn with_tree_fields(box: &@mut FlowContext, f: &fn(&mut tree::Tree<@mut FlowContext>) -> R) -> R { let tree = &mut box.d().tree; f(tree) } } impl FlowTree { - fn add_child(parent: @mut FlowContext, child: @mut FlowContext) { + fn add_child(self, parent: @mut FlowContext, child: @mut FlowContext) { tree::add_child(&self, parent, child) } } @@ -234,7 +233,7 @@ impl FlowTree { impl tree::WriteMethods<@mut FlowContext> for FlowTree { pure fn tree_eq(a: &@mut FlowContext, b: &@mut FlowContext) -> bool { core::managed::mut_ptr_eq(*a, *b) } - fn with_tree_fields(box: &@mut FlowContext, f: fn(&mut tree::Tree<@mut FlowContext>) -> R) -> R { + fn with_tree_fields(box: &@mut FlowContext, f: &fn(&mut tree::Tree<@mut FlowContext>) -> R) -> R { let tree = &mut box.d().tree; f(tree) } diff --git a/src/servo/layout/inline.rs b/src/servo/layout/inline.rs index 253348d8db0..2c6bd6ef909 100644 --- a/src/servo/layout/inline.rs +++ b/src/servo/layout/inline.rs @@ -9,7 +9,6 @@ use layout::text::{TextBoxData, UnscannedMethods, adapt_textbox_with_range}; use util::tree; use core::dlist::DList; -use core::dvec::DVec; use geom::{Point2D, Rect, Size2D}; use gfx::display_list::DisplayList; use gfx::font::FontStyle; @@ -22,6 +21,7 @@ use newcss::values::{CSSTextAlignCenter, CSSTextAlignJustify, CSSTextAlignLeft, use newcss::units::{BoxAuto, BoxLength, Px}; use std::arc; use core::mutable::Mut; +use core::util; /* Lineboxes are represented as offsets into the child list, rather than @@ -57,31 +57,33 @@ pub impl NodeRange { } struct ElementMapping { - priv entries: DVec, + priv entries: ~[NodeRange], } pub impl ElementMapping { static pure fn new() -> ElementMapping { - ElementMapping { entries: DVec() } + ElementMapping { entries: ~[] } } - fn add_mapping(node: AbstractNode, range: &const Range) { + fn add_mapping(&mut self, node: AbstractNode, range: &const Range) { self.entries.push(NodeRange::new(node, range)) } - fn each(cb: &pure fn(nr: &NodeRange) -> bool) { + fn each(&self, cb: &pure fn(nr: &NodeRange) -> bool) { do self.entries.each |nr| { cb(nr) } } - fn eachi(cb: &pure fn(i: uint, nr: &NodeRange) -> bool) { + fn eachi(&self, cb: &pure fn(i: uint, nr: &NodeRange) -> bool) { do self.entries.eachi |i, nr| { cb(i, nr) } } - fn eachi_mut(cb: &fn(i: uint, nr: &NodeRange) -> bool) { + fn eachi_mut(&self, cb: &fn(i: uint, nr: &NodeRange) -> bool) { do self.entries.eachi |i, nr| { cb(i, nr) } } - fn repair_for_box_changes(old_boxes: &DVec<@mut RenderBox>, new_boxes: &DVec<@mut RenderBox>) { + fn repair_for_box_changes(&mut self, old_boxes: &[@mut RenderBox], new_boxes: &[@mut RenderBox]) { + let entries = &mut self.entries; + debug!("--- Old boxes: ---"); for old_boxes.eachi |i, box| { debug!("%u --> %s", i, box.debug_str()); @@ -95,7 +97,7 @@ pub impl ElementMapping { debug!("------------------"); debug!("--- Elem ranges before repair: ---"); - for self.entries.eachi |i: uint, nr: &NodeRange| { + for entries.eachi |i: uint, nr: &NodeRange| { debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); } debug!("----------------------------------"); @@ -107,9 +109,8 @@ pub impl ElementMapping { begin_idx: uint, entry_idx: uint, }; - let repair_stack : DVec = DVec(); + let mut repair_stack : ~[WorkItem] = ~[]; - do self.entries.borrow_mut |entries: &mut [NodeRange]| { // index into entries let mut entries_k = 0; @@ -142,9 +143,8 @@ pub impl ElementMapping { entries[item.entry_idx].range = Range::new(item.begin_idx, new_j - item.begin_idx); } } - } debug!("--- Elem ranges after repair: ---"); - for self.entries.eachi |i: uint, nr: &NodeRange| { + for entries.eachi |i: uint, nr: &NodeRange| { debug!("%u: %? --> %s", i, nr.range, nr.node.debug_str()); } debug!("----------------------------------"); @@ -167,36 +167,36 @@ priv impl TextRunScanner { priv impl TextRunScanner { fn scan_for_runs(&mut self, ctx: &mut LayoutContext, flow: @mut FlowContext) { - assert flow.inline().boxes.len() > 0; + fail_unless!(flow.inline().boxes.len() > 0); - let boxes = &mut flow.inline().boxes; - do boxes.swap |in_boxes| { + let in_boxes = &mut flow.inline().boxes; + //do boxes.swap |in_boxes| { debug!("TextRunScanner: scanning %u boxes for text runs...", in_boxes.len()); - let out_boxes = DVec(); + let mut out_boxes = ~[]; for uint::range(0, in_boxes.len()) |box_i| { debug!("TextRunScanner: considering box: %?", in_boxes[box_i].debug_str()); - if box_i > 0 && !can_coalesce_text_nodes(in_boxes, box_i-1, box_i) { - self.flush_clump_to_list(ctx, flow, in_boxes, &out_boxes); + if box_i > 0 && !can_coalesce_text_nodes(*in_boxes, box_i-1, box_i) { + self.flush_clump_to_list(ctx, flow, *in_boxes, &mut out_boxes); } self.clump.extend_by(1); } // handle remaining clumps if self.clump.length() > 0 { - self.flush_clump_to_list(ctx, flow, in_boxes, &out_boxes); + self.flush_clump_to_list(ctx, flow, *in_boxes, &mut out_boxes); } debug!("TextRunScanner: swapping out boxes."); // swap out old and new box list of flow, by supplying // temp boxes as return value to boxes.swap |...| - dvec::unwrap(out_boxes) - } + util::swap(in_boxes, &mut out_boxes); + //} // helper functions fn can_coalesce_text_nodes(boxes: &[@mut RenderBox], left_i: uint, right_i: uint) -> bool { - assert left_i < boxes.len(); - assert right_i > 0 && right_i < boxes.len(); - assert left_i != right_i; + fail_unless!(left_i < boxes.len()); + fail_unless!(right_i > 0 && right_i < boxes.len()); + fail_unless!(left_i != right_i); let (left, right) = (boxes[left_i], boxes[right_i]); match (left, right) { @@ -222,8 +222,8 @@ priv impl TextRunScanner { ctx: &mut LayoutContext, flow: @mut FlowContext, in_boxes: &[@mut RenderBox], - out_boxes: &DVec<@mut RenderBox>) { - assert self.clump.length() > 0; + out_boxes: &mut ~[@mut RenderBox]) { + fail_unless!(self.clump.length() > 0); debug!("TextRunScanner: flushing boxes in range=%?", self.clump); let is_singleton = self.clump.length() == 1; @@ -274,7 +274,7 @@ priv impl TextRunScanner { // next, concatenate all of the transformed strings together, saving the new char indices let mut run_str : ~str = ~""; - let new_ranges : DVec = DVec(); + let mut new_ranges : ~[Range] = ~[]; let mut char_total = 0u; for uint::range(0, transformed_strs.len()) |i| { let added_chars = str::char_len(transformed_strs[i]); @@ -336,29 +336,29 @@ struct PendingLine { struct LineboxScanner { flow: @mut FlowContext, - new_boxes: DVec<@mut RenderBox>, + new_boxes: ~[@mut RenderBox], work_list: @mut DList<@mut RenderBox>, pending_line: PendingLine, - line_spans: DVec, + line_spans: ~[Range], } fn LineboxScanner(inline: @mut FlowContext) -> LineboxScanner { - assert inline.starts_inline_flow(); + fail_unless!(inline.starts_inline_flow()); LineboxScanner { flow: inline, - new_boxes: DVec(), + new_boxes: ~[], work_list: DList(), pending_line: PendingLine {mut range: Range::empty(), mut width: Au(0)}, - line_spans: DVec() + line_spans: ~[] } } impl LineboxScanner { priv fn reset_scanner(&mut self) { debug!("Resetting line box scanner's state for flow f%d.", self.flow.d().id); - self.line_spans.set(~[]); - self.new_boxes.set(~[]); + self.line_spans = ~[]; + self.new_boxes = ~[]; self.reset_linebox(); } @@ -406,7 +406,7 @@ impl LineboxScanner { let boxes = &mut self.flow.inline().boxes; let elems = &mut self.flow.inline().elems; - elems.repair_for_box_changes(boxes, &self.new_boxes); + elems.repair_for_box_changes(*boxes, self.new_boxes); self.swap_out_results(); } @@ -414,16 +414,18 @@ impl LineboxScanner { debug!("LineboxScanner: Propagating scanned lines[n=%u] to inline flow f%d", self.line_spans.len(), self.flow.d().id); - do self.new_boxes.swap |boxes| { + //do self.new_boxes.swap |boxes| { let inline_boxes = &mut self.flow.inline().boxes; - inline_boxes.set(boxes); - ~[] - }; - do self.line_spans.swap |boxes| { + util::swap(inline_boxes, &mut self.new_boxes); + //inline_boxes = boxes; + // ~[] + //}; + //do self.line_spans.swap |boxes| { let lines = &mut self.flow.inline().lines; - lines.set(boxes); - ~[] - }; + util::swap(lines, &mut self.line_spans); + // lines = boxes; + // ~[] + //}; } priv fn flush_current_line(&mut self) { @@ -567,7 +569,7 @@ impl LineboxScanner { debug!("LineboxScanner: Pushing box b%d to line %u", box.d().id, self.line_spans.len()); if self.pending_line.range.length() == 0 { - assert self.new_boxes.len() <= (core::u16::max_value as uint); + fail_unless!(self.new_boxes.len() <= (core::u16::max_value as uint)); self.pending_line.range.reset(self.new_boxes.len(), 0); } self.pending_line.range.extend_by(1); @@ -579,10 +581,10 @@ impl LineboxScanner { pub struct InlineFlowData { // A vec of all inline render boxes. Several boxes may // correspond to one Node/Element. - boxes: DVec<@mut RenderBox>, + boxes: ~[@mut RenderBox], // vec of ranges into boxes that represents line positions. // these ranges are disjoint, and are the result of inline layout. - lines: DVec, + lines: ~[Range], // vec of ranges into boxes that represent elements. These ranges // must be well-nested, and are only related to the content of // boxes (not lines). Ranges are only kept for non-leaf elements. @@ -591,8 +593,8 @@ pub struct InlineFlowData { pub fn InlineFlowData() -> InlineFlowData { InlineFlowData { - boxes: DVec(), - lines: DVec(), + boxes: ~[], + lines: ~[], elems: ElementMapping::new(), } } @@ -611,7 +613,7 @@ impl InlineLayout for FlowContext { pure fn starts_inline_flow() -> bool { match self { InlineFlow(*) => true, _ => false } } fn bubble_widths_inline(@mut self, ctx: &mut LayoutContext) { - assert self.starts_inline_flow(); + fail_unless!(self.starts_inline_flow()); let mut scanner = TextRunScanner::new(); scanner.scan_for_runs(ctx, self); @@ -634,7 +636,7 @@ impl InlineLayout for FlowContext { contexts and boxes. When called on this context, the context has had its width set by the parent context. */ fn assign_widths_inline(@mut self, ctx: &mut LayoutContext) { - assert self.starts_inline_flow(); + fail_unless!(self.starts_inline_flow()); // initialize (content) box widths, if they haven't been // already. This could be combined with LineboxScanner's walk @@ -750,7 +752,7 @@ impl InlineLayout for FlowContext { fn build_display_list_inline(@mut self, builder: &DisplayListBuilder, dirty: &Rect, offset: &Point2D, list: &Mut) { - assert self.starts_inline_flow(); + fail_unless!(self.starts_inline_flow()); // TODO(Issue #228): once we form line boxes and have their cached bounds, we can be // smarter and not recurse on a line if nothing in it can intersect dirty diff --git a/src/servo/layout/layout_task.rs b/src/servo/layout/layout_task.rs index 94a7adbe95c..462de1a9894 100644 --- a/src/servo/layout/layout_task.rs +++ b/src/servo/layout/layout_task.rs @@ -21,7 +21,6 @@ use util::time::time; use core::cell::Cell; use core::comm::{Chan, Port, SharedChan}; -use core::dvec::DVec; use core::mutable::Mut; use core::task::*; use core::util::replace; @@ -103,7 +102,7 @@ struct Layout { font_ctx: @mut FontContext, // This is used to root reader data - layout_refs: DVec<@mut LayoutData>, + layout_refs: ~[@mut LayoutData], css_select_ctx: Mut, } @@ -120,7 +119,7 @@ fn Layout(render_task: RenderTask, local_image_cache: @mut LocalImageCache(image_cache_task), from_content: from_content, font_ctx: fctx, - layout_refs: DVec(), + layout_refs: ~[], css_select_ctx: Mut(new_css_select_ctx()) } } @@ -162,7 +161,7 @@ impl Layout { true } - fn handle_add_stylesheet(sheet: Stylesheet) { + fn handle_add_stylesheet(&self, sheet: Stylesheet) { let sheet = Cell(sheet); do self.css_select_ctx.borrow_mut |ctx| { ctx.append_sheet(sheet.take(), OriginAuthor); @@ -196,7 +195,7 @@ impl Layout { do time("layout: aux initialization") { // TODO: this is dumb. we don't need an entire traversal to do this - node.initialize_style_for_subtree(&self.layout_refs); + node.initialize_style_for_subtree(&mut self.layout_refs); } // Perform CSS selector matching if necessary. @@ -295,7 +294,7 @@ impl Layout { // to the content task, and ultimately cause the image to be // re-requested. We probably don't need to go all the way back to // the content task for this. - fn make_on_image_available_cb(dom_event_chan: comm::SharedChan) -> @fn() -> ~fn(ImageResponseMsg) { + fn make_on_image_available_cb(&self, dom_event_chan: comm::SharedChan) -> @fn() -> ~fn(ImageResponseMsg) { // This has a crazy signature because the image cache needs to // make multiple copies of the callback, and the dom event // channel is not a copyable type, so this is actually a diff --git a/src/servo/layout/root.rs b/src/servo/layout/root.rs index d5955eeb102..f7c380c228d 100644 --- a/src/servo/layout/root.rs +++ b/src/servo/layout/root.rs @@ -42,12 +42,12 @@ impl RootLayout for FlowContext { /* defer to the block algorithm */ fn bubble_widths_root(@mut self, ctx: &LayoutContext) { - assert self.starts_root_flow(); + fail_unless!(self.starts_root_flow()); self.bubble_widths_block(ctx) } fn assign_widths_root(@mut self, ctx: &LayoutContext) { - assert self.starts_root_flow(); + fail_unless!(self.starts_root_flow()); self.d().position.origin = Au::zero_point(); self.d().position.size.width = ctx.screen_size.size.width; @@ -56,7 +56,7 @@ impl RootLayout for FlowContext { } fn assign_height_root(@mut self, ctx: &LayoutContext) { - assert self.starts_root_flow(); + fail_unless!(self.starts_root_flow()); // this is essentially the same as assign_height_block(), except // the root adjusts self height to at least cover the viewport. @@ -78,7 +78,7 @@ impl RootLayout for FlowContext { fn build_display_list_root(@mut self, builder: &DisplayListBuilder, dirty: &Rect, offset: &Point2D, list: &Mut) { - assert self.starts_root_flow(); + fail_unless!(self.starts_root_flow()); self.build_display_list_block(builder, dirty, offset, list); } diff --git a/src/servo/layout/text.rs b/src/servo/layout/text.rs index f7fa67c9d7f..518b96d6468 100644 --- a/src/servo/layout/text.rs +++ b/src/servo/layout/text.rs @@ -19,9 +19,9 @@ pub fn TextBoxData(run: @TextRun, range: &const Range) -> TextBoxData { pub fn adapt_textbox_with_range(box_data: &mut RenderBoxData, run: @TextRun, range: &const Range) -> @mut RenderBox { - assert range.begin() < run.char_len(); - assert range.end() <= run.char_len(); - assert range.length() > 0; + fail_unless!(range.begin() < run.char_len()); + fail_unless!(range.end() <= run.char_len()); + fail_unless!(range.length() > 0); debug!("Creating textbox with span: (strlen=%u, off=%u, len=%u) of textrun: %s", run.char_len(), range.begin(), range.length(), run.text); diff --git a/src/servo/layout/traverse.rs b/src/servo/layout/traverse.rs index b29fa16f579..463aa320fd0 100644 --- a/src/servo/layout/traverse.rs +++ b/src/servo/layout/traverse.rs @@ -2,17 +2,17 @@ use layout::flow::{FlowContext, FlowTree}; /** Trait for running tree-based traversals over layout contexts */ pub trait FlowContextTraversals { - fn traverse_preorder(preorder_cb: &fn(@mut FlowContext)); - fn traverse_postorder(postorder_cb: &fn(@mut FlowContext)); + fn traverse_preorder(@mut self, preorder_cb: &fn(@mut FlowContext)); + fn traverse_postorder(@mut self, postorder_cb: &fn(@mut FlowContext)); } -impl FlowContextTraversals for @mut FlowContext { - fn traverse_preorder(preorder_cb: &fn(@mut FlowContext)) { +impl FlowContextTraversals for FlowContext { + fn traverse_preorder(@mut self, preorder_cb: &fn(@mut FlowContext)) { preorder_cb(self); do FlowTree.each_child(self) |child| { child.traverse_preorder(preorder_cb); true } } - fn traverse_postorder(postorder_cb: &fn(@mut FlowContext)) { + fn traverse_postorder(@mut self, postorder_cb: &fn(@mut FlowContext)) { do FlowTree.each_child(self) |child| { child.traverse_postorder(postorder_cb); true } postorder_cb(self); } diff --git a/src/servo/platform/osmain.rs b/src/servo/platform/osmain.rs index be7c88544b7..0001cd08382 100644 --- a/src/servo/platform/osmain.rs +++ b/src/servo/platform/osmain.rs @@ -3,7 +3,6 @@ use dom::event::{Event, ResizeEvent}; use platform::resize_rate_limiter::ResizeRateLimiter; use azure::azure_hl::{BackendType, B8G8R8A8, DataSourceSurface, DrawTarget, SourceSurfaceMethods}; -use core::dvec::DVec; use core::comm::{Chan, SharedChan, Port}; use core::task::TaskBuilder; use core::util; @@ -99,7 +98,7 @@ fn mainloop(mode: Mode, po: Port, dom_event_chan: SharedChan, opts: &Opts) { - let key_handlers: @DVec> = @DVec(); + let key_handlers: @mut ~[Chan<()>] = @mut ~[]; let window; match mode { @@ -125,13 +124,11 @@ fn mainloop(mode: Mode, let root_layer = @mut layers::layers::ContainerLayer(); let original_layer_transform; { - let mut image_data = @mut layers::layers::BasicImageData::new(Size2D(0u, 0u), + let image_data = @layers::layers::BasicImageData::new(Size2D(0u, 0u), 0, layers::layers::RGB24Format, ~[]); - //XXXjdm How can we obtain a @mut @ImageData without transmute? - let image_data: @mut @layers::layers::ImageData = unsafe { cast::transmute(image_data) }; - let image = @mut layers::layers::Image::new(image_data); + let image = @mut layers::layers::Image::new(image_data as @layers::layers::ImageData); let image_layer = @mut layers::layers::ImageLayer(image); original_layer_transform = image_layer.common.transform; image_layer.common.set_transform(original_layer_transform.scale(800.0, 600.0, 1.0)); @@ -172,14 +169,12 @@ fn mainloop(mode: Mode, debug!("osmain: compositing buffer rect %?", &buffer.rect); - let image_data = @mut AzureDrawTargetImageData { + let image_data = @AzureDrawTargetImageData { draw_target: buffer.draw_target.clone(), data_source_surface: buffer.draw_target.snapshot().get_data_surface(), size: Size2D(width, height) }; - //XXXjdm How can we extract a @mut @ImageData without transmute? - let image_data: @mut @layers::layers::ImageData = unsafe { cast::transmute(image_data) }; - let image = @mut layers::layers::Image::new(image_data); + let image = @mut layers::layers::Image::new(image_data as @layers::layers::ImageData); // Find or create an image layer. let image_layer; @@ -295,7 +290,7 @@ struct SurfaceSet { fn lend_surface(surfaces: &mut SurfaceSet, receiver: comm::Chan) { // We are in a position to lend out the surface? - assert surfaces.front.have; + fail_unless!(surfaces.front.have); // Ok then take it let old_layer_buffers = util::replace(&mut surfaces.front.layer_buffer_set.buffers, ~[]); let new_layer_buffers = do old_layer_buffers.map |layer_buffer| { @@ -317,14 +312,14 @@ fn lend_surface(surfaces: &mut SurfaceSet, receiver: comm::Chan) // But we (hopefully) have another! surfaces.front <-> surfaces.back; // Let's look - assert surfaces.front.have; + fail_unless!(surfaces.front.have); } fn return_surface(surfaces: &mut SurfaceSet, layer_buffer_set: LayerBufferSet) { //#debug("osmain: returning surface %?", layer_buffer_set); // We have room for a return - assert surfaces.front.have; - assert !surfaces.back.have; + fail_unless!(surfaces.front.have); + fail_unless!(!surfaces.back.have); surfaces.back.layer_buffer_set = layer_buffer_set; @@ -364,7 +359,7 @@ fn on_osmain(f: ~fn(po: Port)) -> Chan { // #[cfg(target_os = "linux")] mod platform { - pub fn runmain(f: fn()) { + pub fn runmain(f: &fn()) { f() } } diff --git a/src/servo/platform/resize_rate_limiter.rs b/src/servo/platform/resize_rate_limiter.rs index 6572977ad29..9a8330072b7 100644 --- a/src/servo/platform/resize_rate_limiter.rs +++ b/src/servo/platform/resize_rate_limiter.rs @@ -28,7 +28,7 @@ pub impl ResizeRateLimiter { fn window_resized(&mut self, width: uint, height: uint) { match self.last_response_port { None => { - assert self.next_resize_event.is_none(); + fail_unless!(self.next_resize_event.is_none()); self.send_event(width, height); } Some(*) => { @@ -48,7 +48,7 @@ pub impl ResizeRateLimiter { fn check_resize_response(&mut self) { match self.next_resize_event { Some((copy width, copy height)) => { - assert self.last_response_port.is_some(); + fail_unless!(self.last_response_port.is_some()); if self.last_response_port.get_ref().peek() { self.send_event(width, height); self.next_resize_event = None; diff --git a/src/servo/servo.rc b/src/servo/servo.rc index 94a9a424bfe..eaa45af1cbd 100755 --- a/src/servo/servo.rc +++ b/src/servo/servo.rc @@ -115,7 +115,7 @@ fn run(opts: &Opts) { match &opts.render_mode { &Screen => run_pipeline_screen(opts), &Png(ref outfile) => { - assert !opts.urls.is_empty(); + fail_unless!(!opts.urls.is_empty()); if opts.urls.len() > 1u { fail!(~"servo asks that you stick to a single URL in PNG output mode") } diff --git a/src/servo/util/tree.rs b/src/servo/util/tree.rs index 7e2155966a4..fe4f40d4236 100644 --- a/src/servo/util/tree.rs +++ b/src/servo/util/tree.rs @@ -13,15 +13,15 @@ pub struct Tree { } pub trait ReadMethods { - fn with_tree_fields(&T, f: fn(&mut Tree) -> R) -> R; + fn with_tree_fields(&T, f: &fn(&mut Tree) -> R) -> R; } pub trait WriteMethods { - fn with_tree_fields(&T, f: fn(&mut Tree) -> R) -> R; + fn with_tree_fields(&T, f: &fn(&mut Tree) -> R) -> R; pure fn tree_eq(&T, &T) -> bool; } -pub fn each_child>(ops: &O, node: &T, f: fn(&T) -> bool) { +pub fn each_child>(ops: &O, node: &T, f: &fn(&T) -> bool) { let mut p = ops.with_tree_fields(node, |f| f.first_child); loop { match copy p { @@ -69,7 +69,7 @@ pub fn empty() -> Tree { } pub fn add_child>(ops: &O, parent: T, child: T) { - assert !ops.tree_eq(&parent, &child); + fail_unless!(!ops.tree_eq(&parent, &child)); ops.with_tree_fields(&child, |child_tf| { match child_tf.parent { @@ -77,8 +77,8 @@ pub fn add_child>(ops: &O, parent: T, child: T) { None => { child_tf.parent = Some(parent); } } - assert child_tf.prev_sibling.is_none(); - assert child_tf.next_sibling.is_none(); + fail_unless!(child_tf.prev_sibling.is_none()); + fail_unless!(child_tf.next_sibling.is_none()); ops.with_tree_fields(&parent, |parent_tf| { match copy parent_tf.last_child { @@ -87,7 +87,7 @@ pub fn add_child>(ops: &O, parent: T, child: T) { } Some(lc) => { ops.with_tree_fields(&lc, |lc_tf| { - assert lc_tf.next_sibling.is_none(); + fail_unless!(lc_tf.next_sibling.is_none()); lc_tf.next_sibling = Some(child); }); child_tf.prev_sibling = Some(lc); @@ -104,7 +104,7 @@ pub fn remove_child>(ops: &O, parent: T, child: T) { match copy child_tf.parent { None => { fail!(~"Not a child"); } Some(parent_n) => { - assert ops.tree_eq(&parent, &parent_n); + fail_unless!(ops.tree_eq(&parent, &parent_n)); // adjust parent fields do ops.with_tree_fields(&parent) |parent_tf| { @@ -169,13 +169,13 @@ mod test { enum dtree { dtree } impl ReadMethods<@dummy> for dtree { - fn with_tree_fields(d: &@dummy, f: fn(&Tree<@dummy>) -> R) -> R { + fn with_tree_fields(d: &@dummy, f: &fn(&Tree<@dummy>) -> R) -> R { f(&d.fields) } } impl WriteMethods<@dummy> for dtree { - fn with_tree_fields(d: &@dummy, f: fn(&Tree<@dummy>) -> R) -> R { + fn with_tree_fields(d: &@dummy, f: &fn(&Tree<@dummy>) -> R) -> R { f(&d.fields) } pure fn tree_eq(a: &@dummy, b: &@dummy) -> bool { ptr_eq(*a, *b) } @@ -203,10 +203,10 @@ mod test { let (p, children) = parent_with_3_children(); let mut i = 0u; for each_child(&dtree, &p) |c| { - assert c.value == i; + fail_unless!(c.value == i); i += 1u; } - assert i == children.len(); + fail_unless!(i == children.len()); } #[test] @@ -217,7 +217,7 @@ mod test { i += 1u; break; } - assert i == 1u; + fail_unless!(i == 1u); } #[test] @@ -229,7 +229,7 @@ mod test { for each_child(&dtree, &p) |_c| { i += 1; } - assert i == 2; + fail_unless!(i == 2); } #[test] @@ -241,7 +241,7 @@ mod test { for each_child(&dtree, &p) |_c| { i += 1; } - assert i == 2; + fail_unless!(i == 2); } #[test] @@ -253,7 +253,7 @@ mod test { for each_child(&dtree, &p) |_c| { i += 1; } - assert i == 2; + fail_unless!(i == 2); } #[test] @@ -267,6 +267,6 @@ mod test { for each_child(&dtree, &p) |_c| { i += 1; } - assert i == 0; + fail_unless!(i == 0); } } diff --git a/src/sharegl b/src/sharegl index c14a4786b98..08f3a25f946 160000 --- a/src/sharegl +++ b/src/sharegl @@ -1 +1 @@ -Subproject commit c14a4786b98dbb135cd0479d749be1bef0b57376 +Subproject commit 08f3a25f9465e7bf5638ddea384cfb2d17272e36