layout/fragment_tree/hoisted_shared_fragment.rs
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use malloc_size_of_derive::MallocSizeOf;
6
7use super::Fragment;
8use crate::positioned::StaticPositionRect;
9
10/// A reference to a Fragment which is shared between `HoistedAbsolutelyPositionedBox`
11/// and its placeholder `AbsoluteOrFixedPositionedFragment` in the original tree position.
12/// This will be used later in order to paint this hoisted box in tree order.
13#[derive(Default, MallocSizeOf)]
14pub(crate) struct HoistedSharedFragment {
15 pub fragment: Option<Fragment>,
16 /// The original "static-position rect" of this absolutely positioned box. This is
17 /// defined by the layout mode from which the box originates. As this fragment is
18 /// hoisted up the tree this rectangle will be adjusted by the offsets of all
19 /// ancestors between the tree position of the absolute and the containing block for
20 /// absolutes that it is laid out in.
21 ///
22 /// See <https://drafts.csswg.org/css-position-3/#staticpos-rect>
23 pub original_static_position_rect: StaticPositionRect,
24}
25
26impl HoistedSharedFragment {
27 pub(crate) fn new(original_static_position_rect: StaticPositionRect) -> Self {
28 Self {
29 fragment: Default::default(),
30 original_static_position_rect,
31 }
32 }
33}