auto merge of #5486 : Ms2ger/servo/int, r=jdm

This commit is contained in:
bors-servo 2015-04-02 08:06:41 -06:00
commit d999fb9db0
15 changed files with 55 additions and 55 deletions

View file

@ -522,7 +522,7 @@ int_range_index! {
#[derive(RustcEncodable)] #[derive(RustcEncodable)]
#[doc = "An index that refers to a character in a text run. This could \ #[doc = "An index that refers to a character in a text run. This could \
point to the middle of a glyph."] point to the middle of a glyph."]
struct CharIndex(int) struct CharIndex(isize)
} }
impl<'a> GlyphStore { impl<'a> GlyphStore {
@ -540,7 +540,7 @@ impl<'a> GlyphStore {
} }
pub fn char_len(&self) -> CharIndex { pub fn char_len(&self) -> CharIndex {
CharIndex(self.entry_buffer.len() as int) CharIndex(self.entry_buffer.len() as isize)
} }
pub fn is_whitespace(&self) -> bool { pub fn is_whitespace(&self) -> bool {
@ -743,8 +743,8 @@ impl<'a> GlyphStore {
pub struct GlyphIterator<'a> { pub struct GlyphIterator<'a> {
store: &'a GlyphStore, store: &'a GlyphStore,
char_index: CharIndex, char_index: CharIndex,
char_range: EachIndex<int, CharIndex>, char_range: EachIndex<isize, CharIndex>,
glyph_range: Option<EachIndex<int, CharIndex>>, glyph_range: Option<EachIndex<isize, CharIndex>>,
} }
impl<'a> GlyphIterator<'a> { impl<'a> GlyphIterator<'a> {
@ -767,7 +767,7 @@ impl<'a> GlyphIterator<'a> {
fn next_complex_glyph(&mut self, entry: &GlyphEntry, i: CharIndex) fn next_complex_glyph(&mut self, entry: &GlyphEntry, i: CharIndex)
-> Option<(CharIndex, GlyphInfo<'a>)> { -> Option<(CharIndex, GlyphInfo<'a>)> {
let glyphs = self.store.detail_store.get_detailed_glyphs_for_entry(i, entry.glyph_count()); let glyphs = self.store.detail_store.get_detailed_glyphs_for_entry(i, entry.glyph_count());
self.glyph_range = Some(range::each_index(CharIndex(0), CharIndex(glyphs.len() as int))); self.glyph_range = Some(range::each_index(CharIndex(0), CharIndex(glyphs.len() as isize)));
self.next() self.next()
} }
} }

View file

@ -92,8 +92,8 @@ impl ConstructionResult {
pub fn debug_id(&self) -> usize { pub fn debug_id(&self) -> usize {
match self { match self {
&ConstructionResult::None => 0u, &ConstructionResult::None => 0,
&ConstructionResult::ConstructionItem(_) => 0u, &ConstructionResult::ConstructionItem(_) => 0,
&ConstructionResult::Flow(ref flow_ref, _) => flow::base(&**flow_ref).debug_id(), &ConstructionResult::Flow(ref flow_ref, _) => flow::base(&**flow_ref).debug_id(),
} }
} }

View file

@ -345,8 +345,8 @@ impl FragmentDisplayListBuilding for Fragment {
// wide. // wide.
let image_aspect_ratio = (image.width as f64) / (image.height as f64); let image_aspect_ratio = (image.width as f64) / (image.height as f64);
let bounds_aspect_ratio = bounds.size.width.to_subpx() / bounds.size.height.to_subpx(); let bounds_aspect_ratio = bounds.size.width.to_subpx() / bounds.size.height.to_subpx();
let intrinsic_size = Size2D(Au::from_px(image.width as int), let intrinsic_size = Size2D(Au::from_px(image.width as isize),
Au::from_px(image.height as int)); Au::from_px(image.height as isize));
match (style.get_background().background_size.clone(), match (style.get_background().background_size.clone(),
image_aspect_ratio < bounds_aspect_ratio) { image_aspect_ratio < bounds_aspect_ratio) {
(background_size::T::Contain, false) | (background_size::T::Cover, true) => { (background_size::T::Contain, false) | (background_size::T::Cover, true) => {
@ -997,9 +997,9 @@ impl FragmentDisplayListBuilding for Fragment {
} }
SpecificFragmentInfo::Canvas(ref canvas_fragment_info) => { SpecificFragmentInfo::Canvas(ref canvas_fragment_info) => {
let width = canvas_fragment_info.replaced_image_fragment_info let width = canvas_fragment_info.replaced_image_fragment_info
.computed_inline_size.map_or(0, |w| to_px(w) as uint); .computed_inline_size.map_or(0, |w| to_px(w) as usize);
let height = canvas_fragment_info.replaced_image_fragment_info let height = canvas_fragment_info.replaced_image_fragment_info
.computed_block_size.map_or(0, |h| to_px(h) as uint); .computed_block_size.map_or(0, |h| to_px(h) as usize);
let (sender, receiver) = channel::<Vec<u8>>(); let (sender, receiver) = channel::<Vec<u8>>();
let canvas_data = match canvas_fragment_info.renderer { let canvas_data = match canvas_fragment_info.renderer {
@ -1534,8 +1534,8 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
struct StopRun { struct StopRun {
start_offset: f32, start_offset: f32,
end_offset: f32, end_offset: f32,
start_index: uint, start_index: usize,
stop_count: uint, stop_count: usize,
} }
fn fmin(a: f32, b: f32) -> f32 { fn fmin(a: f32, b: f32) -> f32 {

View file

@ -394,7 +394,7 @@ pub trait ImmutableFlowUtils {
fn is_leaf(self) -> bool; fn is_leaf(self) -> bool;
/// Returns the number of children that this flow possesses. /// Returns the number of children that this flow possesses.
fn child_count(self) -> uint; fn child_count(self) -> usize;
/// Return true if this flow is a Block Container. /// Return true if this flow is a Block Container.
fn is_block_container(self) -> bool; fn is_block_container(self) -> bool;
@ -409,7 +409,7 @@ pub trait ImmutableFlowUtils {
fn dump(self); fn dump(self);
/// Dumps the flow tree for debugging, with a prefix to indicate that we're at the given level. /// Dumps the flow tree for debugging, with a prefix to indicate that we're at the given level.
fn dump_with_level(self, level: uint); fn dump_with_level(self, level: u32);
} }
pub trait MutableFlowUtils { pub trait MutableFlowUtils {
@ -561,7 +561,7 @@ static HAS_FLOATED_DESCENDANTS_BITMASK: FlowFlags = FlowFlags { bits: 0b0000_001
/// The number of bits we must shift off to handle the text alignment field. /// The number of bits we must shift off to handle the text alignment field.
/// ///
/// NB: If you update this, update `TEXT_ALIGN` above. /// NB: If you update this, update `TEXT_ALIGN` above.
static TEXT_ALIGN_SHIFT: uint = 11; static TEXT_ALIGN_SHIFT: usize = 11;
impl FlowFlags { impl FlowFlags {
/// Propagates text alignment flags from an appropriate parent flow per CSS 2.1. /// Propagates text alignment flags from an appropriate parent flow per CSS 2.1.
@ -650,7 +650,7 @@ impl Descendants {
} }
} }
pub fn len(&self) -> uint { pub fn len(&self) -> usize {
self.descendant_links.len() self.descendant_links.len()
} }
@ -1152,7 +1152,7 @@ impl<'a> ImmutableFlowUtils for &'a (Flow + 'a) {
} }
/// Returns the number of children that this flow possesses. /// Returns the number of children that this flow possesses.
fn child_count(self) -> uint { fn child_count(self) -> usize {
base(self).children.len() base(self).children.len()
} }
@ -1195,7 +1195,7 @@ impl<'a> ImmutableFlowUtils for &'a (Flow + 'a) {
} }
/// Dumps the flow tree for debugging, with a prefix to indicate that we're at the given level. /// Dumps the flow tree for debugging, with a prefix to indicate that we're at the given level.
fn dump_with_level(self, level: uint) { fn dump_with_level(self, level: u32) {
let mut indent = String::new(); let mut indent = String::new();
for _ in range(0, level) { for _ in range(0, level) {
indent.push_str("| ") indent.push_str("| ")

View file

@ -274,8 +274,8 @@ impl CanvasFragmentInfo {
pub fn new(node: &ThreadSafeLayoutNode) -> CanvasFragmentInfo { pub fn new(node: &ThreadSafeLayoutNode) -> CanvasFragmentInfo {
CanvasFragmentInfo { CanvasFragmentInfo {
replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node, replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node,
Some(Au::from_px(node.get_canvas_width() as int)), Some(Au::from_px(node.get_canvas_width() as isize)),
Some(Au::from_px(node.get_canvas_height() as int))), Some(Au::from_px(node.get_canvas_height() as isize))),
renderer: node.get_renderer().map(|rec| Arc::new(Mutex::new(rec))), renderer: node.get_renderer().map(|rec| Arc::new(Mutex::new(rec))),
} }
} }
@ -311,10 +311,9 @@ impl ImageFragmentInfo {
-> ImageFragmentInfo { -> ImageFragmentInfo {
fn convert_length(node: &ThreadSafeLayoutNode, name: &Atom) -> Option<Au> { fn convert_length(node: &ThreadSafeLayoutNode, name: &Atom) -> Option<Au> {
let element = node.as_element(); let element = node.as_element();
element.get_attr(&ns!(""), name).and_then(|string| { element.get_attr(&ns!(""), name)
let n: Option<int> = FromStr::from_str(string).ok(); .and_then(|string| string.parse::<isize>().ok())
n .map(|pixels| Au::from_px(pixels))
}).and_then(|pixels| Some(Au::from_px(pixels)))
} }
ImageFragmentInfo { ImageFragmentInfo {
@ -342,7 +341,7 @@ impl ImageFragmentInfo {
/// Tile an image /// Tile an image
pub fn tile_image(position: &mut Au, size: &mut Au, pub fn tile_image(position: &mut Au, size: &mut Au,
virtual_position: Au, image_size: u32) { virtual_position: Au, image_size: u32) {
let image_size = image_size as int; let image_size = image_size as isize;
let delta_pixels = geometry::to_px(virtual_position - *position); let delta_pixels = geometry::to_px(virtual_position - *position);
let tile_count = (delta_pixels + image_size - 1) / image_size; let tile_count = (delta_pixels + image_size - 1) / image_size;
let offset = Au::from_px(image_size * tile_count); let offset = Au::from_px(image_size * tile_count);
@ -672,7 +671,7 @@ impl UnscannedTextFragmentInfo {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct TableColumnFragmentInfo { pub struct TableColumnFragmentInfo {
/// the number of columns a <col> element should span /// the number of columns a <col> element should span
pub span: int, pub span: u32,
} }
impl TableColumnFragmentInfo { impl TableColumnFragmentInfo {
@ -681,7 +680,7 @@ impl TableColumnFragmentInfo {
let span = { let span = {
let element = node.as_element(); let element = node.as_element();
element.get_attr(&ns!(""), &atom!("span")).and_then(|string| { element.get_attr(&ns!(""), &atom!("span")).and_then(|string| {
let n: Option<int> = FromStr::from_str(string).ok(); let n: Option<u32> = FromStr::from_str(string).ok();
n n
}).unwrap_or(0) }).unwrap_or(0)
}; };
@ -1504,7 +1503,7 @@ impl Fragment {
return None return None
}; };
let mut pieces_processed_count: uint = 0; let mut pieces_processed_count: u32 = 0;
let mut remaining_inline_size = max_inline_size; let mut remaining_inline_size = max_inline_size;
let mut inline_start_range = Range::new(text_fragment_info.range.begin(), CharIndex(0)); let mut inline_start_range = Range::new(text_fragment_info.range.begin(), CharIndex(0));
let mut inline_end_range = None; let mut inline_end_range = None;
@ -1602,7 +1601,7 @@ impl Fragment {
let inline_end_fragment_text = let inline_end_fragment_text =
text_fragment_info.run.text.slice_chars(inline_end_range.begin().to_usize(), text_fragment_info.run.text.slice_chars(inline_end_range.begin().to_usize(),
inline_end_range.end().to_usize()); inline_end_range.end().to_usize());
let mut leading_whitespace_character_count = 0i; let mut leading_whitespace_character_count = 0;
for ch in inline_end_fragment_text.chars() { for ch in inline_end_fragment_text.chars() {
if ch.is_whitespace() { if ch.is_whitespace() {
leading_whitespace_character_count += 1 leading_whitespace_character_count += 1
@ -2129,7 +2128,7 @@ pub enum CoordinateSystem {
fn strip_trailing_whitespace(text_run: &TextRun, range: &mut Range<CharIndex>) -> bool { fn strip_trailing_whitespace(text_run: &TextRun, range: &mut Range<CharIndex>) -> bool {
// FIXME(pcwalton): Is there a more clever (i.e. faster) way to do this? // FIXME(pcwalton): Is there a more clever (i.e. faster) way to do this?
let text = text_run.text.slice_chars(range.begin().to_usize(), range.end().to_usize()); let text = text_run.text.slice_chars(range.begin().to_usize(), range.end().to_usize());
let mut trailing_whitespace_character_count = 0i; let mut trailing_whitespace_character_count = 0;
for ch in text.chars().rev() { for ch in text.chars().rev() {
if ch.is_whitespace() { if ch.is_whitespace() {
trailing_whitespace_character_count += 1 trailing_whitespace_character_count += 1

View file

@ -293,10 +293,10 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> {
let quotes = &style.get_list().quotes; let quotes = &style.get_list().quotes;
debug_assert!(!quotes.0.is_empty()); debug_assert!(!quotes.0.is_empty());
let &(ref open_quote, ref close_quote) = let &(ref open_quote, ref close_quote) =
if self.traversal.quote as uint >= quotes.0.len() { if self.traversal.quote as usize >= quotes.0.len() {
quotes.0.last().unwrap() quotes.0.last().unwrap()
} else { } else {
&quotes.0[self.traversal.quote as uint] &quotes.0[self.traversal.quote as usize]
}; };
if close { if close {
close_quote.to_string() close_quote.to_string()
@ -525,9 +525,9 @@ fn push_alphabetic_representation(mut value: i32, system: &[char], accumulator:
// Step 1. // Step 1.
value = value - 1; value = value - 1;
// Step 2. // Step 2.
string.push(system[(value as uint) % system.len()]); string.push(system[(value as usize) % system.len()]);
// Step 3. // Step 3.
value = ((value as uint) / system.len()) as i32; value = ((value as usize) / system.len()) as i32;
} }
for i in range(0, string.len()).rev() { for i in range(0, string.len()).rev() {
@ -548,9 +548,9 @@ fn push_numeric_representation(mut value: i32, system: &[char], accumulator: &mu
let mut string = SmallVec8::new(); let mut string = SmallVec8::new();
while value != 0 { while value != 0 {
// Step 2.1. // Step 2.1.
string.push(system[(value as uint) % system.len()]); string.push(system[(value as usize) % system.len()]);
// Step 2.2. // Step 2.2.
value = ((value as uint) / system.len()) as i32; value = ((value as usize) / system.len()) as i32;
} }
// Step 3. // Step 3.

View file

@ -154,7 +154,7 @@ pub struct Line {
int_range_index! { int_range_index! {
#[derive(RustcEncodable)] #[derive(RustcEncodable)]
#[doc = "The index of a fragment in a flattened vector of DOM elements."] #[doc = "The index of a fragment in a flattened vector of DOM elements."]
struct FragmentIndex(int) struct FragmentIndex(isize)
} }
bitflags! { bitflags! {
@ -642,8 +642,8 @@ impl LineBreaker {
fn push_fragment_to_line(&mut self, layout_context: &LayoutContext, fragment: Fragment) { fn push_fragment_to_line(&mut self, layout_context: &LayoutContext, fragment: Fragment) {
let indentation = self.indentation_for_pending_fragment(); let indentation = self.indentation_for_pending_fragment();
if self.pending_line_is_empty() { if self.pending_line_is_empty() {
assert!(self.new_fragments.len() <= (u16::MAX as uint)); assert!(self.new_fragments.len() <= (u16::MAX as usize));
self.pending_line.range.reset(FragmentIndex(self.new_fragments.len() as int), self.pending_line.range.reset(FragmentIndex(self.new_fragments.len() as isize),
FragmentIndex(0)); FragmentIndex(0));
} }
@ -727,7 +727,7 @@ impl InlineFragments {
} }
/// Returns the number of inline fragments. /// Returns the number of inline fragments.
pub fn len(&self) -> uint { pub fn len(&self) -> usize {
self.fragments.len() self.fragments.len()
} }
@ -748,12 +748,12 @@ impl InlineFragments {
} }
/// A convenience function to return the fragment at a given index. /// A convenience function to return the fragment at a given index.
pub fn get<'a>(&'a self, index: uint) -> &'a Fragment { pub fn get<'a>(&'a self, index: usize) -> &'a Fragment {
&self.fragments[index] &self.fragments[index]
} }
/// A convenience function to return a mutable reference to the fragment at a given index. /// A convenience function to return a mutable reference to the fragment at a given index.
pub fn get_mut<'a>(&'a mut self, index: uint) -> &'a mut Fragment { pub fn get_mut<'a>(&'a mut self, index: usize) -> &'a mut Fragment {
&mut self.fragments[index] &mut self.fragments[index]
} }
} }

View file

@ -192,7 +192,7 @@ impl ImageResponder<UntrustedNodeAddress> for LayoutImageResponder {
let script_chan = self.script_chan.clone(); let script_chan = self.script_chan.clone();
box move |_, node_address| { box move |_, node_address| {
let ScriptControlChan(ref chan) = script_chan; let ScriptControlChan(ref chan) = script_chan;
debug!("Dirtying {:x}", node_address.0 as uint); debug!("Dirtying {:p}", node_address.0);
let mut nodes = SmallVec1::new(); let mut nodes = SmallVec1::new();
nodes.vec_push(node_address); nodes.vec_push(node_address);
drop(chan.send(ConstellationControlMsg::SendEvent( drop(chan.send(ConstellationControlMsg::SendEvent(

View file

@ -6,7 +6,6 @@
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections)] #![feature(collections)]
#![feature(core)] #![feature(core)]
#![feature(int_uint)]
#![feature(io)] #![feature(io)]
#![feature(plugin)] #![feature(plugin)]
#![feature(rustc_private)] #![feature(rustc_private)]

View file

@ -109,7 +109,8 @@ pub trait ParallelPreorderDomTraversal : PreorderDomTraversal {
{ {
let mut layout_data_ref = node.mutate_layout_data(); let mut layout_data_ref = node.mutate_layout_data();
let layout_data = layout_data_ref.as_mut().expect("no layout data"); let layout_data = layout_data_ref.as_mut().expect("no layout data");
layout_data.data.parallel.children_count.store(child_count as int, Ordering::Relaxed); layout_data.data.parallel.children_count.store(child_count as isize,
Ordering::Relaxed);
} }
// Possibly enqueue the children. // Possibly enqueue the children.
@ -231,7 +232,8 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
let base = flow::mut_base(&mut **flow); let base = flow::mut_base(&mut **flow);
// Reset the count of children for the next layout traversal. // Reset the count of children for the next layout traversal.
base.parallel.children_count.store(base.children.len() as int, Ordering::Relaxed); base.parallel.children_count.store(base.children.len() as isize,
Ordering::Relaxed);
// Possibly enqueue the parent. // Possibly enqueue the parent.
let unsafe_parent = base.parallel.parent; let unsafe_parent = base.parallel.parent;

View file

@ -595,7 +595,7 @@ impl<'a> ChildInlineSizeInfo<'a> {
/// lays out that child in the inline direction. /// lays out that child in the inline direction.
pub fn propagate_to_child(&self, pub fn propagate_to_child(&self,
kid: &mut Flow, kid: &mut Flow,
child_index: uint, child_index: usize,
content_inline_size: Au, content_inline_size: Au,
writing_mode: WritingMode, writing_mode: WritingMode,
inline_start_margin_edge: &mut Au) { inline_start_margin_edge: &mut Au) {

View file

@ -69,7 +69,7 @@ impl Flow for TableColGroupFlow {
for fragment in self.cols.iter() { for fragment in self.cols.iter() {
// Retrieve the specified value from the appropriate CSS property. // Retrieve the specified value from the appropriate CSS property.
let inline_size = fragment.style().content_inline_size(); let inline_size = fragment.style().content_inline_size();
let span: int = match fragment.specific { let span = match fragment.specific {
SpecificFragmentInfo::TableColumn(col_fragment) => max(col_fragment.span, 1), SpecificFragmentInfo::TableColumn(col_fragment) => max(col_fragment.span, 1),
_ => panic!("non-table-column fragment inside table column?!"), _ => panic!("non-table-column fragment inside table column?!"),
}; };

View file

@ -138,7 +138,7 @@ impl TextRunScanner {
}; };
let mut new_line_pos = Vec::new(); let mut new_line_pos = Vec::new();
let old_length = CharIndex(run_text.chars().count() as int); let old_length = CharIndex(run_text.chars().count() as isize);
last_whitespace = util::transform_text(in_fragment.as_slice(), last_whitespace = util::transform_text(in_fragment.as_slice(),
compression, compression,
last_whitespace, last_whitespace,
@ -146,7 +146,7 @@ impl TextRunScanner {
&mut new_line_pos); &mut new_line_pos);
new_line_positions.push(NewLinePositions(new_line_pos)); new_line_positions.push(NewLinePositions(new_line_pos));
let added_chars = CharIndex(run_text.chars().count() as int) - old_length; let added_chars = CharIndex(run_text.chars().count() as isize) - old_length;
new_ranges.push(Range::new(char_total, added_chars)); new_ranges.push(Range::new(char_total, added_chars));
char_total = char_total + added_chars; char_total = char_total + added_chars;
} }

View file

@ -104,7 +104,7 @@ fn insert_ancestors_into_bloom_filter(bf: &mut Box<BloomFilter>,
mut n: LayoutNode, mut n: LayoutNode,
layout_context: &LayoutContext) { layout_context: &LayoutContext) {
debug!("[{}] Inserting ancestors.", tid()); debug!("[{}] Inserting ancestors.", tid());
let mut ancestors = 0u; let mut ancestors = 0;
loop { loop {
ancestors += 1; ancestors += 1;

View file

@ -346,9 +346,9 @@ impl<'ln> LayoutNode<'ln> {
} }
} }
pub fn debug_id(self) -> uint { pub fn debug_id(self) -> usize {
let opaque: OpaqueNode = OpaqueNodeMethods::from_layout_node(&self); let opaque: OpaqueNode = OpaqueNodeMethods::from_layout_node(&self);
opaque.to_untrusted_node_address().0 as uint opaque.to_untrusted_node_address().0 as usize
} }
} }
@ -807,7 +807,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
} }
} }
pub fn debug_id(self) -> uint { pub fn debug_id(self) -> usize {
self.node.debug_id() self.node.debug_id()
} }