mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
libservo: Remove message-based API (#35366)
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
044f77d728
commit
84006ba76d
5 changed files with 301 additions and 791 deletions
|
@ -482,25 +482,25 @@ impl IOCompositor {
|
|||
self.shutdown_state = ShutdownState::FinishedShuttingDown;
|
||||
}
|
||||
|
||||
fn handle_browser_message(&mut self, msg: CompositorMsg) -> bool {
|
||||
fn handle_browser_message(&mut self, msg: CompositorMsg) {
|
||||
trace_msg_from_constellation!(msg, "{msg:?}");
|
||||
|
||||
match self.shutdown_state {
|
||||
ShutdownState::NotShuttingDown => {},
|
||||
ShutdownState::ShuttingDown => {
|
||||
return self.handle_browser_message_while_shutting_down(msg)
|
||||
self.handle_browser_message_while_shutting_down(msg);
|
||||
return;
|
||||
},
|
||||
ShutdownState::FinishedShuttingDown => {
|
||||
error!("compositor shouldn't be handling messages after shutting down");
|
||||
return false;
|
||||
// Messages to the compositor are ignored after shutdown is complete.
|
||||
return;
|
||||
},
|
||||
}
|
||||
|
||||
match msg {
|
||||
CompositorMsg::ShutdownComplete => {
|
||||
warn!("Received `ShutdownComplete` while not shutting down.");
|
||||
error!("Received `ShutdownComplete` while not shutting down.");
|
||||
self.finish_shutting_down();
|
||||
return false;
|
||||
},
|
||||
|
||||
CompositorMsg::ChangeRunningAnimationsState(pipeline_id, animation_state) => {
|
||||
|
@ -605,8 +605,6 @@ impl IOCompositor {
|
|||
self.handle_cross_process_message(cross_proces_message);
|
||||
},
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
/// Accept messages from content processes that need to be relayed to the WebRender
|
||||
|
@ -843,11 +841,10 @@ impl IOCompositor {
|
|||
/// When that involves generating WebRender ids, our approach here is to simply
|
||||
/// generate them, but assume they will never be used, since once shutting down the
|
||||
/// compositor no longer does any WebRender frame generation.
|
||||
fn handle_browser_message_while_shutting_down(&mut self, msg: CompositorMsg) -> bool {
|
||||
fn handle_browser_message_while_shutting_down(&mut self, msg: CompositorMsg) {
|
||||
match msg {
|
||||
CompositorMsg::ShutdownComplete => {
|
||||
self.finish_shutting_down();
|
||||
return false;
|
||||
},
|
||||
CompositorMsg::PipelineExited(pipeline_id, sender) => {
|
||||
debug!("Compositor got pipeline exited: {:?}", pipeline_id);
|
||||
|
@ -902,7 +899,6 @@ impl IOCompositor {
|
|||
debug!("Ignoring message ({:?} while shutting down", msg);
|
||||
},
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// Queue a new frame in the transaction and increase the pending frames count.
|
||||
|
@ -2311,7 +2307,7 @@ impl IOCompositor {
|
|||
feature = "tracing",
|
||||
tracing::instrument(skip_all, fields(servo_profiling = true), level = "trace")
|
||||
)]
|
||||
pub fn receive_messages(&mut self) -> bool {
|
||||
pub fn receive_messages(&mut self) {
|
||||
// Check for new messages coming from the other threads in the system.
|
||||
let mut compositor_messages = vec![];
|
||||
let mut found_recomposite_msg = false;
|
||||
|
@ -2330,11 +2326,12 @@ impl IOCompositor {
|
|||
}
|
||||
}
|
||||
for msg in compositor_messages {
|
||||
if !self.handle_browser_message(msg) {
|
||||
return false;
|
||||
self.handle_browser_message(msg);
|
||||
|
||||
if self.shutdown_state == ShutdownState::FinishedShuttingDown {
|
||||
return;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
|
|
|
@ -4,23 +4,13 @@
|
|||
|
||||
//! Abstract windowing methods. The concrete implementations of these can be found in `platform/`.
|
||||
|
||||
use std::fmt::{Debug, Error, Formatter};
|
||||
use std::time::Duration;
|
||||
use std::fmt::Debug;
|
||||
|
||||
use base::id::{PipelineId, TopLevelBrowsingContextId, WebViewId};
|
||||
use embedder_traits::{
|
||||
ClipboardEventType, EventLoopWaker, GamepadEvent, MediaSessionActionType, MouseButton, Theme,
|
||||
TouchEventType, TouchId, TraversalDirection, WheelDelta,
|
||||
};
|
||||
use embedder_traits::{EventLoopWaker, MouseButton};
|
||||
use euclid::Scale;
|
||||
use keyboard_types::{CompositionEvent, KeyboardEvent};
|
||||
use net::protocols::ProtocolRegistry;
|
||||
use servo_geometry::{DeviceIndependentIntRect, DeviceIndependentIntSize, DeviceIndependentPixel};
|
||||
use servo_url::ServoUrl;
|
||||
use webrender_api::units::{
|
||||
DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel, DevicePoint, DeviceRect,
|
||||
};
|
||||
use webrender_api::ScrollLocation;
|
||||
use webrender_api::units::{DeviceIntRect, DeviceIntSize, DevicePixel, DevicePoint};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum MouseWindowEvent {
|
||||
|
@ -37,157 +27,6 @@ pub enum WebRenderDebugOption {
|
|||
RenderTargetDebug,
|
||||
}
|
||||
|
||||
/// Events that the embedder sends to Servo, including events from the windowing system.
|
||||
#[derive(Clone)]
|
||||
pub enum EmbedderEvent {
|
||||
/// Sent when no message has arrived, but the event loop was kicked for some reason (perhaps
|
||||
/// by another Servo subsystem).
|
||||
///
|
||||
/// FIXME(pcwalton): This is kind of ugly and may not work well with multiprocess Servo.
|
||||
/// It's possible that this should be something like
|
||||
/// `CompositorMessageWindowEvent(compositor_thread::Msg)` instead.
|
||||
Idle,
|
||||
/// Sent when part of the window is marked dirty and needs to be redrawn. Before sending this
|
||||
/// message, the window must make the same GL context as in `PrepareRenderingEvent` current.
|
||||
Refresh,
|
||||
/// Sent when the platform theme changes.
|
||||
ThemeChange(Theme),
|
||||
/// Sent when a navigation request from script is allowed/refused.
|
||||
AllowNavigationResponse(PipelineId, bool),
|
||||
/// Sent when a new URL is to be loaded.
|
||||
LoadUrl(TopLevelBrowsingContextId, ServoUrl),
|
||||
/// Sent when a mouse hit test is to be performed.
|
||||
MouseWindowEventClass(MouseWindowEvent),
|
||||
/// Sent when a mouse move.
|
||||
MouseWindowMoveEventClass(DevicePoint),
|
||||
/// Touch event: type, identifier, point
|
||||
Touch(TouchEventType, TouchId, DevicePoint),
|
||||
/// Sent when user moves the mouse wheel.
|
||||
Wheel(WheelDelta, DevicePoint),
|
||||
/// Sent when the user scrolls. The first point is the delta and the second point is the
|
||||
/// origin.
|
||||
Scroll(ScrollLocation, DeviceIntPoint, TouchEventType),
|
||||
/// Sent when the user zooms.
|
||||
Zoom(f32),
|
||||
/// Simulated "pinch zoom" gesture for non-touch platforms (e.g. ctrl-scrollwheel).
|
||||
PinchZoom(f32),
|
||||
/// Sent when the user resets zoom to default.
|
||||
ResetZoom,
|
||||
/// Sent when the user uses chrome navigation (i.e. backspace or shift-backspace).
|
||||
Navigation(TopLevelBrowsingContextId, TraversalDirection),
|
||||
/// Sent when the user quits the application
|
||||
Quit,
|
||||
/// Sent when the user exits from fullscreen mode
|
||||
ExitFullScreen(TopLevelBrowsingContextId),
|
||||
/// Sent when a key input state changes
|
||||
Keyboard(WebViewId, KeyboardEvent),
|
||||
/// Sent for IME composition updates
|
||||
IMEComposition(CompositionEvent),
|
||||
/// Sent when Ctr+R/Apple+R is called to reload the current page.
|
||||
Reload(TopLevelBrowsingContextId),
|
||||
/// Create a new top-level browsing context.
|
||||
NewWebView(ServoUrl, TopLevelBrowsingContextId),
|
||||
/// Close a top-level browsing context.
|
||||
CloseWebView(TopLevelBrowsingContextId),
|
||||
/// Panic a top-level browsing context.
|
||||
SendError(Option<TopLevelBrowsingContextId>, String),
|
||||
/// Move and/or resize a webview to the given rect.
|
||||
MoveResizeWebView(TopLevelBrowsingContextId, DeviceRect),
|
||||
/// Start painting a webview, and optionally stop painting all others.
|
||||
ShowWebView(TopLevelBrowsingContextId, bool),
|
||||
/// Stop painting a webview.
|
||||
HideWebView(TopLevelBrowsingContextId),
|
||||
/// Start painting a webview on top of all others, and optionally stop painting all others.
|
||||
RaiseWebViewToTop(TopLevelBrowsingContextId, bool),
|
||||
/// Make a webview focused.
|
||||
FocusWebView(TopLevelBrowsingContextId),
|
||||
/// Make none of the webviews focused.
|
||||
BlurWebView,
|
||||
/// Toggles a debug flag in WebRender
|
||||
ToggleWebRenderDebug(WebRenderDebugOption),
|
||||
/// Capture current WebRender
|
||||
CaptureWebRender,
|
||||
/// Clear the network cache.
|
||||
ClearCache,
|
||||
/// Toggle sampling profiler with the given sampling rate and max duration.
|
||||
ToggleSamplingProfiler(Duration, Duration),
|
||||
/// Sent when the user triggers a media action through the UA exposed media UI
|
||||
/// (play, pause, seek, etc.).
|
||||
MediaSessionAction(MediaSessionActionType),
|
||||
/// Set whether to use less resources, by stopping animations and running timers at a heavily limited rate.
|
||||
SetWebViewThrottled(TopLevelBrowsingContextId, bool),
|
||||
/// Virtual keyboard was dismissed
|
||||
IMEDismissed,
|
||||
/// Sent when new Gamepad information is available.
|
||||
Gamepad(GamepadEvent),
|
||||
/// Vertical Synchronization tick
|
||||
Vsync,
|
||||
/// Sent when access to clipboard is required
|
||||
ClipboardAction(ClipboardEventType),
|
||||
}
|
||||
|
||||
impl Debug for EmbedderEvent {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
|
||||
match *self {
|
||||
EmbedderEvent::Idle => write!(f, "Idle"),
|
||||
EmbedderEvent::Refresh => write!(f, "Refresh"),
|
||||
EmbedderEvent::ThemeChange(..) => write!(f, "ThemeChange"),
|
||||
EmbedderEvent::Keyboard(..) => write!(f, "Keyboard"),
|
||||
EmbedderEvent::IMEComposition(..) => write!(f, "IMEComposition"),
|
||||
EmbedderEvent::AllowNavigationResponse(..) => write!(f, "AllowNavigationResponse"),
|
||||
EmbedderEvent::LoadUrl(..) => write!(f, "LoadUrl"),
|
||||
EmbedderEvent::MouseWindowEventClass(..) => write!(f, "Mouse"),
|
||||
EmbedderEvent::MouseWindowMoveEventClass(..) => write!(f, "MouseMove"),
|
||||
EmbedderEvent::Touch(..) => write!(f, "Touch"),
|
||||
EmbedderEvent::Wheel(..) => write!(f, "Wheel"),
|
||||
EmbedderEvent::Scroll(..) => write!(f, "Scroll"),
|
||||
EmbedderEvent::Zoom(..) => write!(f, "Zoom"),
|
||||
EmbedderEvent::PinchZoom(..) => write!(f, "PinchZoom"),
|
||||
EmbedderEvent::ResetZoom => write!(f, "ResetZoom"),
|
||||
EmbedderEvent::Navigation(..) => write!(f, "Navigation"),
|
||||
EmbedderEvent::Quit => write!(f, "Quit"),
|
||||
EmbedderEvent::Reload(..) => write!(f, "Reload"),
|
||||
EmbedderEvent::NewWebView(_, TopLevelBrowsingContextId(webview_id)) => {
|
||||
write!(f, "NewWebView({webview_id:?})")
|
||||
},
|
||||
EmbedderEvent::SendError(..) => write!(f, "SendError"),
|
||||
EmbedderEvent::CloseWebView(TopLevelBrowsingContextId(webview_id)) => {
|
||||
write!(f, "CloseWebView({webview_id:?})")
|
||||
},
|
||||
EmbedderEvent::MoveResizeWebView(webview_id, _) => {
|
||||
write!(f, "MoveResizeWebView({webview_id:?})")
|
||||
},
|
||||
EmbedderEvent::ShowWebView(TopLevelBrowsingContextId(webview_id), hide_others) => {
|
||||
write!(f, "ShowWebView({webview_id:?}, {hide_others})")
|
||||
},
|
||||
EmbedderEvent::HideWebView(TopLevelBrowsingContextId(webview_id)) => {
|
||||
write!(f, "HideWebView({webview_id:?})")
|
||||
},
|
||||
EmbedderEvent::RaiseWebViewToTop(
|
||||
TopLevelBrowsingContextId(webview_id),
|
||||
hide_others,
|
||||
) => {
|
||||
write!(f, "RaiseWebViewToTop({webview_id:?}, {hide_others})")
|
||||
},
|
||||
EmbedderEvent::FocusWebView(TopLevelBrowsingContextId(webview_id)) => {
|
||||
write!(f, "FocusWebView({webview_id:?})")
|
||||
},
|
||||
EmbedderEvent::BlurWebView => write!(f, "BlurWebView"),
|
||||
EmbedderEvent::ToggleWebRenderDebug(..) => write!(f, "ToggleWebRenderDebug"),
|
||||
EmbedderEvent::CaptureWebRender => write!(f, "CaptureWebRender"),
|
||||
EmbedderEvent::ToggleSamplingProfiler(..) => write!(f, "ToggleSamplingProfiler"),
|
||||
EmbedderEvent::ExitFullScreen(..) => write!(f, "ExitFullScreen"),
|
||||
EmbedderEvent::MediaSessionAction(..) => write!(f, "MediaSessionAction"),
|
||||
EmbedderEvent::SetWebViewThrottled(..) => write!(f, "SetWebViewThrottled"),
|
||||
EmbedderEvent::IMEDismissed => write!(f, "IMEDismissed"),
|
||||
EmbedderEvent::ClearCache => write!(f, "ClearCache"),
|
||||
EmbedderEvent::Gamepad(..) => write!(f, "Gamepad"),
|
||||
EmbedderEvent::Vsync => write!(f, "Vsync"),
|
||||
EmbedderEvent::ClipboardAction(_) => write!(f, "ClipboardAction"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum AnimationState {
|
||||
Idle,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue