libservo: Remove EmbedderEvent::WindowResize (#35277)

Remove this event which is completely unused. In addition, lots of code
becomes dead once this happens, so remove that as well. It may be
possible that a different behavior is necessary immediately following a
window resize, but the new API will handle this in a different way than
this embedder event -- which complicates how the event loop is spun in
both the API and servoshell.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-02-04 09:37:25 +01:00 committed by GitHub
parent c94ac5bccb
commit d5daa31b1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 42 deletions

View file

@ -51,8 +51,6 @@ pub enum EmbedderEvent {
/// Sent when part of the window is marked dirty and needs to be redrawn. Before sending this /// 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. /// message, the window must make the same GL context as in `PrepareRenderingEvent` current.
Refresh, Refresh,
/// Sent when the window is resized.
WindowResize,
/// Sent when the platform theme changes. /// Sent when the platform theme changes.
ThemeChange(Theme), ThemeChange(Theme),
/// Sent when a navigation request from script is allowed/refused. /// Sent when a navigation request from script is allowed/refused.
@ -142,7 +140,6 @@ impl Debug for EmbedderEvent {
match *self { match *self {
EmbedderEvent::Idle => write!(f, "Idle"), EmbedderEvent::Idle => write!(f, "Idle"),
EmbedderEvent::Refresh => write!(f, "Refresh"), EmbedderEvent::Refresh => write!(f, "Refresh"),
EmbedderEvent::WindowResize => write!(f, "Resize"),
EmbedderEvent::ThemeChange(..) => write!(f, "ThemeChange"), EmbedderEvent::ThemeChange(..) => write!(f, "ThemeChange"),
EmbedderEvent::Keyboard(..) => write!(f, "Keyboard"), EmbedderEvent::Keyboard(..) => write!(f, "Keyboard"),
EmbedderEvent::IMEComposition(..) => write!(f, "IMEComposition"), EmbedderEvent::IMEComposition(..) => write!(f, "IMEComposition"),

View file

@ -643,17 +643,13 @@ impl Servo {
) )
} }
fn handle_window_event(&mut self, event: EmbedderEvent) -> bool { fn handle_window_event(&mut self, event: EmbedderEvent) {
match event { match event {
EmbedderEvent::Idle => {}, EmbedderEvent::Idle => {},
EmbedderEvent::Refresh => { EmbedderEvent::Refresh => {
self.compositor.borrow_mut().composite(); self.compositor.borrow_mut().composite();
}, },
EmbedderEvent::WindowResize => {
return self.compositor.borrow_mut().on_rendering_context_resized();
},
EmbedderEvent::ThemeChange(theme) => { EmbedderEvent::ThemeChange(theme) => {
let msg = ConstellationMsg::ThemeChange(theme); let msg = ConstellationMsg::ThemeChange(theme);
if let Err(e) = self.constellation_proxy.try_send(msg) { if let Err(e) = self.constellation_proxy.try_send(msg) {
@ -918,7 +914,6 @@ impl Servo {
self.send_to_constellation(ConstellationMsg::Clipboard(clipboard_event)); self.send_to_constellation(ConstellationMsg::Clipboard(clipboard_event));
}, },
} }
false
} }
fn send_to_constellation(&self, msg: ConstellationMsg) { fn send_to_constellation(&self, msg: ConstellationMsg) {
@ -955,21 +950,19 @@ impl Servo {
self.messages_for_embedder.drain(..) self.messages_for_embedder.drain(..)
} }
pub fn handle_events(&mut self, events: impl IntoIterator<Item = EmbedderEvent>) -> bool { pub fn handle_events(&mut self, events: impl IntoIterator<Item = EmbedderEvent>) {
if self.compositor.borrow_mut().receive_messages() { if self.compositor.borrow_mut().receive_messages() {
self.receive_messages(); self.receive_messages();
} }
let mut need_resize = false;
for event in events { for event in events {
trace!("servo <- embedder EmbedderEvent {:?}", event); trace!("servo <- embedder EmbedderEvent {:?}", event);
need_resize |= self.handle_window_event(event); self.handle_window_event(event);
} }
if self.compositor.borrow().shutdown_state != ShutdownState::FinishedShuttingDown { if self.compositor.borrow().shutdown_state != ShutdownState::FinishedShuttingDown {
self.compositor.borrow_mut().perform_updates(); self.compositor.borrow_mut().perform_updates();
} else { } else {
self.messages_for_embedder.push(EmbedderMsg::Shutdown); self.messages_for_embedder.push(EmbedderMsg::Shutdown);
} }
need_resize
} }
pub fn repaint_synchronously(&mut self) { pub fn repaint_synchronously(&mut self) {

View file

@ -58,7 +58,6 @@ pub struct App {
} }
enum Present { enum Present {
Immediate,
Deferred, Deferred,
None, None,
} }
@ -251,7 +250,6 @@ impl App {
// Take any new embedder messages from Servo. // Take any new embedder messages from Servo.
let servo = self.servo.as_mut().expect("Servo should be running."); let servo = self.servo.as_mut().expect("Servo should be running.");
let mut embedder_messages: Vec<_> = servo.get_events().collect(); let mut embedder_messages: Vec<_> = servo.get_events().collect();
let mut need_resize = false;
let mut need_present = false; let mut need_present = false;
let mut need_update = false; let mut need_update = false;
loop { loop {
@ -266,7 +264,8 @@ impl App {
need_update |= servo_event_response.need_update; need_update |= servo_event_response.need_update;
// Runs the compositor, and receives and collects embedder messages from various Servo components. // Runs the compositor, and receives and collects embedder messages from various Servo components.
need_resize |= servo.handle_events(vec![]); servo.handle_events(vec![]);
if self.webviews.shutdown_requested() { if self.webviews.shutdown_requested() {
return PumpResult::Shutdown; return PumpResult::Shutdown;
} }
@ -278,9 +277,7 @@ impl App {
} }
} }
let present = if need_resize { let present = if need_present {
Present::Immediate
} else if need_present {
Present::Deferred Present::Deferred
} else { } else {
Present::None Present::None
@ -322,24 +319,6 @@ impl App {
} }
} }
match present { match present {
Present::Immediate => {
// The window was resized.
trace!("PumpResult::Present::Immediate");
// If we had resized any of the viewports in response to this, we would need to
// call Servo::repaint_synchronously. At the moment we dont, so there wont be
// any paint scheduled, and calling it would hang the compositor forever.
if let Some(ref mut minibrowser) = self.minibrowser {
minibrowser.update(
window.winit_window().unwrap(),
&mut self.webviews,
self.servo.as_ref(),
"PumpResult::Present::Immediate",
);
minibrowser.paint(window.winit_window().unwrap());
}
self.servo.as_mut().unwrap().present();
},
Present::Deferred => { Present::Deferred => {
// The compositor has painted to this frame. // The compositor has painted to this frame.
trace!("PumpResult::Present::Deferred"); trace!("PumpResult::Present::Deferred");
@ -385,11 +364,6 @@ impl App {
}, },
PumpResult::Continue { present, .. } => { PumpResult::Continue { present, .. } => {
match present { match present {
Present::Immediate => {
// The window was resized.
trace!("PumpResult::Present::Immediate");
self.servo.as_mut().unwrap().present();
},
Present::Deferred => { Present::Deferred => {
// The compositor has painted to this frame. // The compositor has painted to this frame.
trace!("PumpResult::Present::Deferred"); trace!("PumpResult::Present::Deferred");