mirror of
https://github.com/servo/servo.git
synced 2025-07-31 03:00:29 +01:00
This is a clean up after #36062 and #35985. It removes the script channel for each pipeline from the compositor. Now all messages are sent via the `Constellation` first, which will allow breaking the dependency on script in the compositor. In addition, scroll states are actually sent via the `Constellation`, which was an oversight from #36062. Finally, a typo in a method name is fixed. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
41 lines
1.3 KiB
Rust
41 lines
1.3 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
//! This module contains the `EventLoop` type, which is the constellation's
|
|
//! view of a script thread. When an `EventLoop` is dropped, an `ExitScriptThread`
|
|
//! message is sent to the script thread, asking it to shut down.
|
|
|
|
use std::marker::PhantomData;
|
|
use std::rc::Rc;
|
|
|
|
use ipc_channel::Error;
|
|
use ipc_channel::ipc::IpcSender;
|
|
use script_traits::ScriptThreadMessage;
|
|
|
|
/// <https://html.spec.whatwg.org/multipage/#event-loop>
|
|
pub struct EventLoop {
|
|
script_chan: IpcSender<ScriptThreadMessage>,
|
|
dont_send_or_sync: PhantomData<Rc<()>>,
|
|
}
|
|
|
|
impl Drop for EventLoop {
|
|
fn drop(&mut self) {
|
|
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<ScriptThreadMessage>) -> Rc<EventLoop> {
|
|
Rc::new(EventLoop {
|
|
script_chan,
|
|
dont_send_or_sync: PhantomData,
|
|
})
|
|
}
|
|
|
|
/// Send a message to the event loop.
|
|
pub fn send(&self, msg: ScriptThreadMessage) -> Result<(), Error> {
|
|
self.script_chan.send(msg)
|
|
}
|
|
}
|