mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
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.
This commit is contained in:
parent
f85f22c04f
commit
04dc8ed201
1 changed files with 12 additions and 3 deletions
|
@ -1672,12 +1672,21 @@ impl ScriptTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scroll_fragment_point(&self, pipeline_id: PipelineId, element: &Element) {
|
fn scroll_fragment_point(&self, pipeline_id: PipelineId, element: &Element) {
|
||||||
let rect = element.upcast::<Node>().get_bounding_content_box();
|
// FIXME(#8275, pcwalton): This is pretty bogus when multiple layers are involved.
|
||||||
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.
|
|
||||||
// Really what needs to happen is that this needs to go through layout to ask which
|
// 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
|
// layer the element belongs to, and have it send the scroll message to the
|
||||||
// compositor.
|
// 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(
|
self.compositor.borrow_mut().send(ScriptToCompositorMsg::ScrollFragmentPoint(
|
||||||
pipeline_id, LayerId::null(), point, false)).unwrap();
|
pipeline_id, LayerId::null(), point, false)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue