mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
layout: Simplify layout debugging scope.
This commit is contained in:
parent
39e082af18
commit
cd00d65ffd
1 changed files with 9 additions and 15 deletions
|
@ -65,14 +65,11 @@ struct State {
|
||||||
impl Scope {
|
impl Scope {
|
||||||
pub fn new(name: String) -> Scope {
|
pub fn new(name: String) -> Scope {
|
||||||
STATE_KEY.with(|ref r| {
|
STATE_KEY.with(|ref r| {
|
||||||
match *r.borrow_mut() {
|
if let Some(ref mut state) = *r.borrow_mut() {
|
||||||
Some(ref mut state) => {
|
|
||||||
let flow_trace = to_value(&flow::base(&*state.flow_root));
|
let flow_trace = to_value(&flow::base(&*state.flow_root));
|
||||||
let data = box ScopeData::new(name.clone(), flow_trace);
|
let data = box ScopeData::new(name.clone(), flow_trace);
|
||||||
state.scope_stack.push(data);
|
state.scope_stack.push(data);
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
Scope
|
Scope
|
||||||
}
|
}
|
||||||
|
@ -82,15 +79,12 @@ impl Scope {
|
||||||
impl Drop for Scope {
|
impl Drop for Scope {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
STATE_KEY.with(|ref r| {
|
STATE_KEY.with(|ref r| {
|
||||||
match *r.borrow_mut() {
|
if let Some(ref mut state) = *r.borrow_mut() {
|
||||||
Some(ref mut state) => {
|
|
||||||
let mut current_scope = state.scope_stack.pop().unwrap();
|
let mut current_scope = state.scope_stack.pop().unwrap();
|
||||||
current_scope.post = to_value(&flow::base(&*state.flow_root));
|
current_scope.post = to_value(&flow::base(&*state.flow_root));
|
||||||
let previous_scope = state.scope_stack.last_mut().unwrap();
|
let previous_scope = state.scope_stack.last_mut().unwrap();
|
||||||
previous_scope.children.push(current_scope);
|
previous_scope.children.push(current_scope);
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue