diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-01-15 14:24:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-15 13:24:14 +0000 |
commit | e81951a973d39ed5cacb067318e05d0d6a078559 (patch) | |
tree | fac08a5c385f1bbea25feaca5be559317c02a3f2 | |
parent | 2cd5e1356c8383935608cc1c719141628d8e21c9 (diff) | |
download | servo-e81951a973d39ed5cacb067318e05d0d6a078559.tar.gz servo-e81951a973d39ed5cacb067318e05d0d6a078559.zip |
layout: Remove the obsolete layout tracing functionality (#35001)
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>
45 files changed, 64 insertions, 675 deletions
diff --git a/Cargo.lock b/Cargo.lock index 5dfd24d8b97..0e46b2816d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4005,8 +4005,6 @@ dependencies = [ "rayon", "script_layout_interface", "selectors", - "serde", - "serde_json", "servo_arc", "servo_config", "servo_geometry", diff --git a/components/layout/block.rs b/components/layout/block.rs index 43817cbbc25..df1f9b8085d 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -67,8 +67,8 @@ use crate::incremental::RelayoutMode; use crate::model::{ AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto, }; +use crate::sequential; use crate::traversal::PreorderFlowTraversal; -use crate::{layout_debug, layout_debug_scope, sequential}; /// Information specific to floated blocks. #[derive(Clone, Serialize)] @@ -922,8 +922,6 @@ impl BlockFlow { mut fragmentation_context: Option<FragmentationContext>, margins_may_collapse: MarginsMayCollapseFlag, ) -> Option<Arc<dyn Flow>> { - let _scope = layout_debug_scope!("assign_block_size_block_base {:x}", self.base.debug_id()); - let mut break_at = None; let content_box = self.fragment.content_box(); if self @@ -1861,8 +1859,6 @@ impl BlockFlow { /// Computes intrinsic inline sizes for a block. pub fn bubble_inline_sizes_for_block(&mut self, consult_children: bool) { - let _scope = layout_debug_scope!("block::bubble_inline_sizes {:x}", self.base.debug_id()); - let mut flags = self.base.flags; if self.definitely_has_zero_block_size() { // This is kind of a hack for Acid2. But it's a harmless one, because (a) this behavior @@ -2186,8 +2182,6 @@ impl Flow for BlockFlow { /// Dual fragments consume some inline-size first, and the remainder is assigned to all child /// (block) contexts. fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!("block::assign_inline_sizes {:x}", self.base.debug_id()); - let shared_context = layout_context.shared_context(); self.compute_inline_sizes(shared_context); @@ -2277,11 +2271,6 @@ impl Flow for BlockFlow { fragmentation_context: Option<FragmentationContext>, ) -> Option<Arc<dyn Flow>> { if self.fragment.is_replaced() { - let _scope = layout_debug_scope!( - "assign_replaced_block_size_if_necessary {:x}", - self.base.debug_id() - ); - // Assign block-size for fragment if it is an image fragment. self.fragment.assign_replaced_block_size_if_necessary(); if !self @@ -2315,10 +2304,6 @@ impl Flow for BlockFlow { { // Root element margins should never be collapsed according to CSS § 8.3.1. debug!("{}", self.is_root()); - debug!( - "assign_block_size: assigning block_size for root flow {:#x?}", - self.base().debug_id() - ); trace!("BlockFlow before assigning: {:?}", &self); let flow = self.assign_block_size_block_base( layout_context, @@ -2328,10 +2313,6 @@ impl Flow for BlockFlow { trace!("BlockFlow after assigning: {:?}", &self); flow } else { - debug!( - "assign_block_size: assigning block_size for block {:#x?}", - self.base().debug_id() - ); trace!("BlockFlow before assigning: {:?}", &self); let flow = self.assign_block_size_block_base( layout_context, @@ -2660,13 +2641,7 @@ impl Flow for BlockFlow { impl fmt::Debug for BlockFlow { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "{:?}({:x}) {:?}", - self.class(), - self.base.debug_id(), - self.base - ) + write!(f, "{:?} {:?}", self.class(), self.base) } } diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 74e2400faa0..c73c534e50d 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -97,14 +97,6 @@ impl ConstructionResult { // inefficient! (*self).clone() } - - pub fn debug_id(&self) -> usize { - match *self { - ConstructionResult::None => 0, - ConstructionResult::ConstructionItem(_) => 0, - ConstructionResult::Flow(ref flow_ref, _) => flow_ref.base().debug_id(), - } - } } /// Represents the output of flow construction for a DOM node that has not yet resulted in a diff --git a/components/layout/flex.rs b/components/layout/flex.rs index 87408ad66f1..7e422078967 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -32,7 +32,6 @@ use crate::model::{ self, AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MaybeAuto, SizeConstraint, }; use crate::traversal::PreorderFlowTraversal; -use crate::{layout_debug, layout_debug_scope}; /// The size of an axis. May be a specified size, a min/max /// constraint, or an unlimited size @@ -513,7 +512,6 @@ impl FlexFlow { inline_end_content_edge: Au, content_inline_size: Au, ) { - let _scope = layout_debug_scope!("flex::block_mode_assign_inline_sizes"); debug!("flex::block_mode_assign_inline_sizes"); // FIXME (mbrubeck): Get correct mode for absolute containing block @@ -560,7 +558,6 @@ impl FlexFlow { _inline_end_content_edge: Au, content_inline_size: Au, ) { - let _scope = layout_debug_scope!("flex::inline_mode_assign_inline_sizes"); debug!("inline_mode_assign_inline_sizes"); debug!("content_inline_size = {:?}", content_inline_size); @@ -718,8 +715,6 @@ impl FlexFlow { } fn inline_mode_assign_block_size(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!("flex::inline_mode_assign_block_size"); - let line_count = self.lines.len() as i32; let line_align = { let line_align = self @@ -932,11 +927,6 @@ impl Flow for FlexFlow { } fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!( - "flex::bubble_inline_sizes {:x}", - self.block_flow.base.debug_id() - ); - // Flexbox Section 9.0: Generate anonymous flex items: // This part was handled in the flow constructor. @@ -968,10 +958,6 @@ impl Flow for FlexFlow { } fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!( - "flex::assign_inline_sizes {:x}", - self.block_flow.base.debug_id() - ); debug!("assign_inline_sizes"); if !self diff --git a/components/layout/flow.rs b/components/layout/flow.rs index b5140f8e8e7..ac167aad890 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -1010,7 +1010,6 @@ impl fmt::Debug for BaseFlow { impl Serialize for BaseFlow { fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { let mut serializer = serializer.serialize_struct("base", 5)?; - serializer.serialize_field("id", &self.debug_id())?; serializer.serialize_field( "stacking_relative_position", &self.stacking_relative_position, @@ -1187,11 +1186,6 @@ impl BaseFlow { self.children.iter_mut() } - pub fn debug_id(&self) -> usize { - let p = self as *const _; - p as usize - } - pub fn collect_stacking_contexts_for_children( &mut self, state: &mut StackingContextCollectionState, diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index e750f08d61d..b50add41e98 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -66,8 +66,6 @@ use crate::inline::{ InlineFragmentContext, InlineFragmentNodeFlags, InlineFragmentNodeInfo, InlineMetrics, LineMetrics, }; -#[cfg(debug_assertions)] -use crate::layout_debug; use crate::model::{ self, style_length, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, SizeConstraint, }; @@ -151,11 +149,6 @@ pub struct Fragment { /// Various flags for this fragment. pub flags: FragmentFlags, - /// A debug ID that is consistent for the life of this fragment (via transform etc). - /// This ID should not be considered stable across multiple layouts or fragment - /// manipulations. - debug_id: DebugId, - /// The ID of the StackingContext that contains this fragment. This is initialized /// to 0, but it assigned during the collect_stacking_contexts phase of display /// list construction. @@ -170,7 +163,6 @@ pub struct Fragment { impl Serialize for Fragment { fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { let mut serializer = serializer.serialize_struct("fragment", 3)?; - serializer.serialize_field("id", &self.debug_id)?; serializer.serialize_field("border_box", &self.border_box)?; serializer.serialize_field("margin", &self.margin)?; serializer.end() @@ -699,7 +691,6 @@ impl Fragment { inline_context: None, pseudo: node.get_pseudo_element_type(), flags, - debug_id: DebugId::new(), stacking_context_id: StackingContextId::root(), established_reference_frame: None, } @@ -730,7 +721,6 @@ impl Fragment { inline_context: None, pseudo, flags: FragmentFlags::empty(), - debug_id: DebugId::new(), stacking_context_id: StackingContextId::root(), established_reference_frame: None, } @@ -757,7 +747,6 @@ impl Fragment { inline_context: None, pseudo: self.pseudo, flags: FragmentFlags::empty(), - debug_id: DebugId::new(), stacking_context_id: StackingContextId::root(), established_reference_frame: None, } @@ -784,7 +773,6 @@ impl Fragment { inline_context: self.inline_context.clone(), pseudo: self.pseudo, flags: FragmentFlags::empty(), - debug_id: self.debug_id.clone(), stacking_context_id: StackingContextId::root(), established_reference_frame: None, } @@ -3274,14 +3262,13 @@ impl fmt::Debug for Fragment { write!( f, - "\n{}({}) [{:?}]\ + "\n{} [{:?}]\ \nborder_box={:?}\ {border_padding_string}\ {margin_string}\ {damage_string}\ {flags_string}", self.specific.get_type(), - self.debug_id, self.specific, self.border_box, ) @@ -3447,53 +3434,3 @@ pub struct SpeculatedInlineContentEdgeOffsets { pub start: Au, pub end: Au, } - -#[cfg(not(debug_assertions))] -#[derive(Clone)] -struct DebugId; - -#[cfg(debug_assertions)] -#[derive(Clone)] -struct DebugId(u16); - -#[cfg(not(debug_assertions))] -impl DebugId { - pub fn new() -> DebugId { - DebugId - } -} - -#[cfg(debug_assertions)] -impl DebugId { - pub fn new() -> DebugId { - DebugId(layout_debug::generate_unique_debug_id()) - } -} - -#[cfg(not(debug_assertions))] -impl fmt::Display for DebugId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{:p}", &self) - } -} - -#[cfg(debug_assertions)] -impl fmt::Display for DebugId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.0) - } -} - -#[cfg(not(debug_assertions))] -impl Serialize for DebugId { - fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { - serializer.serialize_str(&format!("{:p}", &self)) - } -} - -#[cfg(debug_assertions)] -impl Serialize for DebugId { - fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { - serializer.serialize_u16(self.0) - } -} diff --git a/components/layout/inline.rs b/components/layout/inline.rs index aa851a29ed3..e72a0d1524a 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -50,7 +50,7 @@ use crate::fragment::{ }; use crate::model::IntrinsicISizesContribution; use crate::traversal::PreorderFlowTraversal; -use crate::{layout_debug, layout_debug_scope, text, ServoArc}; +use crate::{text, ServoArc}; /// `Line`s are represented as offsets into the child list, rather than /// as an object that "owns" fragments. Choosing a different set of line @@ -1479,8 +1479,6 @@ impl Flow for InlineFlow { fn bubble_inline_sizes(&mut self) { self.update_restyle_damage(); - let _scope = layout_debug_scope!("inline::bubble_inline_sizes {:x}", self.base.debug_id()); - let writing_mode = self.base.writing_mode; for kid in self.base.child_iter_mut() { kid.mut_base().floats = Floats::new(writing_mode); @@ -1579,8 +1577,6 @@ impl Flow for InlineFlow { /// Recursively (top-down) determines the actual inline-size of child contexts and fragments. /// When called on this context, the context has had its inline-size set by the parent context. fn assign_inline_sizes(&mut self, _: &LayoutContext) { - let _scope = layout_debug_scope!("inline::assign_inline_sizes {:x}", self.base.debug_id()); - // Initialize content fragment inline-sizes if they haven't been initialized already. // // TODO: Combine this with `LineBreaker`'s walk in the fragment list, or put this into @@ -1623,8 +1619,6 @@ impl Flow for InlineFlow { /// Note that we do not need to do in-order traversal because the children /// are always block formatting context. fn assign_block_size(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!("inline::assign_block_size {:x}", self.base.debug_id()); - // Divide the fragments into lines. // // TODO(pcwalton, #226): Get the CSS `line-height` property from the @@ -2044,13 +2038,7 @@ impl Flow for InlineFlow { impl fmt::Debug for InlineFlow { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!( - f, - "{:?}({:x}) {:?}", - self.class(), - self.base.debug_id(), - self.base() - ) + write!(f, "{:?} {:?}", self.class(), self.base()) } } diff --git a/components/layout/layout_debug.rs b/components/layout/layout_debug.rs deleted file mode 100644 index a50b92948a5..00000000000 --- a/components/layout/layout_debug.rs +++ /dev/null @@ -1,127 +0,0 @@ -/* 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/. */ - -//! Supports writing a trace file created during each layout scope -//! that can be viewed by an external tool to make layout debugging easier. - -use std::borrow::ToOwned; -use std::cell::RefCell; -use std::fs::File; -use std::io::Write; -#[cfg(debug_assertions)] -use std::sync::atomic::{AtomicUsize, Ordering}; - -use serde::Serialize; -use serde_json::{to_string, to_value, Value}; - -use crate::flow::GetBaseFlow; -use crate::flow_ref::FlowRef; - -thread_local!(static STATE_KEY: RefCell<Option<State>> = const { RefCell::new(None) }); - -#[cfg(debug_assertions)] -static DEBUG_ID_COUNTER: AtomicUsize = AtomicUsize::new(0); - -pub struct Scope; - -#[macro_export] -macro_rules! layout_debug_scope( - ($($arg:tt)*) => ( - if cfg!(debug_assertions) { - layout_debug::Scope::new(format!($($arg)*)) - } else { - layout_debug::Scope - } - ) -); - -#[derive(Serialize)] -struct ScopeData { - name: String, - pre: Value, - post: Value, - children: Vec<ScopeData>, -} - -impl ScopeData { - fn new(name: String, pre: Value) -> ScopeData { - ScopeData { - name, - pre, - post: Value::Null, - children: vec![], - } - } -} - -struct State { - flow_root: FlowRef, - scope_stack: Vec<ScopeData>, -} - -/// A layout debugging scope. The entire state of the flow tree -/// will be output at the beginning and end of this scope. -impl Scope { - pub fn new(name: String) -> Scope { - STATE_KEY.with(|r| { - if let Some(ref mut state) = *r.borrow_mut() { - let flow_trace = to_value(state.flow_root.base()).unwrap(); - let data = Box::new(ScopeData::new(name.clone(), flow_trace)); - state.scope_stack.push(*data); - } - }); - Scope - } -} - -#[cfg(debug_assertions)] -impl Drop for Scope { - fn drop(&mut self) { - STATE_KEY.with(|r| { - if let Some(ref mut state) = *r.borrow_mut() { - let mut current_scope = state.scope_stack.pop().unwrap(); - current_scope.post = to_value(state.flow_root.base()).unwrap(); - let previous_scope = state.scope_stack.last_mut().unwrap(); - previous_scope.children.push(current_scope); - } - }); - } -} - -/// Generate a unique ID. This is used for items such as Fragment -/// which are often reallocated but represent essentially the -/// same data. -#[cfg(debug_assertions)] -pub fn generate_unique_debug_id() -> u16 { - DEBUG_ID_COUNTER.fetch_add(1, Ordering::SeqCst) as u16 -} - -/// Begin a layout debug trace. If this has not been called, -/// creating debug scopes has no effect. -pub fn begin_trace(flow_root: FlowRef) { - assert!(STATE_KEY.with(|r| r.borrow().is_none())); - - STATE_KEY.with(|r| { - let flow_trace = to_value(flow_root.base()).unwrap(); - let state = State { - scope_stack: vec![*Box::new(ScopeData::new("root".to_owned(), flow_trace))], - flow_root: flow_root.clone(), - }; - *r.borrow_mut() = Some(state); - }); -} - -/// End the debug layout trace. This will write the layout -/// trace to disk in the current directory. The output -/// file can then be viewed with an external tool. -pub fn end_trace(generation: u32) { - let mut thread_state = STATE_KEY.with(|r| r.borrow_mut().take().unwrap()); - assert_eq!(thread_state.scope_stack.len(), 1); - let mut root_scope = thread_state.scope_stack.pop().unwrap(); - root_scope.post = to_value(thread_state.flow_root.base()).unwrap(); - - let result = to_string(&root_scope).unwrap(); - let mut file = File::create(format!("layout_trace-{}.json", generation)).unwrap(); - file.write_all(result.as_bytes()).unwrap(); -} diff --git a/components/layout/lib.rs b/components/layout/lib.rs index af624c58628..9990578c4f5 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -4,8 +4,6 @@ #![deny(unsafe_code)] -pub mod layout_debug; - mod block; pub mod construct; pub mod context; diff --git a/components/layout/table.rs b/components/layout/table.rs index 859d3c47516..a2f4bab8cca 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -41,7 +41,6 @@ use crate::table_row::{ TableRowSizeData, }; use crate::table_wrapper::TableLayout; -use crate::{layout_debug, layout_debug_scope}; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableFlow {} @@ -292,11 +291,6 @@ impl Flow for TableFlow { /// The maximum min/pref inline-sizes of each column are set from the rows for the automatic /// table layout calculation. fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!( - "table::bubble_inline_sizes {:x}", - self.block_flow.base.debug_id() - ); - // Get column inline sizes from colgroups for kid in self .block_flow @@ -415,10 +409,6 @@ impl Flow for TableFlow { /// Recursively (top-down) determines the actual inline-size of child contexts and fragments. /// When called on this context, the context has had its inline-size set by the parent context. fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!( - "table::assign_inline_sizes {:x}", - self.block_flow.base.debug_id() - ); debug!( "assign_inline_sizes({}): assigning inline_size for flow", "table" diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index 0faeb8c1c6e..eda92b61b61 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -27,7 +27,6 @@ use crate::flow::{Flow, FlowClass, FlowFlags, GetBaseFlow, OpaqueFlow}; use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::table::InternalTable; use crate::table_row::{CollapsedBorder, CollapsedBorderFrom}; -use crate::{layout_debug, layout_debug_scope}; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableCellFlow {} @@ -199,11 +198,6 @@ impl Flow for TableCellFlow { /// Minimum/preferred inline-sizes set by this function are used in automatic table layout /// calculation. fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!( - "table_cell::bubble_inline_sizes {:x}", - self.block_flow.base.debug_id() - ); - self.block_flow.bubble_inline_sizes_for_block(true); let specified_inline_size = self .block_flow @@ -250,10 +244,6 @@ impl Flow for TableCellFlow { /// When called on this context, the context has had its inline-size set by the parent table /// row. fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!( - "table_cell::assign_inline_sizes {:x}", - self.block_flow.base.debug_id() - ); debug!( "assign_inline_sizes({}): assigning inline_size for flow", "table_cell" diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index bf9f189602f..a378a42ec88 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -16,7 +16,6 @@ use crate::context::LayoutContext; use crate::display_list::{DisplayListBuildState, StackingContextCollectionState}; use crate::flow::{BaseFlow, Flow, FlowClass, ForceNonfloatedFlag, OpaqueFlow}; use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; -use crate::{layout_debug, layout_debug_scope}; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableColGroupFlow {} @@ -69,11 +68,6 @@ impl Flow for TableColGroupFlow { } fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!( - "table_colgroup::bubble_inline_sizes {:x}", - self.base.debug_id() - ); - for fragment in &self.cols { // Retrieve the specified value from the appropriate CSS property. let inline_size = fragment.style().content_inline_size(); diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 246e3a7bdd1..c6b894a1fc6 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -32,7 +32,6 @@ use crate::flow_list::MutFlowListIterator; use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt}; use crate::table_cell::{CollapsedBordersForCell, TableCellFlow}; -use crate::{layout_debug, layout_debug_scope}; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableRowFlow {} @@ -372,11 +371,6 @@ impl Flow for TableRowFlow { /// The specified column inline-sizes of children cells are used in fixed table layout /// calculation. fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!( - "table_row::bubble_inline_sizes {:x}", - self.block_flow.base.debug_id() - ); - // Bubble up the specified inline-sizes from child table cells. let (mut min_inline_size, mut pref_inline_size) = (Au(0), Au(0)); let collapsing_borders = self @@ -466,10 +460,6 @@ impl Flow for TableRowFlow { } fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!( - "table_row::assign_inline_sizes {:x}", - self.block_flow.base.debug_id() - ); debug!( "assign_inline_sizes({}): assigning inline_size for flow", "table_row" diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index 4a21856b9f8..d21301b1004 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -24,7 +24,6 @@ use crate::display_list::{ use crate::flow::{Flow, FlowClass, OpaqueFlow}; use crate::fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use crate::table::{ColumnIntrinsicInlineSize, InternalTable, TableLikeFlow}; -use crate::{layout_debug, layout_debug_scope}; #[allow(unsafe_code)] unsafe impl crate::flow::HasBaseFlow for TableRowGroupFlow {} @@ -122,10 +121,6 @@ impl Flow for TableRowGroupFlow { } fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!( - "table_rowgroup::bubble_inline_sizes {:x}", - self.block_flow.base.debug_id() - ); // Proper calculation of intrinsic sizes in table layout requires access to the entire // table, which we don't have yet. Defer to our parent. } @@ -133,10 +128,6 @@ impl Flow for TableRowGroupFlow { /// Recursively (top-down) determines the actual inline-size of child contexts and fragments. /// When called on this context, the context has had its inline-size set by the parent context. fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!( - "table_rowgroup::assign_inline_sizes {:x}", - self.block_flow.base.debug_id() - ); debug!( "assign_inline_sizes({}): assigning inline_size for flow", "table_rowgroup" diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index 0d33c02e068..f045cc9d856 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -224,11 +224,7 @@ fn construct_flows_at<'dom>(context: &LayoutContext, node: impl LayoutNode<'dom> let mut flow_constructor = FlowConstructor::new(context); if nonincremental_layout || !flow_constructor.repair_if_possible(&tnode) { flow_constructor.process(&tnode); - debug!( - "Constructed flow for {:?}: {:x}", - tnode, - tnode.flow_debug_id() - ); + debug!("Constructed flow for {:?}", tnode,); } } diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 2a10e9103a5..adb78b777cf 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -44,7 +44,6 @@ use crate::data::{InnerLayoutData, LayoutData, LayoutDataFlags}; pub trait ThreadSafeLayoutNodeHelpers<'dom> { fn borrow_layout_data(self) -> Option<AtomicRef<'dom, InnerLayoutData>>; fn mutate_layout_data(self) -> Option<AtomicRefMut<'dom, InnerLayoutData>>; - fn flow_debug_id(self) -> usize; /// Returns the layout data flags for this node. fn flags(self) -> LayoutDataFlags; @@ -83,11 +82,6 @@ where .map(|data| data.0.borrow_mut()) } - fn flow_debug_id(self) -> usize { - self.borrow_layout_data() - .map_or(0, |d| d.flow_construction_result.debug_id()) - } - fn flags(self) -> LayoutDataFlags { self.borrow_layout_data().as_ref().unwrap().flags } diff --git a/components/layout_2020/Cargo.toml b/components/layout_2020/Cargo.toml index 2abc3a751d2..eda1e185bab 100644 --- a/components/layout_2020/Cargo.toml +++ b/components/layout_2020/Cargo.toml @@ -41,8 +41,6 @@ range = { path = "../range" } rayon = { workspace = true } script_layout_interface = { workspace = true } selectors = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } servo_arc = { workspace = true } servo_config = { path = "../config" } servo_geometry = { path = "../geometry" } @@ -51,7 +49,7 @@ style = { workspace = true } style_traits = { workspace = true } taffy = { workspace = true } tracing = { workspace = true, optional = true } -unicode-bidi = { workspace = true, features = ["with_serde"] } +unicode-bidi = { workspace = true } unicode-script = { workspace = true } url = { workspace = true } webrender_api = { workspace = true } diff --git a/components/layout_2020/cell.rs b/components/layout_2020/cell.rs index 5c1dd09ff44..910a6ab2104 100644 --- a/components/layout_2020/cell.rs +++ b/components/layout_2020/cell.rs @@ -6,7 +6,6 @@ use std::fmt; use std::ops::Deref; use atomic_refcell::AtomicRefCell; -use serde::{Serialize, Serializer}; use servo_arc::Arc; pub(crate) struct ArcRefCell<T> { @@ -56,15 +55,3 @@ where self.value.fmt(formatter) } } - -impl<T> Serialize for ArcRefCell<T> -where - T: Serialize, -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: Serializer, - { - self.borrow().serialize(serializer) - } -} diff --git a/components/layout_2020/flexbox/geom.rs b/components/layout_2020/flexbox/geom.rs index 9e18561d8bd..6a302e27486 100644 --- a/components/layout_2020/flexbox/geom.rs +++ b/components/layout_2020/flexbox/geom.rs @@ -4,7 +4,6 @@ //! <https://drafts.csswg.org/css-flexbox/#box-model> -use serde::Serialize; use style::properties::longhands::flex_direction::computed_value::T as FlexDirection; use crate::geom::{LogicalRect, LogicalSides, LogicalVec2}; @@ -68,7 +67,7 @@ impl<T> FlexRelativeSides<T> { /// One of the two bits set by the `flex-direction` property /// (The other is "forward" v.s. reverse.) -#[derive(Clone, Copy, Debug, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, PartialEq)] pub(super) enum FlexAxis { /// The main axis is the inline axis of the container (not necessarily of flex items!), /// cross is block. @@ -79,7 +78,7 @@ pub(super) enum FlexAxis { /// Which flow-relative sides map to the main-start and cross-start sides, respectively. /// See <https://drafts.csswg.org/css-flexbox/#box-model> -#[derive(Clone, Copy, Debug, Serialize)] +#[derive(Clone, Copy, Debug)] pub(super) enum MainStartCrossStart { InlineStartBlockStart, InlineStartBlockEnd, diff --git a/components/layout_2020/flexbox/mod.rs b/components/layout_2020/flexbox/mod.rs index 06cffac3df9..32c1023214f 100644 --- a/components/layout_2020/flexbox/mod.rs +++ b/components/layout_2020/flexbox/mod.rs @@ -4,7 +4,6 @@ use app_units::Au; use geom::{FlexAxis, MainStartCrossStart}; -use serde::Serialize; use servo_arc::Arc as ServoArc; use style::logical_geometry::WritingMode; use style::properties::longhands::align_items::computed_value::T as AlignItems; @@ -30,7 +29,7 @@ mod layout; /// A structure to hold the configuration of a flex container for use during layout /// and preferred width calculation. -#[derive(Clone, Debug, Serialize)] +#[derive(Clone, Debug)] pub(crate) struct FlexContainerConfig { container_is_single_line: bool, writing_mode: WritingMode, @@ -88,11 +87,10 @@ impl FlexContainerConfig { } } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct FlexContainer { children: Vec<ArcRefCell<FlexLevelBox>>, - #[serde(skip_serializing)] style: ServoArc<ComputedValues>, /// The configuration of this [`FlexContainer`]. @@ -143,16 +141,14 @@ impl FlexContainer { } } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) enum FlexLevelBox { FlexItem(FlexItemBox), OutOfFlowAbsolutelyPositionedBox(ArcRefCell<AbsolutelyPositionedBox>), } -#[derive(Serialize)] pub(crate) struct FlexItemBox { independent_formatting_context: IndependentFormattingContext, - #[serde(skip)] block_content_size_cache: ArcRefCell<Option<CachedBlockSizeContribution>>, } diff --git a/components/layout_2020/flow/float.rs b/components/layout_2020/flow/float.rs index c5eff328767..0967ad3006a 100644 --- a/components/layout_2020/flow/float.rs +++ b/components/layout_2020/flow/float.rs @@ -13,7 +13,6 @@ use std::ops::Range; use app_units::{Au, MAX_AU, MIN_AU}; use euclid::num::Zero; -use serde::Serialize; use servo_arc::Arc; use style::computed_values::float::T as FloatProperty; use style::computed_values::position::T as Position; @@ -33,7 +32,7 @@ use crate::style_ext::{DisplayInside, PaddingBorderMargin}; use crate::ContainingBlock; /// A floating box. -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct FloatBox { /// The formatting context that makes up the content of this box. pub contents: IndependentFormattingContext, diff --git a/components/layout_2020/flow/inline/inline_box.rs b/components/layout_2020/flow/inline/inline_box.rs index 57a86cd31e2..2bb5a92d2b0 100644 --- a/components/layout_2020/flow/inline/inline_box.rs +++ b/components/layout_2020/flow/inline/inline_box.rs @@ -6,7 +6,6 @@ use std::vec::IntoIter; use app_units::Au; use fonts::FontMetrics; -use serde::Serialize; use servo_arc::Arc; use style::properties::ComputedValues; @@ -19,10 +18,9 @@ use crate::fragment_tree::BaseFragmentInfo; use crate::style_ext::{ComputedValuesExt, PaddingBorderMargin}; use crate::ContainingBlock; -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct InlineBox { pub base_fragment_info: BaseFragmentInfo, - #[serde(skip_serializing)] pub style: Arc<ComputedValues>, /// The identifier of this inline box in the containing [`super::InlineFormattingContext`]. pub(super) identifier: InlineBoxIdentifier, @@ -56,7 +54,7 @@ impl InlineBox { } } -#[derive(Debug, Default, Serialize)] +#[derive(Debug, Default)] pub(crate) struct InlineBoxes { /// A collection of all inline boxes in a particular [`super::InlineFormattingContext`]. inline_boxes: Vec<ArcRefCell<InlineBox>>, @@ -158,7 +156,7 @@ impl InlineBoxes { } } -#[derive(Clone, Copy, Debug, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, PartialEq)] pub(super) enum InlineBoxTreePathToken { Start(InlineBoxIdentifier), End(InlineBoxIdentifier), @@ -179,7 +177,7 @@ impl InlineBoxTreePathToken { /// [`u32`] is used for the index, in order to save space. The value refers to the token /// in the start tree data structure which can be fetched to find the actual index of /// of the [`InlineBox`] in [`InlineBoxes::inline_boxes`]. -#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)] pub(crate) struct InlineBoxIdentifier { pub index_of_start_in_tree: u32, pub index_in_inline_boxes: u32, diff --git a/components/layout_2020/flow/inline/mod.rs b/components/layout_2020/flow/inline/mod.rs index 1af7841c234..4b138bfbd14 100644 --- a/components/layout_2020/flow/inline/mod.rs +++ b/components/layout_2020/flow/inline/mod.rs @@ -88,7 +88,6 @@ use line::{ TextRunLineItem, }; use line_breaker::LineBreaker; -use serde::Serialize; use servo_arc::Arc; use style::computed_values::text_wrap_mode::T as TextWrapMode; use style::computed_values::vertical_align::T as VerticalAlign; @@ -134,7 +133,7 @@ use crate::{ConstraintSpace, ContainingBlock}; static FONT_SUBSCRIPT_OFFSET_RATIO: f32 = 0.20; static FONT_SUPERSCRIPT_OFFSET_RATIO: f32 = 0.34; -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct InlineFormattingContext { /// All [`InlineItem`]s in this [`InlineFormattingContext`] stored in a flat array. /// [`InlineItem::StartInlineBox`] and [`InlineItem::EndInlineBox`] allow representing @@ -171,14 +170,14 @@ pub(crate) struct InlineFormattingContext { } /// A collection of data used to cache [`FontMetrics`] in the [`InlineFormattingContext`] -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct FontKeyAndMetrics { pub key: FontInstanceKey, pub pt_size: Au, pub metrics: FontMetrics, } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) enum InlineItem { StartInlineBox(ArcRefCell<InlineBox>), EndInlineBox, diff --git a/components/layout_2020/flow/inline/text_run.rs b/components/layout_2020/flow/inline/text_run.rs index 412e9d4e54a..78160337396 100644 --- a/components/layout_2020/flow/inline/text_run.rs +++ b/components/layout_2020/flow/inline/text_run.rs @@ -13,7 +13,6 @@ use fonts::{ use fonts_traits::ByteIndex; use log::warn; use range::Range as ServoRange; -use serde::Serialize; use servo_arc::Arc; use style::computed_values::text_rendering::T as TextRendering; use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse; @@ -38,10 +37,9 @@ pub(crate) const XI_LINE_BREAKING_CLASS_WJ: u8 = 30; pub(crate) const XI_LINE_BREAKING_CLASS_ZWJ: u8 = 42; /// <https://www.w3.org/TR/css-display-3/#css-text-run> -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct TextRun { pub base_fragment_info: BaseFragmentInfo, - #[serde(skip_serializing)] pub parent_style: Arc<ComputedValues>, pub text_range: Range<usize>, @@ -64,14 +62,13 @@ enum SegmentStartSoftWrapPolicy { FollowLinebreaker, } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct TextRunSegment { /// The index of this font in the parent [`super::InlineFormattingContext`]'s collection of font /// information. pub font_index: usize, /// The [`Script`] of this segment. - #[serde(skip_serializing)] pub script: Script, /// The bidi Level of this segment. diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs index 686ac85838a..06f9da7d326 100644 --- a/components/layout_2020/flow/mod.rs +++ b/components/layout_2020/flow/mod.rs @@ -8,7 +8,6 @@ use app_units::{Au, MAX_AU}; use inline::InlineFormattingContext; use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; -use serde::Serialize; use servo_arc::Arc; use style::computed_values::clear::T as StyleClear; use style::properties::ComputedValues; @@ -53,13 +52,13 @@ mod root; pub(crate) use construct::BlockContainerBuilder; pub use root::{BoxTree, CanvasBackground}; -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct BlockFormattingContext { pub contents: BlockContainer, pub contains_floats: bool, } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) enum BlockContainer { BlockLevelBoxes(Vec<ArcRefCell<BlockLevelBox>>), InlineFormattingContext(InlineFormattingContext), @@ -76,7 +75,7 @@ impl BlockContainer { } } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) enum BlockLevelBox { Independent(IndependentFormattingContext), OutOfFlowAbsolutelyPositionedBox(ArcRefCell<AbsolutelyPositionedBox>), @@ -231,9 +230,8 @@ pub(crate) struct CollapsibleWithParentStartMargin(bool); /// The contentes of a BlockContainer created to render a list marker /// for a list that has `list-style-position: outside`. -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct OutsideMarker { - #[serde(skip_serializing)] pub marker_style: Arc<ComputedValues>, pub base: LayoutBoxBase, pub block_container: BlockContainer, diff --git a/components/layout_2020/flow/root.rs b/components/layout_2020/flow/root.rs index 078b225bac5..b80b106da1e 100644 --- a/components/layout_2020/flow/root.rs +++ b/components/layout_2020/flow/root.rs @@ -8,7 +8,6 @@ use script_layout_interface::wrapper_traits::{ LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode, }; use script_layout_interface::{LayoutElementType, LayoutNodeType}; -use serde::Serialize; use servo_arc::Arc; use style::dom::OpaqueNode; use style::properties::ComputedValues; @@ -33,7 +32,6 @@ use crate::style_ext::{ComputedValuesExt, Display, DisplayGeneratingBox, Display use crate::taffy::{TaffyItemBox, TaffyItemBoxInner}; use crate::DefiniteContainingBlock; -#[derive(Serialize)] pub struct BoxTree { /// Contains typically exactly one block-level box, which was generated by the root element. /// There may be zero if that element has `display: none`. @@ -409,7 +407,7 @@ impl BoxTree { } /// <https://drafts.csswg.org/css-backgrounds/#root-background> -#[derive(Clone, Serialize)] +#[derive(Clone)] pub struct CanvasBackground { /// DOM node for the root element pub root_element: OpaqueNode, @@ -420,7 +418,6 @@ pub struct CanvasBackground { pub from_element: OpaqueNode, /// The computed styles to take background properties from. - #[serde(skip)] pub style: Option<Arc<ComputedValues>>, } diff --git a/components/layout_2020/formatting_contexts.rs b/components/layout_2020/formatting_contexts.rs index e1d5b68a83d..8c0a5987956 100644 --- a/components/layout_2020/formatting_contexts.rs +++ b/components/layout_2020/formatting_contexts.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use app_units::Au; -use serde::Serialize; use servo_arc::Arc; use style::properties::ComputedValues; use style::selector_parser::PseudoElement; @@ -28,13 +27,13 @@ use crate::taffy::TaffyContainer; use crate::{ConstraintSpace, ContainingBlock, IndefiniteContainingBlock, LogicalVec2}; /// <https://drafts.csswg.org/css-display/#independent-formatting-context> -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct IndependentFormattingContext { pub base: LayoutBoxBase, pub contents: IndependentFormattingContextContents, } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) enum IndependentFormattingContextContents { NonReplaced(IndependentNonReplacedContents), Replaced(ReplacedContents), @@ -42,7 +41,7 @@ pub(crate) enum IndependentFormattingContextContents { // Private so that code outside of this module cannot match variants. // It should got through methods instead. -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) enum IndependentNonReplacedContents { Flow(BlockFormattingContext), Flex(FlexContainer), @@ -53,7 +52,7 @@ pub(crate) enum IndependentNonReplacedContents { /// The baselines of a layout or a [`crate::fragment_tree::BoxFragment`]. Some layout /// uses the first and some layout uses the last. -#[derive(Clone, Copy, Debug, Default, Serialize)] +#[derive(Clone, Copy, Debug, Default)] pub(crate) struct Baselines { pub first: Option<Au>, pub last: Option<Au>, diff --git a/components/layout_2020/fragment_tree/base_fragment.rs b/components/layout_2020/fragment_tree/base_fragment.rs index 4c1efaf0677..6404c340c00 100644 --- a/components/layout_2020/fragment_tree/base_fragment.rs +++ b/components/layout_2020/fragment_tree/base_fragment.rs @@ -4,25 +4,19 @@ use bitflags::bitflags; use script_layout_interface::{combine_id_with_fragment_type, FragmentType}; -use serde::Serialize; use style::dom::OpaqueNode; use style::selector_parser::PseudoElement; -use crate::layout_debug::DebugId; - /// This data structure stores fields that are common to all non-base /// Fragment types and should generally be the first member of all /// concrete fragments. -#[derive(Clone, Debug, Serialize)] +#[derive(Clone, Debug)] pub(crate) struct BaseFragment { /// A tag which identifies the DOM node and pseudo element of this /// Fragment's content. If this fragment isn't related to any DOM /// node at all, the tag will be None. pub tag: Option<Tag>, - /// An id used to uniquely identify this Fragment in debug builds. - pub debug_id: DebugId, - /// Flags which various information about this fragment used during /// layout. pub flags: FragmentFlags, @@ -32,7 +26,6 @@ impl BaseFragment { pub(crate) fn anonymous() -> Self { BaseFragment { tag: None, - debug_id: DebugId::new(), flags: FragmentFlags::empty(), } } @@ -45,7 +38,7 @@ impl BaseFragment { } /// Information necessary to construct a new BaseFragment. -#[derive(Clone, Copy, Debug, Serialize)] +#[derive(Clone, Copy, Debug)] pub(crate) struct BaseFragmentInfo { /// The tag to use for the new BaseFragment, if it is not an anonymous Fragment. pub tag: Option<Tag>, @@ -74,7 +67,6 @@ impl From<BaseFragmentInfo> for BaseFragment { fn from(info: BaseFragmentInfo) -> Self { Self { tag: info.tag, - debug_id: DebugId::new(), flags: info.flags, } } @@ -82,7 +74,7 @@ impl From<BaseFragmentInfo> for BaseFragment { bitflags! { /// Flags used to track various information about a DOM node during layout. - #[derive(Clone, Copy, Debug, Serialize)] + #[derive(Clone, Copy, Debug)] pub(crate) struct FragmentFlags: u8 { /// Whether or not the node that created this fragment is a `<body>` element on an HTML document. const IS_BODY_ELEMENT_OF_HTML_ELEMENT_ROOT = 1 << 0; @@ -113,7 +105,7 @@ bitflags! { /// A data structure used to hold DOM and pseudo-element information about /// a particular layout object. -#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(crate) struct Tag { pub(crate) node: OpaqueNode, pub(crate) pseudo: Option<PseudoElement>, diff --git a/components/layout_2020/fragment_tree/box_fragment.rs b/components/layout_2020/fragment_tree/box_fragment.rs index 7d61e1e6807..a0d86f290ee 100644 --- a/components/layout_2020/fragment_tree/box_fragment.rs +++ b/components/layout_2020/fragment_tree/box_fragment.rs @@ -5,7 +5,6 @@ use app_units::Au; use atomic_refcell::AtomicRefCell; use base::print_tree::PrintTree; -use serde::Serialize; use servo_arc::Arc as ServoArc; use style::computed_values::overflow_x::T as ComputedOverflow; use style::computed_values::position::T as ComputedPosition; @@ -47,11 +46,9 @@ pub(crate) enum SpecificLayoutInfo { TableOrTableCell(Box<SpecificTableOrTableCellInfo>), } -#[derive(Serialize)] pub(crate) struct BoxFragment { pub base: BaseFragment, - #[serde(skip_serializing)] pub style: ServoArc<ComputedValues>, pub children: Vec<Fragment>, @@ -84,14 +81,11 @@ pub(crate) struct BoxFragment { /// The resolved box insets if this box is `position: sticky`. These are calculated /// during stacking context tree construction because they rely on the size of the /// scroll container. - #[serde(skip_serializing)] pub(crate) resolved_sticky_insets: AtomicRefCell<Option<PhysicalSides<AuOrAuto>>>, - #[serde(skip_serializing)] pub background_mode: BackgroundMode, /// Additional information of from layout that could be used by Javascripts and devtools. - #[serde(skip_serializing)] pub detailed_layout_info: Option<SpecificLayoutInfo>, } diff --git a/components/layout_2020/fragment_tree/fragment.rs b/components/layout_2020/fragment_tree/fragment.rs index 5c8b86d455b..fdc8f75bb9a 100644 --- a/components/layout_2020/fragment_tree/fragment.rs +++ b/components/layout_2020/fragment_tree/fragment.rs @@ -5,10 +5,9 @@ use std::sync::Arc; use app_units::Au; -use base::id::{BrowsingContextId, PipelineId}; +use base::id::PipelineId; use base::print_tree::PrintTree; use fonts::{FontMetrics, GlyphStore}; -use serde::Serialize; use servo_arc::Arc as ServoArc; use style::properties::ComputedValues; use style::values::specified::text::TextDecorationLine; @@ -23,7 +22,7 @@ use crate::cell::ArcRefCell; use crate::geom::{LogicalSides, PhysicalRect}; use crate::style_ext::ComputedValuesExt; -#[derive(Clone, Serialize)] +#[derive(Clone)] pub(crate) enum Fragment { Box(ArcRefCell<BoxFragment>), /// Floating content. A floated fragment is very similar to a normal @@ -46,27 +45,23 @@ pub(crate) enum Fragment { IFrame(ArcRefCell<IFrameFragment>), } -#[derive(Serialize)] pub(crate) struct CollapsedBlockMargins { pub collapsed_through: bool, pub start: CollapsedMargin, pub end: CollapsedMargin, } -#[derive(Clone, Copy, Debug, Serialize)] +#[derive(Clone, Copy, Debug)] pub(crate) struct CollapsedMargin { max_positive: Au, min_negative: Au, } -#[derive(Serialize)] pub(crate) struct TextFragment { pub base: BaseFragment, - #[serde(skip_serializing)] pub parent_style: ServoArc<ComputedValues>, pub rect: PhysicalRect<Au>, pub font_metrics: FontMetrics, - #[serde(skip_serializing)] pub font_key: FontInstanceKey, pub glyphs: Vec<Arc<GlyphStore>>, @@ -77,24 +72,18 @@ pub(crate) struct TextFragment { pub justification_adjustment: Au, } -#[derive(Serialize)] pub(crate) struct ImageFragment { pub base: BaseFragment, - #[serde(skip_serializing)] pub style: ServoArc<ComputedValues>, pub rect: PhysicalRect<Au>, pub clip: PhysicalRect<Au>, - #[serde(skip_serializing)] pub image_key: Option<ImageKey>, } -#[derive(Serialize)] pub(crate) struct IFrameFragment { pub base: BaseFragment, pub pipeline_id: PipelineId, - pub browsing_context_id: BrowsingContextId, pub rect: PhysicalRect<Au>, - #[serde(skip_serializing)] pub style: ServoArc<ComputedValues>, } diff --git a/components/layout_2020/fragment_tree/fragment_tree.rs b/components/layout_2020/fragment_tree/fragment_tree.rs index 35718c708b9..545eef2df0f 100644 --- a/components/layout_2020/fragment_tree/fragment_tree.rs +++ b/components/layout_2020/fragment_tree/fragment_tree.rs @@ -6,7 +6,6 @@ use app_units::Au; use base::print_tree::PrintTree; use euclid::default::{Point2D, Rect, Size2D}; use fxhash::FxHashSet; -use serde::Serialize; use style::animation::AnimationSetKey; use style::dom::OpaqueNode; use webrender_api::units; @@ -17,7 +16,6 @@ use crate::display_list::StackingContext; use crate::flow::CanvasBackground; use crate::geom::PhysicalRect; -#[derive(Serialize)] pub struct FragmentTree { /// Fragments at the top-level of the tree. /// @@ -37,7 +35,6 @@ pub struct FragmentTree { pub(crate) initial_containing_block: PhysicalRect<Au>, /// <https://drafts.csswg.org/css-backgrounds/#special-backgrounds> - #[serde(skip)] pub(crate) canvas_background: CanvasBackground, /// Whether or not the root element is sensitive to scroll input events. diff --git a/components/layout_2020/fragment_tree/hoisted_shared_fragment.rs b/components/layout_2020/fragment_tree/hoisted_shared_fragment.rs index 0b67d981d34..4d3eb1f7265 100644 --- a/components/layout_2020/fragment_tree/hoisted_shared_fragment.rs +++ b/components/layout_2020/fragment_tree/hoisted_shared_fragment.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use app_units::Au; -use serde::Serialize; use style::logical_geometry::WritingMode; use style::values::specified::align::AlignFlags; @@ -13,7 +12,6 @@ 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. -#[derive(Serialize)] pub(crate) struct HoistedSharedFragment { pub fragment: Option<Fragment>, /// The "static-position rect" of this absolutely positioned box. This is defined by the diff --git a/components/layout_2020/fragment_tree/positioning_fragment.rs b/components/layout_2020/fragment_tree/positioning_fragment.rs index 36b51aa3d2a..b2e6c0ebfd3 100644 --- a/components/layout_2020/fragment_tree/positioning_fragment.rs +++ b/components/layout_2020/fragment_tree/positioning_fragment.rs @@ -4,7 +4,6 @@ use app_units::Au; use base::print_tree::PrintTree; -use serde::Serialize; use servo_arc::Arc as ServoArc; use style::properties::ComputedValues; @@ -15,7 +14,6 @@ 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. -#[derive(Serialize)] pub(crate) struct PositioningFragment { pub base: BaseFragment, pub rect: PhysicalRect<Au>, @@ -24,7 +22,6 @@ pub(crate) struct PositioningFragment { pub scrollable_overflow: PhysicalRect<Au>, /// If this fragment was created with a style, the style of the fragment. - #[serde(skip_serializing)] pub style: Option<ServoArc<ComputedValues>>, } diff --git a/components/layout_2020/geom.rs b/components/layout_2020/geom.rs index 2cc7ae434bf..ce6b969b1ef 100644 --- a/components/layout_2020/geom.rs +++ b/components/layout_2020/geom.rs @@ -8,7 +8,6 @@ use std::fmt; use std::ops::{Add, AddAssign, Neg, Sub, SubAssign}; use app_units::Au; -use serde::Serialize; use style::logical_geometry::{BlockFlowDirection, InlineBaseDirection, WritingMode}; use style::values::computed::{ CSSPixelLength, LengthPercentage, MaxSize as StyleMaxSize, Size as StyleSize, @@ -29,19 +28,19 @@ pub type PhysicalSides<U> = euclid::SideOffsets2D<U, CSSPixel>; pub type AuOrAuto = AutoOr<Au>; pub type LengthPercentageOrAuto<'a> = AutoOr<&'a LengthPercentage>; -#[derive(Clone, Copy, PartialEq, Serialize)] +#[derive(Clone, Copy, PartialEq)] pub struct LogicalVec2<T> { pub inline: T, pub block: T, } -#[derive(Clone, Copy, Serialize)] +#[derive(Clone, Copy)] pub struct LogicalRect<T> { pub start_corner: LogicalVec2<T>, pub size: LogicalVec2<T>, } -#[derive(Clone, Copy, Debug, Serialize)] +#[derive(Clone, Copy, Debug)] pub struct LogicalSides<T> { pub inline_start: T, pub inline_end: T, @@ -817,7 +816,7 @@ impl Size<Au> { /// Represents the sizing constraint that the preferred, min and max sizing properties /// impose on one axis. -#[derive(Clone, Copy, Debug, PartialEq, Serialize)] +#[derive(Clone, Copy, Debug, PartialEq)] pub(crate) enum SizeConstraint { /// Represents a definite preferred size, clamped by minimum and maximum sizes (if any). Definite(Au), diff --git a/components/layout_2020/layout_box_base.rs b/components/layout_2020/layout_box_base.rs index 8eed9f87d18..4bd2e9c83af 100644 --- a/components/layout_2020/layout_box_base.rs +++ b/components/layout_2020/layout_box_base.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use atomic_refcell::AtomicRefCell; -use serde::Serialize; use servo_arc::Arc; use style::properties::ComputedValues; @@ -19,12 +18,10 @@ use crate::ConstraintSpace; /// passes. /// /// In the future, this will hold layout results to support incremental layout. -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct LayoutBoxBase { pub base_fragment_info: BaseFragmentInfo, - #[serde(skip_serializing)] pub style: Arc<ComputedValues>, - #[serde(skip_serializing)] pub cached_inline_content_size: AtomicRefCell<Option<(SizeConstraint, InlineContentSizesResult)>>, } diff --git a/components/layout_2020/layout_debug.rs b/components/layout_2020/layout_debug.rs deleted file mode 100644 index 811254279fb..00000000000 --- a/components/layout_2020/layout_debug.rs +++ /dev/null @@ -1,184 +0,0 @@ -/* 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/. */ - -//! Supports writing a trace file created during each layout scope -//! that can be viewed by an external tool to make layout debugging easier. - -use std::cell::RefCell; -use std::fs; -#[cfg(debug_assertions)] -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::Arc; - -#[cfg(not(debug_assertions))] -use serde::ser::Serializer; -use serde::Serialize; -use serde_json::{to_string, to_value, Value}; - -use crate::flow::BoxTree; -use crate::fragment_tree::FragmentTree; - -thread_local!(static STATE_KEY: RefCell<Option<State>> = const { RefCell::new(None) }); - -#[cfg(debug_assertions)] -static DEBUG_ID_COUNTER: AtomicUsize = AtomicUsize::new(0); - -pub struct Scope; - -#[macro_export] -macro_rules! layout_debug_scope( - ($($arg:tt)*) => ( - if cfg!(debug_assertions) { - layout_debug::Scope::new(format!($($arg)*)) - } else { - layout_debug::Scope - } - ) -); - -#[derive(Serialize)] -struct TreeValues { - pub box_tree: Value, - pub fragment_tree: Value, -} - -#[derive(Serialize)] -struct ScopeData { - name: String, - pre: TreeValues, - post: TreeValues, - children: Vec<ScopeData>, -} - -impl ScopeData { - fn new(name: String, box_tree: Value, fragment_tree: Value) -> ScopeData { - ScopeData { - name, - pre: TreeValues { - box_tree, - fragment_tree, - }, - post: TreeValues { - box_tree: Value::Null, - fragment_tree: Value::Null, - }, - children: vec![], - } - } -} - -struct State { - fragment_tree: Arc<FragmentTree>, - box_tree: Arc<BoxTree>, - scope_stack: Vec<ScopeData>, -} - -/// A layout debugging scope. The entire state of the box and fragment trees -/// will be output at the beginning and end of this scope. -impl Scope { - pub fn new(name: String) -> Scope { - STATE_KEY.with(|r| { - if let Some(ref mut state) = *r.borrow_mut() { - let box_tree = to_value(&state.box_tree).unwrap(); - let fragment_tree = to_value(&state.fragment_tree).unwrap(); - let data = Box::new(ScopeData::new(name.clone(), box_tree, fragment_tree)); - state.scope_stack.push(*data); - } - }); - Scope - } -} - -#[cfg(debug_assertions)] -impl Drop for Scope { - fn drop(&mut self) { - STATE_KEY.with(|r| { - if let Some(ref mut state) = *r.borrow_mut() { - let mut current_scope = state.scope_stack.pop().unwrap(); - current_scope.post = TreeValues { - box_tree: to_value(&state.box_tree).unwrap(), - fragment_tree: to_value(&state.fragment_tree).unwrap(), - }; - let previous_scope = state.scope_stack.last_mut().unwrap(); - previous_scope.children.push(current_scope); - } - }); - } -} - -/// Begin a layout debug trace. If this has not been called, -/// creating debug scopes has no effect. -pub fn begin_trace(box_tree: Arc<BoxTree>, fragment_tree: Arc<FragmentTree>) { - assert!(STATE_KEY.with(|r| r.borrow().is_none())); - - STATE_KEY.with(|r| { - let box_tree_value = to_value(&box_tree).unwrap(); - let fragment_tree_value = to_value(&fragment_tree).unwrap(); - let state = State { - scope_stack: vec![*Box::new(ScopeData::new( - "root".to_owned(), - box_tree_value, - fragment_tree_value, - ))], - box_tree, - fragment_tree, - }; - *r.borrow_mut() = Some(state); - }); -} - -/// End the debug layout trace. This will write the layout -/// trace to disk in the current directory. The output -/// file can then be viewed with an external tool. -pub fn end_trace(generation: u32) { - let mut thread_state = STATE_KEY.with(|r| r.borrow_mut().take().unwrap()); - assert_eq!(thread_state.scope_stack.len(), 1); - let mut root_scope = thread_state.scope_stack.pop().unwrap(); - root_scope.post = TreeValues { - box_tree: to_value(&thread_state.box_tree).unwrap_or(Value::Null), - fragment_tree: to_value(&thread_state.fragment_tree).unwrap_or(Value::Null), - }; - let result = to_string(&root_scope).unwrap(); - fs::write( - format!("layout_trace-{}.json", generation), - result.as_bytes(), - ) - .unwrap(); -} - -#[cfg(not(debug_assertions))] -#[derive(Clone, Debug)] -pub struct DebugId; - -#[cfg(debug_assertions)] -#[derive(Clone, Debug, Serialize)] -#[serde(transparent)] -pub struct DebugId(u16); - -#[cfg(not(debug_assertions))] -impl DebugId { - pub fn new() -> DebugId { - DebugId - } -} - -#[cfg(debug_assertions)] -impl DebugId { - pub fn new() -> DebugId { - DebugId(DEBUG_ID_COUNTER.fetch_add(1, Ordering::SeqCst) as u16) - } -} - -impl Default for DebugId { - fn default() -> Self { - Self::new() - } -} - -#[cfg(not(debug_assertions))] -impl Serialize for DebugId { - fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { - serializer.serialize_str(&format!("{:p}", &self)) - } -} diff --git a/components/layout_2020/lib.rs b/components/layout_2020/lib.rs index e3cfe90cf02..940b95309c8 100644 --- a/components/layout_2020/lib.rs +++ b/components/layout_2020/lib.rs @@ -17,7 +17,6 @@ pub mod geom; mod layout_box_base; mod taffy; #[macro_use] -pub mod layout_debug; mod construct_modern; mod lists; mod positioned; @@ -32,7 +31,6 @@ use app_units::Au; pub use flow::BoxTree; pub use fragment_tree::FragmentTree; use geom::AuOrAuto; -use serde::Serialize; use style::logical_geometry::WritingMode; use style::properties::ComputedValues; @@ -115,7 +113,7 @@ impl<'a> From<&'_ DefiniteContainingBlock<'a>> for IndefiniteContainingBlock { } } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct ContainingBlockSize { inline: Au, block: SizeConstraint, diff --git a/components/layout_2020/positioned.rs b/components/layout_2020/positioned.rs index 16905343505..93cb9482500 100644 --- a/components/layout_2020/positioned.rs +++ b/components/layout_2020/positioned.rs @@ -7,7 +7,6 @@ use std::mem; use app_units::Au; use rayon::iter::IntoParallelRefMutIterator; use rayon::prelude::{IndexedParallelIterator, ParallelIterator}; -use serde::Serialize; use style::computed_values::position::T as Position; use style::logical_geometry::WritingMode; use style::properties::ComputedValues; @@ -36,7 +35,7 @@ use crate::{ ConstraintSpace, ContainingBlock, ContainingBlockSize, DefiniteContainingBlock, SizeConstraint, }; -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct AbsolutelyPositionedBox { pub context: IndependentFormattingContext, } diff --git a/components/layout_2020/replaced.rs b/components/layout_2020/replaced.rs index 03214f37070..3b0509ba8e3 100644 --- a/components/layout_2020/replaced.rs +++ b/components/layout_2020/replaced.rs @@ -15,7 +15,6 @@ use ipc_channel::ipc::{self, IpcSender}; use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder}; use pixels::Image; use script_layout_interface::IFrameSize; -use serde::Serialize; use servo_arc::Arc as ServoArc; use style::computed_values::object_fit::T as ObjectFit; use style::logical_geometry::{Direction, WritingMode}; @@ -36,7 +35,7 @@ use crate::sizing::{ComputeInlineContentSizes, ContentSizes, InlineContentSizesR use crate::style_ext::{AspectRatio, Clamp, ComputedValuesExt, ContentBoxSizesAndPBM}; use crate::{ConstraintSpace, ContainingBlock, SizeConstraint}; -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct ReplacedContents { pub kind: ReplacedContentKind, natural_size: NaturalSizes, @@ -60,7 +59,7 @@ pub(crate) struct ReplacedContents { /// /// * IFrames do not have natural width and height or natural ratio according /// to <https://drafts.csswg.org/css-images/#intrinsic-dimensions>. -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct NaturalSizes { pub width: Option<Au>, pub height: Option<Au>, @@ -94,7 +93,6 @@ impl NaturalSizes { } } -#[derive(Serialize)] pub(crate) enum CanvasSource { WebGL(ImageKey), Image(Arc<Mutex<IpcSender<CanvasMsg>>>), @@ -118,24 +116,24 @@ impl fmt::Debug for CanvasSource { } } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct CanvasInfo { pub source: CanvasSource, pub canvas_id: CanvasId, } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct IFrameInfo { pub pipeline_id: PipelineId, pub browsing_context_id: BrowsingContextId, } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct VideoInfo { pub image_key: webrender_api::ImageKey, } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) enum ReplacedContentKind { Image(Option<Arc<Image>>), IFrame(IFrameInfo), @@ -368,7 +366,6 @@ impl ReplacedContents { base: self.base_fragment_info.into(), style: style.clone(), pipeline_id: iframe.pipeline_id, - browsing_context_id: iframe.browsing_context_id, rect, }))] }, diff --git a/components/layout_2020/sizing.rs b/components/layout_2020/sizing.rs index 46eda7ccbde..e363279540c 100644 --- a/components/layout_2020/sizing.rs +++ b/components/layout_2020/sizing.rs @@ -8,7 +8,6 @@ use std::cell::LazyCell; use std::ops::{Add, AddAssign}; use app_units::Au; -use serde::Serialize; use style::properties::ComputedValues; use style::values::computed::LengthPercentage; use style::Zero; @@ -34,7 +33,7 @@ pub(crate) enum IntrinsicSizingMode { Size, } -#[derive(Clone, Copy, Debug, Default, Serialize)] +#[derive(Clone, Copy, Debug, Default)] pub(crate) struct ContentSizes { pub min_content: Au, pub max_content: Au, @@ -257,7 +256,7 @@ pub(crate) fn outer_inline( } } -#[derive(Clone, Copy, Debug, Serialize)] +#[derive(Clone, Copy, Debug)] pub(crate) struct InlineContentSizesResult { pub sizes: ContentSizes, pub depends_on_block_constraints: bool, diff --git a/components/layout_2020/table/mod.rs b/components/layout_2020/table/mod.rs index 9e37a42ea4e..147c5285fc1 100644 --- a/components/layout_2020/table/mod.rs +++ b/components/layout_2020/table/mod.rs @@ -73,7 +73,6 @@ use std::ops::Range; pub(crate) use construct::AnonymousTableContent; pub use construct::TableBuilder; use euclid::{Point2D, Size2D, UnknownUnit, Vector2D}; -use serde::Serialize; use servo_arc::Arc; use style::properties::style_structs::Font; use style::properties::ComputedValues; @@ -90,17 +89,15 @@ use crate::style_ext::BorderStyleColor; pub type TableSize = Size2D<usize, UnknownUnit>; -#[derive(Debug, Serialize)] +#[derive(Debug)] pub struct Table { /// The style of this table. These are the properties that apply to the "wrapper" ie the element /// that contains both the grid and the captions. Not all properties are actually used on the /// wrapper though, such as background and borders, which apply to the grid. - #[serde(skip_serializing)] style: Arc<ComputedValues>, /// The style of this table's grid. This is an anonymous style based on the table's style, but /// eliminating all the properties handled by the "wrapper." - #[serde(skip_serializing)] grid_style: Arc<ComputedValues>, /// The [`BaseFragmentInfo`] for this table's grid. This is necessary so that when the @@ -190,7 +187,7 @@ impl Table { type TableSlotCoordinates = Point2D<usize, UnknownUnit>; pub type TableSlotOffset = Vector2D<usize, UnknownUnit>; -#[derive(Debug, Serialize)] +#[derive(Debug)] pub struct TableSlotCell { /// The [`LayoutBoxBase`] of this table cell. base: LayoutBoxBase, @@ -228,7 +225,6 @@ impl TableSlotCell { } } -#[derive(Serialize)] /// A single table slot. It may be an actual cell, or a reference /// to a previous cell that is spanned here /// @@ -269,13 +265,12 @@ impl TableSlot { } /// A row or column of a table. -#[derive(Clone, Debug, Serialize)] +#[derive(Clone, Debug)] pub struct TableTrack { /// The [`BaseFragmentInfo`] of this cell. base_fragment_info: BaseFragmentInfo, /// The style of this table column. - #[serde(skip_serializing)] style: Arc<ComputedValues>, /// The index of the table row or column group parent in the table's list of row or column @@ -287,7 +282,7 @@ pub struct TableTrack { is_anonymous: bool, } -#[derive(Debug, PartialEq, Serialize)] +#[derive(Debug, PartialEq)] pub enum TableTrackGroupType { HeaderGroup, FooterGroup, @@ -295,13 +290,12 @@ pub enum TableTrackGroupType { ColumnGroup, } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub struct TableTrackGroup { /// The [`BaseFragmentInfo`] of this [`TableTrackGroup`]. base_fragment_info: BaseFragmentInfo, /// The style of this [`TableTrackGroup`]. - #[serde(skip_serializing)] style: Arc<ComputedValues>, /// The type of this [`TableTrackGroup`]. @@ -317,7 +311,7 @@ impl TableTrackGroup { } } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub struct TableCaption { /// The contents of this cell, with its own layout. context: ArcRefCell<IndependentFormattingContext>, diff --git a/components/layout_2020/taffy/mod.rs b/components/layout_2020/taffy/mod.rs index 6e8446506f9..6aed847e094 100644 --- a/components/layout_2020/taffy/mod.rs +++ b/components/layout_2020/taffy/mod.rs @@ -6,7 +6,6 @@ mod stylo_taffy; use std::fmt; use app_units::Au; -use serde::Serialize; use servo_arc::Arc; use style::properties::ComputedValues; use style::values::computed::TextDecorationLine; @@ -21,10 +20,9 @@ use crate::formatting_contexts::IndependentFormattingContext; use crate::fragment_tree::Fragment; use crate::positioned::{AbsolutelyPositionedBox, PositioningContext}; -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) struct TaffyContainer { children: Vec<ArcRefCell<TaffyItemBox>>, - #[serde(skip_serializing)] style: Arc<ComputedValues>, } @@ -72,18 +70,15 @@ impl TaffyContainer { } } -#[derive(Serialize)] pub(crate) struct TaffyItemBox { pub(crate) taffy_layout: taffy::Layout, pub(crate) child_fragments: Vec<Fragment>, - #[serde(skip_serializing)] pub(crate) positioning_context: PositioningContext, - #[serde(skip_serializing)] pub(crate) style: Arc<ComputedValues>, pub(crate) taffy_level_box: TaffyItemBoxInner, } -#[derive(Debug, Serialize)] +#[derive(Debug)] pub(crate) enum TaffyItemBoxInner { InFlowBox(IndependentFormattingContext), OutOfFlowAbsolutelyPositionedBox(ArcRefCell<AbsolutelyPositionedBox>), diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 962d807d068..6a4635e05e0 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -45,7 +45,7 @@ use layout::traversal::{ RecalcStyleAndConstructFlows, }; use layout::wrapper::ThreadSafeLayoutNodeHelpers; -use layout::{layout_debug, layout_debug_scope, parallel, sequential}; +use layout::{parallel, sequential}; use log::{debug, error, trace}; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use metrics::{PaintTimeMetrics, ProfilerMetadataFactory}; @@ -687,7 +687,6 @@ impl LayoutThread { /// benchmarked against those two. It is marked `#[inline(never)]` to aid profiling. #[inline(never)] fn solve_constraints(layout_root: &mut dyn Flow, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!("solve_constraints"); sequential::reflow(layout_root, layout_context, RelayoutMode::Incremental); } @@ -703,8 +702,6 @@ impl LayoutThread { time_profiler_chan: profile_time::ProfilerChan, layout_context: &LayoutContext, ) { - let _scope = layout_debug_scope!("solve_constraints_parallel"); - // NOTE: this currently computes borders, so any pruning should separate that // operation out. parallel::reflow( @@ -1136,10 +1133,6 @@ impl LayoutThread { }, ); - if self.debug.trace_layout { - layout_debug::begin_trace(root_flow.clone()); - } - // Resolve generated content. time_profile!( profile_time::ProfilerCategory::LayoutGeneratedContent, @@ -1214,10 +1207,6 @@ impl LayoutThread { &mut *layout_context, ); - if self.debug.trace_layout { - layout_debug::end_trace(self.generation.get()); - } - if self.debug.dump_flow_tree { root_flow.print("Post layout flow tree".to_owned()); } diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index fbd862dd6ec..7c689ec7cc3 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -34,7 +34,7 @@ use layout::query::{ process_resolved_font_style_query, process_resolved_style_request, process_text_index_request, }; use layout::traversal::RecalcStyle; -use layout::{layout_debug, BoxTree, FragmentTree}; +use layout::{BoxTree, FragmentTree}; use log::{debug, error}; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use metrics::{PaintTimeMetrics, ProfilerMetadataFactory}; @@ -857,12 +857,6 @@ impl LayoutThread { &fragment_tree, ); - if self.debug.trace_layout { - if let Some(box_tree) = &*self.box_tree.borrow() { - layout_debug::begin_trace(box_tree.clone(), fragment_tree.clone()); - } - } - if !reflow_goal.needs_display_list() { return; } @@ -926,10 +920,6 @@ impl LayoutThread { .remove_unused_font_resources(keys, instance_keys) } - if self.debug.trace_layout { - layout_debug::end_trace(self.generation.get()); - } - self.generation.set(self.generation.get() + 1); } diff --git a/ports/servoshell/prefs.rs b/ports/servoshell/prefs.rs index 870926bf871..8fc4d1424ef 100644 --- a/ports/servoshell/prefs.rs +++ b/ports/servoshell/prefs.rs @@ -394,7 +394,7 @@ pub(crate) fn parse_command_line_arguments(args: Vec<String>) -> ArgumentParsing .unwrap_or_else(|err| args_fail(&format!("Error parsing option: -m ({})", err))) }); - let mut layout_threads: Option<usize> = opt_match.opt_str("y").map(|layout_threads_str| { + let layout_threads: Option<usize> = opt_match.opt_str("y").map(|layout_threads_str| { layout_threads_str .parse() .unwrap_or_else(|err| args_fail(&format!("Error parsing option: -y ({})", err))) @@ -425,10 +425,6 @@ pub(crate) fn parse_command_line_arguments(args: Vec<String>) -> ArgumentParsing }) }); - if debug_options.trace_layout { - layout_threads = Some(1); - } - if opt_match.opt_present("devtools") { let port = opt_match .opt_str("devtools") |