mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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
This commit is contained in:
parent
709c52fefb
commit
6bae0b99ca
10 changed files with 184 additions and 122 deletions
|
@ -32,7 +32,7 @@ use std::mem::{self, ManuallyDrop};
|
|||
use std::slice;
|
||||
use style_traits::{CssWriter, ParseError, ToCss};
|
||||
#[cfg(feature = "gecko")]
|
||||
use to_shmem::{SharedMemoryBuilder, ToShmem};
|
||||
use to_shmem::{self, SharedMemoryBuilder, ToShmem};
|
||||
|
||||
pub use crate::values::computed::Length as MozScriptMinSize;
|
||||
pub use crate::values::specified::font::{FontSynthesis, MozScriptSizeMultiplier};
|
||||
|
@ -466,19 +466,20 @@ pub enum FontFamilyList {
|
|||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl ToShmem for FontFamilyList {
|
||||
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> ManuallyDrop<Self> {
|
||||
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> to_shmem::Result<Self> {
|
||||
// In practice, the only SharedFontList objects we create from shared
|
||||
// style sheets are ones with a single generic entry.
|
||||
ManuallyDrop::new(match *self {
|
||||
Ok(ManuallyDrop::new(match *self {
|
||||
FontFamilyList::SharedFontList(ref r) => {
|
||||
assert!(
|
||||
r.mNames.len() == 1 && r.mNames[0].mName.mRawPtr.is_null(),
|
||||
"ToShmem failed for FontFamilyList: cannot handle non-generic families",
|
||||
);
|
||||
if !(r.mNames.len() == 1 && r.mNames[0].mName.mRawPtr.is_null()) {
|
||||
return Err(String::from(
|
||||
"ToShmem failed for FontFamilyList: cannot handle non-generic families",
|
||||
));
|
||||
}
|
||||
FontFamilyList::Generic(r.mNames[0].mGeneric)
|
||||
},
|
||||
FontFamilyList::Generic(t) => FontFamilyList::Generic(t),
|
||||
})
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue