mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01: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
|
@ -24,14 +24,14 @@ use servo::servo_geometry::DeviceIndependentPixel;
|
|||
use servo::servo_url::ServoUrl;
|
||||
use servo::webrender_api::units::DevicePixel;
|
||||
use servo::webrender_traits::SurfmanRenderingContext;
|
||||
use servo::Servo;
|
||||
use servo::{LoadStatus, Servo};
|
||||
use winit::event::{ElementState, MouseButton, WindowEvent};
|
||||
use winit::event_loop::ActiveEventLoop;
|
||||
use winit::window::Window;
|
||||
|
||||
use super::egui_glue::EguiGlow;
|
||||
use super::geometry::winit_position_to_euclid_point;
|
||||
use super::webview::{LoadStatus, WebView, WebViewManager};
|
||||
use super::webview::{WebView, WebViewManager};
|
||||
|
||||
pub struct Minibrowser {
|
||||
pub context: EguiGlow,
|
||||
|
@ -108,7 +108,7 @@ impl Minibrowser {
|
|||
last_mouse_position: None,
|
||||
location: RefCell::new(initial_url.to_string()),
|
||||
location_dirty: false.into(),
|
||||
load_status: LoadStatus::LoadComplete,
|
||||
load_status: LoadStatus::Complete,
|
||||
status_text: None,
|
||||
}
|
||||
}
|
||||
|
@ -300,12 +300,12 @@ impl Minibrowser {
|
|||
}
|
||||
|
||||
match self.load_status {
|
||||
LoadStatus::LoadStart | LoadStatus::HeadParsed => {
|
||||
LoadStatus::Started | LoadStatus::HeadParsed => {
|
||||
if ui.add(Minibrowser::toolbar_button("X")).clicked() {
|
||||
warn!("Do not support stop yet.");
|
||||
}
|
||||
},
|
||||
LoadStatus::LoadComplete => {
|
||||
LoadStatus::Complete => {
|
||||
if ui.add(Minibrowser::toolbar_button("↻")).clicked() {
|
||||
event_queue.borrow_mut().push(MinibrowserEvent::Reload);
|
||||
}
|
||||
|
|
|
@ -148,11 +148,9 @@ mod from_servo {
|
|||
Self::SetClipboardContents(..) => target!("SetClipboardContents"),
|
||||
Self::SetCursor(..) => target!("SetCursor"),
|
||||
Self::NewFavicon(..) => target!("NewFavicon"),
|
||||
Self::HeadParsed(..) => target!("HeadParsed"),
|
||||
Self::HistoryChanged(..) => target!("HistoryChanged"),
|
||||
Self::SetFullscreenState(..) => target!("SetFullscreenState"),
|
||||
Self::LoadStart(..) => target!("LoadStart"),
|
||||
Self::LoadComplete(..) => target!("LoadComplete"),
|
||||
Self::NotifyLoadStatusChanged(..) => target!("NotifyLoadStatusChanged"),
|
||||
Self::Panic(..) => target!("Panic"),
|
||||
Self::GetSelectedBluetoothDevice(..) => target!("GetSelectedBluetoothDevice"),
|
||||
Self::SelectFiles(..) => target!("SelectFiles"),
|
||||
|
|
|
@ -23,8 +23,9 @@ use servo::webrender_api::ScrollLocation;
|
|||
use servo::{
|
||||
CompositorEventVariant, ContextMenuResult, DualRumbleEffectParams, EmbedderMsg, FilterPattern,
|
||||
GamepadEvent, GamepadHapticEffectType, GamepadIndex, GamepadInputBounds,
|
||||
GamepadSupportedHapticEffects, GamepadUpdateType, PermissionPrompt, PermissionRequest,
|
||||
PromptCredentialsInput, PromptDefinition, PromptOrigin, PromptResult, Servo, TouchEventType,
|
||||
GamepadSupportedHapticEffects, GamepadUpdateType, LoadStatus, PermissionPrompt,
|
||||
PermissionRequest, PromptCredentialsInput, PromptDefinition, PromptOrigin, PromptResult, Servo,
|
||||
TouchEventType,
|
||||
};
|
||||
use tinyfiledialogs::{self, MessageBoxIcon, OkCancel, YesNo};
|
||||
|
||||
|
@ -53,13 +54,6 @@ pub struct WebViewManager {
|
|||
shutdown_requested: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum LoadStatus {
|
||||
HeadParsed,
|
||||
LoadStart,
|
||||
LoadComplete,
|
||||
}
|
||||
|
||||
// The state of each Tab/WebView
|
||||
pub struct WebView {
|
||||
pub rect: DeviceRect,
|
||||
|
@ -77,7 +71,7 @@ impl WebView {
|
|||
title: None,
|
||||
url: None,
|
||||
focused: false,
|
||||
load_status: LoadStatus::LoadComplete,
|
||||
load_status: LoadStatus::Complete,
|
||||
servo_webview,
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +165,7 @@ impl WebViewManager {
|
|||
pub fn load_status(&self) -> LoadStatus {
|
||||
match self.focused_webview() {
|
||||
Some(webview) => webview.load_status,
|
||||
None => LoadStatus::LoadComplete,
|
||||
None => LoadStatus::Complete,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,7 +417,7 @@ impl WebViewManager {
|
|||
opts: &Opts,
|
||||
messages: Vec<EmbedderMsg>,
|
||||
) -> ServoEventResponse {
|
||||
let mut need_present = self.load_status() != LoadStatus::LoadComplete;
|
||||
let mut need_present = self.load_status() != LoadStatus::Complete;
|
||||
let mut need_update = false;
|
||||
for message in messages {
|
||||
trace_embedder_msg!(message, "{message:?}");
|
||||
|
@ -638,9 +632,9 @@ impl WebViewManager {
|
|||
EmbedderMsg::NewFavicon(_, _url) => {
|
||||
// FIXME: show favicons in the UI somehow
|
||||
},
|
||||
EmbedderMsg::HeadParsed(webview_id) => {
|
||||
EmbedderMsg::NotifyLoadStatusChanged(webview_id, load_status) => {
|
||||
if let Some(webview) = self.get_mut(webview_id) {
|
||||
webview.load_status = LoadStatus::HeadParsed;
|
||||
webview.load_status = load_status;
|
||||
need_update = true;
|
||||
};
|
||||
},
|
||||
|
@ -653,18 +647,6 @@ impl WebViewManager {
|
|||
EmbedderMsg::SetFullscreenState(_, state) => {
|
||||
self.window.set_fullscreen(state);
|
||||
},
|
||||
EmbedderMsg::LoadStart(webview_id) => {
|
||||
if let Some(webview) = self.get_mut(webview_id) {
|
||||
webview.load_status = LoadStatus::LoadStart;
|
||||
need_update = true;
|
||||
};
|
||||
},
|
||||
EmbedderMsg::LoadComplete(webview_id) => {
|
||||
if let Some(webview) = self.get_mut(webview_id) {
|
||||
webview.load_status = LoadStatus::LoadComplete;
|
||||
need_update = true;
|
||||
};
|
||||
},
|
||||
EmbedderMsg::WebResourceRequested(_, _web_resource_request, _response_sender) => {},
|
||||
EmbedderMsg::Shutdown => {
|
||||
self.shutdown_requested = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue