mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
compositor: Do not allow script to scroll past maximum scroll node offsets (#33428)
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
db0aee6b58
commit
03abf7751a
2 changed files with 10 additions and 3 deletions
|
@ -91,7 +91,16 @@ impl ScrollTreeNode {
|
|||
pub fn set_offset(&mut self, new_offset: LayoutVector2D) -> bool {
|
||||
match self.scroll_info {
|
||||
Some(ref mut info) => {
|
||||
info.offset = new_offset;
|
||||
let scrollable_width = info.scrollable_size.width;
|
||||
let scrollable_height = info.scrollable_size.height;
|
||||
|
||||
if scrollable_width > 0. {
|
||||
info.offset.x = (new_offset.x).min(0.0).max(-scrollable_width);
|
||||
}
|
||||
|
||||
if scrollable_height > 0. {
|
||||
info.offset.y = (new_offset.y).min(0.0).max(-scrollable_height);
|
||||
}
|
||||
true
|
||||
},
|
||||
_ => false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue