diff options
author | Anthony Ramine <nox@nox.paris> | 2020-03-31 22:44:47 +0200 |
---|---|---|
committer | Anthony Ramine <nox@nox.paris> | 2020-04-01 11:40:55 +0200 |
commit | 1cd3d6bd4cd0071c8c35d1f891b9f1edaaf20ac7 (patch) | |
tree | 068880298f0b1b8a7a16415d165edf774d5dd2db /components/script/dom/node.rs | |
parent | fc07a5147cd26fa3d8778b3366358f8ae5bcee36 (diff) | |
download | servo-1cd3d6bd4cd0071c8c35d1f891b9f1edaaf20ac7.tar.gz servo-1cd3d6bd4cd0071c8c35d1f891b9f1edaaf20ac7.zip |
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.
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 7348431d4f3..b7215cfd92b 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -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> { |