mirror of
https://github.com/servo/servo.git
synced 2025-09-19 11:20:09 +01:00
layout: Avoid ClipId, ExternalScrollId and ScrollTreeNodeId references (#39372)
Changes function signatures to accept `ClipId`, `ExternalScrollId` and `ScrollTreeNodeId` instead of `&ClipId`, `&ExternalScrollId` and `&ScrollTreeNodeId`. This avoids several `&` and `*`. Testing: not needed, no behavior change. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
aeeb3cb488
commit
1473121fe5
8 changed files with 74 additions and 75 deletions
|
@ -851,7 +851,7 @@ impl WebViewRenderer {
|
||||||
Some(&hit_test_result.pipeline_id)
|
Some(&hit_test_result.pipeline_id)
|
||||||
{
|
{
|
||||||
let scroll_result = pipeline_details.scroll_tree.scroll_node_or_ancestor(
|
let scroll_result = pipeline_details.scroll_tree.scroll_node_or_ancestor(
|
||||||
&hit_test_result.external_scroll_id,
|
hit_test_result.external_scroll_id,
|
||||||
scroll_location,
|
scroll_location,
|
||||||
ScrollType::InputEvents,
|
ScrollType::InputEvents,
|
||||||
);
|
);
|
||||||
|
|
|
@ -69,8 +69,8 @@ impl StackingContextTreeClipStore {
|
||||||
pub(super) fn add_for_clip_path(
|
pub(super) fn add_for_clip_path(
|
||||||
&mut self,
|
&mut self,
|
||||||
clip_path: ClipPath,
|
clip_path: ClipPath,
|
||||||
parent_scroll_node_id: &ScrollTreeNodeId,
|
parent_scroll_node_id: ScrollTreeNodeId,
|
||||||
parent_clip_chain_id: &ClipId,
|
parent_clip_chain_id: ClipId,
|
||||||
fragment_builder: BuilderForBoxFragment,
|
fragment_builder: BuilderForBoxFragment,
|
||||||
) -> Option<ClipId> {
|
) -> Option<ClipId> {
|
||||||
let geometry_box = match clip_path {
|
let geometry_box = match clip_path {
|
||||||
|
@ -108,8 +108,8 @@ impl StackingContextTreeClipStore {
|
||||||
_ => fragment_builder.border_radius,
|
_ => fragment_builder.border_radius,
|
||||||
},
|
},
|
||||||
layout_rect,
|
layout_rect,
|
||||||
*parent_scroll_node_id,
|
parent_scroll_node_id,
|
||||||
*parent_clip_chain_id,
|
parent_clip_chain_id,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,8 +119,8 @@ impl StackingContextTreeClipStore {
|
||||||
&mut self,
|
&mut self,
|
||||||
shape: BasicShape,
|
shape: BasicShape,
|
||||||
layout_box: LayoutRect,
|
layout_box: LayoutRect,
|
||||||
parent_scroll_node_id: &ScrollTreeNodeId,
|
parent_scroll_node_id: ScrollTreeNodeId,
|
||||||
parent_clip_chain_id: &ClipId,
|
parent_clip_chain_id: ClipId,
|
||||||
) -> Option<ClipId> {
|
) -> Option<ClipId> {
|
||||||
match shape {
|
match shape {
|
||||||
BasicShape::Rect(rect) => {
|
BasicShape::Rect(rect) => {
|
||||||
|
@ -159,8 +159,8 @@ impl StackingContextTreeClipStore {
|
||||||
Some(self.add(
|
Some(self.add(
|
||||||
radii,
|
radii,
|
||||||
shape_rect,
|
shape_rect,
|
||||||
*parent_scroll_node_id,
|
parent_scroll_node_id,
|
||||||
*parent_clip_chain_id,
|
parent_clip_chain_id,
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
BasicShape::Circle(circle) => {
|
BasicShape::Circle(circle) => {
|
||||||
|
@ -207,7 +207,7 @@ impl StackingContextTreeClipStore {
|
||||||
let start = center.add_size(&-radius);
|
let start = center.add_size(&-radius);
|
||||||
let rect = LayoutRect::from_origin_and_size(start, radius * 2.);
|
let rect = LayoutRect::from_origin_and_size(start, radius * 2.);
|
||||||
normalize_radii(&layout_box, &mut radii);
|
normalize_radii(&layout_box, &mut radii);
|
||||||
Some(self.add(radii, rect, *parent_scroll_node_id, *parent_clip_chain_id))
|
Some(self.add(radii, rect, parent_scroll_node_id, parent_clip_chain_id))
|
||||||
},
|
},
|
||||||
BasicShape::Ellipse(ellipse) => {
|
BasicShape::Ellipse(ellipse) => {
|
||||||
let center = match ellipse.position {
|
let center = match ellipse.position {
|
||||||
|
@ -247,7 +247,7 @@ impl StackingContextTreeClipStore {
|
||||||
let start = center.add_size(&-size);
|
let start = center.add_size(&-size);
|
||||||
let rect = LayoutRect::from_origin_and_size(start, size * 2.);
|
let rect = LayoutRect::from_origin_and_size(start, size * 2.);
|
||||||
normalize_radii(&rect, &mut radii);
|
normalize_radii(&rect, &mut radii);
|
||||||
Some(self.add(radii, rect, *parent_scroll_node_id, *parent_clip_chain_id))
|
Some(self.add(radii, rect, parent_scroll_node_id, parent_clip_chain_id))
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ impl<'a> HitTest<'a> {
|
||||||
.stacking_context_tree
|
.stacking_context_tree
|
||||||
.compositor_info
|
.compositor_info
|
||||||
.scroll_tree
|
.scroll_tree
|
||||||
.cumulative_root_to_node_transform(&scroll_tree_node_id)?;
|
.cumulative_root_to_node_transform(scroll_tree_node_id)?;
|
||||||
|
|
||||||
let projected_point = transform.project_point2d(self.point_to_test)?;
|
let projected_point = transform.project_point2d(self.point_to_test)?;
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ impl DisplayListBuilder<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spatial_id(&self, id: ScrollTreeNodeId) -> SpatialId {
|
fn spatial_id(&self, id: ScrollTreeNodeId) -> SpatialId {
|
||||||
self.compositor_info.scroll_tree.webrender_id(&id)
|
self.compositor_info.scroll_tree.webrender_id(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clip_chain_id(&self, id: ClipId) -> ClipChainId {
|
fn clip_chain_id(&self, id: ClipId) -> ClipChainId {
|
||||||
|
|
|
@ -204,7 +204,7 @@ impl StackingContextTree {
|
||||||
&mut self,
|
&mut self,
|
||||||
origin: LayoutPoint,
|
origin: LayoutPoint,
|
||||||
frame_origin_for_query: LayoutPoint,
|
frame_origin_for_query: LayoutPoint,
|
||||||
parent_scroll_node_id: &ScrollTreeNodeId,
|
parent_scroll_node_id: ScrollTreeNodeId,
|
||||||
transform_style: wr::TransformStyle,
|
transform_style: wr::TransformStyle,
|
||||||
transform: LayoutTransform,
|
transform: LayoutTransform,
|
||||||
kind: wr::ReferenceFrameKind,
|
kind: wr::ReferenceFrameKind,
|
||||||
|
@ -223,7 +223,7 @@ impl StackingContextTree {
|
||||||
|
|
||||||
fn define_scroll_frame(
|
fn define_scroll_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
parent_scroll_node_id: &ScrollTreeNodeId,
|
parent_scroll_node_id: ScrollTreeNodeId,
|
||||||
external_id: wr::ExternalScrollId,
|
external_id: wr::ExternalScrollId,
|
||||||
content_rect: LayoutRect,
|
content_rect: LayoutRect,
|
||||||
clip_rect: LayoutRect,
|
clip_rect: LayoutRect,
|
||||||
|
@ -244,7 +244,7 @@ impl StackingContextTree {
|
||||||
|
|
||||||
fn define_sticky_frame(
|
fn define_sticky_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
parent_scroll_node_id: &ScrollTreeNodeId,
|
parent_scroll_node_id: ScrollTreeNodeId,
|
||||||
frame_rect: LayoutRect,
|
frame_rect: LayoutRect,
|
||||||
margins: SideOffsets2D<Option<f32>, LayoutPixel>,
|
margins: SideOffsets2D<Option<f32>, LayoutPixel>,
|
||||||
vertical_offset_bounds: StickyOffsetBounds,
|
vertical_offset_bounds: StickyOffsetBounds,
|
||||||
|
@ -1018,7 +1018,7 @@ impl BoxFragment {
|
||||||
let new_spatial_id = stacking_context_tree.push_reference_frame(
|
let new_spatial_id = stacking_context_tree.push_reference_frame(
|
||||||
reference_frame_data.origin.to_webrender(),
|
reference_frame_data.origin.to_webrender(),
|
||||||
frame_origin_for_query,
|
frame_origin_for_query,
|
||||||
&containing_block.scroll_node_id,
|
containing_block.scroll_node_id,
|
||||||
self.style.get_box().transform_style.to_webrender(),
|
self.style.get_box().transform_style.to_webrender(),
|
||||||
reference_frame_data.transform,
|
reference_frame_data.transform,
|
||||||
reference_frame_data.kind,
|
reference_frame_data.kind,
|
||||||
|
@ -1100,8 +1100,8 @@ impl BoxFragment {
|
||||||
.clip_store
|
.clip_store
|
||||||
.add_for_clip_path(
|
.add_for_clip_path(
|
||||||
self.style.clone_clip_path(),
|
self.style.clone_clip_path(),
|
||||||
&containing_block.scroll_node_id,
|
containing_block.scroll_node_id,
|
||||||
&containing_block.clip_id,
|
containing_block.clip_id,
|
||||||
BuilderForBoxFragment::new(
|
BuilderForBoxFragment::new(
|
||||||
self,
|
self,
|
||||||
&containing_block.rect,
|
&containing_block.rect,
|
||||||
|
@ -1166,7 +1166,7 @@ impl BoxFragment {
|
||||||
|
|
||||||
if let Some(scroll_node_id) = self.build_sticky_frame_if_necessary(
|
if let Some(scroll_node_id) = self.build_sticky_frame_if_necessary(
|
||||||
stacking_context_tree,
|
stacking_context_tree,
|
||||||
&new_scroll_node_id,
|
new_scroll_node_id,
|
||||||
&containing_block.rect,
|
&containing_block.rect,
|
||||||
&new_scroll_frame_size,
|
&new_scroll_frame_size,
|
||||||
) {
|
) {
|
||||||
|
@ -1175,7 +1175,7 @@ impl BoxFragment {
|
||||||
|
|
||||||
if let Some(clip_id) = self.build_clip_frame_if_necessary(
|
if let Some(clip_id) = self.build_clip_frame_if_necessary(
|
||||||
stacking_context_tree,
|
stacking_context_tree,
|
||||||
&new_scroll_node_id,
|
new_scroll_node_id,
|
||||||
new_clip_id,
|
new_clip_id,
|
||||||
&containing_block.rect,
|
&containing_block.rect,
|
||||||
) {
|
) {
|
||||||
|
@ -1184,8 +1184,8 @@ impl BoxFragment {
|
||||||
|
|
||||||
if let Some(clip_id) = stacking_context_tree.clip_store.add_for_clip_path(
|
if let Some(clip_id) = stacking_context_tree.clip_store.add_for_clip_path(
|
||||||
self.style.clone_clip_path(),
|
self.style.clone_clip_path(),
|
||||||
&new_scroll_node_id,
|
new_scroll_node_id,
|
||||||
&new_clip_id,
|
new_clip_id,
|
||||||
BuilderForBoxFragment::new(
|
BuilderForBoxFragment::new(
|
||||||
self,
|
self,
|
||||||
&containing_block.rect,
|
&containing_block.rect,
|
||||||
|
@ -1243,7 +1243,7 @@ impl BoxFragment {
|
||||||
// they shouldn't scroll with the rest of the box content.
|
// they shouldn't scroll with the rest of the box content.
|
||||||
if let Some(overflow_frame_data) = self.build_overflow_frame_if_necessary(
|
if let Some(overflow_frame_data) = self.build_overflow_frame_if_necessary(
|
||||||
stacking_context_tree,
|
stacking_context_tree,
|
||||||
&new_scroll_node_id,
|
new_scroll_node_id,
|
||||||
new_clip_id,
|
new_clip_id,
|
||||||
&containing_block.rect,
|
&containing_block.rect,
|
||||||
) {
|
) {
|
||||||
|
@ -1371,7 +1371,7 @@ impl BoxFragment {
|
||||||
fn build_clip_frame_if_necessary(
|
fn build_clip_frame_if_necessary(
|
||||||
&self,
|
&self,
|
||||||
stacking_context_tree: &mut StackingContextTree,
|
stacking_context_tree: &mut StackingContextTree,
|
||||||
parent_scroll_node_id: &ScrollTreeNodeId,
|
parent_scroll_node_id: ScrollTreeNodeId,
|
||||||
parent_clip_id: ClipId,
|
parent_clip_id: ClipId,
|
||||||
containing_block_rect: &PhysicalRect<Au>,
|
containing_block_rect: &PhysicalRect<Au>,
|
||||||
) -> Option<ClipId> {
|
) -> Option<ClipId> {
|
||||||
|
@ -1396,7 +1396,7 @@ impl BoxFragment {
|
||||||
Some(stacking_context_tree.clip_store.add(
|
Some(stacking_context_tree.clip_store.add(
|
||||||
BorderRadius::zero(),
|
BorderRadius::zero(),
|
||||||
clip_rect,
|
clip_rect,
|
||||||
*parent_scroll_node_id,
|
parent_scroll_node_id,
|
||||||
parent_clip_id,
|
parent_clip_id,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -1404,7 +1404,7 @@ impl BoxFragment {
|
||||||
fn build_overflow_frame_if_necessary(
|
fn build_overflow_frame_if_necessary(
|
||||||
&self,
|
&self,
|
||||||
stacking_context_tree: &mut StackingContextTree,
|
stacking_context_tree: &mut StackingContextTree,
|
||||||
parent_scroll_node_id: &ScrollTreeNodeId,
|
parent_scroll_node_id: ScrollTreeNodeId,
|
||||||
parent_clip_id: ClipId,
|
parent_clip_id: ClipId,
|
||||||
containing_block_rect: &PhysicalRect<Au>,
|
containing_block_rect: &PhysicalRect<Au>,
|
||||||
) -> Option<OverflowFrameData> {
|
) -> Option<OverflowFrameData> {
|
||||||
|
@ -1448,7 +1448,7 @@ impl BoxFragment {
|
||||||
let clip_id = stacking_context_tree.clip_store.add(
|
let clip_id = stacking_context_tree.clip_store.add(
|
||||||
radii,
|
radii,
|
||||||
overflow_clip_rect,
|
overflow_clip_rect,
|
||||||
*parent_scroll_node_id,
|
parent_scroll_node_id,
|
||||||
parent_clip_id,
|
parent_clip_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1466,7 +1466,7 @@ impl BoxFragment {
|
||||||
let clip_id = stacking_context_tree.clip_store.add(
|
let clip_id = stacking_context_tree.clip_store.add(
|
||||||
BuilderForBoxFragment::new(self, containing_block_rect, false, false).border_radius,
|
BuilderForBoxFragment::new(self, containing_block_rect, false, false).border_radius,
|
||||||
scroll_frame_rect,
|
scroll_frame_rect,
|
||||||
*parent_scroll_node_id,
|
parent_scroll_node_id,
|
||||||
parent_clip_id,
|
parent_clip_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1501,7 +1501,7 @@ impl BoxFragment {
|
||||||
fn build_sticky_frame_if_necessary(
|
fn build_sticky_frame_if_necessary(
|
||||||
&self,
|
&self,
|
||||||
stacking_context_tree: &mut StackingContextTree,
|
stacking_context_tree: &mut StackingContextTree,
|
||||||
parent_scroll_node_id: &ScrollTreeNodeId,
|
parent_scroll_node_id: ScrollTreeNodeId,
|
||||||
containing_block_rect: &PhysicalRect<Au>,
|
containing_block_rect: &PhysicalRect<Au>,
|
||||||
scroll_frame_size: &Option<LayoutSize>,
|
scroll_frame_size: &Option<LayoutSize>,
|
||||||
) -> Option<ScrollTreeNodeId> {
|
) -> Option<ScrollTreeNodeId> {
|
||||||
|
|
|
@ -66,7 +66,7 @@ fn root_transform_for_layout_node(
|
||||||
.borrow();
|
.borrow();
|
||||||
let scroll_tree_node_id = box_fragment.spatial_tree_node.borrow();
|
let scroll_tree_node_id = box_fragment.spatial_tree_node.borrow();
|
||||||
let scroll_tree_node_id = (*scroll_tree_node_id)?;
|
let scroll_tree_node_id = (*scroll_tree_node_id)?;
|
||||||
Some(scroll_tree.cumulative_node_to_root_transform(&scroll_tree_node_id))
|
Some(scroll_tree.cumulative_node_to_root_transform(scroll_tree_node_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn process_box_area_request(
|
pub(crate) fn process_box_area_request(
|
||||||
|
|
|
@ -413,7 +413,7 @@ impl ScrollTreeNode {
|
||||||
|
|
||||||
for child_id in &self.children {
|
for child_id in &self.children {
|
||||||
scroll_tree
|
scroll_tree
|
||||||
.get_node(child_id)
|
.get_node(*child_id)
|
||||||
.invalidate_cached_transforms(scroll_tree, invalid);
|
.invalidate_cached_transforms(scroll_tree, invalid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -434,11 +434,11 @@ impl ScrollTree {
|
||||||
/// Add a scroll node to this ScrollTree returning the id of the new node.
|
/// Add a scroll node to this ScrollTree returning the id of the new node.
|
||||||
pub fn add_scroll_tree_node(
|
pub fn add_scroll_tree_node(
|
||||||
&mut self,
|
&mut self,
|
||||||
parent: Option<&ScrollTreeNodeId>,
|
parent: Option<ScrollTreeNodeId>,
|
||||||
info: SpatialTreeNodeInfo,
|
info: SpatialTreeNodeInfo,
|
||||||
) -> ScrollTreeNodeId {
|
) -> ScrollTreeNodeId {
|
||||||
self.nodes.push(ScrollTreeNode {
|
self.nodes.push(ScrollTreeNode {
|
||||||
parent: parent.cloned(),
|
parent,
|
||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
webrender_id: None,
|
webrender_id: None,
|
||||||
info,
|
info,
|
||||||
|
@ -465,24 +465,24 @@ impl ScrollTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a mutable reference to the node with the given index.
|
/// Get a mutable reference to the node with the given index.
|
||||||
pub fn get_node_mut(&mut self, id: &ScrollTreeNodeId) -> &mut ScrollTreeNode {
|
pub fn get_node_mut(&mut self, id: ScrollTreeNodeId) -> &mut ScrollTreeNode {
|
||||||
&mut self.nodes[id.index]
|
&mut self.nodes[id.index]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an immutable reference to the node with the given index.
|
/// Get an immutable reference to the node with the given index.
|
||||||
pub fn get_node(&self, id: &ScrollTreeNodeId) -> &ScrollTreeNode {
|
pub fn get_node(&self, id: ScrollTreeNodeId) -> &ScrollTreeNode {
|
||||||
&self.nodes[id.index]
|
&self.nodes[id.index]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the WebRender [`SpatialId`] for the given [`ScrollNodeId`]. This will
|
/// Get the WebRender [`SpatialId`] for the given [`ScrollNodeId`]. This will
|
||||||
/// panic if [`ScrollTree::build_display_list`] has not been called yet.
|
/// panic if [`ScrollTree::build_display_list`] has not been called yet.
|
||||||
pub fn webrender_id(&self, id: &ScrollTreeNodeId) -> SpatialId {
|
pub fn webrender_id(&self, id: ScrollTreeNodeId) -> SpatialId {
|
||||||
self.get_node(id).webrender_id()
|
self.get_node(id).webrender_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scroll_node_or_ancestor_inner(
|
pub fn scroll_node_or_ancestor_inner(
|
||||||
&mut self,
|
&mut self,
|
||||||
scroll_node_id: &ScrollTreeNodeId,
|
scroll_node_id: ScrollTreeNodeId,
|
||||||
scroll_location: ScrollLocation,
|
scroll_location: ScrollLocation,
|
||||||
context: ScrollType,
|
context: ScrollType,
|
||||||
) -> Option<(ExternalScrollId, LayoutVector2D)> {
|
) -> Option<(ExternalScrollId, LayoutVector2D)> {
|
||||||
|
@ -495,20 +495,19 @@ impl ScrollTree {
|
||||||
node.parent
|
node.parent
|
||||||
};
|
};
|
||||||
|
|
||||||
parent.and_then(|parent| {
|
parent
|
||||||
self.scroll_node_or_ancestor_inner(&parent, scroll_location, context)
|
.and_then(|parent| self.scroll_node_or_ancestor_inner(parent, scroll_location, context))
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_with_external_scroll_node_id(
|
fn node_with_external_scroll_node_id(
|
||||||
&self,
|
&self,
|
||||||
external_id: &ExternalScrollId,
|
external_id: ExternalScrollId,
|
||||||
) -> Option<ScrollTreeNodeId> {
|
) -> Option<ScrollTreeNodeId> {
|
||||||
self.nodes
|
self.nodes
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.find_map(|(index, node)| match &node.info {
|
.find_map(|(index, node)| match &node.info {
|
||||||
SpatialTreeNodeInfo::Scroll(info) if info.external_id == *external_id => {
|
SpatialTreeNodeInfo::Scroll(info) if info.external_id == external_id => {
|
||||||
Some(ScrollTreeNodeId { index })
|
Some(ScrollTreeNodeId { index })
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -521,12 +520,12 @@ impl ScrollTree {
|
||||||
/// new offset if a scroll was performed, otherwise returns None.
|
/// new offset if a scroll was performed, otherwise returns None.
|
||||||
pub fn scroll_node_or_ancestor(
|
pub fn scroll_node_or_ancestor(
|
||||||
&mut self,
|
&mut self,
|
||||||
external_id: &ExternalScrollId,
|
external_id: ExternalScrollId,
|
||||||
scroll_location: ScrollLocation,
|
scroll_location: ScrollLocation,
|
||||||
context: ScrollType,
|
context: ScrollType,
|
||||||
) -> Option<(ExternalScrollId, LayoutVector2D)> {
|
) -> Option<(ExternalScrollId, LayoutVector2D)> {
|
||||||
let scroll_node_id = self.node_with_external_scroll_node_id(external_id)?;
|
let scroll_node_id = self.node_with_external_scroll_node_id(external_id)?;
|
||||||
let result = self.scroll_node_or_ancestor_inner(&scroll_node_id, scroll_location, context);
|
let result = self.scroll_node_or_ancestor_inner(scroll_node_id, scroll_location, context);
|
||||||
if result.is_some() {
|
if result.is_some() {
|
||||||
self.invalidate_cached_transforms();
|
self.invalidate_cached_transforms();
|
||||||
}
|
}
|
||||||
|
@ -609,7 +608,7 @@ impl ScrollTree {
|
||||||
/// point in the root coordinate system.
|
/// point in the root coordinate system.
|
||||||
pub fn cumulative_node_to_root_transform(
|
pub fn cumulative_node_to_root_transform(
|
||||||
&self,
|
&self,
|
||||||
node_id: &ScrollTreeNodeId,
|
node_id: ScrollTreeNodeId,
|
||||||
) -> FastLayoutTransform {
|
) -> FastLayoutTransform {
|
||||||
let node = self.get_node(node_id);
|
let node = self.get_node(node_id);
|
||||||
if let Some(cached_transforms) = node.transformation_cache.get() {
|
if let Some(cached_transforms) = node.transformation_cache.get() {
|
||||||
|
@ -626,7 +625,7 @@ impl ScrollTree {
|
||||||
/// transform is uninvertible.
|
/// transform is uninvertible.
|
||||||
pub fn cumulative_root_to_node_transform(
|
pub fn cumulative_root_to_node_transform(
|
||||||
&self,
|
&self,
|
||||||
node_id: &ScrollTreeNodeId,
|
node_id: ScrollTreeNodeId,
|
||||||
) -> Option<FastLayoutTransform> {
|
) -> Option<FastLayoutTransform> {
|
||||||
let node = self.get_node(node_id);
|
let node = self.get_node(node_id);
|
||||||
if let Some(cached_transforms) = node.transformation_cache.get() {
|
if let Some(cached_transforms) = node.transformation_cache.get() {
|
||||||
|
@ -644,7 +643,7 @@ impl ScrollTree {
|
||||||
node: &ScrollTreeNode,
|
node: &ScrollTreeNode,
|
||||||
) -> (ScrollTreeNodeTransformationCache, AncestorStickyInfo) {
|
) -> (ScrollTreeNodeTransformationCache, AncestorStickyInfo) {
|
||||||
let (parent_transforms, mut sticky_info) = match node.parent {
|
let (parent_transforms, mut sticky_info) = match node.parent {
|
||||||
Some(parent_id) => self.cumulative_node_transform_inner(self.get_node(&parent_id)),
|
Some(parent_id) => self.cumulative_node_transform_inner(self.get_node(parent_id)),
|
||||||
None => (Default::default(), Default::default()),
|
None => (Default::default(), Default::default()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -712,13 +711,13 @@ impl ScrollTree {
|
||||||
&self,
|
&self,
|
||||||
id: ScrollTreeNodeId,
|
id: ScrollTreeNodeId,
|
||||||
) -> Option<ExternalScrollId> {
|
) -> Option<ExternalScrollId> {
|
||||||
let mut maybe_node = Some(self.get_node(&id));
|
let mut maybe_node = Some(self.get_node(id));
|
||||||
|
|
||||||
while let Some(node) = maybe_node {
|
while let Some(node) = maybe_node {
|
||||||
if let Some(external_scroll_id) = node.external_id() {
|
if let Some(external_scroll_id) = node.external_id() {
|
||||||
return Some(external_scroll_id);
|
return Some(external_scroll_id);
|
||||||
}
|
}
|
||||||
maybe_node = node.parent.map(|id| self.get_node(&id));
|
maybe_node = node.parent.map(|id| self.get_node(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
|
@ -752,12 +751,12 @@ impl ScrollTree {
|
||||||
fn debug_print_traversal(
|
fn debug_print_traversal(
|
||||||
&self,
|
&self,
|
||||||
print_tree: &mut PrintTree,
|
print_tree: &mut PrintTree,
|
||||||
current_id: &ScrollTreeNodeId,
|
current_id: ScrollTreeNodeId,
|
||||||
adjacency_list: &[Vec<ScrollTreeNodeId>],
|
adjacency_list: &[Vec<ScrollTreeNodeId>],
|
||||||
) {
|
) {
|
||||||
for node_id in &adjacency_list[current_id.index] {
|
for node_id in &adjacency_list[current_id.index] {
|
||||||
self.nodes[node_id.index].debug_print(print_tree, node_id.index);
|
self.nodes[node_id.index].debug_print(print_tree, node_id.index);
|
||||||
self.debug_print_traversal(print_tree, node_id, adjacency_list);
|
self.debug_print_traversal(print_tree, *node_id, adjacency_list);
|
||||||
}
|
}
|
||||||
print_tree.end_level();
|
print_tree.end_level();
|
||||||
}
|
}
|
||||||
|
@ -775,7 +774,7 @@ impl ScrollTree {
|
||||||
let root_id = ScrollTreeNodeId { index: 0 };
|
let root_id = ScrollTreeNodeId { index: 0 };
|
||||||
|
|
||||||
self.nodes[root_id.index].debug_print(&mut print_tree, root_id.index);
|
self.nodes[root_id.index].debug_print(&mut print_tree, root_id.index);
|
||||||
self.debug_print_traversal(&mut print_tree, &root_id, &adj_list);
|
self.debug_print_traversal(&mut print_tree, root_id, &adj_list);
|
||||||
print_tree.end_level();
|
print_tree.end_level();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -842,7 +841,7 @@ impl CompositorDisplayListInfo {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
let root_scroll_node_id = scroll_tree.add_scroll_tree_node(
|
let root_scroll_node_id = scroll_tree.add_scroll_tree_node(
|
||||||
Some(&root_reference_frame_id),
|
Some(root_reference_frame_id),
|
||||||
SpatialTreeNodeInfo::Scroll(ScrollableNodeInfo {
|
SpatialTreeNodeInfo::Scroll(ScrollableNodeInfo {
|
||||||
external_id: ExternalScrollId(0, pipeline_id),
|
external_id: ExternalScrollId(0, pipeline_id),
|
||||||
content_rect: LayoutRect::from_origin_and_size(LayoutPoint::zero(), content_size),
|
content_rect: LayoutRect::from_origin_and_size(LayoutPoint::zero(), content_size),
|
||||||
|
|
|
@ -25,7 +25,7 @@ fn add_mock_scroll_node(tree: &mut ScrollTree) -> (ScrollTreeNodeId, ExternalScr
|
||||||
|
|
||||||
let external_id = ExternalScrollId(num_nodes as u64, pipeline_id);
|
let external_id = ExternalScrollId(num_nodes as u64, pipeline_id);
|
||||||
let scroll_node_id = tree.add_scroll_tree_node(
|
let scroll_node_id = tree.add_scroll_tree_node(
|
||||||
parent.as_ref(),
|
parent,
|
||||||
SpatialTreeNodeInfo::Scroll(ScrollableNodeInfo {
|
SpatialTreeNodeInfo::Scroll(ScrollableNodeInfo {
|
||||||
external_id,
|
external_id,
|
||||||
content_rect: Size2D::new(200.0, 200.0).into(),
|
content_rect: Size2D::new(200.0, 200.0).into(),
|
||||||
|
@ -48,7 +48,7 @@ fn test_scroll_tree_simple_scroll() {
|
||||||
|
|
||||||
let (scrolled_id, offset) = scroll_tree
|
let (scrolled_id, offset) = scroll_tree
|
||||||
.scroll_node_or_ancestor(
|
.scroll_node_or_ancestor(
|
||||||
&external_id,
|
external_id,
|
||||||
ScrollLocation::Delta(LayoutVector2D::new(20.0, 40.0)),
|
ScrollLocation::Delta(LayoutVector2D::new(20.0, 40.0)),
|
||||||
ScrollType::Script,
|
ScrollType::Script,
|
||||||
)
|
)
|
||||||
|
@ -56,11 +56,11 @@ fn test_scroll_tree_simple_scroll() {
|
||||||
let expected_offset = LayoutVector2D::new(20.0, 40.0);
|
let expected_offset = LayoutVector2D::new(20.0, 40.0);
|
||||||
assert_eq!(scrolled_id, external_id);
|
assert_eq!(scrolled_id, external_id);
|
||||||
assert_eq!(offset, expected_offset);
|
assert_eq!(offset, expected_offset);
|
||||||
assert_eq!(scroll_tree.get_node(&id).offset(), Some(expected_offset));
|
assert_eq!(scroll_tree.get_node(id).offset(), Some(expected_offset));
|
||||||
|
|
||||||
let (scrolled_id, offset) = scroll_tree
|
let (scrolled_id, offset) = scroll_tree
|
||||||
.scroll_node_or_ancestor(
|
.scroll_node_or_ancestor(
|
||||||
&external_id,
|
external_id,
|
||||||
ScrollLocation::Delta(LayoutVector2D::new(-20.0, -40.0)),
|
ScrollLocation::Delta(LayoutVector2D::new(-20.0, -40.0)),
|
||||||
ScrollType::Script,
|
ScrollType::Script,
|
||||||
)
|
)
|
||||||
|
@ -68,17 +68,17 @@ fn test_scroll_tree_simple_scroll() {
|
||||||
let expected_offset = LayoutVector2D::new(0.0, 0.0);
|
let expected_offset = LayoutVector2D::new(0.0, 0.0);
|
||||||
assert_eq!(scrolled_id, external_id);
|
assert_eq!(scrolled_id, external_id);
|
||||||
assert_eq!(offset, expected_offset);
|
assert_eq!(offset, expected_offset);
|
||||||
assert_eq!(scroll_tree.get_node(&id).offset(), Some(expected_offset));
|
assert_eq!(scroll_tree.get_node(id).offset(), Some(expected_offset));
|
||||||
|
|
||||||
// Scroll offsets must be positive.
|
// Scroll offsets must be positive.
|
||||||
let result = scroll_tree.scroll_node_or_ancestor(
|
let result = scroll_tree.scroll_node_or_ancestor(
|
||||||
&external_id,
|
external_id,
|
||||||
ScrollLocation::Delta(LayoutVector2D::new(-20.0, -40.0)),
|
ScrollLocation::Delta(LayoutVector2D::new(-20.0, -40.0)),
|
||||||
ScrollType::Script,
|
ScrollType::Script,
|
||||||
);
|
);
|
||||||
assert!(result.is_none());
|
assert!(result.is_none());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
scroll_tree.get_node(&id).offset(),
|
scroll_tree.get_node(id).offset(),
|
||||||
Some(LayoutVector2D::new(0.0, 0.0))
|
Some(LayoutVector2D::new(0.0, 0.0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ fn test_scroll_tree_simple_scroll_chaining() {
|
||||||
|
|
||||||
let unscrollable_external_id = ExternalScrollId(100 as u64, pipeline_id);
|
let unscrollable_external_id = ExternalScrollId(100 as u64, pipeline_id);
|
||||||
let unscrollable_child_id = scroll_tree.add_scroll_tree_node(
|
let unscrollable_child_id = scroll_tree.add_scroll_tree_node(
|
||||||
Some(&parent_id),
|
Some(parent_id),
|
||||||
SpatialTreeNodeInfo::Scroll(ScrollableNodeInfo {
|
SpatialTreeNodeInfo::Scroll(ScrollableNodeInfo {
|
||||||
external_id: unscrollable_external_id,
|
external_id: unscrollable_external_id,
|
||||||
content_rect: Size2D::new(100.0, 100.0).into(),
|
content_rect: Size2D::new(100.0, 100.0).into(),
|
||||||
|
@ -108,7 +108,7 @@ fn test_scroll_tree_simple_scroll_chaining() {
|
||||||
|
|
||||||
let (scrolled_id, offset) = scroll_tree
|
let (scrolled_id, offset) = scroll_tree
|
||||||
.scroll_node_or_ancestor(
|
.scroll_node_or_ancestor(
|
||||||
&unscrollable_external_id,
|
unscrollable_external_id,
|
||||||
ScrollLocation::Delta(LayoutVector2D::new(20.0, 40.0)),
|
ScrollLocation::Delta(LayoutVector2D::new(20.0, 40.0)),
|
||||||
ScrollType::Script,
|
ScrollType::Script,
|
||||||
)
|
)
|
||||||
|
@ -117,13 +117,13 @@ fn test_scroll_tree_simple_scroll_chaining() {
|
||||||
assert_eq!(scrolled_id, parent_external_id);
|
assert_eq!(scrolled_id, parent_external_id);
|
||||||
assert_eq!(offset, expected_offset);
|
assert_eq!(offset, expected_offset);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
scroll_tree.get_node(&parent_id).offset(),
|
scroll_tree.get_node(parent_id).offset(),
|
||||||
Some(expected_offset)
|
Some(expected_offset)
|
||||||
);
|
);
|
||||||
|
|
||||||
let (scrolled_id, offset) = scroll_tree
|
let (scrolled_id, offset) = scroll_tree
|
||||||
.scroll_node_or_ancestor(
|
.scroll_node_or_ancestor(
|
||||||
&unscrollable_external_id,
|
unscrollable_external_id,
|
||||||
ScrollLocation::Delta(LayoutVector2D::new(10.0, 15.0)),
|
ScrollLocation::Delta(LayoutVector2D::new(10.0, 15.0)),
|
||||||
ScrollType::Script,
|
ScrollType::Script,
|
||||||
)
|
)
|
||||||
|
@ -132,11 +132,11 @@ fn test_scroll_tree_simple_scroll_chaining() {
|
||||||
assert_eq!(scrolled_id, parent_external_id);
|
assert_eq!(scrolled_id, parent_external_id);
|
||||||
assert_eq!(offset, expected_offset);
|
assert_eq!(offset, expected_offset);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
scroll_tree.get_node(&parent_id).offset(),
|
scroll_tree.get_node(parent_id).offset(),
|
||||||
Some(expected_offset)
|
Some(expected_offset)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
scroll_tree.get_node(&unscrollable_child_id).offset(),
|
scroll_tree.get_node(unscrollable_child_id).offset(),
|
||||||
Some(LayoutVector2D::zero())
|
Some(LayoutVector2D::zero())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -149,14 +149,14 @@ fn test_scroll_tree_chain_when_at_extent() {
|
||||||
let (child_id, child_external_id) = add_mock_scroll_node(&mut scroll_tree);
|
let (child_id, child_external_id) = add_mock_scroll_node(&mut scroll_tree);
|
||||||
|
|
||||||
let (scrolled_id, offset) = scroll_tree
|
let (scrolled_id, offset) = scroll_tree
|
||||||
.scroll_node_or_ancestor(&child_external_id, ScrollLocation::End, ScrollType::Script)
|
.scroll_node_or_ancestor(child_external_id, ScrollLocation::End, ScrollType::Script)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let expected_offset = LayoutVector2D::new(0.0, 100.0);
|
let expected_offset = LayoutVector2D::new(0.0, 100.0);
|
||||||
assert_eq!(scrolled_id, child_external_id);
|
assert_eq!(scrolled_id, child_external_id);
|
||||||
assert_eq!(offset, expected_offset);
|
assert_eq!(offset, expected_offset);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
scroll_tree.get_node(&child_id).offset(),
|
scroll_tree.get_node(child_id).offset(),
|
||||||
Some(expected_offset)
|
Some(expected_offset)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ fn test_scroll_tree_chain_when_at_extent() {
|
||||||
// of its scroll area in the y axis.
|
// of its scroll area in the y axis.
|
||||||
let (scrolled_id, offset) = scroll_tree
|
let (scrolled_id, offset) = scroll_tree
|
||||||
.scroll_node_or_ancestor(
|
.scroll_node_or_ancestor(
|
||||||
&child_external_id,
|
child_external_id,
|
||||||
ScrollLocation::Delta(LayoutVector2D::new(0.0, 10.0)),
|
ScrollLocation::Delta(LayoutVector2D::new(0.0, 10.0)),
|
||||||
ScrollType::Script,
|
ScrollType::Script,
|
||||||
)
|
)
|
||||||
|
@ -173,7 +173,7 @@ fn test_scroll_tree_chain_when_at_extent() {
|
||||||
assert_eq!(scrolled_id, parent_external_id);
|
assert_eq!(scrolled_id, parent_external_id);
|
||||||
assert_eq!(offset, expected_offset);
|
assert_eq!(offset, expected_offset);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
scroll_tree.get_node(&parent_id).offset(),
|
scroll_tree.get_node(parent_id).offset(),
|
||||||
Some(expected_offset)
|
Some(expected_offset)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ fn test_scroll_tree_chain_through_overflow_hidden() {
|
||||||
// reflect `overflow: hidden` ie not responsive to non-script scroll events.
|
// reflect `overflow: hidden` ie not responsive to non-script scroll events.
|
||||||
let (parent_id, parent_external_id) = add_mock_scroll_node(&mut scroll_tree);
|
let (parent_id, parent_external_id) = add_mock_scroll_node(&mut scroll_tree);
|
||||||
let (overflow_hidden_id, overflow_hidden_external_id) = add_mock_scroll_node(&mut scroll_tree);
|
let (overflow_hidden_id, overflow_hidden_external_id) = add_mock_scroll_node(&mut scroll_tree);
|
||||||
let node = scroll_tree.get_node_mut(&overflow_hidden_id);
|
let node = scroll_tree.get_node_mut(overflow_hidden_id);
|
||||||
|
|
||||||
if let SpatialTreeNodeInfo::Scroll(ref mut scroll_node_info) = node.info {
|
if let SpatialTreeNodeInfo::Scroll(ref mut scroll_node_info) = node.info {
|
||||||
scroll_node_info.scroll_sensitivity = AxesScrollSensitivity {
|
scroll_node_info.scroll_sensitivity = AxesScrollSensitivity {
|
||||||
|
@ -197,7 +197,7 @@ fn test_scroll_tree_chain_through_overflow_hidden() {
|
||||||
|
|
||||||
let (scrolled_id, offset) = scroll_tree
|
let (scrolled_id, offset) = scroll_tree
|
||||||
.scroll_node_or_ancestor(
|
.scroll_node_or_ancestor(
|
||||||
&overflow_hidden_external_id,
|
overflow_hidden_external_id,
|
||||||
ScrollLocation::Delta(LayoutVector2D::new(20.0, 40.0)),
|
ScrollLocation::Delta(LayoutVector2D::new(20.0, 40.0)),
|
||||||
ScrollType::InputEvents,
|
ScrollType::InputEvents,
|
||||||
)
|
)
|
||||||
|
@ -206,11 +206,11 @@ fn test_scroll_tree_chain_through_overflow_hidden() {
|
||||||
assert_eq!(scrolled_id, parent_external_id);
|
assert_eq!(scrolled_id, parent_external_id);
|
||||||
assert_eq!(offset, expected_offset);
|
assert_eq!(offset, expected_offset);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
scroll_tree.get_node(&parent_id).offset(),
|
scroll_tree.get_node(parent_id).offset(),
|
||||||
Some(expected_offset)
|
Some(expected_offset)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
scroll_tree.get_node(&overflow_hidden_id).offset(),
|
scroll_tree.get_node(overflow_hidden_id).offset(),
|
||||||
Some(LayoutVector2D::new(0.0, 0.0))
|
Some(LayoutVector2D::new(0.0, 0.0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue