diff options
author | Jack Moffitt <jack@metajack.im> | 2013-08-23 17:11:48 -0600 |
---|---|---|
committer | Jack Moffitt <jack@metajack.im> | 2013-08-23 17:11:48 -0600 |
commit | 9f669c29893f884388346fc8cc912e670c176087 (patch) | |
tree | 683fc97b2ee81aef29f628329b5070545342f3e0 /src | |
parent | a3d5ca35a00273f83a5793e71e2cf4fe6c1f8e64 (diff) | |
download | servo-9f669c29893f884388346fc8cc912e670c176087.tar.gz servo-9f669c29893f884388346fc8cc912e670c176087.zip |
Rename to_px to to_nearest_px for clarity.
Diffstat (limited to 'src')
-rw-r--r-- | src/components/gfx/font.rs | 4 | ||||
-rw-r--r-- | src/components/gfx/geometry.rs | 2 | ||||
-rw-r--r-- | src/components/gfx/render_context.rs | 14 | ||||
-rw-r--r-- | src/components/main/layout/layout_task.rs | 3 | ||||
-rw-r--r-- | src/components/script/dom/bindings/element.rs | 2 |
5 files changed, 14 insertions, 11 deletions
diff --git a/src/components/gfx/font.rs b/src/components/gfx/font.rs index 99901cdc643..afd35dcbd16 100644 --- a/src/components/gfx/font.rs +++ b/src/components/gfx/font.rs @@ -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); diff --git a/src/components/gfx/geometry.rs b/src/components/gfx/geometry.rs index f619615f21d..b89d0f29343 100644 --- a/src/components/gfx/geometry.rs +++ b/src/components/gfx/geometry.rs @@ -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 } diff --git a/src/components/gfx/render_context.rs b/src/components/gfx/render_context.rs index 0f1f30d9b99..c9d278fea96 100644 --- a/src/components/gfx/render_context.rs +++ b/src/components/gfx/render_context.rs @@ -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) } } diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs index ee9ce45de6e..141df0e3f33 100644 --- a/src/components/main/layout/layout_task.rs +++ b/src/components/main/layout/layout_task.rs @@ -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()); diff --git a/src/components/script/dom/bindings/element.rs b/src/components/script/dom/bindings/element.rs index 8ca841772de..60d4ca9cfc2 100644 --- a/src/components/script/dom/bindings/element.rs +++ b/src/components/script/dom/bindings/element.rs @@ -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 |