constellation: Rename messages sent to the Constellation (#36341)

Messages that are sent to the `Constellation` have pretty ambiguous
names.
This change does two renames:

- `ConstellationMsg` → `EmbedderToConstellationMessage`
- `ScriptMsg` → `ScriptToConstellationMessage`

This naming reflects that the `Constellation` stands in between the
embedding layer and the script layer and can receive messages from both.
Soon both of these message types will live in `constellation_traits`,
reflecting the idea that the `_traits` variant for a crate is
responsible for exposing the API for that crate.

Testing: No new tests are necessary here as this just renames two enums.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-04-04 21:39:38 +02:00 committed by GitHub
parent c7a7862574
commit 5a35e1faec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 415 additions and 364 deletions

View file

@ -12,11 +12,11 @@ use std::thread;
use backtrace::Backtrace;
use base::id::WebViewId;
use constellation_traits::{ConstellationMsg as FromCompositorMsg, LogEntry};
use constellation_traits::{EmbedderToConstellationMessage, LogEntry};
use crossbeam_channel::Sender;
use log::{Level, LevelFilter, Log, Metadata, Record};
use parking_lot::ReentrantMutex;
use script_traits::{ScriptMsg as FromScriptMsg, ScriptToConstellationChan};
use script_traits::{ScriptToConstellationChan, ScriptToConstellationMessage};
/// A logger directed at the constellation from content processes
/// #[derive(Clone)]
@ -50,7 +50,7 @@ impl Log for FromScriptLogger {
fn log(&self, record: &Record) {
if let Some(entry) = log_entry(record) {
let thread_name = thread::current().name().map(ToOwned::to_owned);
let msg = FromScriptMsg::LogEntry(thread_name, entry);
let msg = ScriptToConstellationMessage::LogEntry(thread_name, entry);
let chan = self.script_to_constellation_chan.lock();
let _ = chan.send(msg);
}
@ -61,15 +61,15 @@ impl Log for FromScriptLogger {
/// A logger directed at the constellation from the compositor
#[derive(Clone)]
pub struct FromCompositorLogger {
pub struct FromEmbedderLogger {
/// A channel to the constellation
pub constellation_chan: Arc<ReentrantMutex<Sender<FromCompositorMsg>>>,
pub constellation_chan: Arc<ReentrantMutex<Sender<EmbedderToConstellationMessage>>>,
}
impl FromCompositorLogger {
impl FromEmbedderLogger {
/// Create a new constellation logger.
pub fn new(constellation_chan: Sender<FromCompositorMsg>) -> FromCompositorLogger {
FromCompositorLogger {
pub fn new(constellation_chan: Sender<EmbedderToConstellationMessage>) -> FromEmbedderLogger {
FromEmbedderLogger {
constellation_chan: Arc::new(ReentrantMutex::new(constellation_chan)),
}
}
@ -80,7 +80,7 @@ impl FromCompositorLogger {
}
}
impl Log for FromCompositorLogger {
impl Log for FromEmbedderLogger {
fn enabled(&self, metadata: &Metadata) -> bool {
metadata.level() <= Level::Warn
}
@ -89,7 +89,7 @@ impl Log for FromCompositorLogger {
if let Some(entry) = log_entry(record) {
let top_level_id = WebViewId::installed();
let thread_name = thread::current().name().map(ToOwned::to_owned);
let msg = FromCompositorMsg::LogEntry(top_level_id, thread_name, entry);
let msg = EmbedderToConstellationMessage::LogEntry(top_level_id, thread_name, entry);
let chan = self.constellation_chan.lock();
let _ = chan.send(msg);
}