mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Fix two regressions from #26113.
This commit is contained in:
parent
35f872e2d9
commit
3d1df8dce7
2 changed files with 12 additions and 10 deletions
|
@ -89,7 +89,7 @@ pub fn traverse_dom<E, D>(
|
||||||
// ThreadLocalStyleContext on the main thread. If the main thread
|
// ThreadLocalStyleContext on the main thread. If the main thread
|
||||||
// ThreadLocalStyleContext has not released its TLS borrow by that point,
|
// ThreadLocalStyleContext has not released its TLS borrow by that point,
|
||||||
// we'll panic on double-borrow.
|
// we'll panic on double-borrow.
|
||||||
let mut maybe_tls: Option<ScopedTLS<ThreadLocalStyleContext<E>>> = None;
|
let mut tls_slots = None;
|
||||||
let mut tlc = ThreadLocalStyleContext::new(traversal.shared_context());
|
let mut tlc = ThreadLocalStyleContext::new(traversal.shared_context());
|
||||||
let mut context = StyleContext {
|
let mut context = StyleContext {
|
||||||
shared: traversal.shared_context(),
|
shared: traversal.shared_context(),
|
||||||
|
@ -129,7 +129,7 @@ pub fn traverse_dom<E, D>(
|
||||||
// depth for all the children.
|
// depth for all the children.
|
||||||
if pool.is_some() && discovered.len() > WORK_UNIT_MAX {
|
if pool.is_some() && discovered.len() > WORK_UNIT_MAX {
|
||||||
let pool = pool.unwrap();
|
let pool = pool.unwrap();
|
||||||
maybe_tls = Some(ScopedTLS::<ThreadLocalStyleContext<E>>::new(pool));
|
let tls = ScopedTLS::<ThreadLocalStyleContext<E>>::new(pool);
|
||||||
let root_opaque = root.as_node().opaque();
|
let root_opaque = root.as_node().opaque();
|
||||||
let drain = discovered.drain(..);
|
let drain = discovered.drain(..);
|
||||||
pool.install(|| {
|
pool.install(|| {
|
||||||
|
@ -151,10 +151,12 @@ pub fn traverse_dom<E, D>(
|
||||||
scope,
|
scope,
|
||||||
pool,
|
pool,
|
||||||
traversal,
|
traversal,
|
||||||
maybe_tls.as_ref().unwrap(),
|
&tls,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tls_slots = Some(tls.into_slots());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nodes_remaining_at_current_depth = discovered.len();
|
nodes_remaining_at_current_depth = discovered.len();
|
||||||
|
@ -164,9 +166,9 @@ pub fn traverse_dom<E, D>(
|
||||||
// Collect statistics from thread-locals if requested.
|
// Collect statistics from thread-locals if requested.
|
||||||
if dump_stats || report_stats {
|
if dump_stats || report_stats {
|
||||||
let mut aggregate = mem::replace(&mut context.thread_local.statistics, Default::default());
|
let mut aggregate = mem::replace(&mut context.thread_local.statistics, Default::default());
|
||||||
let parallel = maybe_tls.is_some();
|
let parallel = tls_slots.is_some();
|
||||||
if let Some(tls) = maybe_tls {
|
if let Some(ref mut tls) = tls_slots {
|
||||||
for mut slot in tls.into_slots().into_vec() {
|
for slot in tls.iter_mut() {
|
||||||
if let Some(cx) = slot.get_mut() {
|
if let Some(cx) = slot.get_mut() {
|
||||||
aggregate += cx.statistics.clone();
|
aggregate += cx.statistics.clone();
|
||||||
}
|
}
|
||||||
|
|
|
@ -714,10 +714,7 @@ impl FontLanguageOverride {
|
||||||
|
|
||||||
/// Returns this value as a `&str`, backed by `storage`.
|
/// Returns this value as a `&str`, backed by `storage`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_str(self, storage: &mut [u8; 4]) -> &str {
|
pub(crate) fn to_str(self, storage: &mut [u8; 4]) -> &str {
|
||||||
if self.0 == 0 {
|
|
||||||
return "normal";
|
|
||||||
}
|
|
||||||
*storage = u32::to_be_bytes(self.0);
|
*storage = u32::to_be_bytes(self.0);
|
||||||
// Safe because we ensure it's ASCII during computing
|
// Safe because we ensure it's ASCII during computing
|
||||||
let slice = if cfg!(debug_assertions) {
|
let slice = if cfg!(debug_assertions) {
|
||||||
|
@ -758,6 +755,9 @@ impl ToCss for FontLanguageOverride {
|
||||||
where
|
where
|
||||||
W: fmt::Write,
|
W: fmt::Write,
|
||||||
{
|
{
|
||||||
|
if self.0 == 0 {
|
||||||
|
return dest.write_str("normal");
|
||||||
|
}
|
||||||
self.to_str(&mut [0; 4]).to_css(dest)
|
self.to_str(&mut [0; 4]).to_css(dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue