Current-pixel-density tests passing

This commit is contained in:
paavininanda 2018-09-03 19:46:15 +05:30
parent 9a83ab6297
commit 25027e476c
9 changed files with 74 additions and 43 deletions

View file

@ -1030,6 +1030,7 @@ pub trait LayoutNodeHelpers {
fn text_content(&self) -> String;
fn selection(&self) -> Option<Range<usize>>;
fn image_url(&self) -> Option<ServoUrl>;
fn image_density(&self) -> Option<f64>;
fn canvas_data(&self) -> Option<HTMLCanvasData>;
fn svg_data(&self) -> Option<SVGSVGData>;
fn iframe_browsing_context_id(&self) -> Option<BrowsingContextId>;
@ -1173,6 +1174,15 @@ impl LayoutNodeHelpers for LayoutDom<Node> {
}
}
#[allow(unsafe_code)]
fn image_density(&self) -> Option<f64> {
unsafe {
self.downcast::<HTMLImageElement>()
.expect("not an image!")
.image_density()
}
}
fn canvas_data(&self) -> Option<HTMLCanvasData> {
self.downcast::<HTMLCanvasElement>()
.map(|canvas| canvas.data())