libservo: Combine LoadStart, HeadParsed, and LoadComplete` messages (#35260)

These will be a single method in the upcoming `WebView` delegate, so it
makes sense to also combine the internal message to match this. In
addition, since `LoadStatus` is now exposed to the API if there is ever
the need to add more statuses or to move to an event-based version, the
API is already set up for this.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-02-03 23:31:17 +01:00 committed by GitHub
parent b8ab820e3c
commit fdfaf7b15c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 97 additions and 92 deletions

View file

@ -193,16 +193,12 @@ pub enum EmbedderMsg {
SetCursor(WebViewId, Cursor),
/// A favicon was detected
NewFavicon(WebViewId, ServoUrl),
/// `<head>` tag finished parsing
HeadParsed(WebViewId),
/// The history state has changed.
HistoryChanged(WebViewId, Vec<ServoUrl>, usize),
/// Enter or exit fullscreen
SetFullscreenState(WebViewId, bool),
/// The load of a page has begun
LoadStart(WebViewId),
/// The load of a page has completed
LoadComplete(WebViewId),
/// The [`LoadStatus`] of the Given `WebView` has changed.
NotifyLoadStatusChanged(WebViewId, LoadStatus),
WebResourceRequested(
Option<WebViewId>,
WebResourceRequest,
@ -286,11 +282,11 @@ impl Debug for EmbedderMsg {
EmbedderMsg::SetClipboardContents(..) => write!(f, "SetClipboardContents"),
EmbedderMsg::SetCursor(..) => write!(f, "SetCursor"),
EmbedderMsg::NewFavicon(..) => write!(f, "NewFavicon"),
EmbedderMsg::HeadParsed(..) => write!(f, "HeadParsed"),
EmbedderMsg::HistoryChanged(..) => write!(f, "HistoryChanged"),
EmbedderMsg::SetFullscreenState(..) => write!(f, "SetFullscreenState"),
EmbedderMsg::LoadStart(..) => write!(f, "LoadStart"),
EmbedderMsg::LoadComplete(..) => write!(f, "LoadComplete"),
EmbedderMsg::NotifyLoadStatusChanged(_, status) => {
write!(f, "NotifyLoadStatusChanged({status:?})")
},
EmbedderMsg::WebResourceRequested(..) => write!(f, "WebResourceRequested"),
EmbedderMsg::Panic(..) => write!(f, "Panic"),
EmbedderMsg::GetSelectedBluetoothDevice(..) => write!(f, "GetSelectedBluetoothDevice"),
@ -736,3 +732,17 @@ pub enum MediaSessionActionType {
/// The action intent is to move the playback time to a specific time.
SeekTo,
}
/// The status of the load in this `WebView`.
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum LoadStatus {
/// The load has started, but the headers have not yet been parsed.
Started,
/// The `<head>` tag has been parsed in the currently loading page. At this point the page's
/// `HTMLBodyElement` is now available in the DOM.
HeadParsed,
/// The `Document` and all subresources have loaded. This is equivalent to
/// `document.readyState` == `complete`.
/// See <https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState>
Complete,
}