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 app_units::Au;
6use malloc_size_of_derive::MallocSizeOf;
7
8use super::Fragment;
9use crate::geom::PhysicalRect;
10
11/// A reference to a Fragment which is shared between `HoistedAbsolutelyPositionedBox`
12/// and its placeholder `AbsoluteOrFixedPositionedFragment` in the original tree position.
13/// This will be used later in order to paint this hoisted box in tree order.
14#[derive(Default, MallocSizeOf)]
15pub(crate) struct HoistedSharedFragment {
16 pub fragment: Option<Fragment>,
17 /// The original "static-position rect" of this absolutely positioned box. This is
18 /// defined by the layout mode from which the box originates. As this fragment is
19 /// hoisted up the tree this rectangle will be adjusted by the offsets of all
20 /// ancestors between the tree position of the absolute and the containing block for
21 /// absolutes that it is laid out in.
22 ///
23 /// See <https://drafts.csswg.org/css-position-3/#staticpos-rect>
24 pub original_static_position_rect: PhysicalRect<Au>,
25}
26
27impl HoistedSharedFragment {
28 pub(crate) fn new(original_static_position_rect: PhysicalRect<Au>) -> Self {
29 Self {
30 fragment: Default::default(),
31 original_static_position_rect,
32 }
33 }
34}