mirror of
https://github.com/servo/servo.git
synced 2025-07-14 19:03:40 +01:00
Rename to_px to to_nearest_px for clarity.
This commit is contained in:
parent
a3d5ca35a0
commit
9f669c2989
5 changed files with 14 additions and 11 deletions
|
@ -399,8 +399,8 @@ impl Font {
|
|||
let azglyph = struct__AzGlyph {
|
||||
mIndex: glyph.index() as uint32_t,
|
||||
mPosition: struct__AzPoint {
|
||||
x: (origin.x + glyph_offset.x).to_px() as AzFloat,
|
||||
y: (origin.y + glyph_offset.y).to_px() as AzFloat
|
||||
x: (origin.x + glyph_offset.x).to_nearest_px() as AzFloat,
|
||||
y: (origin.y + glyph_offset.y).to_nearest_px() as AzFloat
|
||||
}
|
||||
};
|
||||
origin = Point2D(origin.x + glyph_advance, origin.y);
|
||||
|
|
|
@ -89,7 +89,7 @@ impl Au {
|
|||
NumCast::from(px * 60)
|
||||
}
|
||||
|
||||
pub fn to_px(&self) -> int {
|
||||
pub fn to_nearest_px(&self) -> int {
|
||||
((**self as float) / 60f).round() as int
|
||||
}
|
||||
|
||||
|
|
|
@ -124,8 +124,10 @@ trait ToAzureRect {
|
|||
|
||||
impl ToAzureRect for Rect<Au> {
|
||||
fn to_azure_rect(&self) -> Rect<AzFloat> {
|
||||
Rect(Point2D(self.origin.x.to_px() as AzFloat, self.origin.y.to_px() as AzFloat),
|
||||
Size2D(self.size.width.to_px() as AzFloat, self.size.height.to_px() as AzFloat))
|
||||
Rect(Point2D(self.origin.x.to_nearest_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> {
|
||||
fn to_float_px(&self) -> SideOffsets2D<AzFloat> {
|
||||
SideOffsets2D::new(self.top.to_px() as AzFloat,
|
||||
self.right.to_px() as AzFloat,
|
||||
self.bottom.to_px() as AzFloat,
|
||||
self.left.to_px() as AzFloat)
|
||||
SideOffsets2D::new(self.top.to_nearest_px() as AzFloat,
|
||||
self.right.to_nearest_px() as AzFloat,
|
||||
self.bottom.to_nearest_px() as AzFloat,
|
||||
self.left.to_nearest_px() as AzFloat)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,7 +348,8 @@ impl LayoutTask {
|
|||
|
||||
let render_layer = RenderLayer {
|
||||
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());
|
||||
|
|
|
@ -223,7 +223,7 @@ extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut JSVa
|
|||
let (port, chan) = comm::stream();
|
||||
// TODO(tkuehn): currently this just queries top-level page's layout. Need to handle subframes.
|
||||
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
|
||||
}
|
||||
// TODO: if nothing is being rendered(?), return zero dimensions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue