diff --git a/components/gfx/buffer_map.rs b/components/gfx/buffer_map.rs index c16ae23eb13..01070851d88 100644 --- a/components/gfx/buffer_map.rs +++ b/components/gfx/buffer_map.rs @@ -17,17 +17,17 @@ pub struct BufferMap { /// A HashMap that stores the Buffers. map: HashMap, /// The current amount of memory stored by the BufferMap's buffers. - mem: uint, + mem: usize, /// The maximum allowed memory. Unused buffers will be deleted /// when this threshold is exceeded. - max_mem: uint, + max_mem: usize, /// A monotonically increasing counter to track how recently tile sizes were used. - counter: uint, + counter: usize, } /// A key with which to store buffers. It is based on the size of the buffer. #[derive(Eq, Copy)] -struct BufferKey([uint; 2]); +struct BufferKey([usize; 2]); impl Hash for BufferKey { fn hash(&self, state: &mut H) { @@ -46,7 +46,7 @@ impl PartialEq for BufferKey { /// Create a key from a given size impl BufferKey { - fn get(input: Size2D) -> BufferKey { + fn get(input: Size2D) -> BufferKey { BufferKey([input.width, input.height]) } } @@ -56,17 +56,17 @@ struct BufferValue { /// An array of buffers, all the same size buffers: Vec>, /// The counter when this size was last requested - last_action: uint, + last_action: usize, } impl BufferMap { // Creates a new BufferMap with a given buffer limit. - pub fn new(max_mem: uint) -> BufferMap { + pub fn new(max_mem: usize) -> BufferMap { BufferMap { map: HashMap::new(), - mem: 0u, + mem: 0, max_mem: max_mem, - counter: 0u, + counter: 0, } } @@ -125,7 +125,7 @@ impl BufferMap { } // Try to find a buffer for the given size. - pub fn find(&mut self, size: Size2D) -> Option> { + pub fn find(&mut self, size: Size2D) -> Option> { let mut flag = false; // True if key needs to be popped after retrieval. let key = BufferKey::get(size); let ret = match self.map.get_mut(&key) { diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 55af5c98a81..85ca1549a63 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -1125,7 +1125,7 @@ impl DisplayItem { self.base().bounds } - pub fn debug_with_level(&self, level: uint) { + pub fn debug_with_level(&self, level: u32) { let mut indent = String::new(); for _ in range(0, level) { indent.push_str("| ") diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 21ab30ca0af..a44b08bce1e 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -66,7 +66,7 @@ impl FontTableTagConversions for FontTableTag { } pub trait FontTableMethods { - fn with_buffer(&self, F) where F: FnOnce(*const u8, uint); + fn with_buffer(&self, F) where F: FnOnce(*const u8, usize); } #[derive(Clone, Debug)] @@ -145,7 +145,7 @@ impl Font { Some(glyphs) => return glyphs.clone(), } - let mut glyphs = GlyphStore::new(text.chars().count() as int, + let mut glyphs = GlyphStore::new(text.chars().count(), options.flags.contains(IS_WHITESPACE_SHAPING_FLAG)); shaper.as_ref().unwrap().shape_text(text, options, &mut glyphs); diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index 9b4338c86fb..3e59c8305a6 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -6,7 +6,6 @@ #![feature(box_syntax)] #![feature(collections)] #![feature(core)] -#![feature(int_uint)] #![cfg_attr(any(target_os="linux", target_os = "android"), feature(io))] #![feature(plugin)] #![feature(rustc_private)] diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index 53bbe369b1b..0cbd5a739b6 100644 --- a/components/gfx/paint_context.rs +++ b/components/gfx/paint_context.rs @@ -48,7 +48,7 @@ pub struct PaintContext<'a> { /// The rectangle that this context encompasses in page coordinates. pub page_rect: Rect, /// The rectangle that this context encompasses in screen coordinates (pixels). - pub screen_rect: Rect, + pub screen_rect: Rect, /// The clipping rect for the stacking context as a whole. pub clip_rect: Option>, /// The current transient clipping region, if any. A "transient clipping region" is the @@ -622,19 +622,19 @@ impl<'a> PaintContext<'a> { color: Color, dash_size: DashSize) { let rect = bounds.to_azure_rect(); - let draw_opts = DrawOptions::new(1u as AzFloat, 0 as uint16_t); + let draw_opts = DrawOptions::new(1 as AzFloat, 0 as uint16_t); let border_width = match direction { Direction::Top => border.top, Direction::Left => border.left, Direction::Right => border.right, Direction::Bottom => border.bottom }; - let dash_pattern = [border_width * (dash_size as int) as AzFloat, - border_width * (dash_size as int) as AzFloat]; + let dash_pattern = [border_width * (dash_size as i32) as AzFloat, + border_width * (dash_size as i32) as AzFloat]; let stroke_opts = StrokeOptions::new(border_width as AzFloat, JoinStyle::MiterOrBevel, CapStyle::Butt, - 10u as AzFloat, + 10 as AzFloat, &dash_pattern); let (start, end) = match direction { Direction::Top => { diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index d4a95b6e619..e359f73bc79 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -123,7 +123,7 @@ pub struct PaintTask { /// Tracks the number of buffers that the compositor currently owns. The /// PaintTask waits to exit until all buffers are returned. - used_buffer_count: uint, + used_buffer_count: usize, } // If we implement this as a function, we get borrowck errors from borrowing @@ -324,7 +324,7 @@ impl PaintTask where C: PaintListener + Send + 'static { rect: tile.page_rect, screen_pos: tile.screen_rect, resolution: scale, - stride: (width * 4) as uint, + stride: (width * 4) as usize, painted_with_cpu: true, content_age: tile.content_age, }) @@ -619,7 +619,7 @@ impl WorkerThread { rect: tile.page_rect, screen_pos: tile.screen_rect, resolution: scale, - stride: (tile.screen_rect.size.width * 4) as uint, + stride: (tile.screen_rect.size.width * 4), painted_with_cpu: false, content_age: tile.content_age, } diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs index 2ee09e8673b..181c3569bab 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/gfx/platform/freetype/font.rs @@ -43,7 +43,7 @@ fn fixed_to_float_ft(f: i32) -> f64 { pub struct FontTable; impl FontTableMethods for FontTable { - fn with_buffer(&self, _blk: F) where F: FnOnce(*const u8, uint) { + fn with_buffer(&self, _blk: F) where F: FnOnce(*const u8, usize) { panic!() } } diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index 7b22c69c105..d38a3410260 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -47,8 +47,8 @@ impl FontTable { } impl FontTableMethods for FontTable { - fn with_buffer(&self, blk: F) where F: FnOnce(*const u8, uint) { - blk(self.data.bytes().as_ptr(), self.data.len() as uint); + fn with_buffer(&self, blk: F) where F: FnOnce(*const u8, usize) { + blk(self.data.bytes().as_ptr(), self.data.len() as usize); } } diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index 8ecffcf142d..23e9664fd9f 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -45,15 +45,15 @@ impl GlyphEntry { let id_mask = id as u32; let Au(advance) = advance; - let advance_mask = (advance as u32) << GLYPH_ADVANCE_SHIFT as uint; + let advance_mask = (advance as u32) << GLYPH_ADVANCE_SHIFT; GlyphEntry::new(id_mask | advance_mask | FLAG_IS_SIMPLE_GLYPH) } // Create a GlyphEntry for uncommon case; should be accompanied by // initialization of the actual DetailedGlyph data in DetailedGlyphStore - fn complex(starts_cluster: bool, starts_ligature: bool, glyph_count: int) -> GlyphEntry { - assert!(glyph_count <= u16::MAX as int); + fn complex(starts_cluster: bool, starts_ligature: bool, glyph_count: usize) -> GlyphEntry { + assert!(glyph_count <= u16::MAX as usize); debug!("creating complex glyph entry: starts_cluster={}, starts_ligature={}, \ glyph_count={}", @@ -69,17 +69,17 @@ impl GlyphEntry { if !starts_ligature { val |= FLAG_NOT_LIGATURE_GROUP_START; } - val |= (glyph_count as u32) << GLYPH_COUNT_SHIFT as uint; + val |= (glyph_count as u32) << GLYPH_COUNT_SHIFT; GlyphEntry::new(val) } /// Create a GlyphEntry for the case where glyphs couldn't be found for the specified /// character. - fn missing(glyph_count: int) -> GlyphEntry { - assert!(glyph_count <= u16::MAX as int); + fn missing(glyph_count: usize) -> GlyphEntry { + assert!(glyph_count <= u16::MAX as usize); - GlyphEntry::new((glyph_count as u32) << GLYPH_COUNT_SHIFT as uint) + GlyphEntry::new((glyph_count as u32) << GLYPH_COUNT_SHIFT) } } @@ -158,7 +158,7 @@ fn is_simple_glyph_id(id: GlyphId) -> bool { fn is_simple_advance(advance: Au) -> bool { match advance.to_u32() { Some(unsigned_au) => - (unsigned_au & (GLYPH_ADVANCE_MASK >> GLYPH_ADVANCE_SHIFT as uint)) == unsigned_au, + (unsigned_au & (GLYPH_ADVANCE_MASK >> GLYPH_ADVANCE_SHIFT)) == unsigned_au, None => false } } @@ -171,7 +171,7 @@ impl GlyphEntry { // getter methods #[inline(always)] fn advance(&self) -> Au { - NumCast::from((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT as uint).unwrap() + NumCast::from((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT).unwrap() } fn id(&self) -> GlyphId { @@ -201,7 +201,7 @@ impl GlyphEntry { } fn can_break_before(&self) -> BreakType { - let flag = ((self.value & FLAG_CAN_BREAK_MASK) >> FLAG_CAN_BREAK_SHIFT as uint) as u8; + let flag = ((self.value & FLAG_CAN_BREAK_MASK) >> FLAG_CAN_BREAK_SHIFT) as u8; break_flag_to_enum(flag) } @@ -225,7 +225,7 @@ impl GlyphEntry { #[inline(always)] fn set_can_break_before(&self, e: BreakType) -> GlyphEntry { - let flag = (break_enum_to_flag(e) as u32) << FLAG_CAN_BREAK_SHIFT as uint; + let flag = (break_enum_to_flag(e) as u32) << FLAG_CAN_BREAK_SHIFT; GlyphEntry::new(self.value | flag) } @@ -233,7 +233,7 @@ impl GlyphEntry { fn glyph_count(&self) -> u16 { assert!(!self.is_simple()); - ((self.value & GLYPH_COUNT_MASK) >> GLYPH_COUNT_SHIFT as uint) as u16 + ((self.value & GLYPH_COUNT_MASK) >> GLYPH_COUNT_SHIFT) as u16 } #[inline(always)] @@ -278,7 +278,7 @@ struct DetailedGlyphRecord { // source string offset/GlyphEntry offset in the TextRun entry_offset: CharIndex, // offset into the detailed glyphs buffer - detail_offset: int, + detail_offset: usize, } impl PartialOrd for DetailedGlyphRecord { @@ -320,7 +320,7 @@ impl<'a> DetailedGlyphStore { fn add_detailed_glyphs_for_entry(&mut self, entry_offset: CharIndex, glyphs: &[DetailedGlyph]) { let entry = DetailedGlyphRecord { entry_offset: entry_offset, - detail_offset: self.detail_buffer.len() as int, + detail_offset: self.detail_buffer.len(), }; debug!("Adding entry[off={:?}] for detailed glyphs: {:?}", entry_offset, glyphs); @@ -351,7 +351,7 @@ impl<'a> DetailedGlyphStore { return &self.detail_buffer[0..0]; } - assert!((count as uint) <= self.detail_buffer.len()); + assert!((count as usize) <= self.detail_buffer.len()); assert!(self.lookup_is_sorted); let key = DetailedGlyphRecord { @@ -362,16 +362,16 @@ impl<'a> DetailedGlyphStore { let i = (&*self.detail_lookup).binary_search_index(&key) .expect("Invalid index not found in detailed glyph lookup table!"); - assert!(i + (count as uint) <= self.detail_buffer.len()); + assert!(i + (count as usize) <= self.detail_buffer.len()); // return a slice into the buffer - &self.detail_buffer[i .. i + count as uint] + &self.detail_buffer[i .. i + count as usize] } fn get_detailed_glyph_with_index(&'a self, entry_offset: CharIndex, detail_offset: u16) -> &'a DetailedGlyph { - assert!((detail_offset as uint) <= self.detail_buffer.len()); + assert!((detail_offset as usize) <= self.detail_buffer.len()); assert!(self.lookup_is_sorted); let key = DetailedGlyphRecord { @@ -382,8 +382,8 @@ impl<'a> DetailedGlyphStore { let i = self.detail_lookup.as_slice().binary_search_index(&key) .expect("Invalid index not found in detailed glyph lookup table!"); - assert!(i + (detail_offset as uint) < self.detail_buffer.len()); - &self.detail_buffer[i + (detail_offset as uint)] + assert!(i + (detail_offset as usize) < self.detail_buffer.len()); + &self.detail_buffer[i + (detail_offset as usize)] } fn ensure_sorted(&mut self) { @@ -528,11 +528,11 @@ int_range_index! { impl<'a> GlyphStore { // Initializes the glyph store, but doesn't actually shape anything. // Use the set_glyph, set_glyphs() methods to store glyph data. - pub fn new(length: int, is_whitespace: bool) -> GlyphStore { + pub fn new(length: usize, is_whitespace: bool) -> GlyphStore { assert!(length > 0); GlyphStore { - entry_buffer: repeat(GlyphEntry::initial()).take(length as uint) + entry_buffer: repeat(GlyphEntry::initial()).take(length) .collect(), detail_store: DetailedGlyphStore::new(), is_whitespace: is_whitespace, @@ -591,13 +591,13 @@ impl<'a> GlyphStore { assert!(i < self.char_len()); assert!(data_for_glyphs.len() > 0); - let glyph_count = data_for_glyphs.len() as int; + let glyph_count = data_for_glyphs.len(); let first_glyph_data = data_for_glyphs[0]; let entry = match first_glyph_data.is_missing { true => GlyphEntry::missing(glyph_count), false => { - let glyphs_vec: Vec = (0..glyph_count as uint).map(|i| { + let glyphs_vec: Vec = (0..glyph_count).map(|i| { DetailedGlyph::new(data_for_glyphs[i].id, data_for_glyphs[i].advance, data_for_glyphs[i].offset) @@ -730,10 +730,10 @@ impl<'a> GlyphStore { if entry.is_simple() && entry.char_is_space() { // FIXME(pcwalton): This can overflow for very large font-sizes. let advance = - ((entry.value & GLYPH_ADVANCE_MASK) >> (GLYPH_ADVANCE_SHIFT as uint)) + + ((entry.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) + Au::from_frac_px(space).to_u32().unwrap(); entry.value = (entry.value & !GLYPH_ADVANCE_MASK) | - (advance << (GLYPH_ADVANCE_SHIFT as uint)); + (advance << GLYPH_ADVANCE_SHIFT); } } } diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index f8ad5ef4a6c..5a8a52cc130 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -61,7 +61,7 @@ static KERN: u32 = hb_tag!('k', 'e', 'r', 'n'); static LIGA: u32 = hb_tag!('l', 'i', 'g', 'a'); pub struct ShapedGlyphData { - count: int, + count: usize, glyph_infos: *mut hb_glyph_info_t, pos_infos: *mut hb_glyph_position_t, } @@ -77,16 +77,14 @@ impl ShapedGlyphData { unsafe { let mut glyph_count = 0; let glyph_infos = RUST_hb_buffer_get_glyph_infos(buffer, &mut glyph_count); - let glyph_count = glyph_count as int; assert!(!glyph_infos.is_null()); let mut pos_count = 0; let pos_infos = RUST_hb_buffer_get_glyph_positions(buffer, &mut pos_count); - let pos_count = pos_count as int; assert!(!pos_infos.is_null()); assert!(glyph_count == pos_count); ShapedGlyphData { - count: glyph_count, + count: glyph_count as usize, glyph_infos: glyph_infos, pos_infos: pos_infos, } @@ -94,26 +92,26 @@ impl ShapedGlyphData { } #[inline(always)] - fn byte_offset_of_glyph(&self, i: int) -> int { + fn byte_offset_of_glyph(&self, i: usize) -> u32 { assert!(i < self.count); unsafe { - let glyph_info_i = self.glyph_infos.offset(i); - (*glyph_info_i).cluster as int + let glyph_info_i = self.glyph_infos.offset(i as isize); + (*glyph_info_i).cluster } } - pub fn len(&self) -> int { + pub fn len(&self) -> usize { self.count } /// Returns shaped glyph data for one glyph, and updates the y-position of the pen. - pub fn get_entry_for_glyph(&self, i: int, y_pos: &mut Au) -> ShapedGlyphEntry { + pub fn get_entry_for_glyph(&self, i: usize, y_pos: &mut Au) -> ShapedGlyphEntry { assert!(i < self.count); unsafe { - let glyph_info_i = self.glyph_infos.offset(i); - let pos_info_i = self.pos_infos.offset(i); + let glyph_info_i = self.glyph_infos.offset(i as isize); + let pos_info_i = self.pos_infos.offset(i as isize); let x_offset = Shaper::fixed_to_float((*pos_info_i).x_offset); let y_offset = Shaper::fixed_to_float((*pos_info_i).y_offset); let x_advance = Shaper::fixed_to_float((*pos_info_i).x_advance); @@ -273,8 +271,8 @@ impl Shaper { buffer: *mut hb_buffer_t) { let glyph_data = ShapedGlyphData::new(buffer); let glyph_count = glyph_data.len(); - let byte_max = text.len() as int; - let char_max = text.chars().count() as int; + let byte_max = text.len(); + let char_max = text.chars().count(); // GlyphStore records are indexed by character, not byte offset. // so, we must be careful to increment this when saving glyph entries. @@ -296,9 +294,9 @@ impl Shaper { // fast path: all chars are single-byte. if byte_max == char_max { - byte_to_glyph = repeat(NO_GLYPH).take(byte_max as uint).collect(); + byte_to_glyph = repeat(NO_GLYPH).take(byte_max).collect(); } else { - byte_to_glyph = repeat(CONTINUATION_BYTE).take(byte_max as uint) + byte_to_glyph = repeat(CONTINUATION_BYTE).take(byte_max) .collect(); for (i, _) in text.char_indices() { byte_to_glyph[i] = NO_GLYPH; @@ -308,10 +306,10 @@ impl Shaper { debug!("(glyph idx) -> (text byte offset)"); for i in 0..glyph_data.len() { // loc refers to a *byte* offset within the utf8 string. - let loc = glyph_data.byte_offset_of_glyph(i); + let loc = glyph_data.byte_offset_of_glyph(i) as usize; if loc < byte_max { - assert!(byte_to_glyph[loc as uint] != CONTINUATION_BYTE); - byte_to_glyph[loc as uint] = i as i32; + assert!(byte_to_glyph[loc] != CONTINUATION_BYTE); + byte_to_glyph[loc] = i as i32; } else { debug!("ERROR: tried to set out of range byte_to_glyph: idx={}, glyph idx={}", loc, @@ -327,10 +325,10 @@ impl Shaper { } // some helpers - let mut glyph_span: Range = Range::empty(); + let mut glyph_span: Range = Range::empty(); // this span contains first byte of first char, to last byte of last char in range. // so, end() points to first byte of last+1 char, if it's less than byte_max. - let mut char_byte_span: Range = Range::empty(); + let mut char_byte_span: Range = Range::empty(); let mut y_pos = Au(0); // main loop over each glyph. each iteration usually processes 1 glyph and 1+ chars. @@ -342,33 +340,33 @@ impl Shaper { debug!("Processing glyph at idx={}", glyph_span.begin()); let char_byte_start = glyph_data.byte_offset_of_glyph(glyph_span.begin()); - char_byte_span.reset(char_byte_start, 0); + char_byte_span.reset(char_byte_start as usize, 0); // find a range of chars corresponding to this glyph, plus // any trailing chars that do not have associated glyphs. while char_byte_span.end() < byte_max { - let range = text.char_range_at(char_byte_span.end() as uint); + let range = text.char_range_at(char_byte_span.end()); drop(range.ch); - char_byte_span.extend_to(range.next as int); + char_byte_span.extend_to(range.next); debug!("Processing char byte span: off={}, len={} for glyph idx={}", char_byte_span.begin(), char_byte_span.length(), glyph_span.begin()); while char_byte_span.end() != byte_max && - byte_to_glyph[char_byte_span.end() as uint] == NO_GLYPH { + byte_to_glyph[char_byte_span.end()] == NO_GLYPH { debug!("Extending char byte span to include byte offset={} with no associated \ glyph", char_byte_span.end()); - let range = text.char_range_at(char_byte_span.end() as uint); + let range = text.char_range_at(char_byte_span.end()); drop(range.ch); - char_byte_span.extend_to(range.next as int); + char_byte_span.extend_to(range.next); } // extend glyph range to max glyph index covered by char_span, // in cases where one char made several glyphs and left some unassociated chars. let mut max_glyph_idx = glyph_span.end(); for i in char_byte_span.each_index() { - if byte_to_glyph[i as uint] > NO_GLYPH { - max_glyph_idx = cmp::max(byte_to_glyph[i as uint] as int + 1, max_glyph_idx); + if byte_to_glyph[i] > NO_GLYPH { + max_glyph_idx = cmp::max(byte_to_glyph[i] as usize + 1, max_glyph_idx); } } @@ -392,7 +390,7 @@ impl Shaper { let mut all_glyphs_are_within_cluster: bool = true; for j in glyph_span.each_index() { let loc = glyph_data.byte_offset_of_glyph(j); - if !char_byte_span.contains(loc) { + if !char_byte_span.contains(loc as usize) { all_glyphs_are_within_cluster = false; break } @@ -427,10 +425,10 @@ impl Shaper { let mut covered_byte_span = char_byte_span.clone(); // extend, clipping at end of text range. while covered_byte_span.end() < byte_max - && byte_to_glyph[covered_byte_span.end() as uint] == NO_GLYPH { - let range = text.char_range_at(covered_byte_span.end() as uint); + && byte_to_glyph[covered_byte_span.end()] == NO_GLYPH { + let range = text.char_range_at(covered_byte_span.end()); drop(range.ch); - covered_byte_span.extend_to(range.next as int); + covered_byte_span.extend_to(range.next); } if covered_byte_span.begin() >= byte_max { @@ -456,7 +454,7 @@ impl Shaper { // NB: When we acquire the ability to handle ligatures that cross word boundaries, // we'll need to do something special to handle `word-spacing` properly. let shape = glyph_data.get_entry_for_glyph(glyph_span.begin(), &mut y_pos); - let character = text.char_at(char_byte_span.begin() as uint); + let character = text.char_at(char_byte_span.begin()); let advance = self.advance_for_shaped_glyph(shape.advance, character, options); let data = GlyphData::new(shape.codepoint, advance, @@ -486,9 +484,9 @@ impl Shaper { // set the other chars, who have no glyphs let mut i = covered_byte_span.begin(); loop { - let range = text.char_range_at(i as uint); + let range = text.char_range_at(i); drop(range.ch); - i = range.next as int; + i = range.next; if i >= covered_byte_span.end() { break; } char_idx = char_idx + CharIndex(1); glyphs.add_nonglyph_for_char_index(char_idx, false, false); @@ -613,7 +611,7 @@ extern fn get_font_table_func(_: *mut hb_face_t, let skinny_font_table_ptr: *const FontTable = font_table; // private context let mut blob: *mut hb_blob_t = ptr::null_mut(); - (*skinny_font_table_ptr).with_buffer(|buf: *const u8, len: uint| { + (*skinny_font_table_ptr).with_buffer(|buf: *const u8, len: usize| { // HarfBuzz calls `destroy_blob_func` when the buffer is no longer needed. blob = RUST_hb_blob_create(buf as *const c_char, len as c_uint, diff --git a/components/gfx/text/text_run.rs b/components/gfx/text/text_run.rs index eadcffcd733..93c4c6c50b9 100644 --- a/components/gfx/text/text_run.rs +++ b/components/gfx/text/text_run.rs @@ -201,7 +201,7 @@ impl<'a> TextRun { -> Vec { // TODO(Issue #230): do a better job. See Gecko's LineBreaker. let mut glyphs = vec!(); - let (mut byte_i, mut char_i) = (0u, CharIndex(0)); + let (mut byte_i, mut char_i) = (0, CharIndex(0)); let mut cur_slice_is_whitespace = false; let (mut byte_last_boundary, mut char_last_boundary) = (0, CharIndex(0)); while byte_i < text.len() { @@ -330,7 +330,7 @@ impl<'a> TextRun { } /// Returns the index of the first glyph run containing the given character index. - fn index_of_first_glyph_run_containing(&self, index: CharIndex) -> Option { + fn index_of_first_glyph_run_containing(&self, index: CharIndex) -> Option { (&**self.glyphs).binary_search_index_by(&index, CharIndexComparator) } diff --git a/components/gfx/text/util.rs b/components/gfx/text/util.rs index 42bba6c449e..890069b401c 100644 --- a/components/gfx/text/util.rs +++ b/components/gfx/text/util.rs @@ -111,19 +111,19 @@ pub fn transform_text(text: &str, } } -pub fn float_to_fixed(before: int, f: f64) -> i32 { - ((1i32 << before as uint) as f64 * f) as i32 +pub fn float_to_fixed(before: usize, f: f64) -> i32 { + ((1i32 << before) as f64 * f) as i32 } -pub fn fixed_to_float(before: int, f: i32) -> f64 { - f as f64 * 1.0f64 / ((1i32 << before as uint) as f64) +pub fn fixed_to_float(before: usize, f: i32) -> f64 { + f as f64 * 1.0f64 / ((1i32 << before) as f64) } -pub fn fixed_to_rounded_int(before: int, f: i32) -> int { - let half = 1i32 << (before-1) as uint; +pub fn fixed_to_rounded_int(before: isize, f: i32) -> isize { + let half = 1i32 << (before-1) as usize; if f > 0i32 { - ((half + f) >> before as uint) as int + ((half + f) >> before) as isize } else { - -((half - f) >> before as uint) as int + -((half - f) >> before) as isize } } diff --git a/components/util/range.rs b/components/util/range.rs index 0df81a7b413..8873641cc10 100644 --- a/components/util/range.rs +++ b/components/util/range.rs @@ -25,6 +25,15 @@ impl RangeIndex for isize { fn get(self) -> isize { self } } +impl RangeIndex for usize { + type Index = usize; + #[inline] + fn new(x: usize) -> usize { x } + + #[inline] + fn get(self) -> usize { self } +} + /// Implements a range index type with operator overloads #[macro_export] macro_rules! int_range_index {