fonts: Stop using Stylesheet::effective_font_face_rules (#32699)

This function doesn't exist in upstream Stylo and is fairly unecessary.
Removing it will help reduce the difference between downstream Stylo and
upstream Stylo.
This commit is contained in:
Martin Robinson 2024-07-04 23:53:14 +02:00 committed by GitHub
parent 0f2139be27
commit 7eac599aa1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,7 +24,7 @@ use style::font_face::{FontFaceSourceFormat, FontFaceSourceFormatKeyword, Source
use style::media_queries::Device; use style::media_queries::Device;
use style::properties::style_structs::Font as FontStyleStruct; use style::properties::style_structs::Font as FontStyleStruct;
use style::shared_lock::SharedRwLockReadGuard; use style::shared_lock::SharedRwLockReadGuard;
use style::stylesheets::{DocumentStyleSheet, StylesheetInDocument}; use style::stylesheets::{CssRule, DocumentStyleSheet, FontFaceRule, StylesheetInDocument};
use style::Atom; use style::Atom;
use url::Url; use url::Url;
use webrender_api::{FontInstanceKey, FontKey}; use webrender_api::{FontInstanceKey, FontKey};
@ -275,10 +275,14 @@ impl<S: FontSource + Send + 'static> FontContextWebFontMethods for Arc<FontConte
}; };
let mut number_loading = 0; let mut number_loading = 0;
stylesheet.effective_font_face_rules(device, guard, |rule| { for rule in stylesheet.effective_rules(device, guard) {
let font_face = match rule.font_face() { let CssRule::FontFace(ref lock) = *rule else {
Some(font_face) => font_face, continue;
None => return, };
let rule: &FontFaceRule = lock.read_with(guard);
let Some(font_face) = rule.font_face() else {
continue;
}; };
let sources: Vec<Source> = font_face let sources: Vec<Source> = font_face
@ -290,7 +294,7 @@ impl<S: FontSource + Send + 'static> FontContextWebFontMethods for Arc<FontConte
.cloned() .cloned()
.collect(); .collect();
if sources.is_empty() { if sources.is_empty() {
return; continue;
} }
// Fetch all local fonts first, beacause if we try to fetch them later on during the process of // Fetch all local fonts first, beacause if we try to fetch them later on during the process of
@ -334,7 +338,7 @@ impl<S: FontSource + Send + 'static> FontContextWebFontMethods for Arc<FontConte
if let Some(ref synchronous_receiver) = synchronous_receiver { if let Some(ref synchronous_receiver) = synchronous_receiver {
synchronous_receiver.recv().unwrap(); synchronous_receiver.recv().unwrap();
} }
}); }
number_loading number_loading
} }