mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Refactor ImageCache::find_image_or_metadata API.
This commit is contained in:
parent
7d1f968d52
commit
2742fd2bea
9 changed files with 266 additions and 227 deletions
|
@ -432,8 +432,7 @@ impl<'a> From<&'a WebGLContextAttributes> for GLContextAttributes {
|
|||
|
||||
pub mod utils {
|
||||
use crate::dom::window::Window;
|
||||
use net_traits::image_cache::CanRequestImages;
|
||||
use net_traits::image_cache::{ImageOrMetadataAvailable, ImageResponse, UsePlaceholder};
|
||||
use net_traits::image_cache::ImageResponse;
|
||||
use net_traits::request::CorsSettings;
|
||||
use servo_url::ServoUrl;
|
||||
|
||||
|
@ -443,18 +442,15 @@ pub mod utils {
|
|||
cors_setting: Option<CorsSettings>,
|
||||
) -> ImageResponse {
|
||||
let image_cache = window.image_cache();
|
||||
let response = image_cache.find_image_or_metadata(
|
||||
url.into(),
|
||||
let result = image_cache.get_image(
|
||||
url.clone(),
|
||||
window.origin().immutable().clone(),
|
||||
cors_setting,
|
||||
UsePlaceholder::No,
|
||||
CanRequestImages::No,
|
||||
);
|
||||
match response {
|
||||
Ok(ImageOrMetadataAvailable::ImageAvailable(image, url)) => {
|
||||
ImageResponse::Loaded(image, url)
|
||||
},
|
||||
_ => ImageResponse::None,
|
||||
|
||||
match result {
|
||||
Some(image) => ImageResponse::Loaded(image, url),
|
||||
None => ImageResponse::None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue