mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
script: Prevent "scroll to fragment" from scrolling offscreen (#32129)
Previously, the "scroll to fragment" operation could scroll past the end of the screen, because the scroll position was not clamped to viewport boundaries. Correct this by using the `Window::scroll()` method which handles this case. In addition, ensure that `Window`'s `current_viewport` member is initialized properly when it is created.
This commit is contained in:
parent
bef6c295aa
commit
1440406e91
6 changed files with 60 additions and 20 deletions
|
@ -2560,6 +2560,12 @@ impl Window {
|
|||
pipelineid,
|
||||
script_chan: Arc::new(Mutex::new(control_chan)),
|
||||
};
|
||||
|
||||
let initial_viewport = f32_rect_to_au_rect(UntypedRect::new(
|
||||
Point2D::zero(),
|
||||
window_size.initial_viewport.to_untyped(),
|
||||
));
|
||||
|
||||
let win = Box::new(Self {
|
||||
globalscope: GlobalScope::new_inherited(
|
||||
pipelineid,
|
||||
|
@ -2602,7 +2608,7 @@ impl Window {
|
|||
page_clip_rect: Cell::new(MaxRect::max_rect()),
|
||||
resize_event: Default::default(),
|
||||
window_size: Cell::new(window_size),
|
||||
current_viewport: Cell::new(Rect::zero()),
|
||||
current_viewport: Cell::new(initial_viewport.to_untyped()),
|
||||
suppress_reflow: Cell::new(true),
|
||||
pending_reflow_count: Default::default(),
|
||||
current_state: Cell::new(WindowState::Alive),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue