mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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:
parent
b8ab820e3c
commit
fdfaf7b15c
11 changed files with 97 additions and 92 deletions
|
@ -121,6 +121,8 @@ mod from_compositor {
|
|||
}
|
||||
|
||||
mod from_script {
|
||||
use embedder_traits::LoadStatus;
|
||||
|
||||
use super::LogTarget;
|
||||
|
||||
macro_rules! target {
|
||||
|
@ -222,11 +224,17 @@ mod from_script {
|
|||
Self::SetClipboardContents(..) => target_variant!("SetClipboardContents"),
|
||||
Self::SetCursor(..) => target_variant!("SetCursor"),
|
||||
Self::NewFavicon(..) => target_variant!("NewFavicon"),
|
||||
Self::HeadParsed(..) => target_variant!("HeadParsed"),
|
||||
Self::HistoryChanged(..) => target_variant!("HistoryChanged"),
|
||||
Self::SetFullscreenState(..) => target_variant!("SetFullscreenState"),
|
||||
Self::LoadStart(..) => target_variant!("LoadStart"),
|
||||
Self::LoadComplete(..) => target_variant!("LoadComplete"),
|
||||
Self::NotifyLoadStatusChanged(_, LoadStatus::Started) => {
|
||||
target_variant!("NotifyLoadStatusChanged(LoadStatus::Started)")
|
||||
},
|
||||
Self::NotifyLoadStatusChanged(_, LoadStatus::HeadParsed) => {
|
||||
target_variant!("NotifyLoadStatusChanged(LoadStatus::HeadParsed)")
|
||||
},
|
||||
Self::NotifyLoadStatusChanged(_, LoadStatus::Complete) => {
|
||||
target_variant!("NotifyLoadStatusChanged(LoadStatus::Complete")
|
||||
},
|
||||
Self::Panic(..) => target_variant!("Panic"),
|
||||
Self::GetSelectedBluetoothDevice(..) => {
|
||||
target_variant!("GetSelectedBluetoothDevice")
|
||||
|
|
|
@ -24,8 +24,8 @@ use cssparser::match_ignore_ascii_case;
|
|||
use devtools_traits::ScriptToDevtoolsControlMsg;
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::{
|
||||
ClipboardEventType, EmbedderMsg, MouseButton, MouseEventType, TouchEventType, TouchId,
|
||||
WheelDelta,
|
||||
ClipboardEventType, EmbedderMsg, LoadStatus, MouseButton, MouseEventType, TouchEventType,
|
||||
TouchId, WheelDelta,
|
||||
};
|
||||
use encoding_rs::{Encoding, UTF_8};
|
||||
use euclid::default::{Point2D, Rect, Size2D};
|
||||
|
@ -1032,13 +1032,19 @@ impl Document {
|
|||
match state {
|
||||
DocumentReadyState::Loading => {
|
||||
if self.window().is_top_level() {
|
||||
self.send_to_embedder(EmbedderMsg::LoadStart(self.webview_id()));
|
||||
self.send_to_embedder(EmbedderMsg::NotifyLoadStatusChanged(
|
||||
self.webview_id(),
|
||||
LoadStatus::Started,
|
||||
));
|
||||
self.send_to_embedder(EmbedderMsg::Status(self.webview_id(), None));
|
||||
}
|
||||
},
|
||||
DocumentReadyState::Complete => {
|
||||
if self.window().is_top_level() {
|
||||
self.send_to_embedder(EmbedderMsg::LoadComplete(self.webview_id()));
|
||||
self.send_to_embedder(EmbedderMsg::NotifyLoadStatusChanged(
|
||||
self.webview_id(),
|
||||
LoadStatus::Complete,
|
||||
));
|
||||
}
|
||||
update_with_current_instant(&self.dom_complete);
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::EmbedderMsg;
|
||||
use embedder_traits::{EmbedderMsg, LoadStatus};
|
||||
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
|
||||
use js::rust::HandleObject;
|
||||
use servo_url::ServoUrl;
|
||||
|
@ -153,7 +153,10 @@ impl VirtualMethods for HTMLBodyElement {
|
|||
let window = self.owner_window();
|
||||
window.prevent_layout_until_load_event();
|
||||
if window.is_top_level() {
|
||||
window.send_to_embedder(EmbedderMsg::HeadParsed(window.webview_id()));
|
||||
window.send_to_embedder(EmbedderMsg::NotifyLoadStatusChanged(
|
||||
window.webview_id(),
|
||||
LoadStatus::HeadParsed,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue