Bug 1963212 - Reuse FontFaceImpl more aggressively. r=jfkthame

When deep-cloning a stylesheet (like we do for devtools), we end up with
new (identical) LockedFontFaceRule object, but we'd fail to re-use it,
triggering new font loads. Since we don't cache failed loads, this
caused flashing and a temporary state where the used fonts were not what
this DevTools test expects.

Rejigger the code a little bit to push down the decision of whether to
reuse the FontFaceImpl object further down. That allows us to reuse the
FontFace object for the stylesheet caching / deep cloning use-case.

Differential Revision: https://phabricator.services.mozilla.com/D247704
This commit is contained in:
Emilio Cobos Álvarez
2025-05-07 15:36:09 +00:00
committed by ealvarez@mozilla.com
parent fd3e0c3fcd
commit a0a14bcfb9
5 changed files with 147 additions and 125 deletions

View File

@@ -3251,6 +3251,21 @@ pub unsafe extern "C" fn Servo_FontFaceRule_Clone(
with_maybe_worker_shared_lock(|lock| Arc::new(lock.wrap(clone)).into())
}
#[no_mangle]
pub unsafe extern "C" fn Servo_FontFaceRule_Equals(
a: &LockedFontFaceRule,
b: &LockedFontFaceRule,
) -> bool {
if a as *const _ == b as *const _ {
return true;
}
read_locked_arc_worker(a, |a: &FontFaceRule| {
read_locked_arc_worker(b, |b: &FontFaceRule| {
a == b
})
})
}
#[no_mangle]
pub unsafe extern "C" fn Servo_FontFaceRule_GetSourceLocation(
rule: &LockedFontFaceRule,