aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared
diff options
context:
space:
mode:
Diffstat (limited to 'components/shared')
-rw-r--r--components/shared/script/tests/compositor.rs12
-rw-r--r--components/shared/webrender/Cargo.toml1
-rw-r--r--components/shared/webrender/display_list.rs41
3 files changed, 44 insertions, 10 deletions
diff --git a/components/shared/script/tests/compositor.rs b/components/shared/script/tests/compositor.rs
index ee3fd72ad49..c648d5ff681 100644
--- a/components/shared/script/tests/compositor.rs
+++ b/components/shared/script/tests/compositor.rs
@@ -6,7 +6,7 @@ use euclid::Size2D;
use webrender_api::units::LayoutVector2D;
use webrender_api::{ExternalScrollId, PipelineId, ScrollLocation, SpatialId};
use webrender_traits::display_list::{
- ScrollSensitivity, ScrollTree, ScrollTreeNodeId, ScrollableNodeInfo,
+ AxesScrollSensitivity, ScrollSensitivity, ScrollTree, ScrollTreeNodeId, ScrollableNodeInfo,
};
fn add_mock_scroll_node(tree: &mut ScrollTree) -> ScrollTreeNodeId {
@@ -27,7 +27,10 @@ fn add_mock_scroll_node(tree: &mut ScrollTree) -> ScrollTreeNodeId {
Some(ScrollableNodeInfo {
external_id: ExternalScrollId(num_nodes as u64, pipeline_id),
scrollable_size: Size2D::new(100.0, 100.0),
- scroll_sensitivity: ScrollSensitivity::ScriptAndInputEvents,
+ scroll_sensitivity: AxesScrollSensitivity {
+ x: ScrollSensitivity::ScriptAndInputEvents,
+ y: ScrollSensitivity::ScriptAndInputEvents,
+ },
offset: LayoutVector2D::zero(),
}),
)
@@ -158,7 +161,10 @@ fn test_scroll_tree_chain_through_overflow_hidden() {
.scroll_info
.as_mut()
.map(|info| {
- info.scroll_sensitivity = ScrollSensitivity::Script;
+ info.scroll_sensitivity = AxesScrollSensitivity {
+ x: ScrollSensitivity::Script,
+ y: ScrollSensitivity::Script,
+ };
});
let (scrolled_id, offset) = scroll_tree
diff --git a/components/shared/webrender/Cargo.toml b/components/shared/webrender/Cargo.toml
index bed2dcf0f46..40270bfc126 100644
--- a/components/shared/webrender/Cargo.toml
+++ b/components/shared/webrender/Cargo.toml
@@ -26,4 +26,5 @@ webrender_api = { workspace = true }
serde = { workspace = true }
servo_geometry = { path = "../../geometry" }
servo-media = { workspace = true }
+style = { workspace = true }
surfman = { workspace = true, features = ["sm-x11"] }
diff --git a/components/shared/webrender/display_list.rs b/components/shared/webrender/display_list.rs
index 78e8e9492f6..4733e6c4024 100644
--- a/components/shared/webrender/display_list.rs
+++ b/components/shared/webrender/display_list.rs
@@ -6,17 +6,38 @@
use embedder_traits::Cursor;
use serde::{Deserialize, Serialize};
+use style::values::specified::Overflow;
use webrender_api::units::{LayoutSize, LayoutVector2D};
use webrender_api::{Epoch, ExternalScrollId, PipelineId, ScrollLocation, SpatialId};
-/// The scroll sensitivity of a scroll node ie whether it can be scrolled due to input event and
-/// script events or only script events.
+/// The scroll sensitivity of a scroll node in a particular axis ie whether it can be scrolled due to
+/// input events and script events or only script events.
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum ScrollSensitivity {
/// This node can be scrolled by input and script events.
ScriptAndInputEvents,
/// This node can only be scrolled by script events.
Script,
+ /// This node cannot be scrolled.
+ None,
+}
+
+/// Convert [Overflow] to [ScrollSensitivity].
+impl From<Overflow> for ScrollSensitivity {
+ fn from(overflow: Overflow) -> Self {
+ match overflow {
+ Overflow::Hidden => ScrollSensitivity::Script,
+ Overflow::Scroll | Overflow::Auto => ScrollSensitivity::ScriptAndInputEvents,
+ Overflow::Visible | Overflow::Clip => ScrollSensitivity::None,
+ }
+ }
+}
+
+/// The [ScrollSensitivity] of particular node in the vertical and horizontal axes.
+#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
+pub struct AxesScrollSensitivity {
+ pub x: ScrollSensitivity,
+ pub y: ScrollSensitivity,
}
/// Information that Servo keeps alongside WebRender display items
@@ -57,7 +78,7 @@ pub struct ScrollableNodeInfo {
pub scrollable_size: LayoutSize,
/// Whether this `ScrollableNode` is sensitive to input events.
- pub scroll_sensitivity: ScrollSensitivity,
+ pub scroll_sensitivity: AxesScrollSensitivity,
/// The current offset of this scroll node.
pub offset: LayoutVector2D,
@@ -119,7 +140,9 @@ impl ScrollTreeNode {
None => return None,
};
- if info.scroll_sensitivity != ScrollSensitivity::ScriptAndInputEvents {
+ if info.scroll_sensitivity.x != ScrollSensitivity::ScriptAndInputEvents &&
+ info.scroll_sensitivity.y != ScrollSensitivity::ScriptAndInputEvents
+ {
return None;
}
@@ -150,11 +173,15 @@ impl ScrollTreeNode {
let scrollable_height = info.scrollable_size.height;
let original_layer_scroll_offset = info.offset;
- if scrollable_width > 0. {
+ if scrollable_width > 0. &&
+ info.scroll_sensitivity.x == ScrollSensitivity::ScriptAndInputEvents
+ {
info.offset.x = (info.offset.x + delta.x).min(0.0).max(-scrollable_width);
}
- if scrollable_height > 0. {
+ if scrollable_height > 0. &&
+ info.scroll_sensitivity.y == ScrollSensitivity::ScriptAndInputEvents
+ {
info.offset.y = (info.offset.y + delta.y).min(0.0).max(-scrollable_height);
}
@@ -288,7 +315,7 @@ impl CompositorDisplayListInfo {
content_size: LayoutSize,
pipeline_id: PipelineId,
epoch: Epoch,
- root_scroll_sensitivity: ScrollSensitivity,
+ root_scroll_sensitivity: AxesScrollSensitivity,
) -> Self {
let mut scroll_tree = ScrollTree::default();
let root_reference_frame_id = scroll_tree.add_scroll_tree_node(