mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
De-mut field, de-DVec, de-assert.
This commit is contained in:
parent
e85b3798f2
commit
164520ef3c
68 changed files with 330 additions and 326 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ DEPS_rust-layers += \
|
|||
rust-geom \
|
||||
rust-glut \
|
||||
rust-opengles \
|
||||
skia \
|
||||
$(NULL)
|
||||
|
||||
DEPS_sharegl += \
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 433fcc2d6862bea202ad2e3acfd1fe4041064edc
|
||||
Subproject commit a016a795bb9a021c06a665563c4aaf793b0b97ca
|
|
@ -1 +1 @@
|
|||
Subproject commit a0257b8d6d81ead5aeb018e48b37c456177cd92e
|
||||
Subproject commit 252672fd902723cca59423a135c829a70a0b3f0b
|
|
@ -1 +1 @@
|
|||
Subproject commit 6eba2da0919e6d47458d8d4e002aaa7a17a66f77
|
||||
Subproject commit 9f406c72c22fb68691d8d137df679a7d047ec135
|
|
@ -1 +1 @@
|
|||
Subproject commit 1d966254065c59d0c108f3207c4646184fc85635
|
||||
Subproject commit 260f7062a4cae7e3575a3cf97d1119bc076ab221
|
|
@ -1 +1 @@
|
|||
Subproject commit e185c9ad59eb42250db8a1c5d1d1e078265d933d
|
||||
Subproject commit b414d3bf445ac63860a9cf44532280228f001a2b
|
|
@ -1 +1 @@
|
|||
Subproject commit f382fa4ca9bd2b13805156b821d1a8242f9873a1
|
||||
Subproject commit cdc1b0b8d173be4e1c79961742a367dac39d7d86
|
|
@ -1 +1 @@
|
|||
Subproject commit 84684665c678d35057296cdfdfaa4389a23d1d9b
|
||||
Subproject commit 337bc5cb49b2a518527d62cd9af08e169f4f6456
|
|
@ -1 +1 @@
|
|||
Subproject commit 6a58ecc96287aa1c051c0aacba3d3b6857b4dd0d
|
||||
Subproject commit e416f03f4898825bc8f24cfd890004a130e2457b
|
|
@ -1 +1 @@
|
|||
Subproject commit 5d00c01fb4798722b5e5a27f55fccc726068ad08
|
||||
Subproject commit 886cf481cbf9c9eedfbab0344e5f887c11220497
|
|
@ -1 +1 @@
|
|||
Subproject commit 4714bc7a8f7a3d4168b297c4568b38acd5b7a8c9
|
||||
Subproject commit 8e04c939c72083fa311ea709f5aafeaccd83975d
|
|
@ -1 +1 @@
|
|||
Subproject commit 9bf7ae289c9fdbc82d0a8f45a54f18e281fc6875
|
||||
Subproject commit 276a57d204f2d0ae74bda4ed76e63b830ca6332b
|
|
@ -1 +1 @@
|
|||
Subproject commit f796ad48dae00987ab6bc0c64031ecb8358a9c08
|
||||
Subproject commit 62558783027d1aaccb4e689d3ff5aed057a1f5f5
|
|
@ -1 +1 @@
|
|||
Subproject commit ea93796f5c0675d50fa1e92bfd76709a601fe9fe
|
||||
Subproject commit 9b6d463d9045a90e6e3f31e35806af87e46e3852
|
|
@ -1 +1 @@
|
|||
Subproject commit 485845b44db19558c8c911a4a4a864144a85f72b
|
||||
Subproject commit 06b790f226819e30c59b35523407bc671fe4d2ca
|
|
@ -1 +1 @@
|
|||
Subproject commit 6cec2ef974c10669d127d19509ae595ce2b76135
|
||||
Subproject commit ce75a42685824a4c3c63a638a2c76762b7fac813
|
|
@ -1 +1 @@
|
|||
Subproject commit 0adab98b6bc352fa689320ce8cd14ca6d92a88d3
|
||||
Subproject commit c8328148ec5d1ec4fb8a496a41e34badf53e7f88
|
|
@ -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;
|
||||
|
|
|
@ -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(());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, ()> {
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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) );
|
||||
|
|
|
@ -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<GlyphIndex> {
|
||||
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<FractionalPixel> {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
|
|||
|
||||
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<Image> {
|
|||
}
|
||||
};
|
||||
|
||||
assert image.data.len() == data.len();
|
||||
fail_unless!(image.data.len() == data.len());
|
||||
|
||||
Some(Image(image.width, image.height, image.depth, data))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<Au> {
|
||||
//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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Timing functions.
|
||||
use std::time::precise_time_ns;
|
||||
|
||||
pub fn time<T>(msg: &str, callback: fn() -> T) -> T{
|
||||
pub fn time<T>(msg: &str, callback: &fn() -> T) -> T{
|
||||
let start_time = precise_time_ns();
|
||||
let val = callback();
|
||||
let end_time = precise_time_ns();
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ impl<'self, T: Ord + Eq> BinarySearchMethods<T> for &'self [T] {
|
|||
fn test_find_all_elems<T: Eq + Ord>(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<T: Eq + Ord>(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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -19,7 +19,13 @@ pub enum DOMString {
|
|||
null_string
|
||||
}
|
||||
|
||||
pub type rust_box<T> = {rc: uint, td: *sys::TypeDesc, next: *(), prev: *(), payload: T};
|
||||
pub struct rust_box<T> {
|
||||
rc: uint,
|
||||
td: *sys::TypeDesc,
|
||||
next: *(),
|
||||
prev: *(),
|
||||
payload: T
|
||||
}
|
||||
|
||||
pub unsafe fn squirrel_away<T>(x: @T) -> *rust_box<T> {
|
||||
let y: *rust_box<T> = 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<TimerControlMsg>,
|
||||
}
|
||||
|
||||
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<JSVal>,
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,13 +66,13 @@ pub fn Engine<C:Compositor + Owned + Clone>(compositor: C,
|
|||
}
|
||||
|
||||
impl<C:Compositor + Owned + Clone> Engine<C> {
|
||||
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") {
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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<Au>,
|
||||
offset: &Point2D<Au>, list: &Mut<DisplayList>) {
|
||||
|
||||
assert self.starts_block_flow();
|
||||
fail_unless!(self.starts_block_flow());
|
||||
|
||||
// add box that starts block context
|
||||
do self.with_block_box |box| {
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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<uint>,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<R>(box: &@mut FlowContext, f: fn(&mut tree::Tree<@mut FlowContext>) -> R) -> R {
|
||||
fn with_tree_fields<R>(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<R>(box: &@mut FlowContext, f: fn(&mut tree::Tree<@mut FlowContext>) -> R) -> R {
|
||||
fn with_tree_fields<R>(box: &@mut FlowContext, f: &fn(&mut tree::Tree<@mut FlowContext>) -> R) -> R {
|
||||
let tree = &mut box.d().tree;
|
||||
f(tree)
|
||||
}
|
||||
|
|
|
@ -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<NodeRange>,
|
||||
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<WorkItem> = 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<Range> = 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<Range>,
|
||||
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<Range>,
|
||||
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<Au>,
|
||||
offset: &Point2D<Au>, list: &Mut<DisplayList>) {
|
||||
|
||||
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
|
||||
|
|
|
@ -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<SelectCtx>,
|
||||
}
|
||||
|
||||
|
@ -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<Event>) -> @fn() -> ~fn(ImageResponseMsg) {
|
||||
fn make_on_image_available_cb(&self, dom_event_chan: comm::SharedChan<Event>) -> @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
|
||||
|
|
|
@ -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<Au>,
|
||||
offset: &Point2D<Au>, list: &Mut<DisplayList>) {
|
||||
assert self.starts_root_flow();
|
||||
fail_unless!(self.starts_root_flow());
|
||||
|
||||
self.build_display_list_block(builder, dirty, offset, list);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<Msg>,
|
||||
dom_event_chan: SharedChan<Event>,
|
||||
opts: &Opts) {
|
||||
let key_handlers: @DVec<Chan<()>> = @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<LayerBufferSet>) {
|
||||
// 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<LayerBufferSet>)
|
|||
// 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<T: Owned>(f: ~fn(po: Port<T>)) -> Chan<T> {
|
|||
|
||||
// #[cfg(target_os = "linux")]
|
||||
mod platform {
|
||||
pub fn runmain(f: fn()) {
|
||||
pub fn runmain(f: &fn()) {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -13,15 +13,15 @@ pub struct Tree<T> {
|
|||
}
|
||||
|
||||
pub trait ReadMethods<T> {
|
||||
fn with_tree_fields<R>(&T, f: fn(&mut Tree<T>) -> R) -> R;
|
||||
fn with_tree_fields<R>(&T, f: &fn(&mut Tree<T>) -> R) -> R;
|
||||
}
|
||||
|
||||
pub trait WriteMethods<T> {
|
||||
fn with_tree_fields<R>(&T, f: fn(&mut Tree<T>) -> R) -> R;
|
||||
fn with_tree_fields<R>(&T, f: &fn(&mut Tree<T>) -> R) -> R;
|
||||
pure fn tree_eq(&T, &T) -> bool;
|
||||
}
|
||||
|
||||
pub fn each_child<T:Copy,O:ReadMethods<T>>(ops: &O, node: &T, f: fn(&T) -> bool) {
|
||||
pub fn each_child<T:Copy,O:ReadMethods<T>>(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<T>() -> Tree<T> {
|
|||
}
|
||||
|
||||
pub fn add_child<T:Copy,O:WriteMethods<T>>(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<T:Copy,O:WriteMethods<T>>(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<T:Copy,O:WriteMethods<T>>(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<T:Copy,O:WriteMethods<T>>(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<R>(d: &@dummy, f: fn(&Tree<@dummy>) -> R) -> R {
|
||||
fn with_tree_fields<R>(d: &@dummy, f: &fn(&Tree<@dummy>) -> R) -> R {
|
||||
f(&d.fields)
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteMethods<@dummy> for dtree {
|
||||
fn with_tree_fields<R>(d: &@dummy, f: fn(&Tree<@dummy>) -> R) -> R {
|
||||
fn with_tree_fields<R>(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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c14a4786b98dbb135cd0479d749be1bef0b57376
|
||||
Subproject commit 08f3a25f9465e7bf5638ddea384cfb2d17272e36
|
Loading…
Add table
Add a link
Reference in a new issue