servo: Merge #5486 - Stop using int/uint in layout (from Ms2ger:int); r=jdm

Source-Repo: https://github.com/servo/servo
Source-Revision: d999fb9db0d572f63165fa8aa2e24023903b6332
This commit is contained in:
Ms2ger 2015-04-02 08:06:41 -06:00
Родитель 7e83787b33
Коммит c64ea30626
15 изменённых файлов: 55 добавлений и 55 удалений

Просмотреть файл

@ -522,7 +522,7 @@ int_range_index! {
#[derive(RustcEncodable)]
#[doc = "An index that refers to a character in a text run. This could \
point to the middle of a glyph."]
struct CharIndex(int)
struct CharIndex(isize)
}
impl<'a> GlyphStore {
@ -540,7 +540,7 @@ impl<'a> GlyphStore {
}
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 {
@ -743,8 +743,8 @@ impl<'a> GlyphStore {
pub struct GlyphIterator<'a> {
store: &'a GlyphStore,
char_index: CharIndex,
char_range: EachIndex<int, CharIndex>,
glyph_range: Option<EachIndex<int, CharIndex>>,
char_range: EachIndex<isize, CharIndex>,
glyph_range: Option<EachIndex<isize, CharIndex>>,
}
impl<'a> GlyphIterator<'a> {
@ -767,7 +767,7 @@ impl<'a> GlyphIterator<'a> {
fn next_complex_glyph(&mut self, entry: &GlyphEntry, i: CharIndex)
-> Option<(CharIndex, GlyphInfo<'a>)> {
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()
}
}

Просмотреть файл

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

Просмотреть файл

@ -345,8 +345,8 @@ impl FragmentDisplayListBuilding for Fragment {
// wide.
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 intrinsic_size = Size2D(Au::from_px(image.width as int),
Au::from_px(image.height as int));
let intrinsic_size = Size2D(Au::from_px(image.width as isize),
Au::from_px(image.height as isize));
match (style.get_background().background_size.clone(),
image_aspect_ratio < bounds_aspect_ratio) {
(background_size::T::Contain, false) | (background_size::T::Cover, true) => {
@ -997,9 +997,9 @@ impl FragmentDisplayListBuilding for Fragment {
}
SpecificFragmentInfo::Canvas(ref canvas_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
.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 canvas_data = match canvas_fragment_info.renderer {
@ -1534,8 +1534,8 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
struct StopRun {
start_offset: f32,
end_offset: f32,
start_index: uint,
stop_count: uint,
start_index: usize,
stop_count: usize,
}
fn fmin(a: f32, b: f32) -> f32 {

Просмотреть файл

@ -394,7 +394,7 @@ pub trait ImmutableFlowUtils {
fn is_leaf(self) -> bool;
/// 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.
fn is_block_container(self) -> bool;
@ -409,7 +409,7 @@ pub trait ImmutableFlowUtils {
fn dump(self);
/// 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 {
@ -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.
///
/// NB: If you update this, update `TEXT_ALIGN` above.
static TEXT_ALIGN_SHIFT: uint = 11;
static TEXT_ALIGN_SHIFT: usize = 11;
impl FlowFlags {
/// 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()
}
@ -1152,7 +1152,7 @@ impl<'a> ImmutableFlowUtils for &'a (Flow + 'a) {
}
/// Returns the number of children that this flow possesses.
fn child_count(self) -> uint {
fn child_count(self) -> usize {
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.
fn dump_with_level(self, level: uint) {
fn dump_with_level(self, level: u32) {
let mut indent = String::new();
for _ in range(0, level) {
indent.push_str("| ")

Просмотреть файл

@ -274,8 +274,8 @@ impl CanvasFragmentInfo {
pub fn new(node: &ThreadSafeLayoutNode) -> CanvasFragmentInfo {
CanvasFragmentInfo {
replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node,
Some(Au::from_px(node.get_canvas_width() as int)),
Some(Au::from_px(node.get_canvas_height() as int))),
Some(Au::from_px(node.get_canvas_width() as isize)),
Some(Au::from_px(node.get_canvas_height() as isize))),
renderer: node.get_renderer().map(|rec| Arc::new(Mutex::new(rec))),
}
}
@ -311,10 +311,9 @@ impl ImageFragmentInfo {
-> ImageFragmentInfo {
fn convert_length(node: &ThreadSafeLayoutNode, name: &Atom) -> Option<Au> {
let element = node.as_element();
element.get_attr(&ns!(""), name).and_then(|string| {
let n: Option<int> = FromStr::from_str(string).ok();
n
}).and_then(|pixels| Some(Au::from_px(pixels)))
element.get_attr(&ns!(""), name)
.and_then(|string| string.parse::<isize>().ok())
.map(|pixels| Au::from_px(pixels))
}
ImageFragmentInfo {
@ -342,7 +341,7 @@ impl ImageFragmentInfo {
/// Tile an image
pub fn tile_image(position: &mut Au, size: &mut Au,
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 tile_count = (delta_pixels + image_size - 1) / image_size;
let offset = Au::from_px(image_size * tile_count);
@ -672,7 +671,7 @@ impl UnscannedTextFragmentInfo {
#[derive(Copy, Clone)]
pub struct TableColumnFragmentInfo {
/// the number of columns a <col> element should span
pub span: int,
pub span: u32,
}
impl TableColumnFragmentInfo {
@ -681,7 +680,7 @@ impl TableColumnFragmentInfo {
let span = {
let element = node.as_element();
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
}).unwrap_or(0)
};
@ -1504,7 +1503,7 @@ impl Fragment {
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 inline_start_range = Range::new(text_fragment_info.range.begin(), CharIndex(0));
let mut inline_end_range = None;
@ -1602,7 +1601,7 @@ impl Fragment {
let inline_end_fragment_text =
text_fragment_info.run.text.slice_chars(inline_end_range.begin().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() {
if ch.is_whitespace() {
leading_whitespace_character_count += 1
@ -2129,7 +2128,7 @@ pub enum CoordinateSystem {
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?
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() {
if ch.is_whitespace() {
trailing_whitespace_character_count += 1

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -192,7 +192,7 @@ impl ImageResponder<UntrustedNodeAddress> for LayoutImageResponder {
let script_chan = self.script_chan.clone();
box move |_, node_address| {
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();
nodes.vec_push(node_address);
drop(chan.send(ConstellationControlMsg::SendEvent(

Просмотреть файл

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

Просмотреть файл

@ -109,7 +109,8 @@ pub trait ParallelPreorderDomTraversal : PreorderDomTraversal {
{
let mut layout_data_ref = node.mutate_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.
@ -231,7 +232,8 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
let base = flow::mut_base(&mut **flow);
// 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.
let unsafe_parent = base.parallel.parent;

Просмотреть файл

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

Просмотреть файл

@ -69,7 +69,7 @@ impl Flow for TableColGroupFlow {
for fragment in self.cols.iter() {
// Retrieve the specified value from the appropriate CSS property.
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),
_ => panic!("non-table-column fragment inside table column?!"),
};

Просмотреть файл

@ -138,7 +138,7 @@ impl TextRunScanner {
};
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(),
compression,
last_whitespace,
@ -146,7 +146,7 @@ impl TextRunScanner {
&mut 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));
char_total = char_total + added_chars;
}

Просмотреть файл

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

Просмотреть файл

@ -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);
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()
}