Rename to_px to to_nearest_px for clarity.

This commit is contained in:
Jack Moffitt 2013-08-23 17:11:48 -06:00
parent a3d5ca35a0
commit 9f669c2989
5 changed files with 14 additions and 11 deletions

View file

@ -399,8 +399,8 @@ impl Font {
let azglyph = struct__AzGlyph { let azglyph = struct__AzGlyph {
mIndex: glyph.index() as uint32_t, mIndex: glyph.index() as uint32_t,
mPosition: struct__AzPoint { mPosition: struct__AzPoint {
x: (origin.x + glyph_offset.x).to_px() as AzFloat, x: (origin.x + glyph_offset.x).to_nearest_px() as AzFloat,
y: (origin.y + glyph_offset.y).to_px() as AzFloat y: (origin.y + glyph_offset.y).to_nearest_px() as AzFloat
} }
}; };
origin = Point2D(origin.x + glyph_advance, origin.y); origin = Point2D(origin.x + glyph_advance, origin.y);

View file

@ -89,7 +89,7 @@ impl Au {
NumCast::from(px * 60) NumCast::from(px * 60)
} }
pub fn to_px(&self) -> int { pub fn to_nearest_px(&self) -> int {
((**self as float) / 60f).round() as int ((**self as float) / 60f).round() as int
} }

View file

@ -124,8 +124,10 @@ trait ToAzureRect {
impl ToAzureRect for Rect<Au> { impl ToAzureRect for Rect<Au> {
fn to_azure_rect(&self) -> Rect<AzFloat> { fn to_azure_rect(&self) -> Rect<AzFloat> {
Rect(Point2D(self.origin.x.to_px() as AzFloat, self.origin.y.to_px() as AzFloat), Rect(Point2D(self.origin.x.to_nearest_px() as AzFloat,
Size2D(self.size.width.to_px() as AzFloat, self.size.height.to_px() as AzFloat)) self.origin.y.to_nearest_px() as AzFloat),
Size2D(self.size.width.to_nearest_px() as AzFloat,
self.size.height.to_nearest_px() as AzFloat))
} }
} }
@ -135,9 +137,9 @@ trait ToSideOffsetsPx {
impl ToSideOffsetsPx for SideOffsets2D<Au> { impl ToSideOffsetsPx for SideOffsets2D<Au> {
fn to_float_px(&self) -> SideOffsets2D<AzFloat> { fn to_float_px(&self) -> SideOffsets2D<AzFloat> {
SideOffsets2D::new(self.top.to_px() as AzFloat, SideOffsets2D::new(self.top.to_nearest_px() as AzFloat,
self.right.to_px() as AzFloat, self.right.to_nearest_px() as AzFloat,
self.bottom.to_px() as AzFloat, self.bottom.to_nearest_px() as AzFloat,
self.left.to_px() as AzFloat) self.left.to_nearest_px() as AzFloat)
} }
} }

View file

@ -348,7 +348,8 @@ impl LayoutTask {
let render_layer = RenderLayer { let render_layer = RenderLayer {
display_list: display_list.clone(), display_list: display_list.clone(),
size: Size2D(root_size.width.to_px() as uint, root_size.height.to_px() as uint) size: Size2D(root_size.width.to_nearest_px() as uint,
root_size.height.to_nearest_px() as uint)
}; };
self.display_list = Some(display_list.clone()); self.display_list = Some(display_list.clone());

View file

@ -223,7 +223,7 @@ extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVa
let (port, chan) = comm::stream(); let (port, chan) = comm::stream();
// TODO(tkuehn): currently this just queries top-level page's layout. Need to handle subframes. // TODO(tkuehn): currently this just queries top-level page's layout. Need to handle subframes.
match (*page).query_layout(ContentBoxQuery(node, chan), port) { match (*page).query_layout(ContentBoxQuery(node, chan), port) {
Ok(ContentBoxResponse(rect)) => rect.size.width.to_px(), Ok(ContentBoxResponse(rect)) => rect.size.width.to_nearest_px(),
Err(()) => 0 Err(()) => 0
} }
// TODO: if nothing is being rendered(?), return zero dimensions // TODO: if nothing is being rendered(?), return zero dimensions