script: add skeleton implementation of FontFace API (#35262)

This patch implements the `FontFace` interface, but with some caveats

1. The interface is only exposed on `Window`. Support for Workers will
   be handled in the future.
2. The concept of `css-connected` `FontFace` is not implemented, so
   `@font-face` rules in stylesheets will not be represented in the DOM.
3. The constructor only supports using `url()` strings as source
   and `ArrayBuffer` and `ArrayBufferView` are not supported yet.

A skeleton implementation of the `load` method of `FontFaceSet` is also
implemented in this patch. The intention is to support some web pages
that don't load without this method.

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Mukilan Thiyagarajan 2025-02-19 11:20:01 +05:30 committed by GitHub
parent 29e0fad21e
commit 56840e0a35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 1160 additions and 551 deletions

View file

@ -21,6 +21,7 @@ pub enum ScriptHangAnnotation {
DevtoolsMsg,
DocumentEvent,
FileRead,
FontLoading,
FormPlannedNavigation,
ImageCacheMsg,
InputEvent,

View file

@ -17,4 +17,4 @@ int_range_index! {
struct ByteIndex(isize)
}
pub type WebFontLoadFinishedCallback = Arc<dyn Fn(bool) + Send + Sync + 'static>;
pub type StylesheetWebFontLoadFinishedCallback = Arc<dyn Fn(bool) + Send + Sync + 'static>;

View file

@ -524,7 +524,7 @@ enum ToFetchThreadMessage {
FetchResponse(FetchResponseMsg),
}
pub type BoxedFetchCallback = Box<dyn Fn(FetchResponseMsg) + Send + 'static>;
pub type BoxedFetchCallback = Box<dyn FnMut(FetchResponseMsg) + Send + 'static>;
/// A thread to handle fetches in a Servo process. This thread is responsible for
/// listening for new fetch requests as well as updates on those operations and forwarding
@ -601,7 +601,7 @@ impl FetchThread {
matches!(fetch_response_msg, FetchResponseMsg::ProcessResponseEOF(..));
self.active_fetches
.get(&request_id)
.get_mut(&request_id)
.expect("Got fetch response for unknown fetch")(
fetch_response_msg
);

View file

@ -90,43 +90,44 @@ pub enum ProfilerCategory {
ScriptEvent = 0x66,
ScriptFileRead = 0x67,
ScriptImageCacheMsg = 0x68,
ScriptInputEvent = 0x69,
ScriptNetworkEvent = 0x6a,
ScriptFontLoading = 0x68,
ScriptImageCacheMsg = 0x69,
ScriptInputEvent = 0x6a,
ScriptNetworkEvent = 0x6b,
/// The script thread is parsing HTML, rather than doing other work like evaluating scripts or doing layout.
ScriptParseHTML = 0x6b,
ScriptParseHTML = 0x6c,
ScriptPlannedNavigation = 0x6c,
ScriptResize = 0x6d,
ScriptRendering = 0x6e,
ScriptSetScrollState = 0x6f,
ScriptSetViewport = 0x70,
ScriptTimerEvent = 0x71,
ScriptStylesheetLoad = 0x72,
ScriptUpdateReplacedElement = 0x73,
ScriptWebSocketEvent = 0x74,
ScriptWorkerEvent = 0x75,
ScriptServiceWorkerEvent = 0x76,
ScriptPlannedNavigation = 0x6d,
ScriptResize = 0x6e,
ScriptRendering = 0x6f,
ScriptSetScrollState = 0x70,
ScriptSetViewport = 0x71,
ScriptTimerEvent = 0x72,
ScriptStylesheetLoad = 0x73,
ScriptUpdateReplacedElement = 0x74,
ScriptWebSocketEvent = 0x75,
ScriptWorkerEvent = 0x76,
ScriptServiceWorkerEvent = 0x77,
/// The script thread is parsing XML, rather than doing other work like evaluating scripts or doing layout.
ScriptParseXML = 0x77,
ScriptParseXML = 0x78,
ScriptEnterFullscreen = 0x78,
ScriptExitFullscreen = 0x79,
ScriptWorkletEvent = 0x7a,
ScriptPerformanceEvent = 0x7b,
ScriptHistoryEvent = 0x7c,
ScriptPortMessage = 0x7d,
ScriptWebGPUMsg = 0x7e,
ScriptEnterFullscreen = 0x79,
ScriptExitFullscreen = 0x7a,
ScriptWorkletEvent = 0x7b,
ScriptPerformanceEvent = 0x7c,
ScriptHistoryEvent = 0x7d,
ScriptPortMessage = 0x7e,
ScriptWebGPUMsg = 0x7f,
/// Web performance metrics.
TimeToFirstPaint = 0x80,
TimeToFirstContentfulPaint = 0x81,
TimeToInteractive = 0x82,
TimeToFirstPaint = 0x90,
TimeToFirstContentfulPaint = 0x91,
TimeToInteractive = 0x92,
IpcReceiver = 0x83,
IpcBytesReceiver = 0x84,
IpcReceiver = 0x93,
IpcBytesReceiver = 0x94,
}
impl ProfilerCategory {
@ -151,6 +152,7 @@ impl ProfilerCategory {
ProfilerCategory::ScriptEvaluate => "ScriptEvaluate",
ProfilerCategory::ScriptEvent => "ScriptEvent",
ProfilerCategory::ScriptFileRead => "ScriptFileRead",
ProfilerCategory::ScriptFontLoading => "ScriptFontLoading",
ProfilerCategory::ScriptImageCacheMsg => "ScriptImageCacheMsg",
ProfilerCategory::ScriptInputEvent => "ScriptInputEvent",
ProfilerCategory::ScriptNetworkEvent => "ScriptNetworkEvent",