diff options
author | Martin Robinson <mrobinson@igalia.com> | 2015-10-30 17:04:48 -0400 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2015-10-30 17:11:23 -0400 |
commit | 04dc8ed20122405839e583d9efc23e823d758726 (patch) | |
tree | 08fa3b0ac039e556e182c8d7bd50ebe55e8d9119 /components/script/script_task.rs | |
parent | f85f22c04fcd32c8fc3b02032a8ab62285992bd0 (diff) | |
download | servo-04dc8ed20122405839e583d9efc23e823d758726.tar.gz servo-04dc8ed20122405839e583d9efc23e823d758726.zip |
Snap fragment scroll points to pixel boundaries
These don't match hardware pixels, but work well enough when the device
pixel ratio is a whole number.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r-- | components/script/script_task.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 30bb371667b..421077665a8 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -1672,12 +1672,21 @@ impl ScriptTask { } fn scroll_fragment_point(&self, pipeline_id: PipelineId, element: &Element) { - let rect = element.upcast::<Node>().get_bounding_content_box(); - let point = Point2D::new(rect.origin.x.to_f32_px(), rect.origin.y.to_f32_px()); - // FIXME(#2003, pcwalton): This is pretty bogus when multiple layers are involved. + // FIXME(#8275, pcwalton): This is pretty bogus when multiple layers are involved. // Really what needs to happen is that this needs to go through layout to ask which // layer the element belongs to, and have it send the scroll message to the // compositor. + let rect = element.upcast::<Node>().get_bounding_content_box(); + + // In order to align with element edges, we snap to unscaled pixel boundaries, since the + // paint task currently does the same for drawing elements. This is important for pages + // that require pixel perfect scroll positioning for proper display (like Acid2). Since we + // don't have the device pixel ratio here, this might not be accurate, but should work as + // long as the ratio is a whole number. Once #8275 is fixed this should actually take into + // account the real device pixel ratio. + let point = Point2D::new(rect.origin.x.to_nearest_px() as f32, + rect.origin.y.to_nearest_px() as f32); + self.compositor.borrow_mut().send(ScriptToCompositorMsg::ScrollFragmentPoint( pipeline_id, LayerId::null(), point, false)).unwrap(); } |