mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
There were two kinds of layout tracing controlled by the same debugging option: - modern layout: Functionality that dumped a JSON serialization of the layout tree before and after layout. - legacy layout: A scope based tracing that reported the process of layout in a structured way. I don't think anyone working on layout is using either of these two features. For modern layout requiring data structure to implement `serde` serialization is incredibly inconvenient and also generates a lot of extra code. We also have a more modern tracing functionality based on perfetto that we have started to use for layout and IMO it's actually being used and more robust. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
55 lines
2.5 KiB
Rust
55 lines
2.5 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
use app_units::Au;
|
|
use style::logical_geometry::WritingMode;
|
|
use style::values::specified::align::AlignFlags;
|
|
|
|
use super::Fragment;
|
|
use crate::geom::{LogicalVec2, PhysicalRect, PhysicalVec};
|
|
|
|
/// A reference to a Fragment which is shared between `HoistedAbsolutelyPositionedBox`
|
|
/// and its placeholder `AbsoluteOrFixedPositionedFragment` in the original tree position.
|
|
/// This will be used later in order to paint this hoisted box in tree order.
|
|
pub(crate) struct HoistedSharedFragment {
|
|
pub fragment: Option<Fragment>,
|
|
/// The "static-position rect" of this absolutely positioned box. This is defined by the
|
|
/// layout mode from which the box originates.
|
|
///
|
|
/// See <https://drafts.csswg.org/css-position-3/#staticpos-rect>
|
|
pub static_position_rect: PhysicalRect<Au>,
|
|
/// The resolved alignment values used for aligning this absolutely positioned element
|
|
/// if the "static-position rect" ends up being the "inset-modified containing block".
|
|
/// These values are dependent on the layout mode (currently only interesting for
|
|
/// flexbox).
|
|
pub resolved_alignment: LogicalVec2<AlignFlags>,
|
|
/// This is the [`WritingMode`] of the original parent of the element that created this
|
|
/// hoisted absolutely-positioned fragment. This helps to interpret the offset for
|
|
/// static positioning. If the writing mode is right-to-left or bottom-to-top, the static
|
|
/// offset needs to be adjusted by the absolutely positioned element's inline size.
|
|
pub original_parent_writing_mode: WritingMode,
|
|
}
|
|
|
|
impl HoistedSharedFragment {
|
|
pub(crate) fn new(
|
|
static_position_rect: PhysicalRect<Au>,
|
|
resolved_alignment: LogicalVec2<AlignFlags>,
|
|
original_parent_writing_mode: WritingMode,
|
|
) -> Self {
|
|
HoistedSharedFragment {
|
|
fragment: None,
|
|
static_position_rect,
|
|
resolved_alignment,
|
|
original_parent_writing_mode,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl HoistedSharedFragment {
|
|
/// `inset: auto`-positioned elements do not know their precise position until after
|
|
/// they're hoisted. This lets us adjust auto values after the fact.
|
|
pub(crate) fn adjust_offsets(&mut self, offset: &PhysicalVec<Au>) {
|
|
self.static_position_rect = self.static_position_rect.translate(*offset);
|
|
}
|
|
}
|