script_traits: Rename ConstellationControlMsg to ScriptThreadMessage (#35226)

At some point in the past this message was only sent from the
`Constellation` to `script`, but nowadays this is sent from various
parts of servo to the `ScriptThread`, so this is a better name. In
particular, the current name makes it seeem like this message controls
the `Constellation`, which it does not.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-01-30 23:46:17 +01:00 committed by GitHub
parent 006ec58598
commit ad07db0b0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 183 additions and 200 deletions

View file

@ -11,25 +11,23 @@ use std::rc::Rc;
use ipc_channel::ipc::IpcSender;
use ipc_channel::Error;
use script_traits::ConstellationControlMsg;
use script_traits::ScriptThreadMessage;
/// <https://html.spec.whatwg.org/multipage/#event-loop>
pub struct EventLoop {
script_chan: IpcSender<ConstellationControlMsg>,
script_chan: IpcSender<ScriptThreadMessage>,
dont_send_or_sync: PhantomData<Rc<()>>,
}
impl Drop for EventLoop {
fn drop(&mut self) {
let _ = self
.script_chan
.send(ConstellationControlMsg::ExitScriptThread);
let _ = self.script_chan.send(ScriptThreadMessage::ExitScriptThread);
}
}
impl EventLoop {
/// Create a new event loop from the channel to its script thread.
pub fn new(script_chan: IpcSender<ConstellationControlMsg>) -> Rc<EventLoop> {
pub fn new(script_chan: IpcSender<ScriptThreadMessage>) -> Rc<EventLoop> {
Rc::new(EventLoop {
script_chan,
dont_send_or_sync: PhantomData,
@ -37,12 +35,12 @@ impl EventLoop {
}
/// Send a message to the event loop.
pub fn send(&self, msg: ConstellationControlMsg) -> Result<(), Error> {
pub fn send(&self, msg: ScriptThreadMessage) -> Result<(), Error> {
self.script_chan.send(msg)
}
/// The underlying channel to the script thread.
pub fn sender(&self) -> IpcSender<ConstellationControlMsg> {
pub fn sender(&self) -> IpcSender<ScriptThreadMessage> {
self.script_chan.clone()
}
}