mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Add fragment debug id
This commit is contained in:
parent
84dd334160
commit
67706f9c0b
7 changed files with 90 additions and 38 deletions
|
@ -10,10 +10,15 @@ use serde_json::{to_string, to_value, Value};
|
|||
use std::cell::RefCell;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
#[cfg(debug_assertions)]
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None));
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
static DEBUG_ID_COUNTER: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
pub struct Scope;
|
||||
|
||||
#[macro_export]
|
||||
|
@ -80,6 +85,12 @@ impl Drop for Scope {
|
|||
}
|
||||
}
|
||||
|
||||
/// Generate a unique ID for Fragments.
|
||||
#[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(root: Arc<FragmentTreeRoot>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue