mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Stop using int/uint in net_traits.
This commit is contained in:
parent
f22d920b4d
commit
b50b21d1da
5 changed files with 17 additions and 13 deletions
|
@ -327,15 +327,21 @@ impl ImageFragmentInfo {
|
||||||
/// Returns the original inline-size of the image.
|
/// Returns the original inline-size of the image.
|
||||||
pub fn image_inline_size(&mut self) -> Au {
|
pub fn image_inline_size(&mut self) -> Au {
|
||||||
let size = self.image.get_size(self.replaced_image_fragment_info.for_node).unwrap_or(Size2D::zero());
|
let size = self.image.get_size(self.replaced_image_fragment_info.for_node).unwrap_or(Size2D::zero());
|
||||||
Au::from_px(if self.replaced_image_fragment_info.writing_mode_is_vertical { size.height }
|
Au::from_px(if self.replaced_image_fragment_info.writing_mode_is_vertical {
|
||||||
else { size.width })
|
size.height
|
||||||
|
} else {
|
||||||
|
size.width
|
||||||
|
} as isize)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the original block-size of the image.
|
/// Returns the original block-size of the image.
|
||||||
pub fn image_block_size(&mut self) -> Au {
|
pub fn image_block_size(&mut self) -> Au {
|
||||||
let size = self.image.get_size(self.replaced_image_fragment_info.for_node).unwrap_or(Size2D::zero());
|
let size = self.image.get_size(self.replaced_image_fragment_info.for_node).unwrap_or(Size2D::zero());
|
||||||
Au::from_px(if self.replaced_image_fragment_info.writing_mode_is_vertical { size.width }
|
Au::from_px(if self.replaced_image_fragment_info.writing_mode_is_vertical {
|
||||||
else { size.height })
|
size.width
|
||||||
|
} else {
|
||||||
|
size.height
|
||||||
|
} as isize)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tile an image
|
/// Tile an image
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
|
||||||
} else {
|
} else {
|
||||||
// For non-png images, we use stb_image
|
// For non-png images, we use stb_image
|
||||||
// Can't remember why we do this. Maybe it's what cairo wants
|
// Can't remember why we do this. Maybe it's what cairo wants
|
||||||
static FORCE_DEPTH: uint = 4;
|
static FORCE_DEPTH: usize = 4;
|
||||||
|
|
||||||
match stb_image2::load_from_memory_with_depth(buffer, FORCE_DEPTH, true) {
|
match stb_image2::load_from_memory_with_depth(buffer, FORCE_DEPTH, true) {
|
||||||
stb_image2::LoadResult::ImageU8(mut image) => {
|
stb_image2::LoadResult::ImageU8(mut image) => {
|
||||||
|
|
|
@ -20,7 +20,7 @@ use url::Url;
|
||||||
pub struct ImageHolder<NodeAddress> {
|
pub struct ImageHolder<NodeAddress> {
|
||||||
url: Url,
|
url: Url,
|
||||||
image: Option<Arc<Box<Image>>>,
|
image: Option<Arc<Box<Image>>>,
|
||||||
cached_size: Size2D<int>,
|
cached_size: Size2D<u32>,
|
||||||
local_image_cache: Arc<Mutex<LocalImageCache<NodeAddress>>>,
|
local_image_cache: Arc<Mutex<LocalImageCache<NodeAddress>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,16 +55,15 @@ impl<NodeAddress: Send + 'static> ImageHolder<NodeAddress> {
|
||||||
///
|
///
|
||||||
/// The intent is that the impure version is used during layout when dimensions are used for
|
/// The intent is that the impure version is used during layout when dimensions are used for
|
||||||
/// computing layout.
|
/// computing layout.
|
||||||
pub fn size(&self) -> Size2D<int> {
|
pub fn size(&self) -> Size2D<u32> {
|
||||||
self.cached_size
|
self.cached_size
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Query and update the current image size.
|
/// Query and update the current image size.
|
||||||
pub fn get_size(&mut self, node_address: NodeAddress) -> Option<Size2D<int>> {
|
pub fn get_size(&mut self, node_address: NodeAddress) -> Option<Size2D<u32>> {
|
||||||
debug!("get_size() {}", self.url.serialize());
|
debug!("get_size() {}", self.url.serialize());
|
||||||
self.get_image(node_address).map(|img| {
|
self.get_image(node_address).map(|img| {
|
||||||
self.cached_size = Size2D(img.width as int,
|
self.cached_size = Size2D(img.width, img.height);
|
||||||
img.height as int);
|
|
||||||
self.cached_size.clone()
|
self.cached_size.clone()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
#![feature(collections)]
|
#![feature(collections)]
|
||||||
#![feature(core)]
|
#![feature(core)]
|
||||||
#![feature(int_uint)]
|
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
#![feature(std_misc)]
|
#![feature(std_misc)]
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub trait ImageResponder<NodeAddress: Send> {
|
||||||
|
|
||||||
pub struct LocalImageCache<NodeAddress> {
|
pub struct LocalImageCache<NodeAddress> {
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
round_number: uint,
|
round_number: u32,
|
||||||
on_image_available: Option<Box<ImageResponder<NodeAddress>+Send>>,
|
on_image_available: Option<Box<ImageResponder<NodeAddress>+Send>>,
|
||||||
state_map: HashMap<Url, ImageState>
|
state_map: HashMap<Url, ImageState>
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ impl<NodeAddress: Send> LocalImageCache<NodeAddress> {
|
||||||
struct ImageState {
|
struct ImageState {
|
||||||
prefetched: bool,
|
prefetched: bool,
|
||||||
decoded: bool,
|
decoded: bool,
|
||||||
last_request_round: uint,
|
last_request_round: u32,
|
||||||
last_response: ImageResponseMsg
|
last_response: ImageResponseMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue