Bug 1630676 - Fix two regressions from the previous patches.

MANUAL PUSH: Review information for upstream patches would get lost otherwise.
This commit is contained in:
Emilio Cobos Álvarez 2020-04-16 20:54:17 +02:00
parent 2be2ef7470
commit b69a3cb639
2 changed files with 12 additions and 10 deletions

View File

@ -89,7 +89,7 @@ pub fn traverse_dom<E, D>(
// ThreadLocalStyleContext on the main thread. If the main thread
// ThreadLocalStyleContext has not released its TLS borrow by that point,
// 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 context = StyleContext {
shared: traversal.shared_context(),
@ -129,7 +129,7 @@ pub fn traverse_dom<E, D>(
// depth for all the children.
if pool.is_some() && discovered.len() > WORK_UNIT_MAX {
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 drain = discovered.drain(..);
pool.install(|| {
@ -151,10 +151,12 @@ pub fn traverse_dom<E, D>(
scope,
pool,
traversal,
maybe_tls.as_ref().unwrap(),
&tls,
);
});
});
tls_slots = Some(tls.into_slots());
break;
}
nodes_remaining_at_current_depth = discovered.len();
@ -164,9 +166,9 @@ pub fn traverse_dom<E, D>(
// Collect statistics from thread-locals if requested.
if dump_stats || report_stats {
let mut aggregate = mem::replace(&mut context.thread_local.statistics, Default::default());
let parallel = maybe_tls.is_some();
if let Some(tls) = maybe_tls {
for mut slot in tls.into_slots().into_vec() {
let parallel = tls_slots.is_some();
if let Some(ref mut tls) = tls_slots {
for slot in tls.iter_mut() {
if let Some(cx) = slot.get_mut() {
aggregate += cx.statistics.clone();
}

View File

@ -714,10 +714,7 @@ impl FontLanguageOverride {
/// Returns this value as a `&str`, backed by `storage`.
#[inline]
pub fn to_str(self, storage: &mut [u8; 4]) -> &str {
if self.0 == 0 {
return "normal";
}
pub(crate) fn to_str(self, storage: &mut [u8; 4]) -> &str {
*storage = u32::to_be_bytes(self.0);
// Safe because we ensure it's ASCII during computing
let slice = if cfg!(debug_assertions) {
@ -758,6 +755,9 @@ impl ToCss for FontLanguageOverride {
where
W: fmt::Write,
{
if self.0 == 0 {
return dest.write_str("normal");
}
self.to_str(&mut [0; 4]).to_css(dest)
}
}