mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Make layout use available image data before querying the image cache.
This commit is contained in:
parent
5f463d3c97
commit
49d2ea4f74
8 changed files with 102 additions and 5 deletions
|
@ -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())
|
||||
|
|
|
@ -62,6 +62,7 @@ use js::jsapi::{JSContext, JSObject, JSRuntime};
|
|||
use libc::{self, c_void, uintptr_t};
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||
use net_traits::image::base::{Image, ImageMetadata};
|
||||
use ref_slice::ref_slice;
|
||||
use script_layout_interface::{HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType};
|
||||
use script_layout_interface::{OpaqueStyleAndLayoutData, SVGSVGData, TrustedNodeAddress};
|
||||
|
@ -81,6 +82,7 @@ use std::default::Default;
|
|||
use std::iter;
|
||||
use std::mem;
|
||||
use std::ops::Range;
|
||||
use std::sync::Arc as StdArc;
|
||||
use style::context::QuirksMode;
|
||||
use style::dom::OpaqueNode;
|
||||
use style::selector_parser::{SelectorImpl, SelectorParser};
|
||||
|
@ -1086,6 +1088,7 @@ pub trait LayoutNodeHelpers {
|
|||
fn selection(&self) -> Option<Range<usize>>;
|
||||
fn image_url(&self) -> Option<ServoUrl>;
|
||||
fn image_density(&self) -> Option<f64>;
|
||||
fn image_data(&self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)>;
|
||||
fn canvas_data(&self) -> Option<HTMLCanvasData>;
|
||||
fn media_data(&self) -> Option<HTMLMediaData>;
|
||||
fn svg_data(&self) -> Option<SVGSVGData>;
|
||||
|
@ -1233,6 +1236,13 @@ impl LayoutNodeHelpers for LayoutDom<Node> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn image_data(&self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)> {
|
||||
unsafe {
|
||||
self.downcast::<HTMLImageElement>().map(|e| e.image_data())
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn image_density(&self) -> Option<f64> {
|
||||
unsafe {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue