mirror of
https://github.com/servo/servo.git
synced 2025-06-19 14:48:59 +01:00
layout: Avoid a division by zero in tile_image()
.
Fixes a crash on Facebook Timeline.
This commit is contained in:
parent
19d466b062
commit
02b15e016d
4 changed files with 19 additions and 2 deletions
|
@ -390,9 +390,13 @@ impl ImageFragmentInfo {
|
|||
}
|
||||
|
||||
/// Tile an image
|
||||
pub fn tile_image(position: &mut Au, size: &mut Au,
|
||||
virtual_position: Au, image_size: u32) {
|
||||
pub fn tile_image(position: &mut Au, size: &mut Au, virtual_position: Au, image_size: u32) {
|
||||
// Avoid division by zero below!
|
||||
let image_size = image_size as i32;
|
||||
if image_size == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue