mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Don't let base layers override root layer size
Base layers (the background layer of each frame) shouldn't override the size of their root layers. This allows base layers to scroll inside root layer frames. This does mean that when determining the maximum scroll position, we need to look at the size of scrolling root children though.
This commit is contained in:
parent
e01c5cd863
commit
f346a215f3
3 changed files with 17 additions and 4 deletions
|
@ -8,6 +8,7 @@ use windowing::MouseWindowMouseUpEvent;
|
|||
|
||||
use geom::length::Length;
|
||||
use geom::point::{Point2D, TypedPoint2D};
|
||||
use geom::rect::Rect;
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use geom::size::TypedSize2D;
|
||||
use layers::geometry::DevicePixel;
|
||||
|
@ -86,12 +87,20 @@ pub fn handle_scroll_event(layer: Rc<Layer<CompositorData>>,
|
|||
scale)
|
||||
}
|
||||
|
||||
pub fn calculate_content_size_for_layer(layer: Rc<Layer<CompositorData>>)
|
||||
-> TypedSize2D<DevicePixel, f32> {
|
||||
layer.children().iter().fold(Rect::zero(),
|
||||
|unioned_rect, child_rect| {
|
||||
unioned_rect.union(&*child_rect.bounds.borrow())
|
||||
}).size
|
||||
}
|
||||
|
||||
pub fn clamp_scroll_offset_and_scroll_layer(layer: Rc<Layer<CompositorData>>,
|
||||
new_offset: TypedPoint2D<DevicePixel, f32>,
|
||||
window_size: TypedSize2D<DevicePixel, f32>,
|
||||
scale: ScaleFactor<PagePx, DevicePixel, f32>)
|
||||
-> ScrollEventResult {
|
||||
let layer_size = layer.bounds.borrow().size;
|
||||
let layer_size = calculate_content_size_for_layer(layer.clone());
|
||||
let min_x = (window_size.width - layer_size.width).get().min(0.0);
|
||||
let min_y = (window_size.height - layer_size.height).get().min(0.0);
|
||||
let new_offset : TypedPoint2D<DevicePixel, f32> =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue