mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Introduce <LayoutDom<HTMLImageElement>>::current_request
This safe helper contains the only source of unsafety from the actual image layout helpers methods, making them completely safe.
This commit is contained in:
parent
fc07a5147c
commit
1cd3d6bd4c
2 changed files with 26 additions and 43 deletions
|
@ -1493,25 +1493,21 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
fn image_url(self) -> Option<ServoUrl> {
|
||||
unsafe {
|
||||
self.downcast::<HTMLImageElement>()
|
||||
.expect("not an image!")
|
||||
.image_url()
|
||||
}
|
||||
self.downcast::<HTMLImageElement>()
|
||||
.expect("not an image!")
|
||||
.image_url()
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn image_data(self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)> {
|
||||
unsafe { self.downcast::<HTMLImageElement>().map(|e| e.image_data()) }
|
||||
self.downcast::<HTMLImageElement>().map(|e| e.image_data())
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
fn image_density(self) -> Option<f64> {
|
||||
unsafe {
|
||||
self.downcast::<HTMLImageElement>()
|
||||
.expect("not an image!")
|
||||
.image_density()
|
||||
}
|
||||
self.downcast::<HTMLImageElement>()
|
||||
.expect("not an image!")
|
||||
.image_density()
|
||||
}
|
||||
|
||||
fn canvas_data(self) -> Option<HTMLCanvasData> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue