mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
compositor: Do not allow script to scroll beyond node boundaries (#37412)
The compositor was accepting scroll offsets from the ScriptThread without checking their boundaries. In some cases this could cause a temporary discrepancy with the rendered scroll offset. This change makes it so that all offset updates for scroll ayers in the compositor do not scroll past the scroll boundaries of the node. Testing: Two new tests pass with this change: - `/css/css-position/sticky/position-sticky-left-003.html` - `/css/css-position/sticky/position-sticky-top-003.html` Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
b28e796647
commit
29fc878e15
8 changed files with 142 additions and 107 deletions
|
@ -15,7 +15,9 @@ use base::cross_process_instant::CrossProcessInstant;
|
|||
use base::id::{PipelineId, WebViewId};
|
||||
use base::{Epoch, WebRenderEpochToU16};
|
||||
use bitflags::bitflags;
|
||||
use compositing_traits::display_list::{CompositorDisplayListInfo, HitTestInfo, ScrollTree};
|
||||
use compositing_traits::display_list::{
|
||||
CompositorDisplayListInfo, HitTestInfo, ScrollTree, ScrollType,
|
||||
};
|
||||
use compositing_traits::rendering_context::RenderingContext;
|
||||
use compositing_traits::{
|
||||
CompositionPipeline, CompositorMsg, ImageUpdate, SendableFrameTree, WebViewTrait,
|
||||
|
@ -738,22 +740,22 @@ impl IOCompositor {
|
|||
};
|
||||
|
||||
let offset = LayoutVector2D::new(point.x, point.y);
|
||||
if !pipeline_details
|
||||
let Some(offset) = pipeline_details
|
||||
.scroll_tree
|
||||
.set_scroll_offsets_for_node_with_external_scroll_id(
|
||||
external_scroll_id,
|
||||
-offset,
|
||||
ScrollType::Script,
|
||||
)
|
||||
{
|
||||
warn!("Could not scroll not with id: {external_scroll_id:?}");
|
||||
else {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let mut txn = Transaction::new();
|
||||
txn.set_scroll_offsets(
|
||||
external_scroll_id,
|
||||
vec![SampledScrollOffset {
|
||||
offset,
|
||||
offset: -offset,
|
||||
generation: 0,
|
||||
}],
|
||||
);
|
||||
|
|
|
@ -8,6 +8,7 @@ use std::collections::{HashMap, VecDeque};
|
|||
use std::rc::Rc;
|
||||
|
||||
use base::id::{PipelineId, WebViewId};
|
||||
use compositing_traits::display_list::ScrollType;
|
||||
use compositing_traits::viewport_description::{
|
||||
DEFAULT_ZOOM, MAX_ZOOM, MIN_ZOOM, ViewportDescription,
|
||||
};
|
||||
|
@ -931,9 +932,11 @@ impl WebViewRenderer {
|
|||
{
|
||||
let pipeline_details = self.pipelines.get_mut(pipeline_id)?;
|
||||
if previous_pipeline_id.replace(pipeline_id) != Some(pipeline_id) {
|
||||
let scroll_result = pipeline_details
|
||||
.scroll_tree
|
||||
.scroll_node_or_ancestor(scroll_tree_node, scroll_location);
|
||||
let scroll_result = pipeline_details.scroll_tree.scroll_node_or_ancestor(
|
||||
scroll_tree_node,
|
||||
scroll_location,
|
||||
ScrollType::InputEvents,
|
||||
);
|
||||
if let Some((external_scroll_id, offset)) = scroll_result {
|
||||
return Some(ScrollResult {
|
||||
pipeline_id: *pipeline_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue