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>
78 lines
2.6 KiB
Rust
78 lines
2.6 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 base::print_tree::PrintTree;
|
|
use servo_arc::Arc as ServoArc;
|
|
use style::properties::ComputedValues;
|
|
|
|
use super::{BaseFragment, BaseFragmentInfo, Fragment};
|
|
use crate::cell::ArcRefCell;
|
|
use crate::geom::PhysicalRect;
|
|
|
|
/// Can contain child fragments with relative coordinates, but does not contribute to painting
|
|
/// itself. [`PositioningFragment`]s may be completely anonymous, or just non-painting Fragments
|
|
/// generated by boxes.
|
|
pub(crate) struct PositioningFragment {
|
|
pub base: BaseFragment,
|
|
pub rect: PhysicalRect<Au>,
|
|
pub children: Vec<Fragment>,
|
|
/// The scrollable overflow of this anonymous fragment's children.
|
|
pub scrollable_overflow: PhysicalRect<Au>,
|
|
|
|
/// If this fragment was created with a style, the style of the fragment.
|
|
pub style: Option<ServoArc<ComputedValues>>,
|
|
}
|
|
|
|
impl PositioningFragment {
|
|
pub fn new_anonymous(rect: PhysicalRect<Au>, children: Vec<Fragment>) -> ArcRefCell<Self> {
|
|
Self::new_with_base_fragment(BaseFragment::anonymous(), None, rect, children)
|
|
}
|
|
|
|
pub fn new_empty(
|
|
base_fragment_info: BaseFragmentInfo,
|
|
rect: PhysicalRect<Au>,
|
|
style: ServoArc<ComputedValues>,
|
|
) -> ArcRefCell<Self> {
|
|
Self::new_with_base_fragment(base_fragment_info.into(), Some(style), rect, Vec::new())
|
|
}
|
|
|
|
fn new_with_base_fragment(
|
|
base: BaseFragment,
|
|
style: Option<ServoArc<ComputedValues>>,
|
|
rect: PhysicalRect<Au>,
|
|
children: Vec<Fragment>,
|
|
) -> ArcRefCell<Self> {
|
|
let content_origin = rect.origin;
|
|
let scrollable_overflow = children.iter().fold(PhysicalRect::zero(), |acc, child| {
|
|
acc.union(
|
|
&child
|
|
.scrollable_overflow()
|
|
.translate(content_origin.to_vector()),
|
|
)
|
|
});
|
|
ArcRefCell::new(PositioningFragment {
|
|
base,
|
|
style,
|
|
rect,
|
|
children,
|
|
scrollable_overflow,
|
|
})
|
|
}
|
|
|
|
pub fn print(&self, tree: &mut PrintTree) {
|
|
tree.new_level(format!(
|
|
"PositioningFragment\
|
|
\nbase={:?}\
|
|
\nrect={:?}\
|
|
\nscrollable_overflow={:?}",
|
|
self.base, self.rect, self.scrollable_overflow
|
|
));
|
|
|
|
for child in &self.children {
|
|
child.print(tree);
|
|
}
|
|
tree.end_level();
|
|
}
|
|
}
|