layout: Add a hit test item that covers all scroll frame contents (#34347)

When building scroll frames, add a special
`StackingContextContent::Fragment` type for a hit test that covers all
scroll frame contents. This makes it so that you don't have to be
hovering over actual content to scroll the scroll frame.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2024-11-24 20:04:57 +01:00 committed by GitHub
parent c60e4afbee
commit c11e0e8e70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 104 additions and 55 deletions

View file

@ -21,7 +21,7 @@ pub enum ScrollSensitivity {
/// Information that Servo keeps alongside WebRender display items
/// in order to add more context to hit test results.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, PartialEq, Serialize)]
pub struct HitTestInfo {
/// The id of the node of this hit test item.
pub node: u64,
@ -327,17 +327,19 @@ impl CompositorDisplayListInfo {
cursor: Option<Cursor>,
scroll_tree_node: ScrollTreeNodeId,
) -> usize {
let hit_test_info = HitTestInfo {
node,
cursor,
scroll_tree_node,
};
if let Some(last) = self.hit_test_info.last() {
if node == last.node && cursor == last.cursor {
if hit_test_info == *last {
return self.hit_test_info.len() - 1;
}
}
self.hit_test_info.push(HitTestInfo {
node,
cursor,
scroll_tree_node,
});
self.hit_test_info.push(hit_test_info);
self.hit_test_info.len() - 1
}
}