Gate all use of tracing behind Cargo feature (#33845)

Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
Delan Azabani 2024-10-16 18:24:24 +08:00 committed by GitHub
parent 103d3aa7bb
commit fa1f7e5839
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 534 additions and 156 deletions

View file

@ -11,6 +11,9 @@ rust-version.workspace = true
name = "layout_thread_2020"
path = "lib.rs"
[features]
tracing = ["dep:tracing", "layout/tracing"]
[dependencies]
app_units = { workspace = true }
base = { workspace = true }
@ -38,7 +41,7 @@ servo_config = { path = "../config" }
servo_url = { path = "../url" }
style = { workspace = true }
style_traits = { workspace = true }
tracing = { workspace = true }
tracing = { workspace = true, optional = true }
url = { workspace = true }
webrender_api = { workspace = true }
webrender_traits = { workspace = true }

View file

@ -88,7 +88,6 @@ use style::values::computed::{CSSPixelLength, FontSize, Length, NonNegativeLengt
use style::values::specified::font::KeywordInfo;
use style::{driver, Zero};
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
use tracing::{instrument, span, Level};
use url::Url;
use webrender_api::units::LayoutPixel;
use webrender_api::{units, ExternalScrollId, HitTestFlags};
@ -254,7 +253,10 @@ impl Layout for LayoutThread {
);
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn add_stylesheet(
&mut self,
stylesheet: ServoArc<Stylesheet>,
@ -274,7 +276,10 @@ impl Layout for LayoutThread {
}
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn remove_stylesheet(&mut self, stylesheet: ServoArc<Stylesheet>) {
let guard = stylesheet.shared_lock.read();
let stylesheet = DocumentStyleSheet(stylesheet.clone());
@ -283,22 +288,34 @@ impl Layout for LayoutThread {
.remove_all_web_fonts_from_stylesheet(&stylesheet);
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn query_content_box(&self, node: OpaqueNode) -> Option<UntypedRect<Au>> {
process_content_box_request(node, self.fragment_tree.borrow().clone())
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn query_content_boxes(&self, node: OpaqueNode) -> Vec<UntypedRect<Au>> {
process_content_boxes_request(node, self.fragment_tree.borrow().clone())
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn query_client_rect(&self, node: OpaqueNode) -> UntypedRect<i32> {
process_node_geometry_request(node, self.fragment_tree.borrow().clone())
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn query_element_inner_outer_text(
&self,
node: script_layout_interface::TrustedNodeAddress,
@ -316,7 +333,10 @@ impl Layout for LayoutThread {
None
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn query_nodes_from_point(
&self,
point: UntypedPoint2D<f32>,
@ -339,12 +359,18 @@ impl Layout for LayoutThread {
results.iter().map(|result| result.node.into()).collect()
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn query_offset_parent(&self, node: OpaqueNode) -> OffsetParentResponse {
process_offset_parent_query(node, self.fragment_tree.borrow().clone())
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn query_resolved_style(
&self,
node: TrustedNodeAddress,
@ -380,7 +406,10 @@ impl Layout for LayoutThread {
)
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn query_resolved_font_style(
&self,
node: TrustedNodeAddress,
@ -413,12 +442,18 @@ impl Layout for LayoutThread {
)
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn query_scrolling_area(&self, node: Option<OpaqueNode>) -> UntypedRect<i32> {
process_node_scroll_area_request(node, self.fragment_tree.borrow().clone())
}
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn query_text_indext(
&self,
node: OpaqueNode,
@ -663,7 +698,10 @@ impl LayoutThread {
}
/// The high-level routine that performs layout.
#[instrument(skip_all, fields(servo_profiling = true))]
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true))
)]
fn handle_reflow(&mut self, data: &mut ScriptReflowResult) {
let document = unsafe { ServoLayoutNode::new(&data.document) };
let document = document.as_document().unwrap();
@ -783,7 +821,13 @@ impl LayoutThread {
};
if token.should_traverse() {
let span = span!(Level::TRACE, "driver::traverse_dom", servo_profiling = true);
#[cfg(feature = "tracing")]
let span = tracing::span!(
tracing::Level::TRACE,
"driver::traverse_dom",
servo_profiling = true
);
#[cfg(feature = "tracing")]
let _enter = span.enter();
let dirty_root: ServoLayoutNode =
driver::traverse_dom(&traversal, token, rayon_pool).as_node();