diff options
author | Cameron McCormack <cam@mcc.id.au> | 2020-05-11 00:11:45 +0000 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-06-04 01:50:36 +0200 |
commit | 6bae0b99ca8881bf13b71ee088d9966fe21f8de4 (patch) | |
tree | 729c1f963dc3aff2a533eefd63880f4f794a0bc2 /components/style/gecko_string_cache/mod.rs | |
parent | 709c52fefb0a514c9c59fd3ad3ed950392254cd9 (diff) | |
download | servo-6bae0b99ca8881bf13b71ee088d9966fe21f8de4.tar.gz servo-6bae0b99ca8881bf13b71ee088d9966fe21f8de4.zip |
style: Gracefully handle errors creating shared memory UA style sheets.
We still panic in a debug build, so that developers can notice when they
need to add a new static atom after modifying UA sheets.
We also add telemetry to note when this happens, add an app note to a
crash report, in case any crash later on occurs, and re-up the existing,
expired shared memory sheet telemetry probes so we can look at them
again.
Differential Revision: https://phabricator.services.mozilla.com/D73188
Diffstat (limited to 'components/style/gecko_string_cache/mod.rs')
-rw-r--r-- | components/style/gecko_string_cache/mod.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs index b9e3a0c608a..e9208a5e32e 100644 --- a/components/style/gecko_string_cache/mod.rs +++ b/components/style/gecko_string_cache/mod.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![allow(unsafe_code)] - // This is needed for the constants in atom_macro.rs, because we have some // atoms whose names differ only by case, e.g. datetime and dateTime. #![allow(non_upper_case_globals)] @@ -30,7 +29,7 @@ use std::num::NonZeroUsize; use std::ops::Deref; use std::{slice, str}; use style_traits::SpecifiedValueInfo; -use to_shmem::{SharedMemoryBuilder, ToShmem}; +use to_shmem::{self, SharedMemoryBuilder, ToShmem}; #[macro_use] #[allow(improper_ctypes, non_camel_case_types, missing_docs)] @@ -132,14 +131,15 @@ impl Borrow<WeakAtom> for Atom { } impl ToShmem for Atom { - fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> ManuallyDrop<Self> { - assert!( - self.is_static(), - "ToShmem failed for Atom: must be a static atom: {}", - self - ); - - ManuallyDrop::new(Atom(self.0)) + fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> to_shmem::Result<Self> { + if !self.is_static() { + return Err(format!( + "ToShmem failed for Atom: must be a static atom: {}", + self + )); + } + + Ok(ManuallyDrop::new(Atom(self.0))) } } |