mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Use i32 instead of isize in Au methods.
This commit is contained in:
parent
8b522f2e7d
commit
b1ecba9f3d
6 changed files with 23 additions and 23 deletions
|
@ -575,8 +575,8 @@ impl WorkerThread {
|
|||
// painted this tile.
|
||||
let color = THREAD_TINT_COLORS[thread_id % THREAD_TINT_COLORS.len()];
|
||||
paint_context.draw_solid_color(&Rect(Point2D(Au(0), Au(0)),
|
||||
Size2D(Au::from_px(size.width as isize),
|
||||
Au::from_px(size.height as isize))),
|
||||
Size2D(Au::from_px(size.width),
|
||||
Au::from_px(size.height))),
|
||||
color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,8 +353,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_f64_px() / bounds.size.height.to_f64_px();
|
||||
let intrinsic_size = Size2D(Au::from_px(image.width as isize),
|
||||
Au::from_px(image.height as isize));
|
||||
let intrinsic_size = Size2D(Au::from_px(image.width as i32),
|
||||
Au::from_px(image.height as i32));
|
||||
match (style.get_background().background_size.clone(),
|
||||
image_aspect_ratio < bounds_aspect_ratio) {
|
||||
(background_size::T::Contain, false) | (background_size::T::Cover, true) => {
|
||||
|
|
|
@ -271,8 +271,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 isize)),
|
||||
Some(Au::from_px(node.get_canvas_height() as isize))),
|
||||
Some(Au::from_px(node.get_canvas_width() as i32)),
|
||||
Some(Au::from_px(node.get_canvas_height() as i32))),
|
||||
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> {
|
||||
let element = node.as_element();
|
||||
element.get_attr(&ns!(""), name)
|
||||
.and_then(|string| string.parse::<isize>().ok())
|
||||
.map(|pixels| Au::from_px(pixels))
|
||||
.and_then(|string| string.parse().ok())
|
||||
.map(Au::from_px)
|
||||
}
|
||||
|
||||
let image = url.and_then(|url| layout_context.get_or_request_image(url));
|
||||
|
@ -331,7 +331,7 @@ impl ImageFragmentInfo {
|
|||
image.height
|
||||
} else {
|
||||
image.width
|
||||
} as isize)
|
||||
} as i32)
|
||||
}
|
||||
None => Au(0)
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ impl ImageFragmentInfo {
|
|||
image.width
|
||||
} else {
|
||||
image.height
|
||||
} as isize)
|
||||
} as i32)
|
||||
}
|
||||
None => Au(0)
|
||||
}
|
||||
|
@ -354,7 +354,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 isize;
|
||||
let image_size = image_size as i32;
|
||||
let delta_pixels = (virtual_position - *position).to_px();
|
||||
let tile_count = (delta_pixels + image_size - 1) / image_size;
|
||||
let offset = Au::from_px(image_size * tile_count);
|
||||
|
|
|
@ -126,7 +126,7 @@ impl PresentationalHintSynthesis for Stylist {
|
|||
UnsignedIntegerAttribute::CellSpacing) {
|
||||
None => {}
|
||||
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(
|
||||
PropertyDeclaration::BorderSpacing(
|
||||
SpecifiedValue(
|
||||
|
@ -204,7 +204,7 @@ impl PresentationalHintSynthesis for Stylist {
|
|||
match element.get_unsigned_integer_attribute(UnsignedIntegerAttribute::Border) {
|
||||
None => {}
|
||||
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(
|
||||
PropertyDeclaration::BorderTopWidth(SpecifiedValue(
|
||||
longhands::border_top_width::SpecifiedValue(width_value)))));
|
||||
|
|
|
@ -1681,7 +1681,7 @@ pub mod longhands {
|
|||
use util::geometry::Au;
|
||||
pub type T = Au;
|
||||
}
|
||||
const MEDIUM_PX: isize = 16;
|
||||
const MEDIUM_PX: i32 = 16;
|
||||
#[inline] pub fn get_initial_value() -> computed_value::T {
|
||||
Au::from_px(MEDIUM_PX)
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ impl Au {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_px(px: isize) -> Au {
|
||||
pub fn from_px(px: i32) -> Au {
|
||||
Au((px * 60) as i32)
|
||||
}
|
||||
|
||||
|
@ -212,29 +212,29 @@ impl Au {
|
|||
|
||||
/// Rounds this app unit down to the pixel towards zero and returns it.
|
||||
#[inline]
|
||||
pub fn to_px(&self) -> isize {
|
||||
pub fn to_px(&self) -> i32 {
|
||||
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.
|
||||
#[inline]
|
||||
pub fn to_prev_px(&self) -> isize {
|
||||
pub fn to_prev_px(&self) -> i32 {
|
||||
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.
|
||||
#[inline]
|
||||
pub fn to_next_px(&self) -> isize {
|
||||
pub fn to_next_px(&self) -> i32 {
|
||||
let Au(s) = *self;
|
||||
((s as f64) / 60f64).ceil() as isize
|
||||
((s as f64) / 60f64).ceil() as i32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_nearest_px(&self) -> isize {
|
||||
pub fn to_nearest_px(&self) -> i32 {
|
||||
let Au(s) = *self;
|
||||
((s as f64) / 60f64).round() as isize
|
||||
((s as f64) / 60f64).round() as i32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue