зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1874199 - Split the handling of StickyFrame and ScrollFrame in SpatialNode::update_transform(). r=gw
The two cases share some code, but the next patch will add extra logic specific to the StickyFrame case, which makes it cleaner to split them. Differential Revision: https://phabricator.services.mozilla.com/D208236
This commit is contained in:
Родитель
c73c31cbe8
Коммит
64de57eafb
|
@ -518,17 +518,29 @@ impl SpatialNode {
|
|||
self.viewport_transform = cs_scale_offset;
|
||||
self.content_transform = cs_scale_offset;
|
||||
}
|
||||
_ => {
|
||||
// We calculate this here to avoid a double-borrow later.
|
||||
let sticky_offset = self.calculate_sticky_offset(
|
||||
SpatialNodeType::StickyFrame(ref mut info) => {
|
||||
let sticky_offset = Self::calculate_sticky_offset(
|
||||
&state.nearest_scrolling_ancestor_offset,
|
||||
&state.nearest_scrolling_ancestor_viewport,
|
||||
info,
|
||||
);
|
||||
|
||||
// The transformation for the bounds of our viewport is the parent reference frame
|
||||
// transform, plus any accumulated scroll offset from our parents, plus any offset
|
||||
// provided by our own sticky positioning.
|
||||
let accumulated_offset = state.parent_accumulated_scroll_offset + sticky_offset;
|
||||
self.viewport_transform = state.coordinate_system_relative_scale_offset
|
||||
.offset(snap_offset(accumulated_offset, state.coordinate_system_relative_scale_offset.scale).to_untyped());
|
||||
self.content_transform = self.viewport_transform;
|
||||
|
||||
info.current_offset = sticky_offset;
|
||||
|
||||
self.coordinate_system_id = state.current_coordinate_system_id;
|
||||
}
|
||||
SpatialNodeType::ScrollFrame(_) => {
|
||||
// The transformation for the bounds of our viewport is the parent reference frame
|
||||
// transform, plus any accumulated scroll offset from our parents.
|
||||
let accumulated_offset = state.parent_accumulated_scroll_offset;
|
||||
self.viewport_transform = state.coordinate_system_relative_scale_offset
|
||||
.offset(snap_offset(accumulated_offset, state.coordinate_system_relative_scale_offset.scale).to_untyped());
|
||||
|
||||
|
@ -538,12 +550,8 @@ impl SpatialNode {
|
|||
self.content_transform = state.coordinate_system_relative_scale_offset
|
||||
.offset(snap_offset(added_offset, state.coordinate_system_relative_scale_offset.scale).to_untyped());
|
||||
|
||||
if let SpatialNodeType::StickyFrame(ref mut info) = self.node_type {
|
||||
info.current_offset = sticky_offset;
|
||||
}
|
||||
|
||||
self.coordinate_system_id = state.current_coordinate_system_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: remove the field entirely?
|
||||
|
@ -555,15 +563,10 @@ impl SpatialNode {
|
|||
}
|
||||
|
||||
fn calculate_sticky_offset(
|
||||
&self,
|
||||
viewport_scroll_offset: &LayoutVector2D,
|
||||
viewport_rect: &LayoutRect,
|
||||
info: &StickyFrameInfo
|
||||
) -> LayoutVector2D {
|
||||
let info = match self.node_type {
|
||||
SpatialNodeType::StickyFrame(ref info) => info,
|
||||
_ => return LayoutVector2D::zero(),
|
||||
};
|
||||
|
||||
if info.margins.top.is_none() && info.margins.bottom.is_none() &&
|
||||
info.margins.left.is_none() && info.margins.right.is_none() {
|
||||
return LayoutVector2D::zero();
|
||||
|
|
Загрузка…
Ссылка в новой задаче