style: Allow references to static, single-generic C++ SharedFontList objects from Rust FontFamilyList.

UA style sheets only ever specify a single generic font family in font-family
properties, so we pre-create a unique, static SharedFontList for each generic
and change the representation of FontFamilyList to be able to refer to them
by their generic ID.  This avoids having to share refcounted SharedFontList
objects across processes.

Differential Revision: https://phabricator.services.mozilla.com/D17183
This commit is contained in:
Cameron McCormack 2019-03-30 00:15:51 +00:00 committed by Emilio Cobos Álvarez
parent 91586eea0e
commit b6b5ddda71
4 changed files with 59 additions and 23 deletions

View file

@ -567,8 +567,14 @@ impl MallocSizeOf for FontFamily {
match *self {
FontFamily::Values(ref v) => {
// Although a SharedFontList object is refcounted, we always
// attribute its size to the specified value.
unsafe { bindings::Gecko_SharedFontList_SizeOfIncludingThis(v.0.get()) }
// attribute its size to the specified value, as long as it's
// not a value in SharedFontList::sSingleGenerics.
if matches!(v, FontFamilyList::SharedFontList(_)) {
let ptr = v.shared_font_list().get();
unsafe { bindings::Gecko_SharedFontList_SizeOfIncludingThis(ptr) }
} else {
0
}
},
FontFamily::System(_) => 0,
}