Make layout use available image data before querying the image cache.

This commit is contained in:
Josh Matthews 2018-10-12 12:35:12 -04:00
parent 5f463d3c97
commit 49d2ea4f74
8 changed files with 102 additions and 5 deletions

View file

@ -1328,6 +1328,9 @@ pub trait LayoutHTMLImageElementHelpers {
#[allow(unsafe_code)]
unsafe fn image_density(&self) -> Option<f64>;
#[allow(unsafe_code)]
unsafe fn image_data(&self) -> (Option<Arc<Image>>, Option<ImageMetadata>);
fn get_width(&self) -> LengthOrPercentageOrAuto;
fn get_height(&self) -> LengthOrPercentageOrAuto;
}
@ -1351,6 +1354,14 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<HTMLImageElement> {
.clone()
}
#[allow(unsafe_code)]
unsafe fn image_data(&self) -> (Option<Arc<Image>>, Option<ImageMetadata>) {
let current_request = (*self.unsafe_get())
.current_request
.borrow_for_layout();
(current_request.image.clone(), current_request.metadata.clone())
}
#[allow(unsafe_code)]
unsafe fn image_density(&self) -> Option<f64> {
(*self.unsafe_get())