Use i32 instead of isize in Au methods.

This commit is contained in:
Simon Sapin 2015-05-05 18:40:00 +02:00
parent 8b522f2e7d
commit b1ecba9f3d
6 changed files with 23 additions and 23 deletions

View file

@ -575,8 +575,8 @@ impl WorkerThread {
// painted this tile. // painted this tile.
let color = THREAD_TINT_COLORS[thread_id % THREAD_TINT_COLORS.len()]; let color = THREAD_TINT_COLORS[thread_id % THREAD_TINT_COLORS.len()];
paint_context.draw_solid_color(&Rect(Point2D(Au(0), Au(0)), paint_context.draw_solid_color(&Rect(Point2D(Au(0), Au(0)),
Size2D(Au::from_px(size.width as isize), Size2D(Au::from_px(size.width),
Au::from_px(size.height as isize))), Au::from_px(size.height))),
color); color);
} }
} }

View file

@ -353,8 +353,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_f64_px() / bounds.size.height.to_f64_px(); let bounds_aspect_ratio = bounds.size.width.to_f64_px() / bounds.size.height.to_f64_px();
let intrinsic_size = Size2D(Au::from_px(image.width as isize), let intrinsic_size = Size2D(Au::from_px(image.width as i32),
Au::from_px(image.height as isize)); Au::from_px(image.height as i32));
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) => {

View file

@ -271,8 +271,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 isize)), Some(Au::from_px(node.get_canvas_width() as i32)),
Some(Au::from_px(node.get_canvas_height() as isize))), Some(Au::from_px(node.get_canvas_height() as i32))),
renderer: node.get_renderer().map(|rec| Arc::new(Mutex::new(rec))), renderer: node.get_renderer().map(|rec| Arc::new(Mutex::new(rec))),
} }
} }
@ -309,8 +309,8 @@ impl 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) element.get_attr(&ns!(""), name)
.and_then(|string| string.parse::<isize>().ok()) .and_then(|string| string.parse().ok())
.map(|pixels| Au::from_px(pixels)) .map(Au::from_px)
} }
let image = url.and_then(|url| layout_context.get_or_request_image(url)); let image = url.and_then(|url| layout_context.get_or_request_image(url));
@ -331,7 +331,7 @@ impl ImageFragmentInfo {
image.height image.height
} else { } else {
image.width image.width
} as isize) } as i32)
} }
None => Au(0) None => Au(0)
} }
@ -345,7 +345,7 @@ impl ImageFragmentInfo {
image.width image.width
} else { } else {
image.height image.height
} as isize) } as i32)
} }
None => Au(0) None => Au(0)
} }
@ -354,7 +354,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 isize; let image_size = image_size as i32;
let delta_pixels = (virtual_position - *position).to_px(); let delta_pixels = (virtual_position - *position).to_px();
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);

View file

@ -126,7 +126,7 @@ impl PresentationalHintSynthesis for Stylist {
UnsignedIntegerAttribute::CellSpacing) { UnsignedIntegerAttribute::CellSpacing) {
None => {} None => {}
Some(length) => { Some(length) => {
let width_value = specified::Length::Absolute(Au::from_px(length as isize)); let width_value = specified::Length::Absolute(Au::from_px(length as i32));
matching_rules_list.push(from_declaration( matching_rules_list.push(from_declaration(
PropertyDeclaration::BorderSpacing( PropertyDeclaration::BorderSpacing(
SpecifiedValue( SpecifiedValue(
@ -204,7 +204,7 @@ impl PresentationalHintSynthesis for Stylist {
match element.get_unsigned_integer_attribute(UnsignedIntegerAttribute::Border) { match element.get_unsigned_integer_attribute(UnsignedIntegerAttribute::Border) {
None => {} None => {}
Some(length) => { Some(length) => {
let width_value = specified::Length::Absolute(Au::from_px(length as isize)); let width_value = specified::Length::Absolute(Au::from_px(length as i32));
matching_rules_list.push(from_declaration( matching_rules_list.push(from_declaration(
PropertyDeclaration::BorderTopWidth(SpecifiedValue( PropertyDeclaration::BorderTopWidth(SpecifiedValue(
longhands::border_top_width::SpecifiedValue(width_value))))); longhands::border_top_width::SpecifiedValue(width_value)))));

View file

@ -1681,7 +1681,7 @@ pub mod longhands {
use util::geometry::Au; use util::geometry::Au;
pub type T = Au; pub type T = Au;
} }
const MEDIUM_PX: isize = 16; const MEDIUM_PX: i32 = 16;
#[inline] pub fn get_initial_value() -> computed_value::T { #[inline] pub fn get_initial_value() -> computed_value::T {
Au::from_px(MEDIUM_PX) Au::from_px(MEDIUM_PX)
} }

View file

@ -201,7 +201,7 @@ impl Au {
} }
#[inline] #[inline]
pub fn from_px(px: isize) -> Au { pub fn from_px(px: i32) -> Au {
Au((px * 60) as i32) Au((px * 60) as i32)
} }
@ -212,29 +212,29 @@ impl Au {
/// Rounds this app unit down to the pixel towards zero and returns it. /// Rounds this app unit down to the pixel towards zero and returns it.
#[inline] #[inline]
pub fn to_px(&self) -> isize { pub fn to_px(&self) -> i32 {
let Au(a) = *self; let Au(a) = *self;
(a / 60) as isize (a / 60)
} }
/// Rounds this app unit down to the previous (left or top) pixel and returns it. /// Rounds this app unit down to the previous (left or top) pixel and returns it.
#[inline] #[inline]
pub fn to_prev_px(&self) -> isize { pub fn to_prev_px(&self) -> i32 {
let Au(s) = *self; let Au(s) = *self;
((s as f64) / 60f64).floor() as isize ((s as f64) / 60f64).floor() as i32
} }
/// Rounds this app unit up to the next (right or bottom) pixel and returns it. /// Rounds this app unit up to the next (right or bottom) pixel and returns it.
#[inline] #[inline]
pub fn to_next_px(&self) -> isize { pub fn to_next_px(&self) -> i32 {
let Au(s) = *self; let Au(s) = *self;
((s as f64) / 60f64).ceil() as isize ((s as f64) / 60f64).ceil() as i32
} }
#[inline] #[inline]
pub fn to_nearest_px(&self) -> isize { pub fn to_nearest_px(&self) -> i32 {
let Au(s) = *self; let Au(s) = *self;
((s as f64) / 60f64).round() as isize ((s as f64) / 60f64).round() as i32
} }
#[inline] #[inline]