mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
base and bounds methods for DisplayItem
This commit is contained in:
parent
2e4cecc718
commit
ea1a406589
1 changed files with 17 additions and 0 deletions
|
@ -19,6 +19,7 @@ use geometry::Au;
|
|||
use render_context::RenderContext;
|
||||
use text::SendableTextRun;
|
||||
|
||||
use core::cast::transmute_region;
|
||||
use geom::{Point2D, Rect, Size2D};
|
||||
use servo_net::image::base::Image;
|
||||
use servo_util::range::Range;
|
||||
|
@ -151,5 +152,21 @@ impl<E> DisplayItem<E> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn base<'a>(&'a self) -> &'a BaseDisplayItem<E> {
|
||||
// FIXME(tkuehn): Workaround for Rust region bug.
|
||||
unsafe {
|
||||
match *self {
|
||||
SolidColorDisplayItemClass(ref solid_color) => transmute_region(&solid_color.base),
|
||||
TextDisplayItemClass(ref text) => transmute_region(&text.base),
|
||||
ImageDisplayItemClass(ref image_item) => transmute_region(&image_item.base),
|
||||
BorderDisplayItemClass(ref border) => transmute_region(&border.base)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn bounds(&self) -> Rect<Au> {
|
||||
self.base().bounds
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue