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:
Martin Robinson 2024-09-13 05:52:17 +02:00 committed by GitHub
parent db0aee6b58
commit 03abf7751a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -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,